@wendongfly/myhi 1.3.65 → 1.3.67

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.
Files changed (2) hide show
  1. package/dist/chat.html +21 -44
  2. package/package.json +1 -1
package/dist/chat.html CHANGED
@@ -307,7 +307,7 @@
307
307
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z"/><circle cx="12" cy="13" r="4"/></svg>
308
308
  </button>
309
309
  <div class="spacer"></div>
310
- <button class="tb-btn" id="voice-btn" onclick="toggleVoice()" title="语音输入">
310
+ <button class="tb-btn" id="voice-btn" onclick="openVaSheet()" title="语音输入 / 需求助手">
311
311
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 00-3 3v8a3 3 0 006 0V4a3 3 0 00-3-3z"/><path d="M19 10v2a7 7 0 01-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>
312
312
  </button>
313
313
  <button class="tb-btn" id="send-btn" onclick="sendCommand()" title="发送">
@@ -3106,42 +3106,10 @@
3106
3106
  }
3107
3107
  }
3108
3108
 
3109
- // 桌面端:点击切换;触屏:长按录音松手发送,短按提示
3109
+ // 工具栏语音按钮已改为打开 VA 面板(openVaSheet),不再做内嵌录音
3110
3110
  const MIN_RECORD_MS = 400;
3111
3111
  let _voiceStartTime = 0;
3112
3112
 
3113
- _voiceBtn.addEventListener('click', (e) => {
3114
- if (_isTouchDevice()) return; // 触屏由 pointer 事件处理
3115
- _startVoice();
3116
- });
3117
- _voiceBtn.addEventListener('pointerdown', (e) => {
3118
- if (!_isTouchDevice()) return;
3119
- e.preventDefault();
3120
- cmdInput.blur(); // 防止键盘弹出
3121
- _voiceStartTime = Date.now();
3122
- _startVoice();
3123
- });
3124
- _voiceBtn.addEventListener('pointerup', (e) => {
3125
- if (!_isTouchDevice() || !_voiceActive) return;
3126
- e.preventDefault();
3127
- const elapsed = Date.now() - _voiceStartTime;
3128
- if (elapsed < MIN_RECORD_MS) {
3129
- // 短按:取消录音,不上传,给提示
3130
- _voiceActive = false;
3131
- _voiceBtn.classList.remove('recording');
3132
- _voicePlaceholder();
3133
- try { _mediaRecorder?.stream?.getTracks().forEach(t => t.stop()); } catch {}
3134
- try { if (_mediaRecorder?.state !== 'inactive') _mediaRecorder?.stop(); } catch {}
3135
- _mediaRecorder = null;
3136
- addStatusMessage('请长按 🎤 录音(按住说话,松手识别)');
3137
- return;
3138
- }
3139
- _stopVoice();
3140
- });
3141
- _voiceBtn.addEventListener('pointercancel', () => { if (_voiceActive) _stopVoice(); });
3142
-
3143
- window.toggleVoice = _startVoice; // 保留 onclick 兼容
3144
-
3145
3113
  // ── 语音需求助手 ──────────────────────────────────────────
3146
3114
  let _vaLines = [];
3147
3115
  let _vaMR = null;
@@ -3153,10 +3121,16 @@
3153
3121
 
3154
3122
  function _vaSetStatus(t) { _vaStatusEl.textContent = t || ''; }
3155
3123
 
3124
+ function _vaIdleLabel() { return _isTouchDevice() ? '按住说话' : '点击开始录音'; }
3125
+ function _vaActiveLabel() { return _isTouchDevice() ? '松手停止' : '点击停止录音'; }
3126
+
3156
3127
  function _vaRender() {
3157
3128
  const el = document.getElementById('va-transcript');
3158
3129
  if (_vaLines.length === 0) {
3159
- el.innerHTML = '<span style="color:#8b949e">按住大按钮说话,松手自动识别,多轮累积后整理成需求...</span>';
3130
+ const hint = _isTouchDevice()
3131
+ ? '按住大按钮说话,松手自动识别,多轮累积后整理成需求...'
3132
+ : '点击大按钮开始录音,再次点击停止,多轮累积后整理成需求...';
3133
+ el.innerHTML = `<span style="color:#8b949e">${hint}</span>`;
3160
3134
  } else {
3161
3135
  el.textContent = _vaLines.map((t, i) => `[${i + 1}] ${t}`).join('\n\n');
3162
3136
  el.scrollTop = el.scrollHeight;
@@ -3184,7 +3158,7 @@
3184
3158
  };
3185
3159
  _vaMR.start();
3186
3160
  _vaActive = true;
3187
- _vaBtn.textContent = '松手停止';
3161
+ _vaBtn.textContent = _vaActiveLabel();
3188
3162
  _vaBtn.style.background = '#da3633';
3189
3163
  _vaSetStatus('录音中...');
3190
3164
  }
