@wendongfly/myhi 1.0.5 → 1.0.7
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 +40 -14
- package/dist/index.html +4 -3
- package/package.json +1 -1
package/dist/chat.html
CHANGED
|
@@ -129,7 +129,13 @@
|
|
|
129
129
|
/* ── 输入栏 ─────────────────────────────── */
|
|
130
130
|
#input-area { background: #161b22; border-top: 1px solid #30363d; flex-shrink: 0; padding: 0.5rem 0.75rem 0.35rem; }
|
|
131
131
|
#input-area.no-shortcuts { padding-bottom: max(0.5rem, env(safe-area-inset-bottom)); }
|
|
132
|
-
#input-box { background: #0d1117; border: 1px solid #30363d; border-radius: 12px; transition: border-color 0.2s; overflow: hidden; }
|
|
132
|
+
#input-box { background: #0d1117; border: 1px solid #30363d; border-radius: 12px; transition: border-color 0.2s; overflow: hidden; position: relative; }
|
|
133
|
+
#img-preview { display: none; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; border-bottom: 1px solid #21262d; background: #161b22; }
|
|
134
|
+
#img-preview.show { display: flex; }
|
|
135
|
+
#img-preview img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid #30363d; }
|
|
136
|
+
#img-preview .img-info { flex: 1; font-size: 0.78rem; color: #8b949e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
137
|
+
#img-preview .img-remove { width: 24px; height: 24px; border-radius: 50%; border: none; background: #21262d; color: #8b949e; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
|
|
138
|
+
#img-preview .img-remove:hover { background: #f85149; color: #fff; }
|
|
133
139
|
#input-box.focused { border-color: #58a6ff; }
|
|
134
140
|
#input-box.disabled { opacity: 0.5; pointer-events: none; }
|
|
135
141
|
#cmd-input { display: block; width: 100%; background: transparent; color: #e6edf3; border: none; padding: 0.6rem 0.75rem 0.3rem; font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace; font-size: 0.85rem; outline: none; resize: none; line-height: 1.4; max-height: 120px; overflow-y: auto; }
|
|
@@ -223,6 +229,11 @@
|
|
|
223
229
|
<div id="input-area">
|
|
224
230
|
<div id="readonly-overlay">只读模式 — 点击状态栏"获取控制"开始输入</div>
|
|
225
231
|
<div id="input-box">
|
|
232
|
+
<div id="img-preview">
|
|
233
|
+
<img id="img-preview-thumb" src="" alt="">
|
|
234
|
+
<span class="img-info">已添加图片,输入文字后发送</span>
|
|
235
|
+
<button class="img-remove" onclick="clearPendingImage()" title="移除图片">×</button>
|
|
236
|
+
</div>
|
|
226
237
|
<textarea id="cmd-input" rows="1" placeholder="输入消息..." autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
|
227
238
|
<div id="input-toolbar">
|
|
228
239
|
<button class="tb-btn" id="btn-photo" onclick="openCamera()" title="拍照">
|
|
@@ -997,11 +1008,30 @@
|
|
|
997
1008
|
setWorkState('idle');
|
|
998
1009
|
});
|
|
999
1010
|
|
|
1011
|
+
// ── 待发送图片 ──────────────────────────────────
|
|
1012
|
+
let _pendingImage = null; // { path, blobUrl }
|
|
1013
|
+
|
|
1014
|
+
window.clearPendingImage = function() {
|
|
1015
|
+
if (_pendingImage?.blobUrl) URL.revokeObjectURL(_pendingImage.blobUrl);
|
|
1016
|
+
_pendingImage = null;
|
|
1017
|
+
document.getElementById('img-preview').classList.remove('show');
|
|
1018
|
+
cmdInput.placeholder = currentSession?.mode === 'agent' ? '输入消息...' : '输入命令...';
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
function setPendingImage(path, blobUrl) {
|
|
1022
|
+
_pendingImage = { path, blobUrl };
|
|
1023
|
+
const preview = document.getElementById('img-preview');
|
|
1024
|
+
document.getElementById('img-preview-thumb').src = blobUrl || '';
|
|
1025
|
+
preview.classList.add('show');
|
|
1026
|
+
cmdInput.placeholder = '输入文字描述后发送,或直接发送分析图片...';
|
|
1027
|
+
cmdInput.focus();
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1000
1030
|
// ── 输入处理 ──────────────────────────────────
|
|
1001
1031
|
window.sendCommand = sendCommand;
|
|
1002
1032
|
function sendCommand() {
|
|
1003
|
-
const text = cmdInput.value;
|
|
1004
|
-
if (!text) return;
|
|
1033
|
+
const text = cmdInput.value.trim();
|
|
1034
|
+
if (!text && !_pendingImage) return;
|
|
1005
1035
|
|
|
1006
1036
|
// 命名模式:发送的是新会话名称
|
|
1007
1037
|
if (window._renameMode) {
|
|
@@ -1017,33 +1047,30 @@
|
|
|
1017
1047
|
if (!isController) { addStatusMessage('请先获取控制权'); return; }
|
|
1018
1048
|
endStream();
|
|
1019
1049
|
|
|
1020
|
-
|
|
1021
|
-
const
|
|
1022
|
-
const imgPath = imgMatch ? imgMatch[1] : null;
|
|
1023
|
-
const userText = imgMatch ? text.slice(imgMatch[0].length).trim() : text;
|
|
1050
|
+
const imgPath = _pendingImage?.path || null;
|
|
1051
|
+
const userText = text;
|
|
1024
1052
|
const displayText = imgPath ? `📷 ${userText || '分析图片'}` : text;
|
|
1025
1053
|
|
|
1026
1054
|
addInputMessage(displayText);
|
|
1027
1055
|
|
|
1028
1056
|
if (currentSession?.mode === 'agent') {
|
|
1029
|
-
// Agent 模式:组合图片+文字
|
|
1030
1057
|
const prompt = imgPath
|
|
1031
1058
|
? `请直接用 Read 工具读取图片 ${imgPath} 并分析,不要搜索其他文件。${userText || '描述图片内容'}`
|
|
1032
1059
|
: text;
|
|
1033
1060
|
socket.emit('agent:query', { prompt });
|
|
1034
1061
|
showThinking();
|
|
1035
1062
|
} else {
|
|
1036
|
-
// PTY 模式:如果有图片,发送路径+用户文字
|
|
1037
1063
|
const input = imgPath
|
|
1038
1064
|
? (userText ? `${userText} ${imgPath}` : imgPath)
|
|
1039
1065
|
: text;
|
|
1040
1066
|
socket.emit('input', input + '\r');
|
|
1041
1067
|
}
|
|
1042
|
-
cmdHistory.unshift(text);
|
|
1068
|
+
cmdHistory.unshift(imgPath ? `[图片] ${userText}` : text);
|
|
1043
1069
|
if (cmdHistory.length > 100) cmdHistory.pop();
|
|
1044
1070
|
historyIdx = -1;
|
|
1045
1071
|
cmdInput.value = '';
|
|
1046
1072
|
cmdInput.style.height = 'auto';
|
|
1073
|
+
clearPendingImage();
|
|
1047
1074
|
cmdInput.focus();
|
|
1048
1075
|
}
|
|
1049
1076
|
|
|
@@ -1310,10 +1337,9 @@
|
|
|
1310
1337
|
const form = new FormData(); form.append('image', blob, 'photo.jpg');
|
|
1311
1338
|
const res = await fetch(`/upload?sessionId=${SESSION_ID}`, { method: 'POST', body: form }); const data = await res.json();
|
|
1312
1339
|
if (data.path) {
|
|
1313
|
-
//
|
|
1314
|
-
const
|
|
1315
|
-
|
|
1316
|
-
sendCommand();
|
|
1340
|
+
// 暂存图片,等用户输入文字后一起发送
|
|
1341
|
+
const thumbUrl = URL.createObjectURL(blob);
|
|
1342
|
+
setPendingImage(data.path, thumbUrl);
|
|
1317
1343
|
}
|
|
1318
1344
|
else addStatusMessage('上传失败: ' + (data.error || '未知'));
|
|
1319
1345
|
} catch (e) { addStatusMessage('出错: ' + e.message); }
|
package/dist/index.html
CHANGED
|
@@ -396,14 +396,15 @@
|
|
|
396
396
|
|
|
397
397
|
/* ── 盘符选择栏 ── */
|
|
398
398
|
#drive-bar {
|
|
399
|
-
display: flex; gap: 0.
|
|
399
|
+
display: flex; gap: 0.5rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border);
|
|
400
400
|
overflow-x: auto; scrollbar-width: none;
|
|
401
401
|
}
|
|
402
402
|
#drive-bar::-webkit-scrollbar { display: none; }
|
|
403
403
|
.drive-btn {
|
|
404
|
-
padding: 0.
|
|
405
|
-
background: var(--bg); border:
|
|
404
|
+
padding: 0.5rem 1rem; border-radius: 8px; font-size: 1rem; font-weight: 600;
|
|
405
|
+
background: var(--bg); border: 1.5px solid var(--border); color: var(--text);
|
|
406
406
|
cursor: pointer; white-space: nowrap; flex-shrink: 0;
|
|
407
|
+
min-width: 3rem; text-align: center;
|
|
407
408
|
}
|
|
408
409
|
.drive-btn:active, .drive-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(124,58,237,0.12); }
|
|
409
410
|
</style>
|