VSCode 添加图标到 Activity 栏

VSCode add icons to Activity Bar

如何将其他扩展程序图标添加到 Activity Bar
我想在源代码管理和调试图标旁边添加新的自定义图标。
我读了 this page 但没看懂。
我去了路径 C:\Users\Moh\AppData\Local\Programs\Microsoft VS Code\resources\app 并将此配置添加到 package.json:

// etc...
"author": {
  "name": "Microsoft Corporation"
},
"license": "MIT",
"main": "./out/main",

//***************//
// I added following lines:
"contributes": {
  "views": {
    "code-runner": [
      {
        "id": "codeRunner",
        "name": "Code Runner"
      }
    ]
  }
},

// etc...

但没有任何改变。
我选择的路径是否正确?
写的配置是否正确?

此代码已添加到您正在构建的 扩展 package.json 中。如果您不知道这意味着什么,请阅读有关进行首次扩展的文档。

根据文档,它有效:

"contributes": {

    "viewsContainers": {

      "activitybar": [

        {
          "id": "package-explorer",        (use this id for the view name below)
          "title": "Package Explorer",
          "icon": "$(heart)"               (using built-in icons, it is this easy)
        }
      ]
    },

    "views": {

      "package-explorer": [                (id from above)

        {
          "id": "package-dependencies",    (viewlets within "PAckage Explorer")
          "name": "Dependencies",
          "type": "tree"
        },
        {
          "id": "package-outline",
          "name": "Outline"
        }
      ]
    }

Activity 栏是 ViewContainer 的一种。当您单击心形图标时,它会打开侧边栏的一个视图,其中有两个“视图”:DependenciesOutline

这里讨论内置图标:https://code.visualstudio.com/api/references/icons-in-labels but you can use your own as detailed here: https://code.visualstudio.com/api/references/contribution-points#Icon-specifications

当您调试您的扩展时,您将在新的 vscode window 中看到 ViewContainer 和 View 贡献 运行 您的扩展。