Merge pull request #416 from devchat-ai/feat/uri

Feat/uri
This commit is contained in:
Rankin Zheng 2024-01-24 18:03:34 +08:00 committed by GitHub
commit 73a3acc531
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 1 deletions

View File

@ -397,6 +397,29 @@ 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);
ensureChatPanel(context);
ExtensionContextHolder.provider?.reloadWebview();
}
}
}));
}
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) {
registerCodeLensProvider(context);
startRpcServer();
logger.channel()?.info(`registerHandleUri:`);
registerHandleUri(context)
}
exports.activate = activate;