@wendongfly/myhi 1.3.102 → 1.3.103
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 +44 -3
- package/package.json +1 -1
package/dist/chat.html
CHANGED
|
@@ -352,6 +352,7 @@
|
|
|
352
352
|
<button class="tb-btn" id="btn-photo" onclick="openCamera()" title="拍照">
|
|
353
353
|
<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>
|
|
354
354
|
</button>
|
|
355
|
+
<span id="enter-hint" style="display:none;font-size:0.68rem;color:var(--muted);white-space:nowrap;align-self:center;margin-left:0.15rem"></span>
|
|
355
356
|
<div class="spacer"></div>
|
|
356
357
|
<button class="tb-btn" id="voice-btn" onclick="openVaSheet()" title="语音输入 / 需求助手">
|
|
357
358
|
<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>
|
|
@@ -453,6 +454,18 @@
|
|
|
453
454
|
<label class="setting-toggle"><span>显示思考过程</span><input type="checkbox" id="set-thinking" checked></label>
|
|
454
455
|
<label class="setting-toggle"><span>工具调用默认折叠</span><input type="checkbox" id="set-collapse" checked></label>
|
|
455
456
|
</div>
|
|
457
|
+
<div class="setting-group">
|
|
458
|
+
<h4>输入</h4>
|
|
459
|
+
<div style="font-size:0.8rem;color:var(--text2);margin:0.1rem 0 0.35rem">回车键</div>
|
|
460
|
+
<div id="seg-enter" class="seg-row">
|
|
461
|
+
<button class="seg" data-enter="auto">自动</button>
|
|
462
|
+
<button class="seg" data-enter="send">发送</button>
|
|
463
|
+
<button class="seg" data-enter="newline">换行</button>
|
|
464
|
+
</div>
|
|
465
|
+
<div style="font-size:0.72rem;color:var(--muted);margin-top:0.35rem;line-height:1.5">
|
|
466
|
+
自动:电脑回车发送 / Shift+回车换行;手机回车换行、用按钮发送。<br>发送:回车总是发送(换行用 Shift+回车)。换行:回车总是换行(发送用 Ctrl/⌘+回车 或按钮)。
|
|
467
|
+
</div>
|
|
468
|
+
</div>
|
|
456
469
|
<div class="setting-group">
|
|
457
470
|
<h4>语音识别 (ASR)</h4>
|
|
458
471
|
<div style="font-size:0.72rem;color:var(--muted);margin-bottom:0.35rem">SenseVoice 或兼容服务的地址,留空表示禁用语音</div>
|
|
@@ -808,7 +821,7 @@
|
|
|
808
821
|
let workState = 'idle';
|
|
809
822
|
|
|
810
823
|
// 设置
|
|
811
|
-
const DEFAULT_SETTINGS = { parseOutput: true, showThinking: true, collapseTools: true };
|
|
824
|
+
const DEFAULT_SETTINGS = { parseOutput: true, showThinking: true, collapseTools: true, enterMode: 'auto' };
|
|
812
825
|
let settings = loadSettings();
|
|
813
826
|
|
|
814
827
|
function loadSettings() { try { return { ...DEFAULT_SETTINGS, ...JSON.parse(localStorage.getItem('myhi_chat_settings')) }; } catch { return { ...DEFAULT_SETTINGS }; } }
|
|
@@ -837,6 +850,24 @@
|
|
|
837
850
|
}
|
|
838
851
|
document.querySelectorAll('#seg-theme .seg').forEach(b => b.addEventListener('click', () => applyTheme(b.dataset.theme)));
|
|
839
852
|
document.querySelectorAll('#seg-font .seg').forEach(b => b.addEventListener('click', () => applyFont(b.dataset.font)));
|
|
853
|
+
// 回车键行为(自动/发送/换行)——存 settings.enterMode,keydown 处理器读取
|
|
854
|
+
function updateEnterHint() {
|
|
855
|
+
const el = document.getElementById('enter-hint');
|
|
856
|
+
if (!el) return;
|
|
857
|
+
if (window.matchMedia('(pointer: coarse)').matches) { el.style.display = 'none'; return; } // 手机不显示
|
|
858
|
+
const mode = settings.enterMode || 'auto';
|
|
859
|
+
el.textContent = mode === 'newline' ? 'Enter 换行 · Ctrl+Enter 发送' : 'Enter 发送 · Shift+Enter 换行';
|
|
860
|
+
el.style.display = '';
|
|
861
|
+
}
|
|
862
|
+
function syncEnterModeUI() {
|
|
863
|
+
const m = settings.enterMode || 'auto';
|
|
864
|
+
document.querySelectorAll('#seg-enter .seg').forEach(b => b.classList.toggle('active', b.dataset.enter === m));
|
|
865
|
+
updateEnterHint();
|
|
866
|
+
}
|
|
867
|
+
document.querySelectorAll('#seg-enter .seg').forEach(b => b.addEventListener('click', () => {
|
|
868
|
+
settings.enterMode = b.dataset.enter; saveSettings(); syncEnterModeUI();
|
|
869
|
+
}));
|
|
870
|
+
updateEnterHint();
|
|
840
871
|
|
|
841
872
|
// 输出累积
|
|
842
873
|
let outputBuffer = '';
|
|
@@ -2035,8 +2066,17 @@
|
|
|
2035
2066
|
}
|
|
2036
2067
|
return;
|
|
2037
2068
|
}
|
|
2038
|
-
if (e.key === 'Enter'
|
|
2039
|
-
|
|
2069
|
+
if (e.key === 'Enter') {
|
|
2070
|
+
if (e.isComposing || e.keyCode === 229) return; // 中文/日文输入法选词中,绝不发送
|
|
2071
|
+
if (e.ctrlKey || e.metaKey) { e.preventDefault(); sendCommand(); return; } // Ctrl/⌘+回车 始终发送
|
|
2072
|
+
const mode = settings.enterMode || 'auto';
|
|
2073
|
+
const sendOnEnter = mode === 'send' ? !e.shiftKey
|
|
2074
|
+
: mode === 'newline' ? false
|
|
2075
|
+
: (!e.shiftKey && !window.matchMedia('(pointer: coarse)').matches); // 自动:桌面(细指针)发送、触屏换行
|
|
2076
|
+
if (sendOnEnter) { e.preventDefault(); sendCommand(); }
|
|
2077
|
+
return; // 不发送时交给 textarea 默认插入换行
|
|
2078
|
+
}
|
|
2079
|
+
if (e.key === 'ArrowUp' && !cmdInput.value) { if (historyIdx < cmdHistory.length - 1) { historyIdx++; cmdInput.value = cmdHistory[historyIdx]; } e.preventDefault(); }
|
|
2040
2080
|
else if (e.key === 'ArrowDown' && !cmdInput.value) { if (historyIdx > 0) { historyIdx--; cmdInput.value = cmdHistory[historyIdx]; } else if (historyIdx === 0) { historyIdx = -1; cmdInput.value = ''; } e.preventDefault(); }
|
|
2041
2081
|
});
|
|
2042
2082
|
|
|
@@ -2405,6 +2445,7 @@
|
|
|
2405
2445
|
document.getElementById('set-parse').checked = settings.parseOutput;
|
|
2406
2446
|
document.getElementById('set-thinking').checked = settings.showThinking;
|
|
2407
2447
|
document.getElementById('set-collapse').checked = settings.collapseTools;
|
|
2448
|
+
syncEnterModeUI();
|
|
2408
2449
|
// 从服务端加载 ASR URL
|
|
2409
2450
|
fetch('/api/server-config').then(r => r.json()).then(d => {
|
|
2410
2451
|
document.getElementById('set-asr-url').value = d.asrUrl || '';
|
package/package.json
CHANGED