skillmkt 0.3.9 → 0.3.10
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/client/public/app.js +9 -4
- package/package.json +1 -1
package/client/public/app.js
CHANGED
|
@@ -4,6 +4,7 @@ const api = async (p, opt) => (await fetch(`/api${p}${p.includes('?') ? '&' : '?
|
|
|
4
4
|
const el = (h) => { const d = document.createElement('div'); d.innerHTML = h; return d.firstElementChild; };
|
|
5
5
|
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
6
6
|
let S = null, tab = location.hash.slice(1).split('?')[0] || 'skills';
|
|
7
|
+
let saveMsg = '', saveMsgAt = 0; // 保存结果提示——要挺过保存后的连续重渲染(自己 refresh + SSE config 事件)
|
|
7
8
|
|
|
8
9
|
async function refresh() {
|
|
9
10
|
try { S = await api('/state'); }
|
|
@@ -297,11 +298,15 @@ async function render() {
|
|
|
297
298
|
? `连接成功<br>发送:${esc(r.sent)}<br>回复:${esc(r.reply || '(空回复)')}`
|
|
298
299
|
: `连接失败:${esc(r.error)}`;
|
|
299
300
|
};
|
|
301
|
+
if (saveMsg && Date.now() - saveMsgAt < 6000) { const o = app.querySelector('#save-out'); if (o) o.textContent = saveMsg; }
|
|
300
302
|
app.querySelector('#save').onclick = async () => {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
try {
|
|
304
|
+
const targets = [...app.querySelectorAll('[data-h]:checked')].map((x) => x.dataset.h);
|
|
305
|
+
const r = await api('/config', { method: 'POST', body: JSON.stringify({ llm: { base_url: app.querySelector('#murl').value || null, model: app.querySelector('#mmodel').value || null, api_key: app.querySelector('#mkey').value || undefined, concurrency: 2, timeout_ms: 60000 }, default_targets: targets }) });
|
|
306
|
+
saveMsg = r.ok ? `已保存到 config.yml${r.key_enc ? ',密钥已加密' : ''}` : `保存失败:${r.error}`;
|
|
307
|
+
} catch (e) { saveMsg = `保存失败:${e.message}`; }
|
|
308
|
+
saveMsgAt = Date.now();
|
|
309
|
+
await refresh(); // 重渲染会把 save-out 抹掉——上面的 flash 负责补回来
|
|
305
310
|
};
|
|
306
311
|
}
|
|
307
312
|
}
|