From 55c3bdfdfc24682cf674822c018c853ae3af13e7 Mon Sep 17 00:00:00 2001 From: yinxue <2643126914@qq.com> Date: Tue, 13 Jan 2026 12:39:27 +0000 Subject: [PATCH] =?UTF-8?q?=E9=92=88=E5=AF=B9shell=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=96=B9=E5=BC=8F=E8=BF=9B=E8=A1=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.json | 9 ++++++--- src/remote-container.ts | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 86c86f3..e50ce57 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -13,12 +13,15 @@ "warn", { "selector": "import", - "format": [ "camelCase", "PascalCase" ] + "format": [ + "camelCase", + "PascalCase" + ] } ], - "@typescript-eslint/semi": "warn", + "@typescript-eslint/semi": "off", "curly": "warn", - "eqeqeq": "warn", + "eqeqeq": "off", "no-throw-literal": "warn", "semi": "off" }, diff --git a/src/remote-container.ts b/src/remote-container.ts index 96baead..c9619ba 100644 --- a/src/remote-container.ts +++ b/src/remote-container.ts @@ -42,19 +42,25 @@ export default class RemoteContainer { const baseUrl = `vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}`; const url = devstarDomain ? `${baseUrl}&devstar_domain=${devstarDomain}` : baseUrl; - // 通过终端的 creationOptions 获取 shell 路径 + // 获取本地操作系统类型 + // 在远程环境下,os.platform() 返回的是远程系统,但这里我们需要的是本地系统 + // 所以通过终端的 shell 路径来推断 const shellPath = (terminal.creationOptions as any)?.shellPath || ''; - const isWindows = shellPath.toLowerCase().includes('powershell') || + console.log('终端 shell 路径:', shellPath); + + // 检测 Windows(Windows shell 路径包含反斜杠或特定关键字) + const isWindows = shellPath.includes('\\') || + shellPath.toLowerCase().includes('powershell') || shellPath.toLowerCase().includes('pwsh') || shellPath.toLowerCase().includes('cmd'); if (isWindows) { - // PowerShell/CMD: 使用分号分隔,URL 需要特殊的引号处理 - console.log('检测到 Windows shell,使用 PowerShell 语法'); + // Windows PowerShell/CMD: 使用分号分隔,URL 需要特殊的引号处理 + console.log('检测到 Windows 本地系统,使用 PowerShell/CMD 语法'); return `code --new-window; code --open-url '"${url}"'`; } else { - // Bash/Zsh: 使用 && 分隔,标准双引号 - console.log('检测到 Unix shell,使用 Bash 语法'); + // macOS/Linux: 使用 && 分隔,标准双引号 + console.log('检测到 Unix 本地系统(macOS/Linux),使用 Bash/Zsh 语法'); return `code --new-window && code --open-url "${url}"`; } }