check dependence only once
This commit is contained in:
parent
93714a2255
commit
eca629b4f3
@ -32,22 +32,24 @@ function checkOpenAIKey() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkDependencyPackage() {
|
||||
const dependencyInstalled = checkDependency();
|
||||
if (!dependencyInstalled) {
|
||||
// 依赖程序未安装,显示提示信息
|
||||
logger.channel()?.error('devchat package is not installed.');
|
||||
logger.channel()?.info('Please install devchat package first. Use command: pip install devchat');
|
||||
logger.channel()?.show();
|
||||
vscode.window.showErrorMessage('devchat package is not installed.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkOpenAIKey()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function registerOpenChatPanelCommand(context: vscode.ExtensionContext) {
|
||||
let disposable = vscode.commands.registerCommand('devchat.openChatPanel', () => {
|
||||
const dependencyInstalled = checkDependency();
|
||||
if (!dependencyInstalled) {
|
||||
// 依赖程序未安装,显示提示信息
|
||||
logger.channel()?.error('devchat package is not installed.');
|
||||
logger.channel()?.info('Please install devchat package first. Use command: pip install devchat');
|
||||
logger.channel()?.show();
|
||||
vscode.window.showErrorMessage('devchat package is not installed.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkOpenAIKey()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (vscode.workspace.workspaceFolders) {
|
||||
ChatPanel.createOrShow(context.extensionUri);
|
||||
} else {
|
||||
@ -110,6 +112,7 @@ function registerAskForFileCommand(context: vscode.ExtensionContext) {
|
||||
}
|
||||
|
||||
export {
|
||||
checkDependencyPackage,
|
||||
registerOpenChatPanelCommand,
|
||||
registerAddContextCommand,
|
||||
registerAskForCodeCommand,
|
||||
|
@ -2,10 +2,11 @@ import * as vscode from 'vscode';
|
||||
|
||||
|
||||
import {
|
||||
registerOpenChatPanelCommand,
|
||||
registerAddContextCommand,
|
||||
registerAskForCodeCommand,
|
||||
registerAskForFileCommand,
|
||||
checkDependencyPackage,
|
||||
registerOpenChatPanelCommand,
|
||||
registerAddContextCommand,
|
||||
registerAskForCodeCommand,
|
||||
registerAskForFileCommand,
|
||||
} from './contributes/commands';
|
||||
|
||||
import ExtensionContextHolder from './util/extensionContext';
|
||||
@ -13,12 +14,13 @@ import { logger } from './util/logger';
|
||||
|
||||
|
||||
function activate(context: vscode.ExtensionContext) {
|
||||
ExtensionContextHolder.context = context;
|
||||
logger.init(context);
|
||||
ExtensionContextHolder.context = context;
|
||||
logger.init(context);
|
||||
|
||||
registerOpenChatPanelCommand(context);
|
||||
registerAddContextCommand(context);
|
||||
registerAskForCodeCommand(context);
|
||||
registerAskForFileCommand(context);
|
||||
checkDependencyPackage();
|
||||
registerOpenChatPanelCommand(context);
|
||||
registerAddContextCommand(context);
|
||||
registerAskForCodeCommand(context);
|
||||
registerAskForFileCommand(context);
|
||||
}
|
||||
exports.activate = activate;
|
||||
|
Loading…
x
Reference in New Issue
Block a user