Visual Studio Code Webview UI Toolkit 示例项目教程

Visual Studio Code Webview UI Toolkit 示例项目教程

vscode-webview-ui-toolkit-samples项目地址:https://gitcode.com/gh_mirrors/vs/vscode-webview-ui-toolkit-samples

1. 项目的目录结构及介绍

vscode-webview-ui-toolkit-samples/
├── component-gallery/
├── editable-data-grid/
├── hello-world/
├── hello-world-webpack/
├── notepad/
├── weather-webview/
├── README.md
└── LICENSE
  • component-gallery: 展示 Webview UI Toolkit 中所有组件的示例。
  • editable-data-grid: 展示如何创建可编辑数据网格的示例。
  • hello-world: 基本的 "Hello World" 启动扩展。
  • hello-world-webpack: 使用 Webpack 构建的基本 "Hello World" 启动扩展。
  • notepad: 利用 VS Code TreeView API 的简单记事本扩展。
  • weather-webview: 展示在 VS Code 侧边栏中使用工具包的示例。
  • README.md: 项目说明文件。
  • LICENSE: 项目许可证文件。

2. 项目的启动文件介绍

每个示例扩展都有一个 package.json 文件,这是 Node.js 项目的配置文件,也包含了 VS Code 扩展的元数据。以下是一个典型的 package.json 文件示例:

{
  "name": "hello-world",
  "displayName": "Hello World",
  "version": "0.0.1",
  "publisher": "vscode-samples",
  "engines": {
    "vscode": "^1.52.0"
  },
  "categories": [
    "Other"
  ],
  "activationEvents": [
    "onCommand:hello-world.helloWorld"
  ],
  "main": "./out/extension.js",
  "contributes": {
    "commands": [
      {
        "command": "hello-world.helloWorld",
        "title": "Hello World"
      }
    ]
  },
  "scripts": {
    "vscode:prepublish": "npm run compile",
    "compile": "tsc -p ./",
    "watch": "tsc -watch -p ./",
    "pretest": "npm run compile && npm run lint",
    "lint": "eslint src --ext ts",
    "test": "node ./out/test/runTest.js"
  },
  "devDependencies": {
    "@types/vscode": "^1.52.0",
    "@types/glob": "^7.1.3",
    "@types/mocha": "^8.0.4",
    "@types/node": "^12.11.7",
    "eslint": "^7.10.0",
    "glob": "^7.1.6",
    "mocha": "^8.1.3",
    "typescript": "^4.0.3",
    "vscode-test": "^1.4.0"
  }
}
  • name: 扩展的名称。
  • displayName: 扩展的显示名称。
  • version: 扩展的版本号。
  • publisher: 扩展的发布者。
  • engines: 扩展所需的 VS Code 版本。
  • categories: 扩展的分类。
  • activationEvents: 扩展的激活事件。
  • main: 扩展的主入口文件。
  • contributes: 扩展的贡献点,如命令、视图等。
  • scripts: 构建和测试脚本。
  • devDependencies: 开发依赖项。

3. 项目的配置文件介绍

每个示例扩展都有一个 tsconfig.json 文件,这是 TypeScript 项目的配置文件。以下是一个典型的 tsconfig.json 文件示例:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "outDir": "out",
    "rootDir": "src",
    "sourceMap": true,
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": [
    "src"
  ]
}
  • compilerOptions: TypeScript 编译器的选项。
    • module: 指定模块

vscode-webview-ui-toolkit-samples项目地址:https://gitcode.com/gh_mirrors/vs/vscode-webview-ui-toolkit-samples

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

时泓岑Ethanael

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值