Merge pull request '针对shell路径判断方式进行优化' (#1) from fix-bug into main
Reviewed-on: http://192.168.10.4/yinxue/devstar-vscode/pulls/1
This commit is contained in:
@@ -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"
|
||||
},
|
||||
|
||||
@@ -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}"`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user