From fcb8aab3914260c32dbe416fdc47ab6637c4cfb3 Mon Sep 17 00:00:00 2001 From: Levi Yan Date: Mon, 24 Mar 2025 10:28:55 +0800 Subject: [PATCH] feat: add notification for login and logout --- src/main.ts | 4 ---- src/user.ts | 6 +++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 3b1688a..c095347 100644 --- a/src/main.ts +++ b/src/main.ts @@ -40,8 +40,6 @@ export class DevStarExtension { const res = await this.user.login(access_token, devstar_username) if (res === 'ok') { await this.remoteContainer.firstOpenProject(container_host, container_port, container_username, project_path) - } else { - console.error(res) } } else if (devstar_username === this.user.getUsernameFromLocal()) { // 如果同用户已经登录,则忽略; @@ -56,8 +54,6 @@ export class DevStarExtension { const res = await this.user.login(access_token, devstar_username) if (res === 'ok') { await this.remoteContainer.firstOpenProject(container_host, container_port, container_username, project_path) - } else { - console.error(res) } } else if (selection === 'No') { await openProjectWithoutLogging(container_host, container_port, container_username, project_path); diff --git a/src/user.ts b/src/user.ts index dfa19b2..52e29e2 100644 --- a/src/user.ts +++ b/src/user.ts @@ -3,6 +3,7 @@ import * as path from 'path'; import * as os from 'os'; import * as fs from 'fs'; import DevstarAPIHandler from './devstar-api'; +import { showErrorNotification } from './utils'; const { generateKeyPairSync, createHash @@ -56,10 +57,12 @@ export default class User { throw new Error('Upload user public key failed') } } - + + vscode.window.showInformationMessage('用户已登录!') return 'ok' } catch (error) { console.error(error) + await showErrorNotification('用户登录失败!') return 'login failed' } } @@ -67,6 +70,7 @@ export default class User { public logout() { this.setUserTokenToLocal("") this.setUsernameToLocal("") + vscode.window.showInformationMessage('用户已登出!') } public isLogged() {