vscode-yapi-transformyapi转换前端代码插件 安装1.npm install -g yo generator-code 2.yo code vscode插件开发使用vue需要解决跨域问题(参考文章[https://blog.csdn.net/u010750137/article/details/127991644])1.路径转换 function getUri(webview: Webview, extensionUri: Uri, pathList: string[]) { return webview.asWebviewUri(Uri.joinPath(extensionUri, ...pathList)); }
2.修改资源路径 // The CSS file from the Vue build output const stylesUri = getUri(webview, extensionUri, ["dist", "assets", "index.css"]); // The JS file from the Vue build output const scriptUri = getUri(webview, extensionUri, ["dist", "assets", "index.js"]);
webview里面需要解决vue如何与vscode进行通信1.安装npm install --save @types/vscode-webview 2.通过创建vscodeApi实例调用postMessage方法 vscode生成本地文件到用户工作区1.无法使用fs模块,需要借助vscode.workspace.fs模块 2.需要通过vscode.workspace.workspaceFolders获取用户工作区路径 3.文件读取需要对数据进行Unit8Array与字符串转换 // string转unit8Array function stringToUint8Array(str: any) { var arr = []; for (var i = 0, j = str.length; i < j; ++i) { arr.push(str.charCodeAt(i)); } var tmpUint8Array = new Uint8Array(arr); return tmpUint8Array; }
|