{"id":10006821,"date":"2022-11-07T17:01:16","date_gmt":"2022-11-07T09:01:16","guid":{"rendered":"https:\/\/ityet.com\/?p=10006821"},"modified":"2022-11-07T17:01:16","modified_gmt":"2022-11-07T09:01:16","slug":"vs-code-for-web-%e6%b7%b1%e5%85%a5%e6%b5%85%e5%87%ba-server-%e6%a8%a1%e5%9d%97%e8%ae%be%e8%ae%a1%e7%af%87","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10006821","title":{"rendered":"VS Code For Web \u6df1\u5165\u6d45\u51fa &#8212; Server \u6a21\u5757\u8bbe\u8ba1\u7bc7"},"content":{"rendered":"<p>\u5728\u4e86\u89e3\u4e86 VS Code \u7684\u901a\u4fe1\u673a\u5236\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u7740\u624b\u5206\u6790 VS Code Server \u4e2d\u5404\u6a21\u5757\u7684\u5b9e\u73b0\u4ee5\u53ca\u8bbe\u8ba1\u601d\u8def\u4e86\u3002<\/p>\n<p>&lt;!&#8211; more &#8211;&gt;<\/p>\n<h2>VSCode Server \u6a21\u5757\u8bbe\u8ba1<\/h2>\n<p>\u901a\u8fc7\u4e4b\u524d\u7684\u4ecb\u7ecd\u6211\u4eec\u53ef\u4ee5\u4e86\u89e3\u5230\uff0cVS Code \u7684\u80fd\u529b\u662f\u524d\u540e\u7aef\u5206\u79bb\u7684\uff0c\u8fd9\u4f7f\u5f97 <code>remote server<\/code> \u7684\u6539\u9020\u5b9e\u73b0\u53d8\u5f97\u7b80\u5355\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042754112\" alt=\"20221009135447\" title=\"20221009135447\" loading=\"lazy\"><\/p>\n<p>\u901a\u8fc7\u8fd9\u4e00\u5f20\u67b6\u6784\u56fe\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u89c2\u7684\u770b\u5230\u5728 VS Code \u4e2d\uff0c\u524d\u540e\u7aef\u80fd\u529b\u804c\u8d23\u7684\u5212\u5206\u3002<\/p>\n<p>\u53ef\u4ee5\u770b\u51fa\uff0c\u9664\u4e86\u5c11\u6570\u7684\u4e00\u4e9b\u50cf\u672c\u5730\u6587\u4ef6\u4e0a\u4f20\uff0c\u8bed\u6cd5\u9ad8\u4eae\u3001\u4e3b\u9898\u8bbe\u7f6e\u7b49\u80fd\u529b\uff0c\u4e00\u4e9b\u91cd\u4f9d\u8d56\u591a\u8fdb\u7a0b\u901a\u4fe1\u3001OS\u652f\u6301\uff0c\u8bed\u8a00\u7f16\u8bd1\u7684\u80fd\u529b\u90fd\u88ab\u8bbe\u8ba1\u5728\u4e86 Server \u7aef\u4e2d\uff0c\u4ee5\u4fdd\u8bc1 Client \u7aef\u8db3\u591f\u7684\u8f7b\u91cf\u7b80\u6d01\uff0c\u53ef\u4ee5\u8fd0\u884c\u5728 Web \u8fd9\u6837\u7684\u8f7b\u73af\u5883\u4e2d\u3002<\/p>\n<p>\u5728\u672c\u7bc7\u4e2d\uff0c\u6211\u6765\u5e26\u5927\u5bb6\u6d45\u8981\u5206\u6790 Server \u7aef\u7684\u51e0\u4e2a\u91cd\u8981\u6a21\u5757\u7684\u8bbe\u8ba1\u601d\u8def\u4e0e\u5b9e\u73b0\u3002<\/p>\n<h2>Remote File System \u8bbe\u8ba1<\/h2>\n<p><code>Remote File System<\/code> \u8d1f\u8d23\u5904\u7406\u6587\u4ef6\u7cfb\u7edf\u7684\u8bfb\u5199\u64cd\u4f5c\uff0c\u540c\u65f6\u8fd8\u9700\u8981\u5904\u7406\u6587\u4ef6\u7cfb\u7edf\u7684\u53d8\u5316\u4e8b\u4ef6\uff0c\u4ee5\u4fbf\u4e8e\u5ba2\u6237\u7aef\u80fd\u591f\u5b9e\u65f6\u66f4\u65b0\u6587\u4ef6\u7cfb\u7edf\u7684\u53d8\u5316\u3002\u5728 VSCode \u4e2d\uff0c\u5b83\u5c01\u88c5\u4e86\u4e00\u5c42 <code>Virtual file system<\/code> \u6765\u5b9e\u73b0\u5bf9\u4e0d\u540c\u6587\u4ef6\u7cfb\u7edf\u7684\u517c\u5bb9\u63a7\u5236\u3002<\/p>\n<p>\u8fd9\u4e00\u90e8\u5206\u662f VSCode Server \u7684\u6838\u5fc3\u4e2d\u6700\u5bb9\u6613\u5b9e\u73b0\u7684\u90e8\u5206\u3002\u5b83\u672c\u8d28\u4e0a\u5c31\u662f\u4f7f\u4f9d\u8d56\u73b0\u4ee3\u6d4f\u89c8\u5668\u7684 <a href=\"https:\/\/link.segmentfault.com\/?enc=B6oQMnFMkHhe7wUtu0eyKg%3D%3D.UIeFrW6H7sTYNjsIFO%2F6%2BeJIvwXnjCjOYKEcuQwDO7QzLiLXuFh5yLIU04JqG97%2B8qFz1Y1nFes316bhzzHldp51Z9NvAPBA913oLkp4f2s%3D\" rel=\"nofollow\">File_System_Access_API<\/a> \u6765\u5b9e\u73b0\u7684\uff08\u5f3a\u5236\u5728 HTTPS \u4e0b\u4f7f\u7528\uff09\u3002<\/p>\n<pre><code class=\"ts\">async function getTheFile() {\n  \/\/ open file picker\n  [fileHandle] = await window.showOpenFilePicker(pickerOpts);\n\n  \/\/ get file contents\n  const fileData = await fileHandle.getFile();\n}<\/code><\/pre>\n<p>\u5177\u4f53\u7684\u4ee3\u7801\u58f0\u660e\u4f4d\u7f6e\u89c1 <a href=\"https:\/\/link.segmentfault.com\/?enc=zOdJbD3iqUGkPf4RvUCEGw%3D%3D.g0wdwBTUBSkDvm77iWQJS8Tm9eY4gIEmvGOxaprn8uH7WuqAQ5BQQSaLj3gkQh20ImqiFS8Mz%2FCCHyYqPxhwjk%2BI5t01jxrSVvYZ1Rk7OdmJ%2BzjemvvRbEU0rBKvwW%2FaghDZ%2Bd4Mzzya%2BtBBHhbJRw%3D%3D\" rel=\"nofollow\">FileSystemProvider<\/a>\u3002<\/p>\n<p>\u8fd9\u91cc\u4f7f\u7528 <code>vscode-vfs<\/code> \u8fd9\u4e2a\u5e93\u6765\u5b9e\u73b0\u865a\u62df\u6587\u4ef6\u7cfb\u7edf\u3002\u8fd9\u662f\u4e00\u4e2a URI \u65b9\u6848\uff0c\u5b83\u6ce8\u518c\u4e86 <code>File System Provider<\/code>\uff0c\u5e76\u4e14\u8be5\u6587\u4ef6\u7cfb\u7edf\u4e0a\u7684\u8d44\u6e90\u5c06\u7531\u4f7f\u7528\u8be5\u6a21\u5f0f\u7684 URI \u8868\u793a\uff08\u4f8b\u5982<code>vscode-vfs:\/\/vscode\/package.json<\/code>\uff09\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u76f4\u63a5\u6253\u5f00\u8fdc\u7a0b\u5b58\u50a8\u5e93\u4e5f\u5f97\u4ee5\u5b9e\u73b0\uff0c\u4f8b\u5982 <code>Github Codespaces<\/code> \u7684\u6253\u5f00\u5c31\u662f\u8fd9\u6837\u5b9e\u73b0\u7684\u3002<\/p>\n<p>\u4f7f\u7528 <code>vscode-vfs:\/\/github\/microsoft\/vscode<\/code>\uff0c \u901a\u8fc7\u8bbf\u95ee <code>https:\/\/github.com\/microsoft\/vscode<\/code>\uff0c\u5c31\u80fd\u591f\u5728\u4e0d\u8fdb\u884c <code>git clone<\/code>\u7684\u60c5\u51b5\u4e0b\uff0c\u76f4\u63a5\u6253\u5f00\u9879\u76ee\u6587\u4ef6\u5939\u4e86\u3002<\/p>\n<p>\u5b9e\u4f8b\u5316\u540e\uff0c\u5168\u5c40\u90fd\u53ef\u4ee5\u901a\u8fc7\u4f20\u5165 <code>RuntimeEnvironment<\/code>\uff0c\u901a\u8fc7 <code>runtime.fs<\/code> \u6765\u8bbf\u95ee\u4e0e\u8c03\u7528\u3002<\/p>\n<pre><code class=\"ts\">async stat(uri: string): Promise&lt;FileStat&gt; {\n    if (fileFs &amp;&amp; uri.startsWith('file:')) {\n        return fileFs.stat(uri);\n    }\n    const res = await connection.sendRequest(FsStatRequest.type, uri.toString());\n    return res;\n}\n\nreadDirectory(uri: string): Promise&lt;[string, FileType][]&gt; {\n    if (fileFs &amp;&amp; uri.startsWith('file:')) {\n        return fileFs.readDirectory(uri);\n    }\n    return connection.sendRequest(FsReadDirRequest.type, uri.toString());\n}<\/code><\/pre>\n<p>\u5f53\u7136\uff0c\u5bf9\u4e8e\u4e0d\u652f\u6301\u8fd9\u5957 API \u7684\u6d4f\u89c8\u5668\u6765\u8bf4\uff0c\u6253\u5f00\u65f6\u4f1a\u68c0\u6d4b\u63a5\u53e3\uff0c\u5f39\u51fa\u8b66\u544a\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042754113\" alt=\"20221009144016\" title=\"20221009144016\" loading=\"lazy\"><\/p>\n<p>\u81f3\u4e8e\u89e3\u51b3\u65b9\u5f0f\uff0c\u4e4b\u524d\u8bf4\u8fc7\uff0cVSCode \u7684 server \u7aef\u662f\u540c\u6784\u7684\uff0cserver \u81ea\u7136\u4e5f\u80fd\u63d0\u4f9b\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u652f\u6301\uff0c\u4ecd\u53ef\u4ee5\u901a\u8fc7\u6d4f\u89c8\u5668\u7684\u4e0a\u4f20 API \u6765\u5b9e\u73b0\u3002<\/p>\n<h2>Remote Terminal Process \u8bbe\u8ba1<\/h2>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042754114\" alt=\"20221009181331\" title=\"20221009181331\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u91cc\u5b9e\u9645\u4e0a\u662f\u590d\u7528\u4e86VSCode \u4e4b\u524d\u63a8\u51fa\u7684 <code>Remote-Server extension<\/code> \u80fd\u529b\uff0c\u901a\u8fc7 SSH \u96a7\u9053\u7684\u65b9\u5f0f\uff0c\u5c06\u7ec8\u7aef\u7684\u8f93\u5165\u8f93\u51fa\u6d41\u8f6c\u53d1\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u3002\uff08\u518d\u4e00\u6b21\u8bf4\u660e\u4e86\u4e3a\u4ec0\u4e48\u5f3a\u5236\u8981\u6c42\u5728HTTPS\u4e0b\u4f7f\u7528\uff09<\/p>\n<p>\u8fd8\u8bb0\u5f97\u6211\u4eec\u4e4b\u524d\u63d0\u5230\u8fc7\u7684\uff0c<code>Channel<\/code> \u4e3a\u901a\u4fe1\u7684\u6700\u5c0f\u5355\u5143\u5417\uff1f<code>VSCode Server<\/code> \u7684 <code>Remote Terminal<\/code> \u5c31\u662f\u901a\u8fc7\u4e00\u4e2a <code>RemoteTerminalChannel<\/code> \u6765\u5b9e\u73b0\u7684\u3002<\/p>\n<p>\u901a\u8fc7\u76d1\u542c\u4e0e\u89e6\u53d1\u4e0d\u540c\u7684\u4e8b\u4ef6\uff08\u5982<code>onExecuteCommand<\/code>, <code>sendCommandResult<\/code>\uff09\uff0c\u6765\u5b9e\u73b0\u5bf9 <code>Remote Terminal<\/code> \u7684\u4e0d\u540c\u884c\u4e3a\u7684\u4fe1\u606f\u540c\u6b65\u3002<\/p>\n<pre><code class=\"ts\">    async call(ctx: RemoteAgentConnectionContext, command: string, args?: any): Promise&lt;any&gt; {\n        switch (command) {\n            case '$restartPtyHost': return this._ptyService.restartPtyHost?.apply(this._ptyService, args);\n\n            case '$createProcess': {\n                const uriTransformer = createURITransformer(ctx.remoteAuthority);\n                return this._createProcess(uriTransformer, &lt;ICreateTerminalProcessArguments&gt;args);\n            }\n            case '$attachToProcess': return this._ptyService.attachToProcess.apply(this._ptyService, args);\n            case '$detachFromProcess': return this._ptyService.detachFromProcess.apply(this._ptyService, args);\n\n            case '$listProcesses': return this._ptyService.listProcesses.apply(this._ptyService, args);\n            case '$orphanQuestionReply': return this._ptyService.orphanQuestionReply.apply(this._ptyService, args);\n            case '$acceptPtyHostResolvedVariables': return this._ptyService.acceptPtyHostResolvedVariables?.apply(this._ptyService, args);\n\n            case '$start': return this._ptyService.start.apply(this._ptyService, args);\n            case '$input': return this._ptyService.input.apply(this._ptyService, args);\n            case '$acknowledgeDataEvent': return this._ptyService.acknowledgeDataEvent.apply(this._ptyService, args);\n            case '$shutdown': return this._ptyService.shutdown.apply(this._ptyService, args);\n            case '$resize': return this._ptyService.resize.apply(this._ptyService, args);\n            case '$getInitialCwd': return this._ptyService.getInitialCwd.apply(this._ptyService, args);\n            case '$getCwd': return this._ptyService.getCwd.apply(this._ptyService, args);\n\n            case '$processBinary': return this._ptyService.processBinary.apply(this._ptyService, args);\n\n            case '$sendCommandResult': return this._sendCommandResult(args[0], args[1], args[2]);\n            case '$installAutoReply': return this._ptyService.installAutoReply.apply(this._ptyService, args);\n            case '$uninstallAllAutoReplies': return this._ptyService.uninstallAllAutoReplies.apply(this._ptyService, args);\n            case '$getDefaultSystemShell': return this._getDefaultSystemShell.apply(this, args);\n            case '$getProfiles': return this._getProfiles.apply(this, args);\n            case '$getEnvironment': return this._getEnvironment();\n            case '$getWslPath': return this._getWslPath(args[0]);\n            case '$getTerminalLayoutInfo': return this._ptyService.getTerminalLayoutInfo(&lt;IGetTerminalLayoutInfoArgs&gt;args);\n            case '$setTerminalLayoutInfo': return this._ptyService.setTerminalLayoutInfo(&lt;ISetTerminalLayoutInfoArgs&gt;args);\n            case '$serializeTerminalState': return this._ptyService.serializeTerminalState.apply(this._ptyService, args);\n            case '$reviveTerminalProcesses': return this._ptyService.reviveTerminalProcesses.apply(this._ptyService, args);\n            case '$getRevivedPtyNewId': return this._ptyService.getRevivedPtyNewId.apply(this._ptyService, args);\n            case '$setUnicodeVersion': return this._ptyService.setUnicodeVersion.apply(this._ptyService, args);\n            case '$reduceConnectionGraceTime': return this._reduceConnectionGraceTime();\n            case '$updateIcon': return this._ptyService.updateIcon.apply(this._ptyService, args);\n            case '$updateTitle': return this._ptyService.updateTitle.apply(this._ptyService, args);\n            case '$updateProperty': return this._ptyService.updateProperty.apply(this._ptyService, args);\n            case '$refreshProperty': return this._ptyService.refreshProperty.apply(this._ptyService, args);\n            case '$requestDetachInstance': return this._ptyService.requestDetachInstance(args[0], args[1]);\n            case '$acceptDetachedInstance': return this._ptyService.acceptDetachInstanceReply(args[0], args[1]);\n            case '$freePortKillProcess': return this._ptyService.freePortKillProcess?.apply(this._ptyService, args);\n        }\n\n        throw new Error(`IPC Command ${command} not found`);\n    }\n\n    listen(_: any, event: string, arg: any): Event&lt;any&gt; {\n        switch (event) {\n            case '$onPtyHostExitEvent': return this._ptyService.onPtyHostExit || Event.None;\n            case '$onPtyHostStartEvent': return this._ptyService.onPtyHostStart || Event.None;\n            case '$onPtyHostUnresponsiveEvent': return this._ptyService.onPtyHostUnresponsive || Event.None;\n            case '$onPtyHostResponsiveEvent': return this._ptyService.onPtyHostResponsive || Event.None;\n            case '$onPtyHostRequestResolveVariablesEvent': return this._ptyService.onPtyHostRequestResolveVariables || Event.None;\n            case '$onProcessDataEvent': return this._ptyService.onProcessData;\n            case '$onProcessReadyEvent': return this._ptyService.onProcessReady;\n            case '$onProcessExitEvent': return this._ptyService.onProcessExit;\n            case '$onProcessReplayEvent': return this._ptyService.onProcessReplay;\n            case '$onProcessOrphanQuestion': return this._ptyService.onProcessOrphanQuestion;\n            case '$onExecuteCommand': return this.onExecuteCommand;\n            case '$onDidRequestDetach': return this._ptyService.onDidRequestDetach || Event.None;\n            case '$onDidChangeProperty': return this._ptyService.onDidChangeProperty;\n            default:\n                break;\n        }\n\n        throw new Error('Not supported');\n    }<\/code><\/pre>\n<h2>Extension Processes \u8bbe\u8ba1<\/h2>\n<h3>\u5b58\u50a8\u4f4d\u7f6e<\/h3>\n<p>VSCode Server \u4f1a\u5c06\u901a\u8fc7 <code>code-server --install-extension &lt;extension id&gt;<\/code> \u547d\u4ee4\u5b89\u88c5\u7684 extensions \u5b58\u50a8\u5728 <code>$XDG_DATA_HOME\/code-server\/extensions<\/code> \u4e0b\u3002<\/p>\n<p>\u7528\u6237\u914d\u7f6e\u4fe1\u606f\u5b58\u50a8\u5728\u672c\u5730\u7684<code>~\/.vscode<\/code> \u4e0b\uff0c\u4f7f\u7528\u5b98\u65b9\u7684 <a href=\"https:\/\/link.segmentfault.com\/?enc=mpHTrUdmjWzlo9GL9tsBJA%3D%3D.quo4GDJzP6m5Iapp5fV576D1LY8dMKaw7knzIpBLXbSisU0Dnv7T4vQlwNI0Yjrqw5Gt1l3PLFns72pdtRv36vOF0O17gKjgZT7zWcWrgx4%3D\" rel=\"nofollow\">Settings Sync<\/a> \u63d2\u4ef6\u8fdb\u884c\u914d\u7f6e\u6f2b\u6e38\u3002<\/p>\n<h3>\u63d2\u4ef6\u5206\u7c7b<\/h3>\n<p>VSCode \u5c06\u63d2\u4ef6\u5206\u4e3a\u4e86 <code>UI Extension<\/code> \u4e0e <code>Workspace Extension<\/code> \u4e24\u79cd\uff0c\u901a\u8fc7 <code>extensionKind<\/code> \u5b57\u6bb5\u8fdb\u884c\u6307\u5b9a\u3002<\/p>\n<p>\u5982\u679c\u4e0d\u6d89\u53ca\u5230 Node.js \u8c03\u7528\u7684\u7b80\u5355\u63d2\u4ef6\uff0c\u662f\u7eaf\u58f0\u660e\u6027\u8d28\u7684\u4ee3\u7801\u7684\u8bdd\uff08\u4f8b\u5982 Themes\u3001key-binding\uff0c\u6216\u8005\u80fd\u76f4\u63a5\u5229\u7528<a href=\"https:\/\/link.segmentfault.com\/?enc=Uk1nTnmnhvUe%2F6c1mvoOtg%3D%3D.qSwRKsmB1r99WThoKgaYyoLC5wM%2Fs3lBhqtmqMLej4rE7ugR%2B%2FGvxLaPYWrvkKgsLHYh24Us60ZFEmqdJSl8oA%3D%3D\" rel=\"nofollow\">\u5ba2\u6237\u7aef API<\/a> \u80fd\u8986\u76d6\u80fd\u529b\u7684\u63d2\u4ef6\u7b49\uff09\uff0c\u5219\u53ef\u4ee5\u5b9a\u4e49\u4e3a <code>UI Extension<\/code>\uff0c\u76f4\u63a5\u5728\u5ba2\u6237\u7aef\u4e2d\u6267\u884c\uff0c\u670d\u52a1\u7aef\u53ea\u4fdd\u5b58\u63d2\u4ef6\u7684\u914d\u7f6e\u4fe1\u606f\uff0c\u65e0\u9700\u8fdb\u884c\u901a\u4fe1\u3002<\/p>\n<p>\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48 vscode.dev \u4e2d\uff08\u622a\u81f3\u76ee\u524d\u4f4d\u7f6e\uff0c\u8be5\u7f51\u9875\u4e0d\u5305\u542b Server \u80fd\u529b\uff09\uff0c\u6240\u6709\u7684\u4e3b\u9898\u3001\u5305\u62ec\u4f8b\u5982 TS\u3001Python\u3001Markdown\u3001HTML \u7b49\u8bed\u8a00\u7684\u6587\u4ef6\u8865\u5168\u3001\u8bed\u6cd5\u9ad8\u4eae\u3001\u62ec\u53f7\u7740\u8272\u90fd\u662f\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\u7684\u539f\u56e0\u3002\u56e0\u4e3a\u5728\u67b6\u6784\u4e0a\uff0c\u8fd9\u4e9b\u80fd\u529b\u90fd\u662f\u7531\u5ba2\u6237\u7aef\u7684\u5185\u7f6e\u63d2\u4ef6(\u8bed\u8a00\u8865\u5168\u7b49\u76f8\u5173\u7279\u6027\u662f\u901a\u8fc7\u4e13\u95e8\u7f16\u5199\u7684 web worker thread \u65c1\u8def\u6267\u884c)\u63d0\u4f9b\u7684\uff0c\u901a\u8fc7 <a href=\"https:\/\/link.segmentfault.com\/?enc=4Pdj66li3LWTtya2lbTC%2Fw%3D%3D.hGXGYaMwlbVBsU86c%2B8vQCVaVEIxeSCU%2Bn7NmE7HsJjlgFOStSc7tFFg1GrPxLqk3L0hSynggbmLmN3UFoEhnA%3D%3D\" rel=\"nofollow\">VSCode API<\/a> \u76f4\u63a5\u8fdb\u884c\u8c03\u7528\u3002<\/p>\n<p>\u4f46\u5982\u679c\u529f\u80fd\u6d89\u53ca\u5230\u8fd0\u884c\u65f6\u7684\u7cfb\u7edf\u7ea7\u8c03\u7528\uff0c\u5219\u9700\u8981\u88ab\u5b9a\u4e49\u4e3a<code>Workspace Extension<\/code>\uff0c\u5b83\u53ef\u4ee5\u5b8c\u5168\u8bbf\u95ee\u6e90\u7801\u3001\u6587\u4ef6\u7cfb\u7edf\u3001\u4ee5\u53ca\u5927\u90e8\u5206 <code>OS API<\/code>\u3002<\/p>\n<p><code>Workspace Extension<\/code> \u9700\u8981\u5b89\u88c5\u5728\u670d\u52a1\u7aef\uff0c\u5e76\u9700\u8981\u5728\u63d2\u4ef6\u4e2d\u663e\u5f0f\u58f0\u660e\u3002<\/p>\n<p>\u4f53\u73b0\u5728\u7f16\u7801\u89c4\u8303\u4e0a\uff0c\u6211\u4eec\u9700\u8981\u4e3a\u63d2\u4ef6\u9879\u76ee\u7684 <code>package.json<\/code> \u6587\u4ef6\u4e2d\u6dfb\u52a0 <code>main<\/code> \u7684 entrypoint\uff0c\u4ee5\u6267\u884c\u670d\u52a1\u7aef\u63d2\u4ef6\u8c03\u7528\uff0c\u800c <code>UI Extension<\/code> \u7684 entrypoint \u4f7f\u7528 <code>browser<\/code> \u8868\u793a\u3002<\/p>\n<pre><code class=\"json\">{\n    ...\n    &quot;main&quot;: &quot;.\/dist\/node\/extension.js&quot;,\n    &quot;browser&quot;: &quot;.\/dist\/browser\/extension.js&quot;,\n    &quot;capabilities&quot;: {\n        &quot;virtualWorkspaces&quot;: true\n    }\n    ...\n}<\/code><\/pre>\n<p>\u903b\u8f91\u4e0a\uff0c\u63d2\u4ef6\u9700\u8981\u6839\u636e web \u7aef\u4e0e server \u7aef\u5206\u5f00\u7f16\u5199\uff0c\u5e76\u81ea\u884c\u505a\u597d\u517c\u5bb9\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042754115\" alt=\"20221010111137\" title=\"20221010111137\" loading=\"lazy\"><\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000042754109\">https:\/\/segmentfault.com\/a\/1190000042754109<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4e86\u89e3\u4e86 VS Code \u7684\u901a\u4fe1\u673a\u5236\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u7740\u624b\u5206\u6790 VS Code Server \u4e2d\u5404\u6a21\u5757\u7684\u5b9e\u73b0\u4ee5\u53ca\u8bbe\u8ba1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10006821","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006821","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10006821"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006821\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10006821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10006821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10006821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}