@huyooo/ai-chat-frontend-vue 0.2.12 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huyooo/ai-chat-frontend-vue",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "AI Chat Frontend - Vue components with adapter pattern",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -31,8 +31,8 @@
31
31
  "vue": "^3.4.0"
32
32
  },
33
33
  "dependencies": {
34
- "@huyooo/ai-chat-bridge-electron": "^0.2.12",
35
- "@huyooo/ai-chat-shared": "^0.2.12",
34
+ "@huyooo/ai-chat-bridge-electron": "^0.2.13",
35
+ "@huyooo/ai-chat-shared": "^0.2.13",
36
36
  "@iconify/vue": "^4.1.2",
37
37
  "vscode-uri": "^3.1.0",
38
38
  "marked": "^12.0.0",
@@ -21,7 +21,7 @@
21
21
  * ```
22
22
  */
23
23
 
24
- import { ref, onUnmounted, computed, type Ref } from 'vue';
24
+ import { ref, onUnmounted, computed, onMounted, type Ref } from 'vue';
25
25
  import type { ChatAdapter, AsrResultData } from '@huyooo/ai-chat-bridge-electron/renderer';
26
26
 
27
27
  // ============ 类型定义 ============
@@ -216,6 +216,9 @@ registerProcessor('pcm-capture', PcmCaptureProcessor);
216
216
 
217
217
  // ============ Composable ============
218
218
 
219
+ // 全局预热标志:确保只预热一次(避免多个组件实例重复预热)
220
+ let asrWarmupDone = false;
221
+
219
222
  /**
220
223
  * 语音输入 Composable
221
224
  */
@@ -230,6 +233,17 @@ export function useVoiceInput(
230
233
  enableItn = true,
231
234
  } = config;
232
235
 
236
+ // 自动预热 ASR 连接(仅首次调用,延迟执行,避免阻塞初始化)
237
+ if (adapter && !asrWarmupDone && typeof adapter.asrWarmup === 'function') {
238
+ asrWarmupDone = true;
239
+ // 延迟 800ms 预热,避免与首屏渲染竞争资源
240
+ setTimeout(() => {
241
+ adapter.asrWarmup?.().catch(() => {
242
+ // 静默失败,不影响功能
243
+ });
244
+ }, 800);
245
+ }
246
+
233
247
  // 状态
234
248
  const status = ref<VoiceInputStatus>('idle');
235
249
  const currentText = ref('');