@wendongfly/myhi 1.3.70 → 1.3.72

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/dist/chat.html CHANGED
@@ -147,6 +147,8 @@
147
147
  .tb-btn:active { transform: scale(0.92); }
148
148
  .tb-btn.active { color: #58a6ff; }
149
149
  .tb-btn.recording { color: #f85149; animation: pulse 1s infinite; }
150
+ @keyframes va-ring { 0% { box-shadow: 0 0 0 0 rgba(218,54,51,0.6); } 70% { box-shadow: 0 0 0 12px rgba(218,54,51,0); } 100% { box-shadow: 0 0 0 0 rgba(218,54,51,0); } }
151
+ .va-btn-rec { animation: va-ring 1s ease-out infinite !important; }
150
152
  .tb-btn svg { width: 18px; height: 18px; }
151
153
  #send-btn { color: #3fb950; }
152
154
  #send-btn:hover { background: rgba(63,185,80,0.12); color: #3fb950; }
@@ -602,6 +604,13 @@
602
604
  style="background:#1f6feb;color:#fff;font-size:1.1rem;font-weight:700;padding:1.1rem;margin:0 0.2rem 0.3rem;border:none;border-radius:12px;cursor:pointer;touch-action:none;user-select:none;-webkit-user-select:none">
603
605
  按住说话
604
606
  </button>
607
+ <div style="text-align:center;margin:0 0.2rem 0.3rem">
608
+ <input id="va-file-input" type="file" accept="audio/*,video/webm,video/mp4" style="display:none">
609
+ <button id="va-upload-btn" onclick="vaUploadAudio()"
610
+ style="background:#21262d;color:#8b949e;border:1px solid #30363d;border-radius:8px;font-size:0.8rem;padding:0.4rem 1rem;cursor:pointer;width:100%">
611
+ 📎 上传音频文件识别 (mp3 / wav / m4a / webm,最大 200MB)
612
+ </button>
613
+ </div>
605
614
  <div id="va-status" style="text-align:center;font-size:0.78rem;color:#8b949e;min-height:1.3em;margin-bottom:0.2rem"></div>
606
615
  <div style="display:flex;gap:0.4rem;padding:0 0.2rem">
607
616
  <button id="va-direct-btn" class="action-sheet-cancel" onclick="vaDirectSend()"
@@ -3123,7 +3132,10 @@
3123
3132
  const _vaBtn = document.getElementById('va-record-btn');
3124
3133
  const _vaStatusEl = document.getElementById('va-status');
3125
3134
 
3126
- function _vaSetStatus(t) { _vaStatusEl.textContent = t || ''; }
3135
+ function _vaSetStatus(t, color) {
3136
+ _vaStatusEl.textContent = t || '';
3137
+ _vaStatusEl.style.color = color || '#8b949e';
3138
+ }
3127
3139
 
3128
3140
  function _vaIdleLabel() { return _isTouchDevice() ? '按住说话' : '点击开始录音'; }
3129
3141
  function _vaActiveLabel() { return _isTouchDevice() ? '松手停止' : '点击停止录音'; }
@@ -3176,7 +3188,8 @@
3176
3188
  _vaActive = true;
3177
3189
  _vaBtn.textContent = _vaActiveLabel();
3178
3190
  _vaBtn.style.background = '#da3633';
3179
- _vaSetStatus('录音中...');
3191
+ _vaBtn.classList.add('va-btn-rec');
3192
+ _vaSetStatus('● 录音中', '#f85149');
3180
3193
  }
3181
3194
 
3182
3195
  function _vaStop() {
@@ -3184,7 +3197,8 @@
3184
3197
  _vaActive = false;
3185
3198
  _vaBtn.textContent = _vaIdleLabel();
3186
3199
  _vaBtn.style.background = '#1f6feb';
3187
- _vaSetStatus('识别中...');
3200
+ _vaBtn.classList.remove('va-btn-rec');
3201
+ _vaSetStatus('识别中...', '#d29922');
3188
3202
  _vaMR.stop();
3189
3203
  }
3190
3204
 
@@ -3195,16 +3209,16 @@
3195
3209
  const resp = await fetch(`/api/voice-transcribe?sessionId=${SESSION_ID}`, { method: 'POST', body: form });
3196
3210
  const data = await resp.json();
3197
3211
  if (resp.status === 503) {
3198
- _vaSetStatus('ASR 服务未配置');
3212
+ _vaSetStatus('ASR 服务未配置,请在设置中填写语音识别地址', '#f85149');
3199
3213
  } else if (data.text) {
3200
3214
  _vaLines.push(data.text);
3201
3215
  _vaRender();
3202
- _vaSetStatus(`第 ${_vaLines.length} 段已录入,可继续录或点"整理成需求"`);
3216
+ _vaSetStatus(`✓ ${_vaLines.length} 段已录入`, '#3fb950');
3203
3217
  } else {
3204
- _vaSetStatus('未识别到内容,请重试');
3218
+ _vaSetStatus('未识别到内容,请重试', '#d29922');
3205
3219
  }
3206
3220
  } catch (e) {
3207
- _vaSetStatus('上传失败: ' + e.message);
3221
+ _vaSetStatus('上传失败: ' + e.message, '#f85149');
3208
3222
  }
3209
3223
  }
3210
3224
 
@@ -3266,6 +3280,39 @@
3266
3280
  window.closeVaSheet();
3267
3281
  if (!_isTouchDevice()) cmdInput.focus();
3268
3282
  };
3283
+ window.vaUploadAudio = function() {
3284
+ const fi = document.getElementById('va-file-input');
3285
+ fi.onchange = async () => {
3286
+ const file = fi.files[0];
3287
+ if (!file) return;
3288
+ fi.value = '';
3289
+ const uploadBtn = document.getElementById('va-upload-btn');
3290
+ uploadBtn.disabled = true;
3291
+ _vaSetStatus(`上传中: ${file.name} (${(file.size/1024/1024).toFixed(1)}MB)`, '#d29922');
3292
+ try {
3293
+ const fd = new FormData();
3294
+ fd.append('audio', file, file.name);
3295
+ const resp = await fetch('/api/voice-transcribe', { method: 'POST', body: fd });
3296
+ if (resp.status === 503) {
3297
+ _vaSetStatus('ASR 服务未配置,请在设置中填写语音识别地址', '#f85149');
3298
+ return;
3299
+ }
3300
+ const data = await resp.json();
3301
+ if (data.text?.trim()) {
3302
+ _vaLines.push(data.text.trim());
3303
+ _vaRender();
3304
+ _vaSetStatus(`✓ 文件已识别,共 ${_vaLines.length} 段`, '#3fb950');
3305
+ } else {
3306
+ _vaSetStatus('识别失败: ' + (data.error || '空结果'), '#f85149');
3307
+ }
3308
+ } catch (e) {
3309
+ _vaSetStatus('上传失败: ' + e.message, '#f85149');
3310
+ } finally {
3311
+ uploadBtn.disabled = false;
3312
+ }
3313
+ };
3314
+ fi.click();
3315
+ };
3269
3316
 
3270
3317
  // 大录音按钮:手机长按、桌面单击切换
3271
3318
  _vaBtn.addEventListener('pointerdown', (e) => {