check dependence only once
This commit is contained in:
parent
93714a2255
commit
eca629b4f3
@ -32,22 +32,24 @@ function checkOpenAIKey() {
|
|||||||
return true;
|
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) {
|
function registerOpenChatPanelCommand(context: vscode.ExtensionContext) {
|
||||||
let disposable = vscode.commands.registerCommand('devchat.openChatPanel', () => {
|
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) {
|
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,
|
||||||
|
@ -2,10 +2,11 @@ import * as vscode from 'vscode';
|
|||||||
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
registerOpenChatPanelCommand,
|
checkDependencyPackage,
|
||||||
registerAddContextCommand,
|
registerOpenChatPanelCommand,
|
||||||
registerAskForCodeCommand,
|
registerAddContextCommand,
|
||||||
registerAskForFileCommand,
|
registerAskForCodeCommand,
|
||||||
|
registerAskForFileCommand,
|
||||||
} from './contributes/commands';
|
} from './contributes/commands';
|
||||||
|
|
||||||
import ExtensionContextHolder from './util/extensionContext';
|
import ExtensionContextHolder from './util/extensionContext';
|
||||||
@ -13,12 +14,13 @@ import { logger } from './util/logger';
|
|||||||
|
|
||||||
|
|
||||||
function activate(context: vscode.ExtensionContext) {
|
function activate(context: vscode.ExtensionContext) {
|
||||||
ExtensionContextHolder.context = context;
|
ExtensionContextHolder.context = context;
|
||||||
logger.init(context);
|
logger.init(context);
|
||||||
|
|
||||||
registerOpenChatPanelCommand(context);
|
checkDependencyPackage();
|
||||||
registerAddContextCommand(context);
|
registerOpenChatPanelCommand(context);
|
||||||
registerAskForCodeCommand(context);
|
registerAddContextCommand(context);
|
||||||
registerAskForFileCommand(context);
|
registerAskForCodeCommand(context);
|
||||||
|
registerAskForFileCommand(context);
|
||||||
}
|
}
|
||||||
exports.activate = activate;
|
exports.activate = activate;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user