Add registerHandleUri command

This commit is contained in:
smallstone 2024-01-18 17:52:55 +08:00
parent 4f937baa06
commit f2ab969f88
2 changed files with 25 additions and 1 deletions

View File

@ -389,6 +389,27 @@ export function registerDevChatChatCommand(context: vscode.ExtensionContext) {
context.subscriptions.push(disposable);
}
export function registerHandleUri(context: vscode.ExtensionContext){
context.subscriptions.push(vscode.window.registerUriHandler({
handleUri(uri) {
// 解析 URI 并执行相应的操作
if (uri.path.includes('accesskey')) {
const accessKey = uri.path.split('/')[2];
const modelConfig: any = UiUtilWrapper.getConfiguration("devchat", 'Provider.devchat');
const providerConfigNew:any = {}
if (Object.keys(modelConfig).length !== 0){
for (const key of Object.keys(modelConfig || {})) {
const property = modelConfig![key];
providerConfigNew[key] = property;
}
}
providerConfigNew.access_key = accessKey;
vscode.workspace.getConfiguration("devchat").update("Provider.devchat", providerConfigNew, vscode.ConfigurationTarget.Global);
}
}
}));
}
export {
registerOpenChatPanelCommand,
registerAddContextCommand,

View File

@ -17,7 +17,8 @@ import {
registerInstallCommandsCommand,
registerUpdateChatModelsCommand,
registerInstallCommandsPython,
registerDevChatChatCommand
registerDevChatChatCommand,
registerHandleUri,
} from './contributes/commands';
import { regLanguageContext } from './contributes/context';
import { regDevChatView, regTopicView } from './contributes/views';
@ -286,5 +287,7 @@ async function activate(context: vscode.ExtensionContext) {
registerDevChatChatCommand(context);
startRpcServer();
logger.channel()?.info(`registerHandleUri:`);
registerHandleUri(context)
}
exports.activate = activate;