From 7d21c0df5af82d317be29faced838e7646cb5f2f Mon Sep 17 00:00:00 2001 From: Levi Yan Date: Tue, 25 Feb 2025 11:43:06 +0800 Subject: [PATCH] feat: open project without logging --- package.json | 5 ----- src/main.ts | 18 +++++------------- src/remote-container.ts | 8 ++++++++ 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 4ad51aa..cf1db0e 100644 --- a/package.json +++ b/package.json @@ -34,11 +34,6 @@ "command": "devstar.connectRemoteContainer", "title": "Connect to a Remote Container", "category": "DevStar" - }, - { - "command": "devstar.openProject", - "title": "Open Project", - "category": "DevStar" } ], "uriHandlers": [{ diff --git a/src/main.ts b/src/main.ts index 6db0c2f..7342718 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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) - }) + ) ); } } diff --git a/src/remote-container.ts b/src/remote-container.ts index c48f2a5..27fbb9d 100644 --- a/src/remote-container.ts +++ b/src/remote-container.ts @@ -146,3 +146,11 @@ export default class RemoteContainer { } } + + +export async function openProjectWithoutLogging(host: string, port: number, username: string, path: string): Promise { + 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); + } \ No newline at end of file