diff --git a/src/webview/webview.controller.ts b/src/webview/webview.controller.ts index 6654f64..b1d1ed5 100644 --- a/src/webview/webview.controller.ts +++ b/src/webview/webview.controller.ts @@ -5,15 +5,17 @@ import { getWorkspaceConnectionConfigItemByPath } from '../global'; export class WebviewController { @RegisterCommand('openmcp.showOpenMCP') - async showOpenMCP(context: vscode.ExtensionContext, uri: vscode.Uri) { + async showOpenMCP(context: vscode.ExtensionContext, uri: vscode.Uri) { const connectionItem = getWorkspaceConnectionConfigItemByPath(uri.fsPath); + if (!connectionItem) { // 项目不存在连接信息 const cwd = getLaunchCWD(context, uri); - const sigature = getDefaultLanunchSignature(uri.fsPath, cwd); + const signature = getDefaultLanunchSignature(uri.fsPath, cwd); - if (!sigature) { + if (!signature) { + vscode.window.showInformationMessage('OpenMCP: 无法获取启动参数'); vscode.window.showErrorMessage('OpenMCP: 无法获取启动参数'); return; } @@ -21,8 +23,8 @@ export class WebviewController { revealOpenMcpWebviewPanel(context, 'workspace', uri.fsPath, { type: 'stdio', name: 'OpenMCP', - command: sigature.command, - args: sigature.args, + command: signature.command, + args: signature.args, cwd }); } else { diff --git a/src/webview/webview.service.ts b/src/webview/webview.service.ts index 4dfe7e6..76afa9b 100644 --- a/src/webview/webview.service.ts +++ b/src/webview/webview.service.ts @@ -6,7 +6,8 @@ import { routeMessage } from '../../openmcp-sdk/service'; export function getWebviewContent(context: vscode.ExtensionContext, panel: vscode.WebviewPanel): string | undefined { const viewRoot = fspath.join(context.extensionPath, 'openmcp-sdk', 'renderer'); - const htmlIndexPath = fspath.join(viewRoot, 'index.html'); + const htmlIndexPath = fspath.join(viewRoot, 'index.html'); + const html = fs.readFileSync(htmlIndexPath, { encoding: 'utf-8' })?.replace(/( { const absLocalPath = fspath.resolve(viewRoot, $2); const webviewUri = panel.webview.asWebviewUri(vscode.Uri.file(absLocalPath)); @@ -14,6 +15,10 @@ export function getWebviewContent(context: vscode.ExtensionContext, panel: vscod const replaceHref = $1 + webviewUri?.toString() + '"'; return replaceHref; }); + + console.log(html); + + return html; }