pygmalion 0.1.12 → 0.1.13
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/package.json +1 -1
- package/src/web-public/app.js +213 -100
- package/src/web-public/index.html +54 -4
- package/src/web-public/style.css +5 -0
- package/src/web-server.js +16 -8
package/package.json
CHANGED
package/src/web-public/app.js
CHANGED
|
@@ -425,26 +425,160 @@ $('#btn-del-bot').addEventListener('click', async () => {
|
|
|
425
425
|
} catch (err) { $('#bot-error').textContent = err.message; }
|
|
426
426
|
});
|
|
427
427
|
|
|
428
|
-
/* ------------------------------- 脚本监管 ------------------------------- */
|
|
429
|
-
let lifeRefreshTimer = null;
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
428
|
+
/* ------------------------------- 脚本监管 ------------------------------- */
|
|
429
|
+
let lifeRefreshTimer = null;
|
|
430
|
+
let scriptLogTimer = null;
|
|
431
|
+
let currentScriptLog = null;
|
|
432
|
+
const scriptSelection = {
|
|
433
|
+
life: { kind: null, name: null },
|
|
434
|
+
toy: { kind: null, name: null },
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
function selectScriptSpace(space) {
|
|
438
|
+
document.querySelectorAll('[data-script-space]').forEach((button) => {
|
|
439
|
+
const active = button.dataset.scriptSpace === space;
|
|
440
|
+
button.classList.toggle('active', active);
|
|
441
|
+
button.setAttribute('aria-selected', String(active));
|
|
442
|
+
});
|
|
443
|
+
$('#script-space-life').classList.toggle('hidden', space !== 'life');
|
|
444
|
+
$('#script-space-toy').classList.toggle('hidden', space !== 'toy');
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function selectAssetKind(group, kind) {
|
|
448
|
+
const space = $(`#script-space-${group}`);
|
|
449
|
+
space.querySelectorAll('[data-asset-kind]').forEach((button) => {
|
|
450
|
+
const active = button.dataset.assetKind === kind;
|
|
451
|
+
button.classList.toggle('active', active);
|
|
452
|
+
button.setAttribute('aria-selected', String(active));
|
|
453
|
+
});
|
|
454
|
+
space.querySelectorAll('[data-asset-panel]').forEach((panel) => {
|
|
455
|
+
panel.classList.toggle('hidden', panel.dataset.assetPanel !== kind);
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
async function showFirstLog(group) {
|
|
460
|
+
if (scriptSelection[group].name || window.matchMedia('(max-width: 700px)').matches) return;
|
|
461
|
+
const attribute = group === 'life' ? 'data-log' : 'data-toylog';
|
|
462
|
+
const first = $(`#${group}-logs button[${attribute}]`);
|
|
463
|
+
if (first) await showScriptLog(group, first.getAttribute(attribute));
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function resetInspector(group) {
|
|
467
|
+
scriptSelection[group] = { kind: null, name: null };
|
|
468
|
+
$(`#${group}-inspector-kind`).textContent = 'PREVIEW';
|
|
469
|
+
$(`#${group}-inspector-title`).textContent = '选择一条日志或脚本';
|
|
470
|
+
$(`#${group}-inspector-state`).textContent = '日志打开后自动追踪更新';
|
|
471
|
+
$(`#${group}-preview-empty`).classList.remove('hidden');
|
|
472
|
+
$(`#${group}-source`).classList.add('hidden');
|
|
473
|
+
$(`#${group}-log-body`).classList.add('hidden');
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function syncSelectedResource(group) {
|
|
477
|
+
const selected = scriptSelection[group];
|
|
478
|
+
$(`#script-space-${group}`).querySelectorAll('[data-resource-kind]').forEach((button) => {
|
|
479
|
+
button.classList.toggle('active', button.dataset.resourceKind === selected.kind && button.dataset.resourceName === selected.name);
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function showInspector(group, kind, name, text, live = false) {
|
|
484
|
+
scriptSelection[group] = { kind, name };
|
|
485
|
+
const isLog = kind === 'log';
|
|
486
|
+
$(`#${group}-inspector-kind`).textContent = isLog ? 'LOG OUTPUT' : 'SOURCE CODE';
|
|
487
|
+
$(`#${group}-inspector-title`).textContent = name;
|
|
488
|
+
$(`#${group}-inspector-state`).textContent = isLog && live ? '实时追踪中 · 每 2 秒更新' : (isLog ? '运行日志' : '只读源码');
|
|
489
|
+
$(`#${group}-preview-empty`).classList.add('hidden');
|
|
490
|
+
const source = $(`#${group}-source`);
|
|
491
|
+
const log = $(`#${group}-log-body`);
|
|
492
|
+
source.classList.toggle('hidden', isLog);
|
|
493
|
+
log.classList.toggle('hidden', !isLog);
|
|
494
|
+
(isLog ? log : source).textContent = text;
|
|
495
|
+
syncSelectedResource(group);
|
|
496
|
+
if (window.matchMedia('(max-width: 700px)').matches) {
|
|
497
|
+
$(`#script-space-${group} .inspector-panel`).scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
async function fetchScriptText(url) {
|
|
502
|
+
const response = await fetch(url);
|
|
503
|
+
const text = await response.text();
|
|
504
|
+
if (!response.ok) {
|
|
505
|
+
try { throw new Error(JSON.parse(text).error || `HTTP ${response.status}`); }
|
|
506
|
+
catch (err) { if (err instanceof SyntaxError) throw new Error(`HTTP ${response.status}`); throw err; }
|
|
507
|
+
}
|
|
508
|
+
return text;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function startScriptLogPolling() {
|
|
512
|
+
if (scriptLogTimer) return;
|
|
513
|
+
scriptLogTimer = setInterval(async () => {
|
|
514
|
+
if (!currentScriptLog || lifeView.classList.contains('hidden')) return;
|
|
515
|
+
const { group, name } = currentScriptLog;
|
|
516
|
+
const area = group === 'life' ? 'life' : 'toys';
|
|
517
|
+
try {
|
|
518
|
+
const text = await fetchScriptText(`/api/me/roles/${lifeRoleId}/${area}/log/${encodeURIComponent(name)}`);
|
|
519
|
+
if (currentScriptLog?.group === group && currentScriptLog?.name === name) $(`#${group}-log-body`).textContent = text;
|
|
520
|
+
} catch { /* 单次刷新失败忽略,下一轮再试 */ }
|
|
521
|
+
}, 2000);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
function stopScriptLogPolling() {
|
|
525
|
+
if (scriptLogTimer) { clearInterval(scriptLogTimer); scriptLogTimer = null; }
|
|
526
|
+
currentScriptLog = null;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
async function showScriptLog(group, name) {
|
|
530
|
+
const area = group === 'life' ? 'life' : 'toys';
|
|
531
|
+
try {
|
|
532
|
+
const text = await fetchScriptText(`/api/me/roles/${lifeRoleId}/${area}/log/${encodeURIComponent(name)}`);
|
|
533
|
+
selectScriptSpace(group);
|
|
534
|
+
selectAssetKind(group, 'logs');
|
|
535
|
+
currentScriptLog = { group, name };
|
|
536
|
+
showInspector(group, 'log', name, text, true);
|
|
537
|
+
startScriptLogPolling();
|
|
538
|
+
} catch (err) { status(err.message, true); }
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
async function showScriptSource(group, name) {
|
|
542
|
+
const area = group === 'life' ? 'life' : 'toys';
|
|
543
|
+
try {
|
|
544
|
+
const text = await fetchScriptText(`/api/me/roles/${lifeRoleId}/${area}/script/${encodeURIComponent(name)}`);
|
|
545
|
+
if (currentScriptLog?.group === group) currentScriptLog = null;
|
|
546
|
+
selectScriptSpace(group);
|
|
547
|
+
selectAssetKind(group, 'scripts');
|
|
548
|
+
showInspector(group, 'source', name, text);
|
|
549
|
+
} catch (err) { status(err.message, true); }
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
function resourceButton(group, kind, name, attribute) {
|
|
553
|
+
const active = scriptSelection[group].kind === kind && scriptSelection[group].name === name ? ' active' : '';
|
|
554
|
+
return `<button class="log-btn${active}" type="button" ${attribute}="${esc(name)}" data-resource-kind="${kind}" data-resource-name="${esc(name)}"><span class="item-name">${esc(name)}</span></button>`;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function startLifeRefresh() {
|
|
558
|
+
if (lifeRefreshTimer) return;
|
|
559
|
+
lifeRefreshTimer = setInterval(refreshLife, 3000);
|
|
433
560
|
}
|
|
434
561
|
function stopLifeRefresh() {
|
|
435
562
|
if (lifeRefreshTimer) { clearInterval(lifeRefreshTimer); lifeRefreshTimer = null; }
|
|
436
563
|
}
|
|
437
564
|
async function openLife(rid) {
|
|
438
|
-
lifeRoleId = rid;
|
|
439
|
-
const role = roles.find((r) => r.roleId === rid);
|
|
565
|
+
lifeRoleId = rid;
|
|
566
|
+
const role = roles.find((r) => r.roleId === rid);
|
|
440
567
|
$('#life-role-name').textContent = role?.persona?.name || '未命名角色';
|
|
441
568
|
rolesView.classList.add('hidden');
|
|
442
569
|
editorView.classList.add('hidden');
|
|
443
570
|
lifeView.classList.remove('hidden');
|
|
444
571
|
pageTitle.textContent = '脚本监管';
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
572
|
+
selectScriptSpace('life');
|
|
573
|
+
selectAssetKind('life', 'logs');
|
|
574
|
+
selectAssetKind('toy', 'logs');
|
|
575
|
+
resetInspector('life');
|
|
576
|
+
resetInspector('toy');
|
|
577
|
+
stopScriptLogPolling();
|
|
578
|
+
lifeView.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
579
|
+
await refreshLife();
|
|
580
|
+
await showFirstLog('life');
|
|
581
|
+
startLifeRefresh();
|
|
448
582
|
}
|
|
449
583
|
function fmtDur(ms) {
|
|
450
584
|
const s = Math.max(0, Math.floor(ms / 1000));
|
|
@@ -456,9 +590,10 @@ function fmtDur(ms) {
|
|
|
456
590
|
async function refreshLife() {
|
|
457
591
|
const data = await api(`/api/me/roles/${lifeRoleId}/life`);
|
|
458
592
|
$('#life-manifest').textContent = JSON.stringify(data.manifest || {}, null, 2);
|
|
459
|
-
// 运行中脚本(dsh 用 life_run 启动;由脚本自己决定何时结束,插件只监管)
|
|
460
|
-
const running = data.running || [];
|
|
461
|
-
$('#life-running').
|
|
593
|
+
// 运行中脚本(dsh 用 life_run 启动;由脚本自己决定何时结束,插件只监管)
|
|
594
|
+
const running = data.running || [];
|
|
595
|
+
$('#life-running-count').textContent = `${running.length} 个运行中`;
|
|
596
|
+
$('#life-running').innerHTML = running.length
|
|
462
597
|
? running.map((r) => `<div class="run-row">
|
|
463
598
|
<span class="run-info">${esc(r.scriptName)} · PID ${esc(r.pid)} · 已运行 ${fmtDur(r.elapsedMs)}</span>
|
|
464
599
|
<button class="ghost run-log" data-log="${esc(r.logName)}">日志</button>
|
|
@@ -466,72 +601,58 @@ async function refreshLife() {
|
|
|
466
601
|
</div>`).join('')
|
|
467
602
|
: '<div class="muted">没有脚本在运行(dsh 用 life_run 启动,可长驻循环)</div>';
|
|
468
603
|
// 脚本清单(点击查看源码)
|
|
469
|
-
const scripts = Object.keys(data.manifest?.scripts || {});
|
|
470
|
-
$('#life-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
604
|
+
const scripts = Object.keys(data.manifest?.scripts || {});
|
|
605
|
+
$('#life-script-count').textContent = scripts.length;
|
|
606
|
+
$('#life-scripts').innerHTML = scripts.length
|
|
607
|
+
? scripts.map((n) => resourceButton('life', 'source', n, 'data-script')).join('')
|
|
608
|
+
: '<div class="muted">life/ 下还没有脚本</div>';
|
|
609
|
+
$('#life-backup-count').textContent = (data.backups || []).length;
|
|
610
|
+
$('#life-backups').innerHTML = (data.backups || []).length
|
|
611
|
+
? data.backups.map((b) => `<div class="backup-item" title="${esc(b)}">${esc(b)}</div>`).join('')
|
|
612
|
+
: '<div class="muted">暂无备份</div>';
|
|
613
|
+
const logs = $('#life-logs');
|
|
614
|
+
$('#life-log-count').textContent = (data.logs || []).length;
|
|
615
|
+
logs.innerHTML = (data.logs || []).length
|
|
616
|
+
? data.logs.map((n) => resourceButton('life', 'log', n, 'data-log')).join('')
|
|
617
|
+
: '<div class="muted">还没有运行日志</div>';
|
|
480
618
|
// 玩具操控脚本(toys/)
|
|
481
619
|
try {
|
|
482
|
-
const t = await api(`/api/me/roles/${lifeRoleId}/toys`);
|
|
483
|
-
$('#toy-running').
|
|
484
|
-
|
|
485
|
-
: '
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
}
|
|
518
|
-
$('#life-logs').addEventListener('click', async (e) => {
|
|
519
|
-
const btn = e.target.closest('button[data-log]');
|
|
520
|
-
if (!btn) return;
|
|
521
|
-
await showLog(btn.dataset.log);
|
|
522
|
-
});
|
|
523
|
-
$('#life-scripts').addEventListener('click', async (e) => {
|
|
524
|
-
const btn = e.target.closest('button[data-script]');
|
|
525
|
-
if (!btn) return;
|
|
526
|
-
const src = $('#life-source');
|
|
527
|
-
try {
|
|
528
|
-
src.textContent = await (await fetch(`/api/me/roles/${lifeRoleId}/life/script/${encodeURIComponent(btn.dataset.script)}`)).text();
|
|
529
|
-
src.classList.remove('hidden');
|
|
530
|
-
} catch (err) { status(err.message, true); }
|
|
531
|
-
});
|
|
532
|
-
$('#life-running').addEventListener('click', async (e) => {
|
|
533
|
-
const logBtn = e.target.closest('button.run-log');
|
|
534
|
-
if (logBtn) { await showLog(logBtn.dataset.log); return; }
|
|
620
|
+
const t = await api(`/api/me/roles/${lifeRoleId}/toys`);
|
|
621
|
+
$('#toy-running-count').textContent = `${(t.running || []).length} 个运行中`;
|
|
622
|
+
$('#toy-running').innerHTML = (t.running || []).length
|
|
623
|
+
? t.running.map((r) => `<div class="run-row"><span class="run-info">${esc(r.scriptName)} · PID ${esc(r.pid)}${r.startedAt ? ` · 启动 ${new Date(r.startedAt).toLocaleTimeString('zh-CN', { hour12: false })}` : ''}</span>${r.logName ? `<button class="ghost toy-run-log" data-toylog="${esc(r.logName)}">日志</button>` : ''}<button class="ghost danger toy-stop" data-run="${esc(r.runId)}">终止</button></div>`).join('')
|
|
624
|
+
: '<div class="muted">没有玩具脚本在运行(dsh 用 toy_run_script 运行)</div>';
|
|
625
|
+
$('#toy-script-count').textContent = (t.scripts || []).length;
|
|
626
|
+
$('#toy-scripts').innerHTML = (t.scripts || []).length
|
|
627
|
+
? t.scripts.map((n) => resourceButton('toy', 'source', n, 'data-toyscript')).join('')
|
|
628
|
+
: '<div class="muted">toys/ 下还没有脚本</div>';
|
|
629
|
+
$('#toy-log-count').textContent = (t.logs || []).length;
|
|
630
|
+
$('#toy-logs').innerHTML = (t.logs || []).length
|
|
631
|
+
? t.logs.map((n) => resourceButton('toy', 'log', n, 'data-toylog')).join('')
|
|
632
|
+
: '<div class="muted">还没有玩具运行日志</div>';
|
|
633
|
+
} catch { /* 老版本无 toys 端点时忽略 */ }
|
|
634
|
+
}
|
|
635
|
+
document.querySelectorAll('[data-script-space]').forEach((button) => button.addEventListener('click', async () => {
|
|
636
|
+
const group = button.dataset.scriptSpace;
|
|
637
|
+
selectScriptSpace(group);
|
|
638
|
+
await showFirstLog(group);
|
|
639
|
+
const selected = scriptSelection[group];
|
|
640
|
+
currentScriptLog = selected.kind === 'log' ? { group, name: selected.name } : null;
|
|
641
|
+
}));
|
|
642
|
+
document.querySelectorAll('[data-asset-kind]').forEach((button) => button.addEventListener('click', () => selectAssetKind(button.dataset.assetGroup, button.dataset.assetKind)));
|
|
643
|
+
$('#life-logs').addEventListener('click', async (e) => {
|
|
644
|
+
const btn = e.target.closest('button[data-log]');
|
|
645
|
+
if (!btn) return;
|
|
646
|
+
await showScriptLog('life', btn.dataset.log);
|
|
647
|
+
});
|
|
648
|
+
$('#life-scripts').addEventListener('click', async (e) => {
|
|
649
|
+
const btn = e.target.closest('button[data-script]');
|
|
650
|
+
if (!btn) return;
|
|
651
|
+
await showScriptSource('life', btn.dataset.script);
|
|
652
|
+
});
|
|
653
|
+
$('#life-running').addEventListener('click', async (e) => {
|
|
654
|
+
const logBtn = e.target.closest('button.run-log');
|
|
655
|
+
if (logBtn) { await showScriptLog('life', logBtn.dataset.log); return; }
|
|
535
656
|
const btn = e.target.closest('button[data-run]');
|
|
536
657
|
if (!btn) return;
|
|
537
658
|
try {
|
|
@@ -540,8 +661,10 @@ $('#life-running').addEventListener('click', async (e) => {
|
|
|
540
661
|
await refreshLife();
|
|
541
662
|
} catch (err) { status(err.message, true); }
|
|
542
663
|
});
|
|
543
|
-
$('#toy-running').addEventListener('click', async (e) => {
|
|
544
|
-
const
|
|
664
|
+
$('#toy-running').addEventListener('click', async (e) => {
|
|
665
|
+
const logBtn = e.target.closest('button.toy-run-log');
|
|
666
|
+
if (logBtn) { await showScriptLog('toy', logBtn.dataset.toylog); return; }
|
|
667
|
+
const btn = e.target.closest('button.toy-stop');
|
|
545
668
|
if (!btn) return;
|
|
546
669
|
try {
|
|
547
670
|
const r = await api(`/api/me/roles/${lifeRoleId}/toys/stop`, 'POST', { runId: btn.dataset.run });
|
|
@@ -549,27 +672,17 @@ $('#toy-running').addEventListener('click', async (e) => {
|
|
|
549
672
|
await refreshLife();
|
|
550
673
|
} catch (err) { status(err.message, true); }
|
|
551
674
|
});
|
|
552
|
-
$('#toy-logs').addEventListener('click', async (e) => {
|
|
553
|
-
const btn = e.target.closest('button[data-toylog]');
|
|
554
|
-
if (!btn) return;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
});
|
|
562
|
-
$('#
|
|
563
|
-
const btn = e.target.closest('button[data-toyscript]');
|
|
564
|
-
if (!btn) return;
|
|
565
|
-
try {
|
|
566
|
-
const txt = await (await fetch(`/api/me/roles/${lifeRoleId}/toys/script/${encodeURIComponent(btn.dataset.toyscript)}`)).text();
|
|
567
|
-
$('#toy-log-body').classList.add('hidden');
|
|
568
|
-
$('#toy-source').textContent = txt;
|
|
569
|
-
$('#toy-source').classList.remove('hidden');
|
|
570
|
-
} catch (err) { status(err.message, true); }
|
|
571
|
-
});
|
|
572
|
-
$('#btn-close-life').addEventListener('click', () => { stopLifeLogPolling(); stopLifeRefresh(); currentLifeLog = null; showRoles(); });
|
|
675
|
+
$('#toy-logs').addEventListener('click', async (e) => {
|
|
676
|
+
const btn = e.target.closest('button[data-toylog]');
|
|
677
|
+
if (!btn) return;
|
|
678
|
+
await showScriptLog('toy', btn.dataset.toylog);
|
|
679
|
+
});
|
|
680
|
+
$('#toy-scripts').addEventListener('click', async (e) => {
|
|
681
|
+
const btn = e.target.closest('button[data-toyscript]');
|
|
682
|
+
if (!btn) return;
|
|
683
|
+
await showScriptSource('toy', btn.dataset.toyscript);
|
|
684
|
+
});
|
|
685
|
+
$('#btn-close-life').addEventListener('click', () => { stopScriptLogPolling(); stopLifeRefresh(); showRoles(); });
|
|
573
686
|
|
|
574
687
|
/* ------------------------------- 表情包管理 ------------------------------- */
|
|
575
688
|
async function openMemes(rid) {
|
|
@@ -89,10 +89,60 @@
|
|
|
89
89
|
</form>
|
|
90
90
|
</section>
|
|
91
91
|
|
|
92
|
-
<section id="life-view" class="workspace-view monitor-view hidden"
|
|
93
|
-
<
|
|
94
|
-
<
|
|
95
|
-
|
|
92
|
+
<section id="life-view" class="workspace-view monitor-view hidden">
|
|
93
|
+
<div class="view-header monitor-header"><div><p class="eyebrow">SCRIPT WORKSPACE</p><h2><span id="life-role-name"></span> 的脚本</h2><p>查看运行状态、源码和实时日志,无需离开当前视口。</p></div><button id="btn-close-life" class="icon-button" type="button" aria-label="关闭">×</button></div>
|
|
94
|
+
<div class="script-type-tabs" role="tablist" aria-label="脚本类型">
|
|
95
|
+
<button class="script-type-tab active" type="button" role="tab" aria-selected="true" aria-controls="script-space-life" data-script-space="life"><span>生活脚本</span><b id="life-running-count">0 个运行中</b></button>
|
|
96
|
+
<button class="script-type-tab" type="button" role="tab" aria-selected="false" aria-controls="script-space-toy" data-script-space="toy"><span>玩具脚本</span><b id="toy-running-count">0 个运行中</b></button>
|
|
97
|
+
<span class="monitor-live"><i></i> 每 3 秒自动刷新</span>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<section id="script-space-life" class="script-space" role="tabpanel">
|
|
101
|
+
<section class="runtime-panel"><div class="panel-title"><div><p class="eyebrow">RUNTIME</p><h3>正在运行</h3></div></div><div id="life-running" class="list-surface runtime-list"></div></section>
|
|
102
|
+
<div class="script-workbench">
|
|
103
|
+
<aside class="asset-panel">
|
|
104
|
+
<div class="asset-tabs" role="tablist" aria-label="生活脚本资源">
|
|
105
|
+
<button class="asset-tab active" type="button" role="tab" aria-selected="true" data-asset-group="life" data-asset-kind="logs">日志 <b id="life-log-count">0</b></button>
|
|
106
|
+
<button class="asset-tab" type="button" role="tab" aria-selected="false" data-asset-group="life" data-asset-kind="scripts">脚本 <b id="life-script-count">0</b></button>
|
|
107
|
+
<button class="asset-tab" type="button" role="tab" aria-selected="false" data-asset-group="life" data-asset-kind="backups">备份 <b id="life-backup-count">0</b></button>
|
|
108
|
+
</div>
|
|
109
|
+
<div class="asset-list-wrap">
|
|
110
|
+
<div id="life-logs" class="list-surface asset-list" data-asset-panel="logs"></div>
|
|
111
|
+
<div id="life-scripts" class="list-surface asset-list hidden" data-asset-panel="scripts"></div>
|
|
112
|
+
<div id="life-backups" class="list-surface asset-list hidden" data-asset-panel="backups"></div>
|
|
113
|
+
</div>
|
|
114
|
+
<details class="raw-data"><summary>运行清单</summary><pre id="life-manifest" class="code"></pre></details>
|
|
115
|
+
</aside>
|
|
116
|
+
<section class="inspector-panel">
|
|
117
|
+
<header class="inspector-header"><div><p id="life-inspector-kind" class="eyebrow">PREVIEW</p><h3 id="life-inspector-title">选择一条日志或脚本</h3></div><span id="life-inspector-state" class="inspector-state">日志打开后自动追踪更新</span></header>
|
|
118
|
+
<div id="life-preview-empty" class="preview-empty"><span>⌁</span><b>内容查看器</b><p>从左侧选择日志、脚本或运行中项目。</p></div>
|
|
119
|
+
<pre id="life-source" class="code inspector-code hidden"></pre>
|
|
120
|
+
<pre id="life-log-body" class="code inspector-code hidden"></pre>
|
|
121
|
+
</section>
|
|
122
|
+
</div>
|
|
123
|
+
</section>
|
|
124
|
+
|
|
125
|
+
<section id="script-space-toy" class="script-space hidden" role="tabpanel">
|
|
126
|
+
<section class="runtime-panel"><div class="panel-title"><div><p class="eyebrow">RUNTIME</p><h3>正在运行</h3></div></div><div id="toy-running" class="list-surface runtime-list"></div></section>
|
|
127
|
+
<div class="script-workbench">
|
|
128
|
+
<aside class="asset-panel">
|
|
129
|
+
<div class="asset-tabs" role="tablist" aria-label="玩具脚本资源">
|
|
130
|
+
<button class="asset-tab active" type="button" role="tab" aria-selected="true" data-asset-group="toy" data-asset-kind="logs">日志 <b id="toy-log-count">0</b></button>
|
|
131
|
+
<button class="asset-tab" type="button" role="tab" aria-selected="false" data-asset-group="toy" data-asset-kind="scripts">脚本 <b id="toy-script-count">0</b></button>
|
|
132
|
+
</div>
|
|
133
|
+
<div class="asset-list-wrap">
|
|
134
|
+
<div id="toy-logs" class="list-surface asset-list" data-asset-panel="logs"></div>
|
|
135
|
+
<div id="toy-scripts" class="list-surface asset-list hidden" data-asset-panel="scripts"></div>
|
|
136
|
+
</div>
|
|
137
|
+
</aside>
|
|
138
|
+
<section class="inspector-panel">
|
|
139
|
+
<header class="inspector-header"><div><p id="toy-inspector-kind" class="eyebrow">PREVIEW</p><h3 id="toy-inspector-title">选择一条日志或脚本</h3></div><span id="toy-inspector-state" class="inspector-state">日志打开后自动追踪更新</span></header>
|
|
140
|
+
<div id="toy-preview-empty" class="preview-empty"><span>⌁</span><b>内容查看器</b><p>从左侧选择日志、脚本或运行中项目。</p></div>
|
|
141
|
+
<pre id="toy-log-body" class="code inspector-code hidden"></pre>
|
|
142
|
+
<pre id="toy-source" class="code inspector-code hidden"></pre>
|
|
143
|
+
</section>
|
|
144
|
+
</div>
|
|
145
|
+
</section>
|
|
96
146
|
</section>
|
|
97
147
|
|
|
98
148
|
<section id="meme-view" class="workspace-view meme-view hidden"><div class="view-header"><div><p class="eyebrow">REACTION LIBRARY</p><h2><span id="meme-role-name"></span> 的表情包</h2><p>管理角色可以理解、选择并发送的反应图。</p></div><button id="btn-close-meme" class="icon-button" type="button" aria-label="关闭">×</button></div>
|
package/src/web-public/style.css
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
:root{--ink:#23242b;--muted:#73757f;--line:#e8e8ed;--paper:#fff;--wash:#f7f7f8;--dark:#25252f;--violet:#6d5ce7;--violet-dark:#5544d5;--violet-pale:#f0efff;--green:#26734d;--red:#c64c56;--amber:#9b6b1e;--radius:16px;--shadow:0 10px 30px #2826370b}*{box-sizing:border-box}body{margin:0;background:var(--wash);color:var(--ink);font:14px/1.55 Inter,ui-sans-serif,system-ui,"Microsoft YaHei",sans-serif}.hidden{display:none!important}.site-shell{min-height:100vh}.button{border:1px solid transparent;border-radius:10px;cursor:pointer;font:inherit;font-weight:650;padding:10px 15px;transition:.18s ease}.button:hover{transform:translateY(-1px)}.button.primary{background:var(--violet);color:#fff;box-shadow:0 6px 14px #6d5ce735}.button.primary:hover{background:var(--violet-dark)}.button.secondary{background:#fff;border-color:var(--line);color:var(--ink)}.button.danger{background:#fff2f3;border-color:#f3dadd;color:var(--red)}.wide{width:100%}.eyebrow{color:var(--violet);font-size:10px;font-weight:800;letter-spacing:.14em;margin:0 0 6px}.optional{color:#999ba5;font-size:12px;font-weight:400}.muted{color:var(--muted)}.form-error{color:var(--red);font-size:13px}.text-button{background:none;border:0;color:var(--violet);cursor:pointer;font:inherit;font-weight:650;padding:8px 0}.auth-screen{align-items:center;background:var(--dark);display:grid;grid-template-columns:minmax(300px,1fr) minmax(360px,520px);justify-content:center;min-height:100vh;overflow:hidden;padding:40px}.auth-card{background:#fff;border-radius:24px;box-shadow:0 30px 60px #0003;justify-self:center;padding:42px;position:relative;width:min(100%,440px);z-index:1}.auth-art{height:100%;min-height:540px;position:relative}.auth-art:before,.auth-art:after,.auth-art span{border:1px solid #ffffff1d;border-radius:999px;content:"";left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.auth-art:before{height:460px;width:460px}.auth-art:after{height:300px;width:300px}.auth-art span:first-child{background:#7869ee;height:110px;width:110px;box-shadow:0 0 0 26px #7869ee25,0 0 60px #7869ee}.auth-art span:nth-child(2){background:#edb45c;border:0;height:12px;left:20%;top:23%;width:12px}.auth-art span:nth-child(3){background:#a4e3c2;border:0;height:16px;left:70%;top:74%;width:16px}.brand{align-items:center;color:var(--ink);display:inline-flex;font-size:17px;font-weight:760;gap:9px;letter-spacing:-.03em;text-decoration:none}.brand i{align-items:center;background:var(--violet);border-radius:9px;color:white;display:inline-flex;font:700 19px Georgia,serif;height:29px;justify-content:center;width:29px}.brand-large{margin-bottom:48px}.auth-copy h1{font-size:31px;letter-spacing:-.055em;line-height:1.15;margin:0 0 13px}.auth-copy>p:last-child{color:var(--muted);margin:0 0 30px}.form-stack{display:grid;gap:15px}.form-stack label,.form-grid label,.inline-entry label{color:#555762;display:grid;font-size:12px;font-weight:650;gap:6px}input,textarea{background:#fff;border:1px solid #dedee5;border-radius:9px;color:var(--ink);font:inherit;font-weight:400;outline:none;padding:10px 11px;transition:border .15s,box-shadow .15s;width:100%}input:focus,textarea:focus{border-color:var(--violet);box-shadow:0 0 0 3px #6d5ce71a}textarea{resize:vertical}.auth-card .form-error{margin:10px 0 0;min-height:19px}.app-shell{display:grid;grid-template-columns:230px minmax(0,1fr);min-height:100vh}.sidebar{background:var(--dark);color:#d8d8df;display:flex;flex-direction:column;padding:26px 16px}.sidebar .brand{color:#fff;padding:0 10px}.side-nav{display:grid;gap:5px;margin-top:48px}.nav-item{align-items:center;background:none;border:0;border-radius:9px;color:#b8b8c3;cursor:pointer;display:flex;font:inherit;font-weight:600;gap:10px;padding:11px 12px;text-align:left;width:100%}.nav-item b{color:#a29be9;font-size:16px;font-weight:400;width:18px}.nav-item:hover,.nav-item.active{background:#ffffff12;color:#fff}.nav-item.active{box-shadow:inset 2px 0 var(--violet)}.sidebar-foot{border-top:1px solid #ffffff16;display:grid;gap:5px;margin-top:auto;padding-top:16px}.nav-item.subdued{color:#898994}.app-main{margin:0 auto;max-width:1240px;padding:36px 46px 80px;width:100%}.app-header{align-items:center;display:flex;justify-content:space-between;margin:0 0 36px}.app-header h1{font-size:26px;letter-spacing:-.045em;line-height:1.1;margin:0}.account-chip{align-items:center;color:var(--muted);display:flex;font-size:13px;font-weight:650;gap:9px}.account-avatar{align-items:center;background:var(--violet-pale);border-radius:50%;color:var(--violet);display:inline-flex;font-size:13px;height:32px;justify-content:center;width:32px}.toast{background:#272632;border-radius:11px;box-shadow:var(--shadow);color:white;left:50%;padding:10px 15px;position:fixed;top:20px;transform:translateX(-50%);z-index:10}.toast.error{background:#ae3f4a}.workspace-view{animation:appear .2s ease}@keyframes appear{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}.intro-row,.view-header{align-items:flex-start;display:flex;gap:20px;justify-content:space-between;margin-bottom:22px}.intro-row h2,.view-header h2{font-size:21px;letter-spacing:-.035em;margin:0}.intro-row p,.view-header p{color:var(--muted);margin:5px 0 0}.role-grid{display:grid;gap:14px;grid-template-columns:repeat(auto-fill,minmax(310px,1fr))}.role-card{background:var(--paper);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);display:flex;flex-direction:column;min-height:210px;padding:20px}.role-main{display:grid;gap:7px}.role-main strong{font-size:18px;letter-spacing:-.025em}.role-main .row:first-child{align-items:center}.row{align-items:center;display:flex;flex-wrap:wrap;gap:7px}.role-card .muted{font-size:13px}.role-actions{border-top:1px solid var(--line);gap:6px;margin-top:auto;padding-top:15px}.role-actions button{background:none;border:0;color:#555660;cursor:pointer;font:inherit;font-size:13px;font-weight:650;padding:6px}.role-actions button:hover{color:var(--violet)}.role-actions button.danger{color:var(--red)}.tag{background:#f5f5f7;border:1px solid #e5e5e9;border-radius:999px;color:#777884;font-size:11px;font-weight:650;padding:2px 8px}.tag.ok{background:#ebf8f0;border-color:#c8e9d4;color:var(--green)}.tag.sleeping{background:#fff6e6;border-color:#f1d9a9;color:var(--amber)}.quiet-note{align-items:flex-start;border-top:1px solid var(--line);color:var(--muted);display:flex;font-size:12px;gap:14px;margin-top:28px;padding:17px 2px}.quiet-note b{color:#4d4e57;white-space:nowrap}.panel-view,.editor-view,.monitor-view,.meme-view{background:var(--paper);border:1px solid var(--line);border-radius:20px;box-shadow:var(--shadow);padding:28px}.icon-button{align-items:center;background:#f5f5f7;border:0;border-radius:50%;color:#6c6c75;cursor:pointer;display:inline-flex;font-size:24px;height:34px;justify-content:center;line-height:1;width:34px}.info-callout{background:var(--violet-pale);border-radius:11px;color:#555275;font-size:13px;margin-bottom:20px;padding:13px 15px}.inline-entry{align-items:end;display:flex;gap:12px;margin-bottom:20px;max-width:520px}.inline-entry label{flex:1}.list-surface{display:grid;gap:7px}.list-surface:empty:after{color:var(--muted);content:"暂无内容"}.editor-view{padding:0;overflow:hidden}.editor-view>.view-header{background:#fbfbfc;border-bottom:1px solid var(--line);margin:0;padding:28px}.editor-form{padding:0 28px}.editor-section{border-bottom:1px solid var(--line);padding:30px 0}.section-heading{align-items:flex-start;display:flex;gap:14px;margin-bottom:22px}.section-heading>span{align-items:center;background:var(--violet-pale);border-radius:50%;color:var(--violet);display:flex;font-size:11px;font-weight:800;height:28px;justify-content:center;width:28px}.section-heading h3,.connection-heading h3{font-size:16px;letter-spacing:-.02em;margin:0}.section-heading p{color:var(--muted);font-size:13px;margin:3px 0 0}.form-grid{display:grid;gap:15px;grid-template-columns:repeat(2,minmax(0,1fr))}.form-grid.compact{gap:12px}.span-2{grid-column:span 2}.device-pick{background:#fafafd;border:1px solid var(--line);border-radius:11px;margin-top:15px;padding:13px}.field-label{font-size:12px;font-weight:650;margin-bottom:8px}.device-checkboxes{color:var(--muted);display:flex;flex-wrap:wrap;gap:8px 18px;font-size:13px}.device-checkboxes label{align-items:center;display:flex;gap:6px}.device-checkboxes input{width:auto}.switch-row{align-items:center;background:#fafafd;border:1px solid var(--line);border-radius:11px;cursor:pointer;display:flex;gap:10px;margin-top:15px;padding:11px 13px}.switch-row input{height:1px;opacity:0;position:absolute;width:1px}.switch{background:#d4d5dc;border-radius:99px;display:inline-block;flex:none;height:22px;position:relative;width:38px}.switch:after{background:white;border-radius:50%;box-shadow:0 1px 3px #0003;content:"";height:16px;left:3px;position:absolute;top:3px;transition:.18s;width:16px}.switch-row input:checked+.switch{background:var(--violet)}.switch-row input:checked+.switch:after{transform:translateX(16px)}.switch-row b,.switch-row small{display:block}.switch-row small{color:var(--muted);font-size:12px;margin-top:1px}.advanced{border:1px solid var(--line);border-radius:10px;color:#5d5d68;margin-top:15px;padding:0 13px}.advanced summary{cursor:pointer;font-weight:650;padding:12px 0}.advanced summary span{color:var(--muted);font-size:12px;font-weight:400}.advanced[open]{padding-bottom:14px}.form-footer{align-items:center;display:flex;justify-content:space-between;padding:22px 0}.connection-card{background:#272631;color:white;margin-top:22px;padding:27px 28px}.connection-heading{align-items:flex-start;display:flex;justify-content:space-between;margin-bottom:20px}.connection-heading .eyebrow{color:#aaa2ff}.connection-heading p:last-child{color:#c5c5cd;font-size:13px;margin:5px 0 0}.connection-dot{background:#6fe09e;border-radius:50%;box-shadow:0 0 0 5px #6fe09e1f;height:8px;margin:7px;width:8px}.connection-card input{background:#ffffff0c;border-color:#ffffff25;color:white}.connection-card .form-grid label{color:#dad9e0}.setting-pills{display:flex;gap:8px;margin-top:15px}.check-pill{background:#ffffff12;border:1px solid #ffffff1a;border-radius:99px;color:#dfdfe7;font-size:12px;padding:7px 10px}.check-pill input{margin-right:5px;width:auto}.connection-actions{align-items:center;display:flex;justify-content:space-between;margin-top:20px}.connection-actions>div{display:flex;gap:8px}.connection-actions .secondary{background:#ffffff10;border-color:#ffffff25;color:white}.monitor-grid{display:grid;gap:14px;grid-template-columns:repeat(2,minmax(0,1fr))}.monitor-card{background:#fafafd;border:1px solid var(--line);border-radius:12px;padding:16px}.monitor-card h3{font-size:13px;margin:0 0 12px}.span-wide{grid-column:span 2}.log-btn{background:white;border:1px solid var(--line);border-radius:8px;color:#4a4b55;cursor:pointer;font:12px ui-monospace,monospace;padding:8px;text-align:left}.run-row{align-items:center;background:white;border:1px solid var(--line);border-radius:9px;display:flex;gap:8px;justify-content:space-between;padding:8px}.run-info{font:12px ui-monospace,monospace}.run-row .ghost,.meme-card .ghost{background:white;border:1px solid var(--line);border-radius:7px;color:#50515a;cursor:pointer;font:inherit;padding:5px 8px}.run-row .danger,.meme-card .danger{color:var(--red)}.raw-data{margin-top:16px}.raw-data summary{color:var(--muted);cursor:pointer;font-size:13px}.code{background:#1f2029;border-radius:10px;color:#e9e9ee;font:12px/1.55 ui-monospace,Consolas,monospace;margin:12px 0;max-height:340px;overflow:auto;padding:15px;white-space:pre-wrap;word-break:break-all}.upload-card{align-items:center;background:#fafafd;border:1px dashed #cfcfda;border-radius:13px;display:flex;flex-wrap:wrap;gap:15px;justify-content:space-between;margin-bottom:22px;padding:18px}.upload-card b{font-size:14px}.upload-card p{color:var(--muted);font-size:12px;margin:3px 0 0}.upload-actions{align-items:center;display:flex;gap:8px}.upload-actions input{font-size:12px;max-width:220px}.meme-grid{display:grid;gap:14px;grid-template-columns:repeat(auto-fill,minmax(190px,1fr))}.meme-card{background:#fafafd;border:1px solid var(--line);border-radius:12px;overflow:hidden}.meme-card img{aspect-ratio:1;display:block;object-fit:cover;width:100%}.meme-meta{display:grid;gap:8px;padding:10px}.meme-meta label{color:var(--muted);display:grid;font-size:11px;gap:3px}.meme-meta input{font-size:12px;padding:6px 7px}@media(max-width:820px){.app-shell{display:block}.sidebar{align-items:center;flex-direction:row;gap:15px;padding:12px 15px;position:sticky;top:0;z-index:5}.side-nav{display:flex;margin:0}.sidebar-foot{border:0;display:flex;margin:0 0 0 auto;padding:0}.sidebar-foot .nav-item{font-size:0;padding:8px}.sidebar-foot .nav-item b{font-size:16px}.app-main{padding:28px 20px 60px}.app-header{margin-bottom:26px}.role-grid{grid-template-columns:1fr}.auth-screen{grid-template-columns:1fr;padding:24px}.auth-art{display:none}.auth-card{padding:32px}.brand-large{margin-bottom:35px}}@media(max-width:560px){.sidebar .brand span{display:none}.nav-item{font-size:12px;padding:8px}.side-nav{margin-right:auto}.app-header{align-items:flex-start;gap:12px}.account-chip span:last-child{display:none}.intro-row,.view-header{gap:12px}.intro-row{align-items:flex-end}.form-grid,.monitor-grid{grid-template-columns:1fr}.span-2,.span-wide{grid-column:auto}.editor-view>.view-header,.editor-form{padding-left:18px;padding-right:18px}.connection-card{padding:22px 18px}.connection-actions{align-items:flex-start;flex-direction:column}.upload-card{align-items:flex-start;flex-direction:column}.upload-actions{align-items:flex-start;flex-direction:column;width:100%}.upload-actions input{max-width:none}.quiet-note{flex-direction:column;gap:4px}}
|
|
2
2
|
/* 编辑页按需展开,脚本监管按脚本类型分区。 */
|
|
3
3
|
.editor-nav{background:#fbfbfc;border-bottom:1px solid var(--line);display:flex;gap:6px;margin:0 -28px;padding:11px 28px;position:sticky;top:0;z-index:2}.editor-nav a{border-radius:7px;color:var(--muted);font-size:12px;font-weight:650;padding:5px 8px;text-decoration:none}.editor-nav a:hover{background:var(--violet-pale);color:var(--violet)}.editor-section{padding:0!important}.editor-section[open]{padding-bottom:30px!important}.section-heading{cursor:pointer;margin:0!important;padding:24px 0}.section-heading::-webkit-details-marker{display:none}.section-heading::marker{content:""}.script-monitor{border-top:1px solid var(--line);margin-top:26px;padding-top:24px}.script-monitor:first-of-type{border-top:0;margin-top:0;padding-top:0}.script-monitor-heading{margin-bottom:14px}.script-monitor-heading .eyebrow{margin-bottom:3px}.script-monitor-heading h3{font-size:17px;margin:0}@media(max-width:560px){.editor-nav{margin-left:-18px;margin-right:-18px;overflow:auto;padding-left:18px;padding-right:18px;white-space:nowrap}}
|
|
4
|
+
|
|
5
|
+
/* 脚本工作台 */
|
|
6
|
+
.monitor-view{overflow:hidden;padding:0}.monitor-header{background:#fbfbfc;border-bottom:1px solid var(--line);margin:0;padding:22px 26px}.monitor-header p:last-child{font-size:13px}.script-type-tabs{align-items:center;border-bottom:1px solid var(--line);display:flex;gap:4px;padding:10px 18px}.script-type-tab{align-items:center;background:transparent;border:0;border-radius:10px;color:#656772;cursor:pointer;display:flex;font:inherit;font-weight:700;gap:9px;padding:9px 12px}.script-type-tab:hover{background:#f5f5f8;color:var(--ink)}.script-type-tab.active{background:var(--violet-pale);color:var(--violet)}.script-type-tab b{background:#ededf2;border-radius:999px;color:#858691;font-size:10px;font-weight:700;padding:2px 7px}.script-type-tab.active b{background:#fff;color:var(--violet)}.monitor-live{align-items:center;color:var(--muted);display:flex;font-size:11px;gap:6px;margin-left:auto;padding:0 8px}.monitor-live i{background:#45ad74;border-radius:50%;box-shadow:0 0 0 4px #45ad7418;height:6px;width:6px}.script-space{padding:16px 18px 18px}.runtime-panel{background:#fafafd;border:1px solid var(--line);border-radius:12px;margin-bottom:12px;padding:12px}.panel-title{align-items:center;display:flex;justify-content:space-between;margin-bottom:8px}.panel-title .eyebrow{margin:0}.panel-title h3{font-size:13px;margin:0}.runtime-list{max-height:126px;overflow:auto}.script-workbench{border:1px solid var(--line);border-radius:13px;display:grid;grid-template-columns:minmax(250px,310px) minmax(0,1fr);height:clamp(480px,calc(100vh - 390px),680px);min-height:0;overflow:hidden}.asset-panel{background:#fafafd;border-right:1px solid var(--line);display:flex;flex-direction:column;min-height:0;min-width:0}.asset-tabs{border-bottom:1px solid var(--line);display:flex;padding:8px 8px 0}.asset-tab{background:transparent;border:0;border-bottom:2px solid transparent;color:var(--muted);cursor:pointer;font:inherit;font-size:12px;font-weight:700;padding:8px 9px}.asset-tab:hover{color:var(--ink)}.asset-tab.active{border-bottom-color:var(--violet);color:var(--violet)}.asset-tab b{background:#e9e9ee;border-radius:999px;font-size:10px;margin-left:3px;padding:1px 6px}.asset-list-wrap{flex:1;min-height:0;overflow:auto;padding:10px}.asset-list{align-content:start}.asset-list .muted{font-size:12px;padding:8px}.log-btn{align-items:center;display:flex;min-height:36px;overflow:hidden;position:relative;width:100%}.log-btn:hover{border-color:#cbc8e9;background:#f9f8ff}.log-btn.active{background:var(--violet-pale);border-color:#cdc7ff;color:var(--violet);font-weight:700}.log-btn .item-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.raw-data{border-top:1px solid var(--line);margin:0;padding:9px 12px}.raw-data summary{font-size:11px}.raw-data .code{max-height:240px}.inspector-panel{background:#1f2029;display:flex;flex-direction:column;min-height:0;min-width:0}.inspector-header{align-items:center;background:#292a35;border-bottom:1px solid #ffffff12;color:#fff;display:flex;justify-content:space-between;min-height:62px;padding:11px 16px}.inspector-header .eyebrow{color:#aaa2ff;margin:0}.inspector-header h3{font-size:13px;font-weight:650;margin:2px 0 0;max-width:48vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.inspector-state{color:#9798a5;font-size:10px;white-space:nowrap}.preview-empty{align-items:center;color:#777986;display:flex;flex:1;flex-direction:column;justify-content:center;text-align:center}.preview-empty span{color:#8277df;font:40px Georgia,serif}.preview-empty b{color:#d2d2d8;font-size:13px;margin-top:4px}.preview-empty p{font-size:11px;margin:4px 0}.inspector-code{border-radius:0;flex:1;margin:0;max-height:none;min-height:0;padding:16px 18px;white-space:pre;word-break:normal}.run-row{min-width:0}.run-info{flex:1;min-width:140px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.runtime-list>.muted{font-size:12px;padding:4px}.backup-item{background:#fff;border:1px solid var(--line);border-radius:8px;color:#5d5f69;font:11px ui-monospace,monospace;overflow:hidden;padding:8px;text-overflow:ellipsis;white-space:nowrap}
|
|
7
|
+
@media(max-width:900px){.script-workbench{grid-template-columns:minmax(220px,270px) minmax(0,1fr)}.inspector-state{display:none}}
|
|
8
|
+
@media(max-width:700px){.monitor-header{padding:18px}.monitor-header p:last-child{display:none}.script-type-tabs{overflow:auto;padding:8px 12px;white-space:nowrap}.monitor-live{display:none}.script-space{padding:12px}.runtime-list{max-height:150px}.script-workbench{display:flex;height:auto;min-height:0;overflow:visible;flex-direction:column}.asset-panel{border-bottom:1px solid var(--line);border-right:0;height:270px}.inspector-panel{height:430px}.inspector-header h3{max-width:70vw}.asset-tab{flex:1}.run-row{align-items:flex-start;flex-wrap:wrap}.run-info{flex-basis:100%;white-space:normal}.monitor-view{border-radius:14px}}
|
package/src/web-server.js
CHANGED
|
@@ -203,10 +203,16 @@ export function createWebServer(deps) {
|
|
|
203
203
|
if (!role) return null;
|
|
204
204
|
const toysDir = join(role.workspace, 'toys');
|
|
205
205
|
const scripts = await readdir(toysDir).then((a) => a.filter((n) => /\.(mjs|js|ts)$/.test(n)).sort()).catch(() => []);
|
|
206
|
-
const logs = await readdir(join(toysDir, '.logs')).then((a) => a.sort().reverse()).catch(() => []);
|
|
207
|
-
const running = (typeof devices?.listScriptRuns === 'function' ? devices.listScriptRuns() : [])
|
|
208
|
-
.filter((r) => r.roleId === roleId)
|
|
209
|
-
.map((r) => ({
|
|
206
|
+
const logs = await readdir(join(toysDir, '.logs')).then((a) => a.sort().reverse()).catch(() => []);
|
|
207
|
+
const running = (typeof devices?.listScriptRuns === 'function' ? devices.listScriptRuns() : [])
|
|
208
|
+
.filter((r) => r.roleId === roleId)
|
|
209
|
+
.map((r) => ({
|
|
210
|
+
runId: r.runId,
|
|
211
|
+
scriptName: r.scriptName,
|
|
212
|
+
pid: r.pid,
|
|
213
|
+
startedAt: r.startedAt,
|
|
214
|
+
logName: `${r.scriptName.replace(/\.[^.]+$/, '')}-${r.startedAt}.log`,
|
|
215
|
+
}));
|
|
210
216
|
return { scripts, logs: logs.slice(0, 50), running };
|
|
211
217
|
}
|
|
212
218
|
/** 安全化角色 id 参数(防路径穿越)。 */
|
|
@@ -214,10 +220,12 @@ export function createWebServer(deps) {
|
|
|
214
220
|
const rid = String(raw ?? '');
|
|
215
221
|
return /^[A-Za-z0-9._-]+$/.test(rid) ? rid : null;
|
|
216
222
|
}
|
|
217
|
-
function logFileNameParam(raw) {
|
|
218
|
-
const n = String(raw ?? '');
|
|
219
|
-
|
|
220
|
-
|
|
223
|
+
function logFileNameParam(raw) {
|
|
224
|
+
const n = String(raw ?? '');
|
|
225
|
+
// 日志以“脚本名-时间戳.log”命名;脚本名允许中文,故不能只接受 ASCII \w。
|
|
226
|
+
// 仍拒绝路径分隔、控制字符和 Windows 非法文件名字符,防止路径穿越。
|
|
227
|
+
return /^[^/\\\x00-\x1f<>:"|?*]+\.log$/.test(n) && n !== '..' ? n : null;
|
|
228
|
+
}
|
|
221
229
|
function scriptFileNameParam(raw) {
|
|
222
230
|
const n = String(raw ?? '');
|
|
223
231
|
// 排除法:允许中文等任意文件名,只禁路径分隔与 Windows 非法字符(防穿越)
|