@wendongfly/myhi 1.3.224 → 1.3.226
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/admin.html +192 -3
- package/dist/admin.html.gz +0 -0
- package/dist/amr-worker.cjs +19 -0
- package/dist/build-info.json +3 -3
- package/dist/chat.html +21 -1
- package/dist/chat.html.gz +0 -0
- package/dist/index.html +31 -13
- package/dist/index.html.gz +0 -0
- package/dist/index.js +7 -7
- package/dist/index.min.js +179 -179
- package/dist/minutes.html +116 -7
- package/dist/minutes.html.gz +0 -0
- package/dist/studio.html +79 -2
- package/dist/studio.html.gz +0 -0
- package/dist/vendor/amrnb.cjs +24414 -0
- package/package.json +1 -1
package/dist/minutes.html
CHANGED
|
@@ -116,11 +116,24 @@
|
|
|
116
116
|
#player { display: flex; align-items: center; gap: 0.5rem; margin: 0.6rem 0 0.2rem; flex-wrap: wrap; }
|
|
117
117
|
#player audio { flex: 1; min-width: 240px; height: 36px; }
|
|
118
118
|
#player small { color: var(--muted); }
|
|
119
|
-
#hist .h { padding: 0.45rem 0.4rem; border-top: 1px solid var(--border); cursor: pointer; border-radius: 6px; }
|
|
119
|
+
#hist .h { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.4rem; border-top: 1px solid var(--border); cursor: pointer; border-radius: 6px; }
|
|
120
|
+
#hist .h .x { min-width: 0; flex: 1; }
|
|
120
121
|
#hist .h:first-child { border-top: none; }
|
|
121
122
|
#hist .h:hover, #hist .h.on { background: var(--surface2); }
|
|
122
123
|
#hist .h div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
123
124
|
#hist .h small { color: var(--muted); }
|
|
125
|
+
/* 历史:每条右侧 🗑(悬停显示,触屏常显);「管理」模式多选删除 / 清空 */
|
|
126
|
+
#hist .hsel { display: none; flex-shrink: 0; margin: 0; }
|
|
127
|
+
#hist.man .hsel { display: inline-block; }
|
|
128
|
+
#hist .hdel { flex-shrink: 0; opacity: 0; cursor: pointer; padding: 0.15rem 0.3rem; border-radius: 5px; color: var(--muted); font-size: 0.85rem; }
|
|
129
|
+
#hist .h:hover .hdel { opacity: 1; }
|
|
130
|
+
#hist .hdel:hover { background: var(--bg); color: var(--red); }
|
|
131
|
+
@media (hover: none) { #hist .hdel { opacity: 0.7; } }
|
|
132
|
+
#hist.man .hdel { display: none; }
|
|
133
|
+
#hist-bar { display: none; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin: 0.2rem 0 0.4rem; font-size: 0.75rem; }
|
|
134
|
+
#hist-bar button { background: none; border: 1px solid var(--border); color: var(--text2); border-radius: 6px; padding: 0.2rem 0.55rem; cursor: pointer; font: inherit; }
|
|
135
|
+
#hist-bar button.danger { color: var(--red); border-color: var(--red); }
|
|
136
|
+
#hist-bar button:disabled { opacity: 0.45; cursor: default; }
|
|
124
137
|
</style>
|
|
125
138
|
</head>
|
|
126
139
|
<body>
|
|
@@ -133,7 +146,7 @@
|
|
|
133
146
|
</div><div id="lscroll">
|
|
134
147
|
<div class="card">
|
|
135
148
|
<label class="lbl">会议录音</label>
|
|
136
|
-
<div class="file" id="drop" onclick="$('file').click()"><b>点这里选录音文件</b>,或拖进来<br><small>mp3、m4a、wav、aac、amr、webm、mp4 等,最大 1GB</small></div>
|
|
149
|
+
<div class="file" id="drop" onclick="$('file').click()"><b>点这里选录音文件</b>,或拖进来<br><small>mp3、m4a、wav、aac、amr、webm、mp4 等,最大 1GB</small><small id="drop-mob" style="display:none"><br>手机上:点这里后选「文件」,在文件管理里找录音机录好的录音(一般是 m4a)。不要选「录音机」现场录——那样录出来是电话音质的 amr,转写效果差</small></div>
|
|
137
150
|
<input type="file" id="file" accept="audio/*,video/mp4,video/webm,.m4a,.amr,.mp3,.wav,.aac" style="display:none">
|
|
138
151
|
<div id="fname" class="hint"></div>
|
|
139
152
|
<label class="lbl" for="title">会议名称</label>
|
|
@@ -153,7 +166,7 @@
|
|
|
153
166
|
<div class="hint" id="cfg-hint"></div>
|
|
154
167
|
</div>
|
|
155
168
|
<div class="card">
|
|
156
|
-
<div style="display:flex;align-items:center;margin-bottom:0.3rem"><b>历史</b><a style="margin-left:auto;font-size:0.75rem" onclick="loadHistory()">刷新</a></div>
|
|
169
|
+
<div style="display:flex;align-items:center;margin-bottom:0.3rem"><b>历史</b><a id="hist-man" style="margin-left:auto;font-size:0.75rem;cursor:pointer" onclick="histManage(!$('hist').classList.contains('man'))">管理</a><a style="margin-left:0.8rem;font-size:0.75rem;cursor:pointer" onclick="loadHistory()">刷新</a></div><div id="hist-bar"><button onclick="histSelAll()">全选</button><button id="hist-delsel" class="danger" onclick="histDelSel()" disabled>删除所选</button><button class="danger" style="margin-left:auto" onclick="histClear()">清空全部</button></div>
|
|
157
170
|
<div id="hist"><div class="empty" style="padding:1rem">还没有整理过会议</div></div>
|
|
158
171
|
</div>
|
|
159
172
|
</div>
|
|
@@ -185,6 +198,23 @@
|
|
|
185
198
|
// 原录音播放器:只建一个,每次重绘把它挪回新位置(同一轮里挪回去不会打断播放)
|
|
186
199
|
const AUD = document.createElement('audio'); AUD.controls = true; AUD.preload = 'metadata';
|
|
187
200
|
let AUD_JOB = null;
|
|
201
|
+
// 播不了(浏览器不支持的格式且服务端也转不了,如 wma / AMR-WB):藏起播放器,给出原因 + 下载原录音
|
|
202
|
+
let AUD_ERR = null; // { id, html }:轮询重绘后保持
|
|
203
|
+
const audUrl = (id) => '/api/minutes/jobs/' + encodeURIComponent(id) + '/audio';
|
|
204
|
+
function showAudErr() {
|
|
205
|
+
const box = document.getElementById('pl-err');
|
|
206
|
+
const on = !!(AUD_ERR && CUR && AUD_ERR.id === CUR.id);
|
|
207
|
+
AUD.style.display = on ? 'none' : '';
|
|
208
|
+
if (box) { box.style.display = on ? '' : 'none'; if (on) box.innerHTML = AUD_ERR.html; }
|
|
209
|
+
}
|
|
210
|
+
AUD.addEventListener('error', async () => {
|
|
211
|
+
const id = AUD_JOB; if (!id) return;
|
|
212
|
+
let why = '';
|
|
213
|
+
try { const r = await fetch(audUrl(id)); if (!r.ok) why = (await r.json()).error || ''; } catch {}
|
|
214
|
+
const ext = ((CUR && CUR.id === id && CUR.audio?.file) || '').split('.').pop().toLowerCase();
|
|
215
|
+
AUD_ERR = { id, html: '浏览器播放不了这个录音' + (ext ? '(.' + esc(ext) + ')' : '') + (why ? ':' + esc(why) : '') + '。可以 <a href="' + audUrl(id) + '?original=1">下载原录音</a> 用本机播放器听;逐字稿和纪要不受影响。' };
|
|
216
|
+
showAudErr();
|
|
217
|
+
});
|
|
188
218
|
AUD.addEventListener('timeupdate', () => {
|
|
189
219
|
if (TAB !== 'tr' || !CUR?.segments?.length) return;
|
|
190
220
|
const t = AUD.currentTime; let k = -1;
|
|
@@ -214,10 +244,23 @@
|
|
|
214
244
|
h.push('生成纪要用的模型:' + esc(CFG.model || 'Claude Code 默认') + '(首页 ⚙ 设置 › 系统设置 · 模型 › 会议纪要)');
|
|
215
245
|
$('cfg-hint').innerHTML = h.join('<br>');
|
|
216
246
|
}
|
|
247
|
+
// 安卓浏览器(荣耀 / 华为 / 小米…)看到 accept="audio/*" 只弹「相机 / 录音机 / 媒体」,没有「文件」入口,
|
|
248
|
+
// 选不到录音机 App 存好的 m4a;选「录音机」又是现场快速录音,存成 8kHz 的 amr。去掉 accept 才会出现完整的文件选择器,
|
|
249
|
+
// 格式改由下面 pickFile 检查(服务端也会再查一遍)
|
|
250
|
+
const IS_ANDROID = /Android/i.test(navigator.userAgent);
|
|
251
|
+
if (IS_ANDROID) { $('file').removeAttribute('accept'); $('drop-mob').style.display = ''; }
|
|
252
|
+
const AUDIO_EXTS = new Set(['mp3', 'm4a', 'wav', 'aac', 'amr', 'ogg', 'opus', 'webm', 'mp4', 'flac', 'wma', 'mov', '3gp']);
|
|
217
253
|
function pickFile(f) {
|
|
218
254
|
if (!f) return;
|
|
255
|
+
const ext = (f.name.match(/\.([^.]+)$/) || [])[1]?.toLowerCase() || '';
|
|
256
|
+
if (!AUDIO_EXTS.has(ext)) {
|
|
257
|
+
FILE = null; $('file').value = '';
|
|
258
|
+
$('fname').innerHTML = `<span style="color:var(--red)">「${esc(f.name)}」不是录音文件,请选 mp3、m4a、wav、aac、amr、webm、mp4 等</span>`;
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
219
261
|
FILE = f;
|
|
220
|
-
$('fname').innerHTML = `已选:<b>${esc(f.name)}</b>(${fmtSize(f.size)}
|
|
262
|
+
$('fname').innerHTML = `已选:<b>${esc(f.name)}</b>(${fmtSize(f.size)})`
|
|
263
|
+
+ (ext === 'amr' ? '<br><span style="color:var(--yellow,#d29922)">这是 amr 格式(电话音质,8kHz),转写和区分发言人效果会差一些。手机录音机 App 里录好的 m4a 效果更好:点上面重新选,选「文件」找到它</span>' : '');
|
|
221
264
|
if (!$('title').value.trim()) $('title').value = f.name.replace(/\.[^.]+$/, '').slice(0, 60);
|
|
222
265
|
}
|
|
223
266
|
$('file').onchange = (e) => pickFile(e.target.files[0]);
|
|
@@ -316,10 +359,11 @@
|
|
|
316
359
|
${job.status === 'error' ? `<div class="hint err">${esc(job.error || '')}</div>` : ''}
|
|
317
360
|
${(job.notes || []).map((n) => `<div class="hint warn">${esc(n)}</div>`).join('')}
|
|
318
361
|
${(job.savedTo || []).length ? `<div class="hint ok">已保存到项目:${job.savedTo.map(esc).join('、')}</div>` : ''}
|
|
319
|
-
<div id="player"><span id="pl-slot"></span><small>原录音,可边听边对照${job.segments?.some((s) => s.start != null) ? ';在「逐字稿」里点任意一段从那里开始播放 <label style="white-space:nowrap"><input type="checkbox" id="follow" checked> 播放时跟随滚动</label>' : ''}</small></div>
|
|
362
|
+
<div id="player"><span id="pl-slot"></span><div id="pl-err" class="hint warn" style="display:none;margin:0"></div><small>原录音,可边听边对照${job.segments?.some((s) => s.start != null) ? ';在「逐字稿」里点任意一段从那里开始播放 <label style="white-space:nowrap"><input type="checkbox" id="follow" checked> 播放时跟随滚动</label>' : ''}</small></div>
|
|
320
363
|
${body}${tabs}${pane}`;
|
|
321
|
-
if (AUD_JOB !== job.id) { AUD_JOB = job.id; AUD.src =
|
|
364
|
+
if (AUD_JOB !== job.id) { AUD_JOB = job.id; AUD_ERR = null; AUD.src = audUrl(job.id); }
|
|
322
365
|
$('pl-slot').replaceWith(AUD);
|
|
366
|
+
showAudErr();
|
|
323
367
|
AUD.dispatchEvent(new Event('timeupdate'));
|
|
324
368
|
document.querySelectorAll('#hist .h').forEach((h) => h.classList.toggle('on', h.dataset.id === job.id));
|
|
325
369
|
clearTimeout(POLL);
|
|
@@ -370,13 +414,78 @@
|
|
|
370
414
|
const d = await api('/api/minutes/jobs').catch(() => null);
|
|
371
415
|
const jobs = d?.jobs || [];
|
|
372
416
|
const ST = { transcribing: '转写中', summarizing: '生成纪要中', done: '已完成', error: '出错', cancelled: '已取消' };
|
|
373
|
-
$('hist').innerHTML = jobs.length ? jobs.map((j) => `<div class="h" data-id="${esc(j.id)}"><div>${esc(j.title)}</div><small>${esc(j.meetingDate)}${j.duration ? ' · ' + fmt(j.duration) : ''}${j.speakers ? ' · ' + j.speakers + ' 人' : ''} · ${ST[j.status] || j.status}</small></div>`).join('')
|
|
417
|
+
$('hist').innerHTML = jobs.length ? jobs.map((j) => `<div class="h" data-id="${esc(j.id)}" data-st="${esc(j.status)}"><div class="x"><div>${esc(j.title)}</div><small>${esc(j.meetingDate)}${j.duration ? ' · ' + fmt(j.duration) : ''}${j.speakers ? ' · ' + j.speakers + ' 人' : ''} · ${ST[j.status] || j.status}</small></div></div>`).join('')
|
|
374
418
|
: '<div class="empty" style="padding:1rem">还没有整理过会议</div>';
|
|
375
419
|
$('hist').querySelectorAll('.h').forEach((h) => h.onclick = async () => {
|
|
376
420
|
const r = await api('/api/minutes/jobs/' + encodeURIComponent(h.dataset.id)).catch(() => null);
|
|
377
421
|
if (r?.ok) { TAB = 'minutes'; EDIT = false; showJob(r.job); if (innerWidth <= 860) $('result').scrollIntoView({ behavior: 'smooth' }); }
|
|
378
422
|
});
|
|
379
423
|
if (CUR) document.querySelectorAll('#hist .h').forEach((h) => h.classList.toggle('on', h.dataset.id === CUR.id));
|
|
424
|
+
histDecorate();
|
|
425
|
+
}
|
|
426
|
+
// ── 删除历史:单条 🗑 / 管理模式多选 / 清空(成员只删自己的,管理员能删全部;进行中的不删)──
|
|
427
|
+
const RESULT0 = $('result').innerHTML; // 删掉当前打开的那条后,右侧回到初始说明
|
|
428
|
+
let HMAN = false;
|
|
429
|
+
const HBUSY = ["transcribing","summarizing"];
|
|
430
|
+
const histSelIds = () => [...$('hist').querySelectorAll('.hsel:checked')].map((c) => c.closest('.h').dataset.id);
|
|
431
|
+
function histUpdSel() {
|
|
432
|
+
const n = histSelIds().length, b = $('hist-delsel');
|
|
433
|
+
b.textContent = n ? '删除所选(' + n + ')' : '删除所选'; b.disabled = !n;
|
|
434
|
+
}
|
|
435
|
+
function histAfterDelete(ids) {
|
|
436
|
+
if (CUR && ids.includes(CUR.id)) { clearTimeout(POLL); CUR = null; $('result').innerHTML = RESULT0; }
|
|
437
|
+
loadHistory();
|
|
438
|
+
}
|
|
439
|
+
async function histPost(body) {
|
|
440
|
+
const d = await api('/api/minutes/jobs/delete', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }).catch((e) => ({ ok: false, error: e.message }));
|
|
441
|
+
if (!d.ok) { alert('删除失败:' + (d.error || '未知错误')); return null; }
|
|
442
|
+
if (d.busy) alert('已删除 ' + d.deleted + ' 条;还有 ' + d.busy + ' 条正在进行,没有删除(先取消再删)');
|
|
443
|
+
return d;
|
|
444
|
+
}
|
|
445
|
+
window.histDelOne = async (ev, id) => {
|
|
446
|
+
ev.stopPropagation();
|
|
447
|
+
if (!confirm('删除这条纪要?录音、逐字稿和纪要会一起删掉(已保存到项目里的不受影响),不可恢复。')) return;
|
|
448
|
+
const d = await api('/api/minutes/jobs/' + encodeURIComponent(id), { method: 'DELETE' }).catch((e) => ({ ok: false, error: e.message }));
|
|
449
|
+
if (!d.ok) return alert('删除失败:' + (d.error || '未知错误'));
|
|
450
|
+
histAfterDelete([id]);
|
|
451
|
+
};
|
|
452
|
+
window.histManage = (on) => {
|
|
453
|
+
HMAN = on;
|
|
454
|
+
$('hist').classList.toggle('man', on);
|
|
455
|
+
$('hist-bar').style.display = on ? 'flex' : 'none';
|
|
456
|
+
$('hist-man').textContent = on ? '完成' : '管理';
|
|
457
|
+
if (!on) $('hist').querySelectorAll('.hsel').forEach((c) => { c.checked = false; });
|
|
458
|
+
histUpdSel();
|
|
459
|
+
};
|
|
460
|
+
window.histSelAll = () => {
|
|
461
|
+
const cs = [...$('hist').querySelectorAll('.hsel:not(:disabled)')];
|
|
462
|
+
const all = cs.length && cs.every((c) => c.checked);
|
|
463
|
+
cs.forEach((c) => { c.checked = !all; });
|
|
464
|
+
histUpdSel();
|
|
465
|
+
};
|
|
466
|
+
window.histDelSel = async () => {
|
|
467
|
+
const ids = histSelIds();
|
|
468
|
+
if (!ids.length || !confirm('删除选中的 ' + ids.length + ' 条纪要?录音、逐字稿和纪要会一起删掉(已保存到项目里的不受影响),不可恢复。')) return;
|
|
469
|
+
if (await histPost({ ids })) histAfterDelete(ids);
|
|
470
|
+
};
|
|
471
|
+
window.histClear = async () => {
|
|
472
|
+
if (!confirm('清空全部纪要历史?录音、逐字稿和纪要会一起删掉(已保存到项目里的不受影响),不可恢复。\n(管理员会清掉所有成员的;正在进行的不删)')) return;
|
|
473
|
+
const d = await histPost({ all: true });
|
|
474
|
+
if (d) { histManage(false); histAfterDelete(CUR && !HBUSY.includes(CUR.status) ? [CUR.id] : []); }
|
|
475
|
+
};
|
|
476
|
+
// 每次重画列表后:给每行补上勾选框和 🗑,管理模式下点整行 = 勾选
|
|
477
|
+
function histDecorate() {
|
|
478
|
+
$('hist').querySelectorAll('.h').forEach((h) => {
|
|
479
|
+
const busy = HBUSY.includes(h.dataset.st);
|
|
480
|
+
const c = document.createElement('input'); c.type = 'checkbox'; c.className = 'hsel'; c.disabled = busy;
|
|
481
|
+
c.title = busy ? '正在进行,不能删除' : '选择';
|
|
482
|
+
c.onclick = (e) => e.stopPropagation(); c.onchange = histUpdSel;
|
|
483
|
+
h.prepend(c);
|
|
484
|
+
if (!busy) { const d = document.createElement('span'); d.className = 'hdel'; d.textContent = '🗑'; d.title = '删除'; d.onclick = (e) => histDelOne(e, h.dataset.id); h.append(d); }
|
|
485
|
+
const open = h.onclick;
|
|
486
|
+
h.onclick = (e) => { if (HMAN) { if (!c.disabled) { c.checked = !c.checked; histUpdSel(); } return; } open?.(e); };
|
|
487
|
+
});
|
|
488
|
+
histUpdSel();
|
|
380
489
|
}
|
|
381
490
|
loadConfig(); loadHistory();
|
|
382
491
|
const q = new URLSearchParams(location.search).get('job');
|
package/dist/minutes.html.gz
CHANGED
|
Binary file
|
package/dist/studio.html
CHANGED
|
@@ -120,6 +120,18 @@
|
|
|
120
120
|
#hist .h .x { min-width: 0; flex: 1; }
|
|
121
121
|
#hist .h .x div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
122
122
|
#hist .h .x small { color: var(--muted); }
|
|
123
|
+
/* 历史:每条右侧 🗑(悬停显示,触屏常显);「管理」模式多选删除 / 清空 */
|
|
124
|
+
#hist .hsel { display: none; flex-shrink: 0; margin: 0; }
|
|
125
|
+
#hist.man .hsel { display: inline-block; }
|
|
126
|
+
#hist .hdel { flex-shrink: 0; opacity: 0; cursor: pointer; padding: 0.15rem 0.3rem; border-radius: 5px; color: var(--muted); font-size: 0.85rem; }
|
|
127
|
+
#hist .h:hover .hdel { opacity: 1; }
|
|
128
|
+
#hist .hdel:hover { background: var(--bg); color: var(--red); }
|
|
129
|
+
@media (hover: none) { #hist .hdel { opacity: 0.7; } }
|
|
130
|
+
#hist.man .hdel { display: none; }
|
|
131
|
+
#hist-bar { display: none; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin: 0.2rem 0 0.4rem; font-size: 0.75rem; }
|
|
132
|
+
#hist-bar button { background: none; border: 1px solid var(--border); color: var(--text2); border-radius: 6px; padding: 0.2rem 0.55rem; cursor: pointer; font: inherit; }
|
|
133
|
+
#hist-bar button.danger { color: var(--red); border-color: var(--red); }
|
|
134
|
+
#hist-bar button:disabled { opacity: 0.45; cursor: default; }
|
|
123
135
|
#zoom { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 50; align-items: center; justify-content: center; cursor: zoom-out; }
|
|
124
136
|
#zoom.on { display: flex; }
|
|
125
137
|
#zoom img { max-width: 94vw; max-height: 94vh; }
|
|
@@ -177,7 +189,7 @@
|
|
|
177
189
|
<div class="hint" id="qc-hint"></div>
|
|
178
190
|
</div>
|
|
179
191
|
<div class="card">
|
|
180
|
-
<div style="display:flex;align-items:center;margin-bottom:0.3rem"><b>历史</b><a style="margin-left:auto;font-size:0.75rem;cursor:pointer" onclick="loadHistory()">刷新</a></div>
|
|
192
|
+
<div style="display:flex;align-items:center;margin-bottom:0.3rem"><b>历史</b><a id="hist-man" style="margin-left:auto;font-size:0.75rem;cursor:pointer" onclick="histManage(!$('hist').classList.contains('man'))">管理</a><a style="margin-left:0.8rem;font-size:0.75rem;cursor:pointer" onclick="loadHistory()">刷新</a></div><div id="hist-bar"><button onclick="histSelAll()">全选</button><button id="hist-delsel" class="danger" onclick="histDelSel()" disabled>删除所选</button><button class="danger" style="margin-left:auto" onclick="histClear()">清空全部</button></div>
|
|
181
193
|
<div id="hist"><div class="empty" style="padding:1rem">还没有出过图</div></div>
|
|
182
194
|
</div>
|
|
183
195
|
</div>
|
|
@@ -414,13 +426,78 @@
|
|
|
414
426
|
async function loadHistory() {
|
|
415
427
|
const d = await api('/api/studio/jobs').catch(() => null);
|
|
416
428
|
const jobs = d?.jobs || [];
|
|
417
|
-
$('hist').innerHTML = jobs.length ? jobs.map((j) => `<div class="h" data-id="${esc(j.id)}">${j.thumbs[0] ? `<img src="${imgUrl(j, j.thumbs[0])}" alt="">` : '<img alt="">'}<div class="x"><div>${esc(j.need)}</div><small>${new Date(j.createdAt).toLocaleString()} · ${j.status === 'running' ? '出图中' : j.status === 'cancelled' ? '已取消' : j.thumbs.length + ' 张'}</small></div></div>`).join('')
|
|
429
|
+
$('hist').innerHTML = jobs.length ? jobs.map((j) => `<div class="h" data-id="${esc(j.id)}" data-st="${esc(j.status)}">${j.thumbs[0] ? `<img src="${imgUrl(j, j.thumbs[0])}" alt="">` : '<img alt="">'}<div class="x"><div>${esc(j.need)}</div><small>${new Date(j.createdAt).toLocaleString()} · ${j.status === 'running' ? '出图中' : j.status === 'cancelled' ? '已取消' : j.thumbs.length + ' 张'}</small></div></div>`).join('')
|
|
418
430
|
: '<div class="empty" style="padding:1rem">还没有出过图</div>';
|
|
419
431
|
$('hist').querySelectorAll('.h').forEach((h) => h.onclick = async () => {
|
|
420
432
|
const r = await api('/api/studio/jobs/' + encodeURIComponent(h.dataset.id)).catch(() => null);
|
|
421
433
|
if (r?.ok) { showJob(r.job); if (innerWidth <= 860) $('result').scrollIntoView({ behavior: 'smooth' }); }
|
|
422
434
|
});
|
|
423
435
|
if (CUR) document.querySelectorAll('#hist .h').forEach((h) => h.classList.toggle('on', h.dataset.id === CUR.id));
|
|
436
|
+
histDecorate();
|
|
437
|
+
}
|
|
438
|
+
// ── 删除历史:单条 🗑 / 管理模式多选 / 清空(成员只删自己的,管理员能删全部;进行中的不删)──
|
|
439
|
+
const RESULT0 = $('result').innerHTML; // 删掉当前打开的那条后,右侧回到初始说明
|
|
440
|
+
let HMAN = false;
|
|
441
|
+
const HBUSY = ["running"];
|
|
442
|
+
const histSelIds = () => [...$('hist').querySelectorAll('.hsel:checked')].map((c) => c.closest('.h').dataset.id);
|
|
443
|
+
function histUpdSel() {
|
|
444
|
+
const n = histSelIds().length, b = $('hist-delsel');
|
|
445
|
+
b.textContent = n ? '删除所选(' + n + ')' : '删除所选'; b.disabled = !n;
|
|
446
|
+
}
|
|
447
|
+
function histAfterDelete(ids) {
|
|
448
|
+
if (CUR && ids.includes(CUR.id)) { clearTimeout(POLL); CUR = null; $('result').innerHTML = RESULT0; }
|
|
449
|
+
loadHistory();
|
|
450
|
+
}
|
|
451
|
+
async function histPost(body) {
|
|
452
|
+
const d = await api('/api/studio/jobs/delete', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }).catch((e) => ({ ok: false, error: e.message }));
|
|
453
|
+
if (!d.ok) { alert('删除失败:' + (d.error || '未知错误')); return null; }
|
|
454
|
+
if (d.busy) alert('已删除 ' + d.deleted + ' 条;还有 ' + d.busy + ' 条正在进行,没有删除(先取消再删)');
|
|
455
|
+
return d;
|
|
456
|
+
}
|
|
457
|
+
window.histDelOne = async (ev, id) => {
|
|
458
|
+
ev.stopPropagation();
|
|
459
|
+
if (!confirm('删除这条出图?图片文件会一起删掉(已保存到项目里的不受影响),不可恢复。')) return;
|
|
460
|
+
const d = await api('/api/studio/jobs/' + encodeURIComponent(id), { method: 'DELETE' }).catch((e) => ({ ok: false, error: e.message }));
|
|
461
|
+
if (!d.ok) return alert('删除失败:' + (d.error || '未知错误'));
|
|
462
|
+
histAfterDelete([id]);
|
|
463
|
+
};
|
|
464
|
+
window.histManage = (on) => {
|
|
465
|
+
HMAN = on;
|
|
466
|
+
$('hist').classList.toggle('man', on);
|
|
467
|
+
$('hist-bar').style.display = on ? 'flex' : 'none';
|
|
468
|
+
$('hist-man').textContent = on ? '完成' : '管理';
|
|
469
|
+
if (!on) $('hist').querySelectorAll('.hsel').forEach((c) => { c.checked = false; });
|
|
470
|
+
histUpdSel();
|
|
471
|
+
};
|
|
472
|
+
window.histSelAll = () => {
|
|
473
|
+
const cs = [...$('hist').querySelectorAll('.hsel:not(:disabled)')];
|
|
474
|
+
const all = cs.length && cs.every((c) => c.checked);
|
|
475
|
+
cs.forEach((c) => { c.checked = !all; });
|
|
476
|
+
histUpdSel();
|
|
477
|
+
};
|
|
478
|
+
window.histDelSel = async () => {
|
|
479
|
+
const ids = histSelIds();
|
|
480
|
+
if (!ids.length || !confirm('删除选中的 ' + ids.length + ' 条出图?图片文件会一起删掉(已保存到项目里的不受影响),不可恢复。')) return;
|
|
481
|
+
if (await histPost({ ids })) histAfterDelete(ids);
|
|
482
|
+
};
|
|
483
|
+
window.histClear = async () => {
|
|
484
|
+
if (!confirm('清空全部出图历史?图片文件会一起删掉(已保存到项目里的不受影响),不可恢复。\n(管理员会清掉所有成员的;正在进行的不删)')) return;
|
|
485
|
+
const d = await histPost({ all: true });
|
|
486
|
+
if (d) { histManage(false); histAfterDelete(CUR && !HBUSY.includes(CUR.status) ? [CUR.id] : []); }
|
|
487
|
+
};
|
|
488
|
+
// 每次重画列表后:给每行补上勾选框和 🗑,管理模式下点整行 = 勾选
|
|
489
|
+
function histDecorate() {
|
|
490
|
+
$('hist').querySelectorAll('.h').forEach((h) => {
|
|
491
|
+
const busy = HBUSY.includes(h.dataset.st);
|
|
492
|
+
const c = document.createElement('input'); c.type = 'checkbox'; c.className = 'hsel'; c.disabled = busy;
|
|
493
|
+
c.title = busy ? '正在进行,不能删除' : '选择';
|
|
494
|
+
c.onclick = (e) => e.stopPropagation(); c.onchange = histUpdSel;
|
|
495
|
+
h.prepend(c);
|
|
496
|
+
if (!busy) { const d = document.createElement('span'); d.className = 'hdel'; d.textContent = '🗑'; d.title = '删除'; d.onclick = (e) => histDelOne(e, h.dataset.id); h.append(d); }
|
|
497
|
+
const open = h.onclick;
|
|
498
|
+
h.onclick = (e) => { if (HMAN) { if (!c.disabled) { c.checked = !c.checked; histUpdSel(); } return; } open?.(e); };
|
|
499
|
+
});
|
|
500
|
+
histUpdSel();
|
|
424
501
|
}
|
|
425
502
|
loadConfig(); loadHistory();
|
|
426
503
|
const q = new URLSearchParams(location.search).get('job');
|
package/dist/studio.html.gz
CHANGED
|
Binary file
|