check dependence only once

This commit is contained in:
bobo.yang 2023-05-11 10:27:54 +08:00
parent 93714a2255
commit eca629b4f3
2 changed files with 29 additions and 24 deletions

View File

@ -32,8 +32,7 @@ function checkOpenAIKey() {
return true; return true;
} }
function registerOpenChatPanelCommand(context: vscode.ExtensionContext) { function checkDependencyPackage() {
let disposable = vscode.commands.registerCommand('devchat.openChatPanel', () => {
const dependencyInstalled = checkDependency(); const dependencyInstalled = checkDependency();
if (!dependencyInstalled) { if (!dependencyInstalled) {
// 依赖程序未安装,显示提示信息 // 依赖程序未安装,显示提示信息
@ -47,7 +46,10 @@ function registerOpenChatPanelCommand(context: vscode.ExtensionContext) {
if (!checkOpenAIKey()) { if (!checkOpenAIKey()) {
return; return;
} }
}
function registerOpenChatPanelCommand(context: vscode.ExtensionContext) {
let disposable = vscode.commands.registerCommand('devchat.openChatPanel', () => {
if (vscode.workspace.workspaceFolders) { if (vscode.workspace.workspaceFolders) {
ChatPanel.createOrShow(context.extensionUri); ChatPanel.createOrShow(context.extensionUri);
} else { } else {
@ -110,6 +112,7 @@ function registerAskForFileCommand(context: vscode.ExtensionContext) {
} }
export { export {
checkDependencyPackage,
registerOpenChatPanelCommand, registerOpenChatPanelCommand,
registerAddContextCommand, registerAddContextCommand,
registerAskForCodeCommand, registerAskForCodeCommand,

View File

@ -2,6 +2,7 @@ import * as vscode from 'vscode';
import { import {
checkDependencyPackage,
registerOpenChatPanelCommand, registerOpenChatPanelCommand,
registerAddContextCommand, registerAddContextCommand,
registerAskForCodeCommand, registerAskForCodeCommand,
@ -16,6 +17,7 @@ function activate(context: vscode.ExtensionContext) {
ExtensionContextHolder.context = context; ExtensionContextHolder.context = context;
logger.init(context); logger.init(context);
checkDependencyPackage();
registerOpenChatPanelCommand(context); registerOpenChatPanelCommand(context);
registerAddContextCommand(context); registerAddContextCommand(context);
registerAskForCodeCommand(context); registerAskForCodeCommand(context);