import type { Webview } from 'vscode' import { randomBytes } from 'node:crypto' import * as fs from 'node:fs' import { Uri } from 'vscode' export function makeNonce(): string { return randomBytes(16).toString('base64').replace(/[+/=]/g, '') } /** vite 产物目录,也是 webview 唯一放行的本地资源目录(localResourceRoots)。 */ export function webviewUiRoot(extensionUri: Uri): Uri { return Uri.joinPath(extensionUri, 'dist', 'webview-ui') } /** * 读 dist/webview-ui 下的一个入口页面,改成能在 webview 里跑的样子: * 资源路径改写成 webview URI、每个 `