diff --git a/CHANGELOG.md b/CHANGELOG.md index c8cd11e..a13d4d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## [main] 0.1.10 - 修复 issue #48: 修复错误的引导路径。 -- 修复非中文语言下,初始化引导界面不跟随主界面的问题。 +- 完成引导界面的多语言。 - 修复部分模型的 usage 无法正常显示的问题。 - 实现 openmcp 工具测试的并行实现和暂停功能。 diff --git a/renderer/src/api/message-bridge.ts b/renderer/src/api/message-bridge.ts index 231973d..36e6f6e 100644 --- a/renderer/src/api/message-bridge.ts +++ b/renderer/src/api/message-bridge.ts @@ -1,6 +1,7 @@ import { pinkLog, redLog } from '@/views/setting/util'; import { acquireVsCodeApi, electronApi, getPlatform } from './platform'; import { isReactive } from 'vue'; +import { v4 as uuidv4 } from 'uuid'; export interface VSCodeMessage { command: string; @@ -9,6 +10,7 @@ export interface VSCodeMessage { } export interface RestFulResponse { + _id?: string code: number; msg: T; } @@ -163,8 +165,8 @@ export class MessageBridge { const command = message.command; const data = message.data; - const handlers = this.handlers.get(command) || []; - handlers.forEach(handler => handler(data)); + const handlers = this.handlers.get(command) || new Set(); + handlers.forEach(handler => handler(data)); } public postMessage(message: VSCodeMessage) { @@ -231,15 +233,26 @@ export class MessageBridge { * @returns */ public commandRequest(command: string, data?: ICommandRequestData): Promise> { + const _id = uuidv4(); + + return new Promise((resolve, reject) => { + const handler = this.addCommandListener(command, (data) => { + if (data._id === undefined) { + console.warn('detect data without id, data: ' + JSON.stringify(data, null, 2)); + } - return new Promise((resolve, reject) => { - this.addCommandListener(command, (data) => { - resolve(data as RestFulResponse); - }, { once: true }); + if (data._id === _id) { + handler(); + resolve(data as RestFulResponse); + } + }, { once: false }); this.postMessage({ - command, - data: this.deserializeReactiveData(data) + command, + data: this.deserializeReactiveData({ + _id, + ...data + }) }); }); } diff --git a/renderer/src/components/guide/tour.vue b/renderer/src/components/guide/tour.vue index 668194c..aa1a764 100644 --- a/renderer/src/components/guide/tour.vue +++ b/renderer/src/components/guide/tour.vue @@ -1,23 +1,23 @@