@Gamma11,感谢您的回答。绝对有助于解决“定义迷宫”
稍微详细说明一下(也许可以简化/澄清webview-视图-样本使用更严格的 JS(相对于 TS)版本):
1 - 在 package.json 中,您有以下条目将视图定义为位于侧边栏资源管理器中的 Web 视图:
"views": {
"explorer": [
{
"type": "webview",
"id": "calicoColors.colorsView",
"name": "Trillion Files"
}
]
}
2 - 同样在 package.json 中发送到 JS 的激活
"activationEvents": [
"onView:calicoColors.colorsView"
]
3 - 在 JS 中,事件由 vscode.commands.registerCommand 拾取
function activate(context){
var thisProvider={
resolveWebviewView:function(thisWebview, thisWebviewContext, thisToken){
thisWebviewView.webview.options={enableScripts:true}
thisWebviewView.webview.html="<!doctype><html>[etc etc]";
}
};
context.subscriptions.push(
vscode.commands.registerWebviewViewProvider("calicoColors.colorView", thisProvider);
);
}
function deactivate() { }
module.exports = {
activate,
deactivate
}
还有很多属性可以进入 thisProvider,但是这个最少的代码可以在侧边栏中启动并运行面板。