feat: clean - clean ssh key and logout

This commit is contained in:
Levi Yan
2025-04-23 09:13:42 +08:00
parent 5385a9bc84
commit 473eab1c8c

View File

@@ -1,4 +1,5 @@
import * as vscode from 'vscode';
import * as fs from 'fs';
import QuickAccessTreeProvider from './views/quick-access-tree';
import DSHome from './home';
import RemoteContainer, { openProjectWithoutLogging } from './remote-container';
@@ -95,7 +96,17 @@ export class DevStarExtension {
vscode.commands.registerCommand('devstar.showHome', (url: string) =>
this.dsHome.toggle(url)
),
vscode.commands.registerCommand('devstar.logout', () => {
vscode.commands.registerCommand('devstar.clean', () => {
// 先清除ssh key
if (fs.existsSync(this.user.getUserPrivateKeyPath())) {
fs.unlinkSync(this.user.getUserPrivateKeyPath())
}
if (fs.existsSync(this.user.getUserPublicKeyPath())) {
fs.unlinkSync(this.user.getUserPublicKeyPath())
}
console.log("User's ssh key has been deleted!")
// 退出登录
this.user.logout()
})
);