feat: open project without logging

This commit is contained in:
Levi Yan
2025-02-25 11:43:06 +08:00
parent 04b2d6bcaf
commit 7d21c0df5a
3 changed files with 13 additions and 18 deletions

View File

@@ -34,11 +34,6 @@
"command": "devstar.connectRemoteContainer",
"title": "Connect to a Remote Container",
"category": "DevStar"
},
{
"command": "devstar.openProject",
"title": "Open Project",
"category": "DevStar"
}
],
"uriHandlers": [{

View File

@@ -1,7 +1,7 @@
import * as vscode from 'vscode';
import QuickAccessTreeProvider from './views/quick-access-tree';
import DSHome from './home';
import RemoteContainer from './remote-container';
import {openProjectWithoutLogging} from './remote-container';
export class DevStarExtension {
dsHome: DSHome;
@@ -20,13 +20,9 @@ export class DevStarExtension {
const username = params.get('username');
const path = params.get('path');
if (host && port && username && path) {
await vscode.commands.executeCommand('devstar.openProject', {
host: host,
port: parseInt(port, 10),
username: username,
path: decodeURIComponent(path) // 解码路径
});
if (host && port && username && path) {
await openProjectWithoutLogging(host, parseInt(port, 10), username, decodeURIComponent(path))
} else {
vscode.window.showErrorMessage('Missing required parameters.');
}
@@ -55,11 +51,7 @@ export class DevStarExtension {
context.subscriptions.push(
vscode.commands.registerCommand('devstar.showHome', (url: string) =>
this.dsHome.toggle(url)
),
vscode.commands.registerCommand('devstar.openProject', (args) => {
const { host, port, username, path } = args;
RemoteContainer.openRemoteFolder(host, port, username, path)
})
)
);
}
}

View File

@@ -146,3 +146,11 @@ export default class RemoteContainer {
}
}
export async function openProjectWithoutLogging(host: string, port: number, username: string, path: string): Promise<void> {
const command = `code --remote ssh-remote+${username}@${host}:${port} ${path} --reuse-window`
let terminal = vscode.window.activeTerminal || vscode.window.createTerminal(`Ext Terminal`);
terminal.show(true);
terminal.sendText(command);
}