From 418807206521671e5d9e50024b9a3ad9a9d67d5b Mon Sep 17 00:00:00 2001 From: Levi Yan Date: Sun, 23 Mar 2025 17:15:33 +0800 Subject: [PATCH] refactor: set showErrorNotification as a function for reuse --- src/home.ts | 7 +------ src/utils.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/home.ts b/src/home.ts index 37baf94..c923747 100644 --- a/src/home.ts +++ b/src/home.ts @@ -132,12 +132,7 @@ export default class DSHome { vscode.window.showWarningMessage(data.message) break; case 'showErrorNotification': - const selection = await vscode.window.showErrorMessage(data.message, 'Open Console', 'Report a problem',); - if (selection === 'Open Console') { - vscode.commands.executeCommand('workbench.action.toggleDevTools'); - } else if (selection === 'Report a problem') { - vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://gitee.com/SuperIDE/DevStar/issues')); - } + await utils.showErrorNotification(data.message) break; } } diff --git a/src/utils.ts b/src/utils.ts index b9ba852..ad1e4e4 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -106,4 +106,13 @@ export async function getVsCodeCommitId(): Promise { export function getDevstarDomain(): string | undefined { // 从用户配置中读取 return vscode.workspace.getConfiguration('devstar').get('devstarDomain') +} + +export async function showErrorNotification(message: string): Promise { + const selection = await vscode.window.showErrorMessage(message, 'Open Console', 'Report a problem',); + if (selection === 'Open Console') { + vscode.commands.executeCommand('workbench.action.toggleDevTools'); + } else if (selection === 'Report a problem') { + vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://gitee.com/SuperIDE/DevStar/issues')); + } } \ No newline at end of file