修复远程终端识别本地操作系统问题并完善工作流配置 #7
@@ -13,12 +13,15 @@
|
|||||||
"warn",
|
"warn",
|
||||||
{
|
{
|
||||||
"selector": "import",
|
"selector": "import",
|
||||||
"format": [ "camelCase", "PascalCase" ]
|
"format": [
|
||||||
|
"camelCase",
|
||||||
|
"PascalCase"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"@typescript-eslint/semi": "warn",
|
"@typescript-eslint/semi": "off",
|
||||||
"curly": "warn",
|
"curly": "warn",
|
||||||
"eqeqeq": "warn",
|
"eqeqeq": "off",
|
||||||
"no-throw-literal": "warn",
|
"no-throw-literal": "warn",
|
||||||
"semi": "off"
|
"semi": "off"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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 baseUrl = `vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}`;
|
||||||
const url = devstarDomain ? `${baseUrl}&devstar_domain=${devstarDomain}` : baseUrl;
|
const url = devstarDomain ? `${baseUrl}&devstar_domain=${devstarDomain}` : baseUrl;
|
||||||
|
|
||||||
// 通过终端的 creationOptions 获取 shell 路径
|
// 获取本地操作系统类型
|
||||||
|
// 在远程环境下,os.platform() 返回的是远程系统,但这里我们需要的是本地系统
|
||||||
|
// 所以通过终端的 shell 路径来推断
|
||||||
const shellPath = (terminal.creationOptions as any)?.shellPath || '';
|
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('pwsh') ||
|
||||||
shellPath.toLowerCase().includes('cmd');
|
shellPath.toLowerCase().includes('cmd');
|
||||||
|
|
||||||
if (isWindows) {
|
if (isWindows) {
|
||||||
// PowerShell/CMD: 使用分号分隔,URL 需要特殊的引号处理
|
// Windows PowerShell/CMD: 使用分号分隔,URL 需要特殊的引号处理
|
||||||
console.log('检测到 Windows shell,使用 PowerShell 语法');
|
console.log('检测到 Windows 本地系统,使用 PowerShell/CMD 语法');
|
||||||
return `code --new-window; code --open-url '"${url}"'`;
|
return `code --new-window; code --open-url '"${url}"'`;
|
||||||
} else {
|
} else {
|
||||||
// Bash/Zsh: 使用 && 分隔,标准双引号
|
// macOS/Linux: 使用 && 分隔,标准双引号
|
||||||
console.log('检测到 Unix shell,使用 Bash 语法');
|
console.log('检测到 Unix 本地系统(macOS/Linux),使用 Bash/Zsh 语法');
|
||||||
return `code --new-window && code --open-url "${url}"`;
|
return `code --new-window && code --open-url "${url}"`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user