feat: 避免打开同一个项目(home、open with vscode)

This commit is contained in:
Levi Yan
2025-05-31 22:51:28 +08:00
parent a8d5f4acb8
commit 91ac39ac0b
5 changed files with 46 additions and 9 deletions

View File

@@ -30,7 +30,7 @@ export default class RemoteContainer {
.then((res) => {
if (res === 'success') {
// only success then open folder
this.openRemoteFolder(host, port, username, path);
this.openRemoteFolder(host, port, username, path, context);
}
})
}
@@ -232,7 +232,7 @@ export default class RemoteContainer {
*
* @host 表示project name
*/
openRemoteFolder(host: string, port: number, username: string, path: string): void {
openRemoteFolder(host: string, port: number, username: string, path: string, context:vscode.ExtensionContext): void {
if (vscode.env.remoteName) {
// 远程环境打开local terminal
vscode.commands.executeCommand('workbench.action.terminal.newLocal').then(() => {
@@ -245,6 +245,9 @@ export default class RemoteContainer {
})
} else {
// 本地环境
// 在打开之前需要先将host的信息记录到global state中让home能够确认打开的host是哪个project的
context.globalState.update('currentHost', host)
let terminal = vscode.window.activeTerminal || vscode.window.createTerminal(`Ext Terminal`);
terminal.show(true);
// 在原窗口打开