@@ -3192,7 +3166,7 @@
3192
3166
  function _vaStop() {
3193
3167
  if (!_vaActive || !_vaMR) return;
3194
3168
  _vaActive = false;
3195
- _vaBtn.textContent = '按住说话';
3169
+ _vaBtn.textContent = _vaIdleLabel();
3196
3170
  _vaBtn.style.background = '#1f6feb';
3197
3171
  _vaSetStatus('识别中...');
3198
3172
  _vaMR.stop();
@@ -3219,11 +3193,13 @@
3219
3193
  }
3220
3194
 
3221
3195
  window.openVaSheet = function() {
3222
- document.getElementById('va-sheet').classList.add('active');
3196
+ document.getElementById('va-sheet').classList.add('open');
3197
+ _vaBtn.textContent = _vaIdleLabel();
3198
+ _vaBtn.style.background = '#1f6feb';
3223
3199
  _vaRender();
3224
3200
  };
3225
3201
  window.closeVaSheet = function() {
3226
- document.getElementById('va-sheet').classList.remove('active');
3202
+ document.getElementById('va-sheet').classList.remove('open');
3227
3203
  if (_vaActive) _vaStop();
3228
3204
  };
3229
3205
  window.vaClear = function() {
@@ -3269,19 +3245,20 @@
3269
3245
  if (!_isTouchDevice()) cmdInput.focus();
3270
3246
  };
3271
3247
 
3272
- // 大录音按钮事件(长按逻辑与主录音按钮一致)
3248
+ // 大录音按钮:手机长按、桌面单击切换
3273
3249
  _vaBtn.addEventListener('pointerdown', (e) => {
3250
+ if (!_isTouchDevice()) return; // 桌面由 click 事件处理,pointer 不介入
3274
3251
  e.preventDefault();
3275
3252
  _vaStartTime2 = Date.now();
3276
3253
  _vaStart();
3277
3254
  });
3278
3255
  _vaBtn.addEventListener('pointerup', (e) => {
3256
+ if (!_isTouchDevice() || !_vaActive) return;
3279
3257
  e.preventDefault();
3280
- if (!_vaActive) return;
3281
3258
  const elapsed = Date.now() - _vaStartTime2;
3282
3259
  if (elapsed < MIN_RECORD_MS) {
3283
3260
  _vaActive = false;
3284
- _vaBtn.textContent = '按住说话';
3261
+ _vaBtn.textContent = _vaIdleLabel();
3285
3262
  _vaBtn.style.background = '#1f6feb';
3286
3263
  try { _vaMR?.stream?.getTracks().forEach(t => t.stop()); } catch {}
3287
3264
  try { if (_vaMR?.state !== 'inactive') _vaMR?.stop(); } catch {}
@@ -3291,9 +3268,9 @@
3291
3268
  }
3292
3269
  _vaStop();
3293
3270
  });
3294
- _vaBtn.addEventListener('pointercancel', () => { if (_vaActive) _vaStop(); });
3271
+ _vaBtn.addEventListener('pointercancel', () => { if (_vaActive && _isTouchDevice()) _vaStop(); });
3295
3272
  _vaBtn.addEventListener('click', (e) => {
3296
- if (_isTouchDevice()) return; // 触屏由 pointer 处理
3273
+ if (_isTouchDevice()) return; // 手机由 pointer 处理
3297
3274
  if (_vaActive) { _vaStop(); } else { _vaStart(); }
3298
3275
  });
3299
3276
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wendongfly/myhi",
3
- "version": "1.3.65",
3
+ "version": "1.3.67",
4
4
  "description": "Web-based terminal sharing with chat UI — control your terminal from phone via LAN/Tailscale",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",