feat(electron-shell): 补录壳子源码(排除运行环境与构建产物)

This commit is contained in:
2026-09-24 16:14:24 +08:00
parent 08a9b962b4
commit f3311339e5
56 changed files with 17858 additions and 0 deletions
@@ -0,0 +1,745 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>37du 壳子 · 基于数据的重排版提案 v2(Run-centric Console)</title>
<style>
/* ============================================================
v2 · 信息架构重排版:一切围绕「运行」组织
左轨=场景轨 · 中央=上下文(总览/执行台/计划) · 右轨=活动轨
单文件自包含 · 双主题 · 数据均取自真实接口字段
============================================================ */
:root {
--canvas: #F4F6F9;
--surface: #FFFFFF;
--surface-2: #F1F4F8;
--border: #E4E9F0;
--border-strong: #CDD6E1;
--text: #182230;
--text-sub: #5A6674;
--text-faint: #7C8896;
--primary: #1E6FA8;
--primary-strong: #17608F;
--primary-tint: #E9F2FA;
--ok: #1F8A4C; --ok-tint: #E7F5EC;
--err: #D64545; --err-tint: #FBEBEB;
--warn: #B26B00; --warn-tint: #FBF3E0;
--r-frame: 14px; --r-card: 12px; --r-ctl: 8px;
--sh-sm: 0 1px 2px rgba(15, 23, 42, .05);
--sh-md: 0 8px 24px -12px rgba(15, 23, 42, .14);
--font: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
--mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}
.frame[data-theme="dark"] {
--canvas: #0E1116; --surface: #151A21; --surface-2: #1B222B;
--border: #27303D; --border-strong: #39465A;
--text: #E8EDF4; --text-sub: #9AA7B5; --text-faint: #6E7C8C;
--primary: #3E93CF; --primary-strong: #5FA9DE; --primary-tint: #14304A;
--ok: #4CC38A; --ok-tint: #12291C;
--err: #E5726F; --err-tint: #2E1717;
--warn: #DFA63E; --warn-tint: #2D2312;
--sh-sm: 0 1px 2px rgba(0,0,0,.3);
--sh-md: 0 10px 28px -14px rgba(0,0,0,.55);
}
* { box-sizing: border-box; }
body {
margin: 0; background: #E9ECF1; color: #182230;
font-family: var(--font); font-size: 14px; line-height: 1.6;
-webkit-font-smoothing: antialiased;
}
body.dark { background: #0B0E12; color: #E8EDF4; }
.intro { max-width: 1280px; margin: 0 auto; padding: 26px 24px 6px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.intro h1 { margin: 0; font-size: 19px; font-weight: 700; }
.intro h1 small { color: #7C8896; font-weight: 500; font-size: 13px; }
.intro p { margin: 4px 0 0; font-size: 12.5px; color: #5A6674; }
body.dark .intro p { color: #9AA7B5; }
.theme-toggle {
border: 1px solid #CDD6E1; background: #fff; color: #182230;
border-radius: 999px; padding: 7px 16px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.theme-toggle:hover { border-color: #1E6FA8; color: #1E6FA8; }
body.dark .theme-toggle { background: #1B222B; border-color: #39465A; color: #E8EDF4; }
body.dark .theme-toggle:hover { border-color: #3E93CF; color: #3E93CF; }
.stage { max-width: 1280px; margin: 18px auto 0; padding: 0 24px; }
.frame {
border-radius: var(--r-frame); background: var(--canvas);
border: 1px solid var(--border); box-shadow: var(--sh-md);
overflow: hidden; display: flex; flex-direction: column; height: 820px;
}
/* ---------- 标题栏 ---------- */
.titlebar {
height: 40px; flex-shrink: 0; display: flex; align-items: center; gap: 10px;
padding-left: 14px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.titlebar .mark { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; background: var(--primary); color: #fff; font: 700 9px/1 var(--mono); }
.titlebar .tname { font-size: 12.5px; font-weight: 600; }
.titlebar .tver { font: 500 10.5px/1 var(--mono); color: var(--text-faint); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }
.titlebar .tsp { flex: 1; }
.win-ctl { display: flex; height: 100%; }
.win-ctl span { width: 44px; display: grid; place-items: center; color: var(--text-faint); font-size: 11px; }
.win-ctl span:hover { background: var(--surface-2); }
.win-ctl span.close:hover { background: var(--err); color: #fff; }
/* ---------- 三栏骨架 ---------- */
.shell { flex: 1; display: grid; grid-template-columns: 206px minmax(0, 1fr) 288px; min-height: 0; }
/* ===== 左轨 · 场景轨 ===== */
.rail { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 10px; min-height: 0; }
.me {
display: flex; align-items: center; gap: 9px;
padding: 8px 8px; margin-bottom: 10px;
border: 1px solid var(--border); border-radius: var(--r-card);
cursor: pointer; transition: border-color .13s ease;
}
.me:hover { border-color: var(--border-strong); }
.me .ava { width: 28px; height: 28px; border-radius: 8px; background: var(--primary-tint); color: var(--primary); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.me .mm { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.me .mm b { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .mm span { font-size: 10.5px; color: var(--text-faint); }
.me .ticket { font: 500 9.5px/1 var(--mono); color: var(--warn); background: var(--warn-tint); border-radius: 999px; padding: 3px 7px; flex-shrink: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.nv {
display: flex; align-items: center; gap: 9px; height: 32px; padding: 0 9px;
border-radius: var(--r-ctl); font-size: 12.5px; color: var(--text-sub);
cursor: pointer; position: relative; transition: background .12s ease, color .12s ease;
}
.nv:hover { background: var(--surface-2); color: var(--text); }
.nv.active { background: var(--primary-tint); color: var(--primary); font-weight: 600; }
.nv.active::before { content: ''; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.nv svg { width: 14px; height: 14px; flex-shrink: 0; }
.nv .bdg { margin-left: auto; font: 500 10px/1 var(--mono); color: var(--text-faint); background: var(--surface-2); border-radius: 999px; padding: 2px 6px; }
.nv.active .bdg { background: transparent; color: var(--primary); }
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 0 9px 7px; font-size: 10.5px; font-weight: 700; letter-spacing: .07em; color: var(--text-faint); }
.rail-head .cnt { font: 500 10px/1 var(--mono); background: var(--surface-2); border-radius: 999px; padding: 2px 6px; }
.scenes { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 1px; min-height: 0; }
.sc-rail {
display: flex; align-items: center; gap: 8px; height: 33px; padding: 0 9px;
border-radius: var(--r-ctl); cursor: pointer; transition: background .12s ease;
}
.sc-rail:hover { background: var(--surface-2); }
.sc-rail.active { background: var(--primary-tint); }
.sc-rail .tile { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 9.5px; font-weight: 700; flex-shrink: 0; }
.t-sky { background: var(--primary-tint); color: var(--primary); }
.t-honey { background: var(--warn-tint); color: var(--warn); }
.t-mint { background: var(--ok-tint); color: var(--ok); }
.t-blush { background: var(--err-tint); color: var(--err); }
.sc-rail .nm { flex: 1; font-size: 12px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-rail.active .nm { color: var(--primary); font-weight: 600; }
.sc-rail .dep { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dep.on { background: var(--ok); }
.dep.off { background: var(--warn); }
.rail-foot { border-top: 1px solid var(--border); padding: 9px 9px 1px; margin-top: 8px; display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-faint); }
.rail-foot a { color: var(--primary); text-decoration: none; cursor: pointer; }
/* ===== 中央 · 上下文区 ===== */
.center { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.view { display: none; flex: 1; min-height: 0; overflow: auto; padding: 20px 22px; }
.view.on { display: block; }
/* --- 执行台 --- */
.run-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.run-head .big-tile { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; font-weight: 700; flex-shrink: 0; }
.run-head .rh-m { flex: 1; min-width: 0; }
.run-head h2 { margin: 0; font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip { font: 500 10.5px/1 var(--mono); color: var(--text-faint); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; }
.chip.ok { color: var(--ok); background: var(--ok-tint); border-color: transparent; font-family: var(--font); }
.chip.warn { color: var(--warn); background: var(--warn-tint); border-color: transparent; font-family: var(--font); cursor: pointer; }
.run-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-sub); }
.rh-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--sh-sm); }
.card + .card { margin-top: 12px; }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 0; }
.card-h h3 { margin: 0; font-size: 12.5px; font-weight: 700; letter-spacing: .01em; }
.card-h .ops { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-faint); }
.card-b { padding: 12px 16px 14px; }
/* 参数 */
.fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; color: var(--text-sub); display: flex; justify-content: space-between; }
.field label em { font-style: normal; font-size: 10.5px; color: var(--text-faint); }
.ctl {
height: 32px; border: 1px solid var(--border-strong); border-radius: var(--r-ctl);
background: var(--surface); color: var(--text); padding: 0 10px; font: 400 12.5px/1 var(--font);
display: flex; align-items: center; justify-content: space-between; cursor: pointer;
}
.ctl:hover { border-color: var(--primary); }
.ctl .arr { color: var(--text-faint); font-size: 9px; }
.restored { display: flex; align-items: center; gap: 7px; margin-top: 11px; font-size: 11px; color: var(--text-faint); }
.restored a { color: var(--primary); cursor: pointer; text-decoration: none; }
/* 运行卡 */
.run-card { border: 1px solid var(--border); }
.run-card.live { border-color: rgba(30, 111, 168, .45); box-shadow: 0 0 0 3px var(--primary-tint); }
.state-pills { display: flex; gap: 2px; background: var(--surface-2); border-radius: 999px; padding: 2px; }
.state-pill { font-size: 10.5px; color: var(--text-faint); padding: 3px 10px; border-radius: 999px; cursor: pointer; border: none; background: transparent; font-family: inherit; }
.state-pill.on { background: var(--surface); color: var(--text); box-shadow: var(--sh-sm); font-weight: 600; }
.run-body { padding: 14px 16px; }
.st { display: none; }
.run-card[data-state="idle"] .st-idle { display: block; }
.run-card[data-state="running"] .st-running { display: block; }
.run-card[data-state="done"] .st-done { display: block; }
.go-btn {
display: inline-flex; align-items: center; gap: 9px;
height: 40px; padding: 0 26px; border: none; border-radius: 10px;
background: var(--primary-strong); color: #fff; font: 600 13.5px/1 var(--font);
cursor: pointer; box-shadow: 0 6px 16px -8px rgba(23, 96, 143, .55);
transition: transform .12s ease, box-shadow .12s ease;
}
.go-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 20px -8px rgba(23, 96, 143, .6); }
.go-hint { font-size: 11px; color: var(--text-faint); margin-left: 12px; }
.prog-row { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; }
.prog-row .pct { font: 600 19px/1 var(--mono); letter-spacing: -.02em; }
.prog-row .track { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.prog-row .fill { width: 62%; height: 100%; border-radius: 999px; background: var(--primary); }
.live-b { font: 600 9.5px/1 var(--mono); letter-spacing: .08em; color: var(--ok); background: var(--ok-tint); padding: 3px 8px; border-radius: 999px; animation: pulse 1.6s ease infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.logs { background: var(--surface-2); border-radius: var(--r-ctl); padding: 9px 12px; font: 400 11.5px/1.8 var(--mono); max-height: 148px; overflow: auto; }
.lg { display: flex; gap: 10px; }
.lg .t { color: var(--text-faint); flex-shrink: 0; }
.lg .lv { font-weight: 600; width: 40px; flex-shrink: 0; }
.lv.i { color: var(--primary); }
.lv.w { color: var(--warn); }
.lg .m { color: var(--text); word-break: break-all; }
.done-banner { display: flex; align-items: flex-start; gap: 10px; padding: 11px 13px; border-radius: var(--r-ctl); background: var(--ok-tint); margin-bottom: 11px; }
.done-banner .ic { width: 20px; height: 20px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 700; flex-shrink: 0; }
.done-banner .db { flex: 1; }
.done-banner .db b { font-size: 12.5px; display: block; }
.done-banner .db span { font-size: 11.5px; color: var(--text-sub); }
.done-banner .again { border: 1px solid var(--border-strong); background: transparent; border-radius: var(--r-ctl); padding: 6px 13px; font: 500 12px/1 var(--font); color: var(--text-sub); cursor: pointer; }
.done-banner .again:hover { border-color: var(--primary); color: var(--primary); }
/* 场景内定时 */
.sched-inline { display: flex; align-items: center; gap: 10px; padding: 10px 0 2px; }
.sched-inline .si { flex: 1; display: flex; align-items: center; gap: 9px; font-size: 12px; }
.sched-inline .si b { font-weight: 600; }
.sched-inline .si span { color: var(--text-faint); font-size: 11.5px; }
.cron-chip { font: 500 10.5px/1 var(--mono); color: var(--primary); background: var(--primary-tint); border-radius: 6px; padding: 3px 7px; }
.switch { width: 30px; height: 17px; border-radius: 999px; background: var(--border-strong); position: relative; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: left .15s ease; }
.switch.on { background: var(--ok); }
.switch.on::after { left: 15px; }
.mini-btn { border: 1px solid var(--border-strong); background: transparent; color: var(--text-sub); border-radius: var(--r-ctl); padding: 5px 11px; font: 500 11.5px/1 var(--font); cursor: pointer; }
.mini-btn:hover { border-color: var(--primary); color: var(--primary); }
/* --- 总览 --- */
.ov-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 14px; }
.ov-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.ov-head .sub { margin: 3px 0 0; font-size: 12px; color: var(--text-faint); }
.kpis { display: flex; gap: 8px; }
.kpi { display: flex; align-items: baseline; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-ctl); padding: 7px 12px; }
.kpi b { font: 600 15px/1 var(--mono); }
.kpi b em { font-style: normal; font-size: 10.5px; color: var(--text-faint); font-weight: 500; }
.kpi span { font-size: 11px; color: var(--text-faint); }
.kpi.ok b { color: var(--ok); }
.queue { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.q-item { display: flex; align-items: center; gap: 11px; padding: 11px 14px; }
.q-when { text-align: center; flex-shrink: 0; width: 46px; }
.q-when b { display: block; font: 600 15px/1.1 var(--mono); }
.q-when span { font-size: 10px; color: var(--text-faint); }
.q-m { flex: 1; min-width: 0; }
.q-m b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-m span { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }
.ov-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ov-sc { display: flex; align-items: center; gap: 12px; padding: 13px 15px; cursor: pointer; font-family: inherit; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-card); box-shadow: var(--sh-sm); transition: border-color .13s ease, box-shadow .13s ease; }
.ov-sc:hover { border-color: var(--border-strong); box-shadow: var(--sh-md); }
.ov-sc .tile { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.ov-sc .m { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ov-sc .m b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-sc .m span { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-sc .meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.ov-sc .meta i { font-style: normal; font-size: 10px; color: var(--text-faint); font-family: var(--mono); }
.ov-sc .meta .st2 { font-size: 10px; }
.st2.ok { color: var(--ok); }
.st2.warn { color: var(--warn); }
.ov-sc .go { flex-shrink: 0; font-size: 11.5px; font-weight: 600; color: var(--primary); border: 1px solid var(--border-strong); border-radius: var(--r-ctl); padding: 5px 12px; transition: all .13s ease; }
.ov-sc:hover .go { background: var(--primary); border-color: var(--primary); color: #fff; }
/* --- 计划 --- */
.sched-list { display: flex; flex-direction: column; }
.sched-row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.sched-row:last-child { border-bottom: none; }
.sr-when { width: 108px; flex-shrink: 0; }
.sr-when b { display: block; font-size: 12.5px; }
.sr-when span { font-size: 10.5px; color: var(--text-faint); font-family: var(--mono); }
.sr-m { flex: 1; min-width: 0; }
.sr-m b { display: block; font-size: 13px; }
.sr-m span { font-size: 11px; color: var(--text-faint); }
.sr-last { width: 120px; flex-shrink: 0; font-size: 11px; color: var(--text-faint); }
.sr-acts { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.link-btn { border: none; background: none; font: 500 11.5px/1 var(--font); color: var(--primary); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.link-btn:hover { background: var(--primary-tint); }
.link-btn.danger { color: var(--err); }
.link-btn.danger:hover { background: var(--err-tint); }
/* ===== 右轨 · 活动轨 ===== */
.activity { background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: auto; padding: 12px; gap: 12px; min-height: 0; }
.act-sec { display: flex; flex-direction: column; }
.act-h { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 8px; }
.act-h h4 { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .07em; color: var(--text-faint); }
.act-h a { font-size: 10.5px; color: var(--primary); text-decoration: none; cursor: pointer; }
.act-item { display: flex; align-items: flex-start; gap: 9px; padding: 7px 8px; border-radius: var(--r-ctl); cursor: pointer; }
.act-item:hover { background: var(--surface-2); }
.act-item .aw { font: 500 10.5px/1.5 var(--mono); color: var(--text-faint); width: 62px; flex-shrink: 0; }
.act-item .aw b { display: block; color: var(--text); font-size: 11.5px; }
.act-item .am { flex: 1; min-width: 0; font-size: 11.5px; color: var(--text-sub); line-height: 1.45; }
.act-item .am b { color: var(--text); font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-item .am span { display: block; font-size: 10.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-item .am span.err { color: var(--err); }
.act-item .st3 { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.st3.ok { background: var(--ok-tint); color: var(--ok); }
.st3.err { background: var(--err-tint); color: var(--err); }
.st3.plan { background: var(--primary-tint); color: var(--primary); font-size: 8px; }
.plat-row { display: flex; align-items: center; gap: 9px; padding: 8px 8px; }
.plat-row + .plat-row { border-top: 1px dashed var(--border); }
.plat-row .pd { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.plat-row .pd.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-tint); }
.plat-row .pd.off { background: var(--border-strong); }
.plat-row .pm { flex: 1; min-width: 0; line-height: 1.3; }
.plat-row .pm b { font-size: 12px; display: block; }
.plat-row .pm span { font-size: 10.5px; color: var(--text-faint); }
.plat-row .pm span.ok2 { color: var(--ok); }
.ticket-card { border: 1px solid var(--border); border-radius: var(--r-card); padding: 11px 13px; background: var(--warn-tint); }
.ticket-card b { font-size: 12px; color: var(--warn); display: flex; align-items: center; gap: 6px; }
.ticket-card p { margin: 4px 0 8px; font-size: 10.5px; color: var(--text-sub); line-height: 1.55; }
.ticket-card .mini-btn { background: var(--surface); }
/* ---------- 状态栏 ---------- */
.statusbar { height: 26px; flex-shrink: 0; display: flex; align-items: center; gap: 16px; padding: 0 14px; font-size: 10.5px; color: var(--text-faint); background: var(--surface); border-top: 1px solid var(--border); }
.statusbar .si { display: inline-flex; align-items: center; gap: 5px; }
.statusbar i { width: 5px; height: 5px; border-radius: 50%; }
.statusbar i.on { background: var(--ok); }
.statusbar i.mid { background: var(--warn); }
.statusbar .sp { flex: 1; }
.statusbar .mono { font-family: var(--mono); }
/* ---------- IA 对照表 ---------- */
.mapping { max-width: 1280px; margin: 34px auto 56px; padding: 0 24px; }
.mapping h2 { font-size: 16px; margin: 0 0 12px; }
.map-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #E4E9F0; border-radius: 12px; overflow: hidden; font-size: 12.5px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
body.dark .map-table { background: #151A21; border-color: #27303D; }
.map-table th { text-align: left; font-size: 11px; letter-spacing: .05em; color: #7C8896; background: #F7F9FB; padding: 10px 14px; border-bottom: 1px solid #E4E9F0; }
body.dark .map-table th { background: #1B222B; border-color: #27303D; color: #6E7C8C; }
.map-table td { padding: 10px 14px; border-bottom: 1px solid #EFF2F6; color: #3D4854; vertical-align: top; }
body.dark .map-table td { border-color: #222B37; color: #C6D0DC; }
.map-table tr:last-child td { border-bottom: none; }
.map-table td:first-child { font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
.map-table td.moved { color: #1E6FA8; font-weight: 600; }
body.dark .map-table td.moved { color: #5FA9DE; }
.map-table td.cut { color: #B3403E; }
body.dark .map-table td.cut { color: #E5726F; }
</style>
</head>
<body>
<div class="intro">
<div>
<h1>基于数据的重排版 v2 <small>· Run-centric Console</small></h1>
<p>原子实体是「运行」:场景=模板 · 定时=触发器 · 平台会话=前置条件 · 日志/进度/结果=过程与产物。左轨选场景,中央看上下文,右轨看活动流 —— 点左侧导航或场景可切换视图</p>
</div>
<button class="theme-toggle" onclick="document.body.classList.toggle('dark');document.querySelector('.frame').dataset.theme=document.body.classList.contains('dark')?'dark':'light'">◐ 深 / 浅主题</button>
</div>
<div class="stage">
<div class="frame" data-theme="light">
<div class="titlebar">
<span class="mark">37</span><span class="tname">自动化工作台</span><span class="tver">v2.3.1</span>
<span class="tsp"></span>
<div class="win-ctl"><span>—</span><span>▢</span><span class="close">✕</span></div>
</div>
<div class="shell">
<!-- ============ 左轨:场景轨 ============ -->
<aside class="rail">
<div class="me" title="个人中心">
<span class="ava">张</span>
<span class="mm"><b>张三</b><span>人力资源部 · zhangsan</span></span>
<span class="ticket">票 5天</span>
</div>
<div class="nav">
<div class="nv" data-view="overview" onclick="switchView('overview')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><rect x="3" y="3" width="8" height="8" rx="2"/><rect x="13" y="3" width="8" height="8" rx="2"/><rect x="3" y="13" width="8" height="8" rx="2"/><rect x="13" y="13" width="8" height="8" rx="2"/></svg>
<span>总览</span>
</div>
<div class="nv" data-view="sched" onclick="switchView('sched')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg>
<span>计划</span>
<span class="bdg">3</span>
</div>
</div>
<div class="rail-head"><span>场景库</span><span class="cnt">6</span></div>
<div class="scenes">
<div class="sc-rail active" onclick="switchView('run')"><span class="tile t-sky">考</span><span class="nm">考勤月报封存检查</span><span class="dep on"></span></div>
<div class="sc-rail" onclick="switchView('run')"><span class="tile t-honey">假</span><span class="nm">请假单批量补录</span><span class="dep off"></span></div>
<div class="sc-rail" onclick="switchView('run')"><span class="tile t-mint">周</span><span class="nm">周报数据汇总</span><span class="dep on"></span></div>
<div class="sc-rail" onclick="switchView('run')"><span class="tile t-blush">邮</span><span class="nm">邮件定时巡检</span><span class="dep on"></span></div>
<div class="sc-rail" onclick="switchView('run')"><span class="tile t-sky">薪</span><span class="nm">薪酬条分发</span><span class="dep off"></span></div>
<div class="sc-rail" onclick="switchView('run')"><span class="tile t-mint">档</span><span class="nm">档案归档巡检</span><span class="dep on"></span></div>
</div>
<div class="rail-foot"><span>壳子 v2.3.1</span><a>检查更新</a></div>
</aside>
<!-- ============ 中央:上下文区 ============ -->
<main class="center">
<!-- ▍执行台:选中场景后,参数/运行/日志/定时 全部围绕这一次执行组织 -->
<section class="view on" id="view-run">
<div class="run-head">
<span class="big-tile t-sky">考</span>
<div class="rh-m">
<h2>考勤月报封存检查 <span class="chip">v1.4.0</span> <span class="chip ok">OA · 已登录</span> <span class="chip warn">装浏览器</span></h2>
<p>抓取当月 OA 考勤原始表,校验异常打卡并生成封存报表回传中心机</p>
</div>
<div class="rh-actions">
<button class="mini-btn">插件详情</button>
</div>
</div>
<!-- 参数卡:fields[] 数据驱动 · 恢复上次值(新增可负担性) -->
<div class="card">
<div class="card-h">
<h3>执行参数</h3>
<span class="ops">3 项 · 全部必填已就绪</span>
</div>
<div class="card-b">
<div class="fields">
<div class="field">
<label>报表月份 <em>uses_month</em></label>
<div class="ctl"><span>2025-11</span><span class="arr">▾</span></div>
</div>
<div class="field">
<label>失败重试次数 <em>int</em></label>
<div class="ctl"><span>2</span></div>
</div>
<div class="field">
<label>异常通知邮箱 <em>text</em></label>
<div class="ctl"><span style="color:var(--text-faint)">zhangsan@37du.cn</span></div>
</div>
</div>
<div class="restored">↺ 已恢复上次执行参数(11 日 14:02) · <a>恢复默认</a></div>
</div>
</div>
<!-- 运行卡:待执行 / 执行中 / 已完成 三态切换(右上角示意按钮) -->
<div class="card run-card live" id="run-card" data-state="running">
<div class="card-h">
<h3>运行</h3>
<div class="state-pills" onclick="event.stopPropagation()">
<button class="state-pill" data-s="idle" onclick="setRun('idle')">待执行</button>
<button class="state-pill on" data-s="running" onclick="setRun('running')">执行中</button>
<button class="state-pill" data-s="done" onclick="setRun('done')">已完成</button>
</div>
</div>
<div class="run-body">
<!-- 待执行 -->
<div class="st st-idle">
<button class="go-btn">▶ 一键执行</button>
<span class="go-hint">使用本机 Chrome 会话执行 · 日志实时显示在此卡片,不再占用全局底栏</span>
</div>
<!-- 执行中 -->
<div class="st st-running">
<div class="prog-row">
<span class="pct">62%</span>
<div class="track"><div class="fill"></div></div>
<span class="live-b">● LIVE</span>
<span class="chip">run_8f3a</span>
</div>
<div class="logs">
<div class="lg"><span class="t">14:02:01</span><span class="lv i">INFO</span><span class="m">启动 Chrome 会话,加载 OA 首页</span></div>
<div class="lg"><span class="t">14:02:07</span><span class="lv i">INFO</span><span class="m">登录态校验通过(cookie 有效)</span></div>
<div class="lg"><span class="t">14:02:09</span><span class="lv i">INFO</span><span class="m">进入 考勤月报 → 2025-11,开始抓取表格</span></div>
<div class="lg"><span class="t">14:02:24</span><span class="lv w">WARN</span><span class="m">抓取到 2 行异常打卡,已标记待人工复核</span></div>
<div class="lg"><span class="t">14:02:31</span><span class="lv i">INFO</span><span class="m">正在生成封存 ZIP 并回传中心机…</span></div>
</div>
</div>
<!-- 已完成 -->
<div class="st st-done">
<div class="done-banner">
<span class="ic">✓</span>
<div class="db">
<b>执行完成 · 耗时 31s</b>
<span>报表已封存并回传中心机 · 2 行异常打卡待人工复核</span>
</div>
<button class="again">↻ 再次执行</button>
</div>
<div class="logs">
<div class="lg"><span class="t">14:02:31</span><span class="lv i">INFO</span><span class="m">报表封存完成,已生成 ZIP 并回传中心机</span></div>
<div class="lg"><span class="t">14:02:32</span><span class="lv i">INFO</span><span class="m">===== 执行完成 =====(耗时 31s)</span></div>
</div>
</div>
</div>
</div>
<!-- 该场景绑定的定时(schedule 数据本来就是 per-plugin 的) -->
<div class="card">
<div class="card-h">
<h3>定时触发</h3>
<button class="mini-btn">+ 新建定时</button>
</div>
<div class="card-b">
<div class="sched-inline">
<span class="si"><b>每个工作日 08:00</b><span>下次 明天 08:00 · 上次 今天 08:00 成功</span><span class="cron-chip">0 8 * * 1-5</span></span>
<span class="switch on"></span>
</div>
</div>
</div>
</section>
<!-- ▍总览:原首页溶解为 KPI 行 + 队列条 + 场景网格 -->
<section class="view" id="view-overview">
<div class="ov-head">
<div>
<h2>早上好,张三</h2>
<p class="sub">2025年12月11日 星期四 · 昨日自动执行 12 次,全部成功</p>
</div>
<div class="kpis">
<div class="kpi"><b>6</b><span>场景</span></div>
<div class="kpi"><b>3</b><span>计划</span></div>
<div class="kpi"><b>2<em>/2</em></b><span>平台在线</span></div>
<div class="kpi ok"><b>✓ 14:02</b><span>上次执行</span></div>
</div>
</div>
<div class="sec-h" style="font-size:12.5px;font-weight:700;margin-bottom:9px">接下来自动执行</div>
<div class="queue">
<div class="card q-item">
<span class="q-when"><b>08:00</b><span>明天</span></span>
<span class="q-m"><b>考勤月报封存检查</b><span>0 8 * * 1-5 · 工作日</span></span>
<span class="chip ok">OA ✓</span>
</div>
<div class="card q-item">
<span class="q-when"><b>18:00</b><span>周五</span></span>
<span class="q-m"><b>周报数据汇总</b><span>0 18 * * 5 · 每周五</span></span>
<span class="chip ok">OA ✓</span>
</div>
</div>
<div class="sec-h" style="font-size:12.5px;font-weight:700;margin:0 0 9px">全部场景</div>
<div class="ov-grid">
<button class="ov-sc" onclick="switchView('run')">
<span class="tile t-sky">考</span>
<span class="m"><b>考勤月报封存检查</b><span>抓取当月考勤原始表并封存</span>
<span class="meta"><i>v1.4.0</i><span class="st2 ok">OA 已登录</span><span class="st2" style="color:var(--text-faint)">· 定时 1</span></span></span>
<span class="go">执行</span>
</button>
<button class="ov-sc" onclick="switchView('run')">
<span class="tile t-honey">假</span>
<span class="m"><b>请假单批量补录</b><span>按名单批量补录历史请假单</span>
<span class="meta"><i>v0.9.2</i><span class="st2 warn">HR 未登录</span></span></span>
<span class="go">执行</span>
</button>
<button class="ov-sc" onclick="switchView('run')">
<span class="tile t-mint">周</span>
<span class="m"><b>周报数据汇总</b><span>拉取各部门周报生成汇总快照</span>
<span class="meta"><i>v2.1.0</i><span class="st2 ok">OA 已登录</span><span class="st2" style="color:var(--text-faint)">· 定时 1</span></span></span>
<span class="go">执行</span>
</button>
<button class="ov-sc" onclick="switchView('run')">
<span class="tile t-blush">邮</span>
<span class="m"><b>邮件定时巡检</b><span>巡检公共邮箱未读工单</span>
<span class="meta"><i>v1.0.3</i><span class="st2 ok">MAIL 已登录</span></span></span>
<span class="go">执行</span>
</button>
<button class="ov-sc" onclick="switchView('run')">
<span class="tile t-sky">薪</span>
<span class="m"><b>薪酬条分发</b><span>按月生成薪酬条并站内分发</span>
<span class="meta"><i>v1.2.7</i><span class="st2 warn">HR 未登录</span></span></span>
<span class="go">执行</span>
</button>
<button class="ov-sc" onclick="switchView('run')">
<span class="tile t-mint">档</span>
<span class="m"><b>档案归档巡检</b><span>巡检档案库完整性并归档</span>
<span class="meta"><i>v0.6.1</i><span class="st2 ok">OA 已登录</span></span></span>
<span class="go">执行</span>
</button>
</div>
</section>
<!-- ▍计划:schedules 从 CRUD 表格变成时间队列 -->
<section class="view" id="view-sched">
<div class="ov-head">
<div>
<h2>计划</h2>
<p class="sub">按下次执行时间排序 · 配置自动备份到中心机</p>
</div>
<button class="mini-btn" style="height:32px;padding:0 15px">+ 新建任务</button>
</div>
<div class="card sched-list">
<div class="sched-row">
<span class="sr-when"><b>明天 08:00</b><span>12-12 周五</span></span>
<span class="sr-m"><b>考勤月报封存检查</b><span>工作日触发 · 参数:2025-11 · 重试 2 次</span></span>
<span class="cron-chip">0 8 * * 1-5</span>
<span class="sr-last">上次 今天 08:00<br>✓ 成功 31s</span>
<span class="sr-acts"><span class="switch on"></span><button class="link-btn">编辑</button><button class="link-btn danger">删除</button></span>
</div>
<div class="sched-row">
<span class="sr-when"><b>周五 18:00</b><span>12-12 周五</span></span>
<span class="sr-m"><b>周报数据汇总</b><span>每周触发 · 全部默认参数</span></span>
<span class="cron-chip">0 18 * * 5</span>
<span class="sr-last">上次 12-05 18:00<br>✓ 成功 12s</span>
<span class="sr-acts"><span class="switch on"></span><button class="link-btn">编辑</button><button class="link-btn danger">删除</button></span>
</div>
<div class="sched-row">
<span class="sr-when"><b>12-01 09:00</b><span>已过期</span></span>
<span class="sr-m"><b>档案归档巡检</b><span>每月 1 日触发 · 已停用</span></span>
<span class="cron-chip">0 9 1 * *</span>
<span class="sr-last">上次 12-01 09:00<br>✓ 成功 8s</span>
<span class="sr-acts"><span class="switch"></span><button class="link-btn">编辑</button><button class="link-btn danger">删除</button></span>
</div>
</div>
</section>
</main>
<!-- ============ 右轨:活动轨(三处散落数据合并成一条流) ============ -->
<aside class="activity">
<div class="act-sec">
<div class="act-h"><h4>接下来自动执行</h4><a onclick="switchView('sched')">全部</a></div>
<div class="act-item" onclick="switchView('sched')">
<span class="st3 plan">⏰</span>
<span class="am"><b>考勤月报封存检查</b><span>明天 08:00 · 工作日</span></span>
</div>
<div class="act-item" onclick="switchView('sched')">
<span class="st3 plan">⏰</span>
<span class="am"><b>周报数据汇总</b><span>周五 18:00 · 每周</span></span>
</div>
</div>
<div class="act-sec">
<div class="act-h"><h4>最近运行</h4></div>
<div class="act-item" onclick="switchView('run')">
<span class="st3 ok">✓</span>
<span class="am"><b>考勤月报封存检查</b><span>14:02 · 31s · 手动</span></span>
</div>
<div class="act-item" onclick="switchView('run')">
<span class="st3 ok">✓</span>
<span class="am"><b>周报数据汇总</b><span>09:31 · 12s · 定时</span></span>
</div>
<div class="act-item" onclick="switchView('run')">
<span class="st3 err">✕</span>
<span class="am"><b>请假单批量补录</b><span class="err">09:12 · HR 会话过期</span></span>
</div>
</div>
<div class="act-sec">
<div class="act-h"><h4>平台会话</h4><a>配置账号</a></div>
<div class="plat-row">
<span class="pd on"></span>
<span class="pm"><b>OA 办公系统</b><span class="ok2">已登录 · zhangsan</span></span>
<button class="mini-btn">登出</button>
</div>
<div class="plat-row">
<span class="pd off"></span>
<span class="pm"><b>HR 人事系统</b><span>未登录 · 未配置个人账号</span></span>
<button class="mini-btn">登录</button>
</div>
</div>
<div class="act-sec" style="margin-top:auto">
<div class="ticket-card">
<b>⚠ 授权票据剩余 5 天</b>
<p>最长允许离线 7 天,到期前联网刷新即可,不影响本地已装场景。</p>
<button class="mini-btn">立即刷新</button>
</div>
</div>
</aside>
</div>
<div class="statusbar">
<span class="si"><i class="on"></i>服务已连接</span>
<span class="si"><i class="on"></i>Chrome 131</span>
<span class="si"><i class="mid"></i>插件同步 2 分钟前</span>
<span class="sp"></span>
<span class="mono">127.0.0.1:8765</span>
<span class="mono">WS 正常</span>
</div>
</div>
</div>
<!-- ---------- 数据 → 界面 归属对照 ---------- -->
<div class="mapping">
<h2>数据 → 界面归属对照(重排了什么,为什么)</h2>
<table class="map-table">
<tr><th>数据(接口字段)</th><th>现在的位置</th><th>新家</th><th>理由</th></tr>
<tr>
<td>run / progress / logs</td>
<td>topbar 进度条 + 执行按钮环 + 全局底栏日志(三处)</td>
<td class="moved">执行台·运行卡(日志内联,三态一体)</td>
<td>日志是「这次运行」的属性,跟着运行走;完成后同卡片展示结果与摘要</td>
</tr>
<tr>
<td>schedules + next_run_at</td>
<td>独立的定时任务页(CRUD 表格)</td>
<td class="moved">计划视图(按时间排序的队列)+ 场景执行台内联「定时触发」</td>
<td>next_run_at 本来就有,但现状没有「接下来发生什么」的时间感;同时定时数据绑定插件,就地可见</td>
</tr>
<tr>
<td>platforms + online</td>
<td>首页卡片区 + 个人中心抽屉(两处重复)</td>
<td class="moved">右轨·平台会话(唯一入口)+ 场景头的依赖芯片</td>
<td>它是运行的前置条件,应该常驻可见、一键登录,而不是藏在两个地方</td>
</tr>
<tr>
<td>recents(最近 8 次)</td>
<td>首页底部摘要条</td>
<td class="moved">右轨·最近运行(点击回放 → 执行台)</td>
<td>run_id 与 getRun 都在,点击可回放日志,把摘要升级成入口</td>
</tr>
<tr>
<td>fields[](插件参数)</td>
<td>插件页平铺表单,每次进入重置默认值</td>
<td class="moved">执行台·参数卡 + 「恢复上次参数」</td>
<td>新增可负担性:上次值本地持久化,重复执行不再逐项重填</td>
</tr>
<tr>
<td>首页(问候/统计卡)</td>
<td>独立 home 视图</td>
<td class="cut">溶解:KPI 行并入总览头部</td>
<td>统计数字全部可由其余视图直接得出,独立页面信息密度过低</td>
</tr>
<tr>
<td>WS/Chrome/更新/授权状态</td>
<td>topbar 芯片堆 + 全局提示条(3-4 处)</td>
<td class="cut">收敛:状态栏 + 右轨票据卡 + 更新横幅(低频事件)</td>
<td>常驻态进状态栏,异常态才升级为横幅/卡片,topbar 不再堆芯片</td>
</tr>
<tr>
<td>authExpired / 票据</td>
<td>顶部橙色横幅(挤占布局)</td>
<td class="moved">右轨·授权票据卡(剩余天数 + 刷新)</td>
<td>7 天倒计时是持续性状态,横幅只该在临期/过期时出现</td>
</tr>
</table>
</div>
<script>
function switchView(v) {
document.querySelectorAll('.view').forEach(el => el.classList.toggle('on', el.id === 'view-' + v))
document.querySelectorAll('.nv').forEach(el => el.classList.toggle('active', el.dataset.view === v))
document.querySelectorAll('.sc-rail').forEach(el => el.classList.toggle('active', v === 'run'))
document.querySelector('.center').scrollTop = 0
}
function setRun(s) {
const card = document.getElementById('run-card')
card.dataset.state = s
card.classList.toggle('live', s === 'running')
document.querySelectorAll('.state-pill').forEach(el => el.classList.toggle('on', el.dataset.s === s))
}
</script>
</body>
</html>
@@ -0,0 +1,603 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>37du 壳子前端 · 重设计提案(Soft Precision)</title>
<style>
/* ============================================================
提案稿 · Soft Precision(精密工作台 × 克制的奶油残留)
单文件自包含 · 双主题 · 仅供设计评审
============================================================ */
:root {
/* 中性色(冷灰,替代奶油底) */
--canvas: #F4F6F9;
--surface: #FFFFFF;
--surface-2: #F1F4F8;
--surface-3: #E9EDF3;
--border: #E4E9F0;
--border-strong: #CDD6E1;
--text: #182230;
--text-sub: #5A6674;
--text-faint: #7C8896;
/* 主色:保留天蓝家族,但压深到 AA 可读 */
--primary: #1E6FA8;
--primary-strong: #17608F;
--primary-tint: #E9F2FA;
--primary-ring: rgba(30, 111, 168, .16);
/* 语义色:可读优先 */
--ok: #1F8A4C; --ok-tint: #E7F5EC;
--err: #D64545; --err-tint: #FBEBEB;
--warn: #B26B00; --warn-tint: #FBF3E0;
/* 结构 */
--r-frame: 14px; --r-card: 12px; --r-ctl: 8px;
--sh-sm: 0 1px 2px rgba(15, 23, 42, .05);
--sh-md: 0 8px 24px -12px rgba(15, 23, 42, .14);
--font: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
--mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}
.frame[data-theme="dark"] {
--canvas: #0E1116;
--surface: #151A21;
--surface-2: #1B222B;
--surface-3: #222B37;
--border: #27303D;
--border-strong: #39465A;
--text: #E8EDF4;
--text-sub: #9AA7B5;
--text-faint: #6E7C8C;
--primary: #3E93CF;
--primary-strong: #5FA9DE;
--primary-tint: #14304A;
--primary-ring: rgba(94, 169, 222, .22);
--ok: #4CC38A; --ok-tint: #12291C;
--err: #E5726F; --err-tint: #2E1717;
--warn: #DFA63E; --warn-tint: #2D2312;
--sh-sm: 0 1px 2px rgba(0, 0, 0, .3);
--sh-md: 0 10px 28px -14px rgba(0, 0, 0, .55);
}
* { box-sizing: border-box; }
body {
margin: 0; background: #E9ECF1; color: #182230;
font-family: var(--font); font-size: 14px; line-height: 1.6;
-webkit-font-smoothing: antialiased;
}
.dark body, body.dark { background: #0B0E12; color: #E8EDF4; }
/* ---------- 顶部说明条 ---------- */
.intro {
max-width: 1240px; margin: 0 auto; padding: 28px 24px 8px;
display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
}
.intro h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .01em; }
.intro p { margin: 4px 0 0; font-size: 12.5px; color: #5A6674; }
body.dark .intro p { color: #9AA7B5; }
.theme-toggle {
border: 1px solid #CDD6E1; background: #fff; color: #182230;
border-radius: 999px; padding: 7px 16px; font-size: 13px; cursor: pointer;
font-family: inherit; transition: all .15s ease; white-space: nowrap;
}
.theme-toggle:hover { border-color: #1E6FA8; color: #1E6FA8; }
body.dark .theme-toggle { background: #1B222B; border-color: #39465A; color: #E8EDF4; }
body.dark .theme-toggle:hover { border-color: #3E93CF; color: #3E93CF; }
/* ---------- 应用框架 ---------- */
.stage { max-width: 1240px; margin: 20px auto 0; padding: 0 24px; }
.frame {
border-radius: var(--r-frame);
background: var(--canvas);
border: 1px solid var(--border);
box-shadow: var(--sh-md);
overflow: hidden;
display: flex; flex-direction: column;
height: 780px;
transition: background .2s ease, border-color .2s ease;
}
/* 标题栏(提案:frameless 自绘,替换系统标题栏 + 页内 topbar 的双层结构) */
.titlebar {
height: 40px; flex-shrink: 0;
display: flex; align-items: center; gap: 10px;
padding: 0 0 0 14px;
background: var(--surface);
border-bottom: 1px solid var(--border);
-webkit-app-region: drag;
}
.titlebar .mark {
width: 20px; height: 20px; border-radius: 6px;
display: grid; place-items: center;
background: var(--primary); color: #fff;
font: 700 9px/1 var(--mono); letter-spacing: .02em;
}
.titlebar .tname { font-size: 12.5px; font-weight: 600; }
.titlebar .tver {
font: 500 10.5px/1 var(--mono); color: var(--text-faint);
border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px;
}
.titlebar .tsp { flex: 1; }
.win-ctl { display: flex; height: 100%; -webkit-app-region: no-drag; }
.win-ctl span {
width: 44px; display: grid; place-items: center;
color: var(--text-faint); font-size: 11px; cursor: default;
}
.win-ctl span:hover { background: var(--surface-2); }
.win-ctl span.close:hover { background: var(--err); color: #fff; }
/* 主体三栏 */
.shell { flex: 1; display: flex; min-height: 0; }
/* 左侧导航轨 */
.rail {
width: 212px; flex-shrink: 0;
background: var(--surface);
border-right: 1px solid var(--border);
display: flex; flex-direction: column;
padding: 12px 10px;
}
.nav-sec { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.nav-item {
display: flex; align-items: center; gap: 10px;
height: 34px; padding: 0 10px; border-radius: var(--r-ctl);
font-size: 13px; color: var(--text-sub); cursor: pointer;
position: relative; transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-tint); color: var(--primary); font-weight: 600; }
.nav-item.active::before {
content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px;
width: 3px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-item .nv-badge {
margin-left: auto; font: 500 10.5px/1 var(--mono);
color: var(--text-faint); background: var(--surface-2);
border-radius: 999px; padding: 2px 7px;
}
.nav-item.active .nv-badge { background: transparent; color: var(--primary); }
.rail-head {
display: flex; align-items: center; justify-content: space-between;
padding: 0 10px 8px;
font-size: 11px; font-weight: 700; letter-spacing: .06em;
color: var(--text-faint);
}
.rail-head .cnt { font: 500 10.5px/1 var(--mono); background: var(--surface-2); border-radius: 999px; padding: 2px 7px; }
.scene-nav { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 1px; }
.sn-item {
display: flex; align-items: center; gap: 9px;
height: 34px; padding: 0 10px; border-radius: var(--r-ctl);
cursor: pointer; transition: background .12s ease;
}
.sn-item:hover { background: var(--surface-2); }
.sn-item.active { background: var(--primary-tint); }
.sn-item.active .sn-name { color: var(--primary); font-weight: 600; }
.sn-dot { width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; }
.sn-dot.c1 { background: var(--primary-tint); color: var(--primary); }
.sn-dot.c2 { background: var(--warn-tint); color: var(--warn); }
.sn-dot.c3 { background: var(--ok-tint); color: var(--ok); }
.sn-dot.c4 { background: var(--err-tint); color: var(--err); }
.sn-name { flex: 1; font-size: 12.5px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sn-item.active .sn-name { color: var(--primary); }
.sn-ver { font: 400 10px/1 var(--mono); color: var(--text-faint); }
.rail-foot {
border-top: 1px solid var(--border);
padding: 10px 10px 2px; margin-top: 8px;
display: flex; align-items: center; justify-content: space-between;
font-size: 11px; color: var(--text-faint);
}
.rail-foot a { color: var(--primary); text-decoration: none; font-size: 11px; cursor: pointer; }
/* 内容区 */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page { flex: 1; min-height: 0; overflow: auto; padding: 22px 26px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: .01em; }
.page-head .sub { margin: 4px 0 0; font-size: 12.5px; color: var(--text-faint); }
.conn-pill {
display: inline-flex; align-items: center; gap: 7px;
font-size: 11.5px; color: var(--ok);
background: var(--ok-tint); border: 1px solid transparent;
padding: 5px 12px; border-radius: 999px; font-weight: 500;
}
.conn-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
/* 统计行 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat {
background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
padding: 14px 16px; box-shadow: var(--sh-sm);
display: flex; align-items: center; gap: 12px;
}
.st-ic {
width: 34px; height: 34px; border-radius: var(--r-ctl); flex-shrink: 0;
display: grid; place-items: center;
}
.st-ic svg { width: 16px; height: 16px; }
.st-ic.sky { background: var(--primary-tint); color: var(--primary); }
.st-ic.ok { background: var(--ok-tint); color: var(--ok); }
.st-ic.warn { background: var(--warn-tint); color: var(--warn); }
.st-ic.err { background: var(--err-tint); color: var(--err); }
.st-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.st-meta b { font: 600 20px/1.1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.st-meta b em { font-style: normal; font-size: 12px; color: var(--text-faint); font-weight: 500; }
.st-meta span { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 分节 */
.sec { margin-bottom: 20px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sec-head h3 { margin: 0; font-size: 13px; font-weight: 700; color: var(--text); }
.sec-head .more { font-size: 12px; color: var(--primary); cursor: pointer; }
.sec-head .note { font-size: 11.5px; color: var(--text-faint); }
/* 场景卡 */
.scenes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.sc {
background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
box-shadow: var(--sh-sm);
padding: 14px 16px; display: flex; align-items: center; gap: 13px;
cursor: pointer; transition: border-color .13s ease, box-shadow .13s ease;
font-family: inherit; text-align: left;
}
.sc:hover { border-color: var(--border-strong); box-shadow: var(--sh-md); }
.sc-ic { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.sc-ic.c1 { background: var(--primary-tint); color: var(--primary); }
.sc-ic.c2 { background: var(--warn-tint); color: var(--warn); }
.sc-ic.c3 { background: var(--ok-tint); color: var(--ok); }
.sc-ic.c4 { background: var(--err-tint); color: var(--err); }
.sc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sc-body b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-desc { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-meta { font-size: 10.5px; color: var(--text-faint); display: flex; align-items: center; gap: 7px; }
.sc-meta .ver { font-family: var(--mono); }
.sc-meta .plat { color: var(--ok); }
.sc-meta .plat.off { color: var(--warn); }
.sc-run {
flex-shrink: 0; font-size: 12px; font-weight: 600;
color: var(--primary); border: 1px solid var(--border-strong);
background: var(--surface); border-radius: var(--r-ctl);
padding: 6px 14px; transition: all .13s ease;
}
.sc:hover .sc-run { background: var(--primary); border-color: var(--primary); color: #fff; }
/* 最近运行 */
.recent { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--sh-sm); padding: 4px 6px; }
.rec {
display: flex; align-items: center; gap: 11px; width: 100%;
padding: 9px 10px; border: none; background: transparent; border-radius: var(--r-ctl);
font-family: inherit; cursor: pointer; text-align: left;
}
.rec:hover { background: var(--surface-2); }
.rec-ic { width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 10px; font-weight: 700; }
.rec-ic.ok { background: var(--ok-tint); color: var(--ok); }
.rec-ic.err { background: var(--err-tint); color: var(--err); }
.rec-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.rec-msg { flex: 1; font-size: 12px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-msg.err { color: var(--err); }
.rec-time { font: 400 11px/1 var(--mono); color: var(--text-faint); }
/* 底部日志抽屉(可折叠,替代常驻 230px) */
.logdock {
flex-shrink: 0; background: var(--surface);
border-top: 1px solid var(--border);
display: flex; flex-direction: column;
}
.logdock-head {
height: 38px; display: flex; align-items: center; gap: 10px;
padding: 0 12px 0 16px; cursor: pointer;
}
.logdock-head .lt { font-size: 12.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.live {
font: 600 9.5px/1 var(--mono); letter-spacing: .08em;
color: var(--ok); background: var(--ok-tint);
padding: 3px 8px; border-radius: 999px;
}
.lv-tabs { display: flex; gap: 2px; margin-left: 8px; }
.lv-tab {
font-size: 11px; color: var(--text-faint); padding: 4px 10px;
border-radius: 999px; cursor: pointer; border: 1px solid transparent;
}
.lv-tab.on { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.lv-tab:hover { color: var(--text); }
.logdock-head .sp { flex: 1; }
.logdock-head .tool { font-size: 11.5px; color: var(--text-faint); cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.logdock-head .tool:hover { background: var(--surface-2); color: var(--text); }
.chev { transition: transform .18s ease; color: var(--text-faint); }
.logdock.collapsed .chev { transform: rotate(180deg); }
.logdock.collapsed .logdock-body { display: none; }
.logdock-body {
height: 150px; overflow: auto; padding: 2px 16px 12px;
font: 400 12px/1.85 var(--mono);
}
.logline { display: flex; gap: 12px; }
.logline .t { color: var(--text-faint); flex-shrink: 0; }
.logline .lv { font-weight: 600; flex-shrink: 0; width: 46px; }
.logline .lv.i { color: var(--primary); }
.logline .lv.w { color: var(--warn); }
.logline .lv.e { color: var(--err); }
.logline .m { color: var(--text); word-break: break-all; }
.logline.hl { background: var(--surface-2); border-radius: 6px; }
.logline.hl .m { color: var(--ok); font-weight: 600; }
/* 状态栏 */
.statusbar {
height: 28px; flex-shrink: 0;
display: flex; align-items: center; gap: 18px;
padding: 0 16px; font-size: 11px; color: var(--text-faint);
background: var(--surface); border-top: 1px solid var(--border);
}
.statusbar .si { display: inline-flex; align-items: center; gap: 6px; }
.statusbar i { width: 6px; height: 6px; border-radius: 50%; }
.statusbar i.on { background: var(--ok); }
.statusbar i.mid { background: var(--warn); }
.statusbar .sp { flex: 1; }
.statusbar .mono { font-family: var(--mono); }
/* ---------- Tokens 图鉴 ---------- */
.tokens { max-width: 1240px; margin: 40px auto 60px; padding: 0 24px; }
.tokens h2 { font-size: 16px; margin: 0 0 14px; }
.tok-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tok-card { background: #fff; border: 1px solid #E4E9F0; border-radius: 12px; padding: 18px 20px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.tok-card h4 { margin: 0 0 12px; font-size: 12px; letter-spacing: .06em; color: #7C8896; text-transform: uppercase; }
body.dark .tok-card { background: #151A21; border-color: #27303D; }
body.dark .tok-card h4 { color: #6E7C8C; }
.swatches { display: flex; flex-direction: column; gap: 6px; }
.sw-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.sw { width: 44px; height: 26px; border-radius: 6px; border: 1px solid rgba(15,23,42,.08); flex-shrink: 0; }
.sw-name { width: 130px; color: #5A6674; font-family: var(--mono); font-size: 11.5px; }
body.dark .sw-name { color: #9AA7B5; }
.sw-note { color: #7C8896; font-size: 11.5px; }
.type-row { display: flex; align-items: baseline; gap: 14px; padding: 7px 0; border-bottom: 1px dashed #E4E9F0; }
body.dark .type-row { border-color: #27303D; }
.type-row:last-child { border-bottom: none; }
.type-tag { width: 92px; flex-shrink: 0; font: 500 11px/1 var(--mono); color: #7C8896; }
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; font-size: 12.5px; }
.vs .col { border-radius: 10px; padding: 14px 16px; }
.vs .old { background: #FBF9F4; border: 1px dashed #E0D9C9; }
.vs .new { background: #F4F8FB; border: 1px solid #CBE0EF; }
.vs h5 { margin: 0 0 8px; font-size: 12px; }
.vs .old h5 { color: #9C9589; }
.vs .new h5 { color: #1E6FA8; }
.vs ul { margin: 0; padding-left: 16px; color: #5A6674; display: flex; flex-direction: column; gap: 4px; }
.foot-note { max-width: 1240px; margin: 0 auto 40px; padding: 0 24px; font-size: 11.5px; color: #7C8896; text-align: center; }
</style>
</head>
<body>
<div class="intro">
<div>
<h1>37du 壳子前端 · 重设计提案 <span style="color:#7C8896;font-weight:500;font-size:13px">Soft Precision</span></h1>
<p>精密工作台的秩序 × 天蓝品牌延续 × 奶油感收束为点缀 —— 右上角可切换深浅主题预览</p>
</div>
<button class="theme-toggle" onclick="document.body.classList.toggle('dark');document.querySelectorAll('.frame').forEach(f=>f.dataset.theme=document.body.classList.contains('dark')?'dark':'light')">◐ 切换深 / 浅主题</button>
</div>
<div class="stage">
<div class="frame" data-theme="light">
<!-- 标题栏:替代「系统标题栏 + 页内 topbar」双层 -->
<div class="titlebar">
<span class="mark">37</span>
<span class="tname">自动化工作台</span>
<span class="tver">v2.3.1</span>
<span class="tsp"></span>
<div class="win-ctl"><span>—</span><span>▢</span><span class="close">✕</span></div>
</div>
<div class="shell">
<!-- 左轨:主导航 + 场景库 -->
<aside class="rail">
<div class="nav-sec">
<div class="nav-item active">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/></svg>
<span>工作台</span>
</div>
<div class="nav-item">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg>
<span>定时任务</span>
<span class="nv-badge">3</span>
</div>
</div>
<div class="rail-head"><span>场景库</span><span class="cnt">6</span></div>
<div class="scene-nav">
<div class="sn-item active"><span class="sn-dot c1">考</span><span class="sn-name">考勤月报封存检查</span><span class="sn-ver">1.4.0</span></div>
<div class="sn-item"><span class="sn-dot c2">假</span><span class="sn-name">请假单批量补录</span><span class="sn-ver">0.9.2</span></div>
<div class="sn-item"><span class="sn-dot c3">周</span><span class="sn-name">周报数据汇总</span><span class="sn-ver">2.1.0</span></div>
<div class="sn-item"><span class="sn-dot c4">邮</span><span class="sn-name">邮件定时巡检</span><span class="sn-ver">1.0.3</span></div>
<div class="sn-item"><span class="sn-dot c1">薪</span><span class="sn-name">薪酬条分发</span><span class="sn-ver">1.2.7</span></div>
<div class="sn-item"><span class="sn-dot c3">档</span><span class="sn-name">档案归档巡检</span><span class="sn-ver">0.6.1</span></div>
</div>
<div class="rail-foot"><span>壳子 v2.3.1</span><a>检查更新</a></div>
</aside>
<!-- 主内容 -->
<div class="content">
<div class="page">
<div class="page-head">
<div>
<h2>早上好,张三</h2>
<p class="sub">2025年12月11日 星期四 · 6 个可用场景 · 昨日自动执行 12 次</p>
</div>
<span class="conn-pill"><i></i>服务已连接</span>
</div>
<div class="stats">
<div class="stat">
<span class="st-ic sky"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/></svg></span>
<div class="st-meta"><b>6</b><span>可用场景</span></div>
</div>
<div class="stat">
<span class="st-ic sky"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg></span>
<div class="st-meta"><b>3</b><span>定时任务</span></div>
</div>
<div class="stat">
<span class="st-ic ok"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span>
<div class="st-meta"><b>2<em>/2</em></b><span>平台在线</span></div>
</div>
<div class="stat">
<span class="st-ic ok"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><path d="M8.5 12.5l2.5 2.5 4.5-5"/></svg></span>
<div class="st-meta"><b style="font-size:15px;line-height:1.3">执行成功</b><span>考勤月报 · 14:02</span></div>
</div>
</div>
<div class="sec">
<div class="sec-head"><h3>常用场景</h3><span class="more">全部场景 →</span></div>
<div class="scenes">
<button class="sc">
<span class="sc-ic c1">考</span>
<span class="sc-body">
<b>考勤月报封存检查</b>
<span class="sc-desc">抓取当月 OA 考勤原始表,校验异常并封存归档</span>
<span class="sc-meta"><span class="ver">v1.4.0</span>·<span class="plat">OA 已登录</span></span>
</span>
<span class="sc-run">执行</span>
</button>
<button class="sc">
<span class="sc-ic c2">假</span>
<span class="sc-body">
<b>请假单批量补录</b>
<span class="sc-desc">按名单批量补录历史请假单并回写审批状态</span>
<span class="sc-meta"><span class="ver">v0.9.2</span>·<span class="plat off">HR 未登录</span></span>
</span>
<span class="sc-run">执行</span>
</button>
<button class="sc">
<span class="sc-ic c3">周</span>
<span class="sc-body">
<b>周报数据汇总</b>
<span class="sc-desc">拉取各部门周报并生成汇总看板快照</span>
<span class="sc-meta"><span class="ver">v2.1.0</span>·<span class="plat">OA 已登录</span></span>
</span>
<span class="sc-run">执行</span>
</button>
<button class="sc">
<span class="sc-ic c4">邮</span>
<span class="sc-body">
<b>邮件定时巡检</b>
<span class="sc-desc">巡检公共邮箱未读工单并推送提醒</span>
<span class="sc-meta"><span class="ver">v1.0.3</span>·<span class="plat">MAIL 已登录</span></span>
</span>
<span class="sc-run">执行</span>
</button>
</div>
</div>
<div class="sec">
<div class="sec-head"><h3>最近动态</h3><span class="note">最近 3 次执行</span></div>
<div class="recent">
<button class="rec">
<span class="rec-ic ok">✓</span><span class="rec-name">考勤月报封存检查</span>
<span class="rec-msg">执行完成 · 生成报表 1 份,2 行异常待复核</span>
<span class="rec-time">14:02</span>
</button>
<button class="rec">
<span class="rec-ic ok">✓</span><span class="rec-name">周报数据汇总</span>
<span class="rec-msg">执行完成 · 已同步快照至中心机</span>
<span class="rec-time">09:31</span>
</button>
<button class="rec">
<span class="rec-ic err">✕</span><span class="rec-name">请假单批量补录</span>
<span class="rec-msg err">登录态失效:HR 会话已过期,请重新登录平台</span>
<span class="rec-time">09:12</span>
</button>
</div>
</div>
</div>
<!-- 日志抽屉:可折叠,不再常驻占高 -->
<div class="logdock" id="logdock">
<div class="logdock-head" onclick="document.getElementById('logdock').classList.toggle('collapsed')">
<span class="lt">运行日志 <span class="live">● LIVE</span></span>
<div class="lv-tabs" onclick="event.stopPropagation()">
<span class="lv-tab on">全部</span><span class="lv-tab">INFO</span><span class="lv-tab">WARN</span><span class="lv-tab">ERROR</span>
</div>
<span class="sp"></span>
<span class="tool">复制</span><span class="tool">清空</span>
<svg class="chev" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="m6 14 6-6 6 6"/></svg>
</div>
<div class="logdock-body">
<div class="logline"><span class="t">14:02:01</span><span class="lv i">INFO</span><span class="m">[考勤月报] 启动 Chrome 会话,加载 OA 首页</span></div>
<div class="logline"><span class="t">14:02:07</span><span class="lv i">INFO</span><span class="m">登录态校验通过(cookie 有效)</span></div>
<div class="logline"><span class="t">14:02:09</span><span class="lv i">INFO</span><span class="m">进入 考勤月报 → 2025-11,开始抓取表格</span></div>
<div class="logline"><span class="t">14:02:24</span><span class="lv w">WARN</span><span class="m">抓取到 2 行异常打卡,已标记待人工复核</span></div>
<div class="logline"><span class="t">14:02:31</span><span class="lv i">INFO</span><span class="m">报表封存完成,已生成 ZIP 并回传中心机</span></div>
<div class="logline hl"><span class="t">14:02:32</span><span class="lv i">INFO</span><span class="m">===== 执行完成 =====(耗时 31s)</span></div>
</div>
</div>
<!-- 状态栏:收纳原 topbar 里的零散芯片 -->
<div class="statusbar">
<span class="si"><i class="on"></i>服务已连接</span>
<span class="si"><i class="on"></i>Chrome 131 已就绪</span>
<span class="si"><i class="mid"></i>授权剩余 5 天</span>
<span class="sp"></span>
<span class="mono">插件同步 2 分钟前</span>
<span class="mono">127.0.0.1:8765</span>
</div>
</div>
</div>
</div>
</div>
<!-- ---------- Tokens 图鉴 ---------- -->
<div class="tokens">
<h2>设计 Token 图鉴</h2>
<div class="tok-grid">
<div class="tok-card">
<h4>色彩 · 主色与语义(全部过 AA 对比度)</h4>
<div class="swatches">
<div class="sw-row"><span class="sw" style="background:#17608F"></span><span class="sw-name">primary-strong</span><span class="sw-note">按钮底色,白字 5.9:1</span></div>
<div class="sw-row"><span class="sw" style="background:#1E6FA8"></span><span class="sw-name">primary</span><span class="sw-note">链接 / 激活态 / 图标</span></div>
<div class="sw-row"><span class="sw" style="background:#E9F2FA"></span><span class="sw-name">primary-tint</span><span class="sw-note">选中底 / 色块容器</span></div>
<div class="sw-row"><span class="sw" style="background:#1F8A4C"></span><span class="sw-name">ok</span><span class="sw-note">成功 · 白字 4.8:1</span></div>
<div class="sw-row"><span class="sw" style="background:#D64545"></span><span class="sw-name">err</span><span class="sw-note">错误 · 替代过浅的 #E58B8B</span></div>
<div class="sw-row"><span class="sw" style="background:#B26B00"></span><span class="sw-name">warn</span><span class="sw-note">警告 · 白字 5.1:1</span></div>
</div>
</div>
<div class="tok-card">
<h4>字体 · 收敛为 7 档,数字一律等宽</h4>
<div class="type-row"><span class="type-tag">28 / 700</span><span style="font-size:28px;font-weight:700;letter-spacing:-.02em">28 页面大数字</span></div>
<div class="type-row"><span class="type-tag">20 / 700</span><span style="font-size:20px;font-weight:700">20 页面标题</span></div>
<div class="type-row"><span class="type-tag">16 / 600</span><span style="font-size:16px;font-weight:600">16 卡片区块标题</span></div>
<div class="type-row"><span class="type-tag">14 / 600</span><span style="font-size:14px;font-weight:600">14 列表主文本</span></div>
<div class="type-row"><span class="type-tag">13 / 400</span><span style="font-size:13px">13 正文基准</span></div>
<div class="type-row"><span class="type-tag">12 / 400</span><span style="font-size:12px;color:#5A6674">12 辅助说明(下限)</span></div>
<div class="type-row"><span class="type-tag">mono</span><span style="font-family:var(--mono);font-size:13px">v1.4.0 · 0 8 * * * · 14:02:31</span></div>
</div>
<div class="tok-card">
<h4>结构 · 发丝线优先,阴影只做两层</h4>
<div class="swatches">
<div class="sw-row"><span class="sw" style="background:#fff;border:1px solid #E4E9F0"></span><span class="sw-name">surface + hairline</span><span class="sw-note">1px 边线替代大部分投影</span></div>
<div class="sw-row"><span class="sw" style="background:#F1F4F8;border:1px solid #E4E9F0"></span><span class="sw-name">surface-2</span><span class="sw-note">hover / 次级容器</span></div>
<div class="sw-row"><span class="sw" style="background:linear-gradient(180deg,#fff,#FBFCFE);box-shadow:0 8px 24px -12px rgba(15,23,42,.14)"></span><span class="sw-name">shadow-md</span><span class="sw-note">仅悬浮卡片与弹层使用</span></div>
<div class="sw-row"><span class="sw" style="border-radius:12px"></span><span class="sw-name">radius 12 / 8</span><span class="sw-note">卡片 12 · 控件 8(从 16-22 收敛)</span></div>
</div>
</div>
<div class="tok-card">
<h4>方向对照 · 为什么改</h4>
<div class="vs">
<div class="col old">
<h5>现状 · 奶油治愈风</h5>
<ul>
<li>登录页=科技终端,工作台=可爱手账,身份分裂</li>
<li>主按钮浅蓝底白字 ≈2:1,对比度不达标</li>
<li>10.5px 小字遍地、字号 17 档碎片化</li>
<li>窗口卡片套卡片,四层圆角互相打架</li>
<li>浮动涂鸦 + 面板 hover 上浮,工具感被稀释</li>
</ul>
</div>
<div class="col new">
<h5>提案 · Soft Precision</h5>
<ul>
<li>冷灰画布 + 发丝线,主色压深保品牌色相</li>
<li>一套 token 管到底,深浅主题同源切换</li>
<li>自绘标题栏 + 状态栏,像原生桌面应用</li>
<li>日志改可折叠抽屉,状态芯片收进状态栏</li>
<li>动效只留 120-180ms 交互反馈,去掉常驻漂浮</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<p class="foot-note">提案稿 · 静态预览(单文件 HTML,数据为虚构示例)· 评审通过后按「token 层 → 布局壳 → 组件」三步落地到 Vue 组件</p>
</body>
</html>
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>37du 自动化工作台</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,23 @@
{
"name": "37du-shell-frontend",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.2",
"element-plus": "^2.14.5",
"vue": "^3.5.13"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.2.1",
"vite": "^6.0.3"
},
"allowScripts": {
"esbuild@0.25.12": true
}
}
+903
View File
@@ -0,0 +1,903 @@
<template>
<div v-if="booting" class="boot">
<span class="boot-logo">37</span>
<span class="boot-txt">{{ syncing ? '正在同步插件,请稍候…' : (store.appName || '自动化工作台') }}</span>
<span class="boot-dots"><i></i><i></i><i></i></span>
</div>
<LoginPage v-else-if="!store.current" :app-name="store.appName" @ok="onLogin" />
<div class="__app" v-else>
<!-- 壳子更新提示:已就绪重启更新 / 下载失败重试 / 发现新版本可下载(下载进度改用弹窗) -->
<div v-if="updBarVisible" class="update-bar">
<template v-if="shellUpdate.downloaded">
<span class="upd-txt">发现新版本 <b>v{{ shellUpdate.new }}</b><em v-if="shellUpdate.notes">{{ shellUpdate.notes }}</em></span>
<el-button size="small" type="primary" round :loading="updating" @click="doShellUpdate">重启更新</el-button>
</template>
<template v-else-if="updDl.status === 'failed'">
<span class="upd-txt">新版本下载失败<em>{{ updDl.error }}</em></span>
<el-button size="small" type="primary" round :loading="downloading" @click="onShellDownload">重试</el-button>
</template>
<template v-else-if="shellUpdate.available">
<span class="upd-txt">发现新版本 <b>v{{ shellUpdate.latest }}</b><em v-if="shellUpdate.notes">{{ shellUpdate.notes }}</em></span>
<div class="upd-actions">
<el-button size="small" type="primary" round :loading="downloading" @click="onShellDownload">立即下载</el-button>
<el-button size="small" round @click="shellDismissed = true">暂不</el-button>
</div>
</template>
</div>
<!-- 授权已过期:离线超 7 天须联网刷新票据后才能继续使用 -->
<div v-if="store.authExpired" class="auth-expired-bar">
<span class="ae-txt">授权已过期(最长离线 7 天),需联网刷新授权后才能继续使用</span>
<el-button size="small" type="primary" round :loading="syncingPlugins" @click="onPluginSync">立即刷新</el-button>
</div>
<!-- 顶栏已拆分融入三栏:品牌→左轨 / 账号→右轨 / Chrome→状态栏 -->
<!-- 主体:左场景轨 | 中上下文(总览/运行台/计划)| 右活动流 -->
<div class="body">
<!-- 左:品牌 + 场景轨(主导航 + 场景库) -->
<aside class="rail side">
<div class="side-brand">
<span class="logo">37</span>
<strong>{{ store.appName }}</strong>
</div>
<nav class="nav-main">
<div class="nav-item" :class="{ active: store.view === 'overview' }" @click="openOverview">
<el-icon><HomeFilled /></el-icon><span>总览</span>
</div>
<div class="nav-item" :class="{ active: store.view === 'scenes' }" @click="openScenes">
<el-icon><Grid /></el-icon><span>场景</span>
</div>
<div class="nav-item" :class="{ active: store.view === 'plans' }" @click="openPlans">
<el-icon><Clock /></el-icon><span>计划</span>
</div>
</nav>
<!-- 场景库 -->
<div class="side-head">
<span class="sec-title">场景</span>
<div class="side-head-r">
<span class="count">{{ store.plugins.length }}</span>
<el-tooltip content="插件同步" placement="top">
<el-button class="sync-btn" text :icon="Refresh" :loading="syncingPlugins"
:disabled="store.running" @click="onPluginSync" />
</el-tooltip>
</div>
</div>
<ul class="scene-list">
<li
v-for="(p, i) in store.plugins"
:key="p.id"
:class="{ active: p.id === store.selectedId && store.view === 'run' }"
@click="openRun(p.id)"
>
<span class="scene-icon" :style="{ background: grad(i) }">
{{ p.name.slice(0, 1) }}
</span>
<span class="scene-name">{{ p.name }}</span>
<em>v{{ p.version }}</em>
</li>
</ul>
<div v-if="!store.plugins.length" class="scene-empty">当前账号暂无可用场景<br><span>请联系管理员进行授权</span></div>
</aside>
<!-- 中:上下文区(视图路由) -->
<main class="rail main">
<div class="page-scroll">
<HomePage v-if="store.view === 'overview'" />
<ScenesPage v-else-if="store.view === 'scenes'" />
<PluginPage v-else-if="store.view === 'run'" />
<SchedulePage v-else-if="store.view === 'plans'" />
</div>
</main>
<!-- 右:账号 + 活动流(当前运行 + 最近运行;只回显,细节在运行台) -->
<aside class="rail activity">
<div class="act-acct">
<span class="acct-display">
<el-avatar :size="26" class="acct-avatar" :src="accountAvatar()" :key="accountAvatar()" @error="onAvatarError">
<span class="acct-avatar-fb">{{ (store.nickname || store.current).slice(0, 1).toUpperCase() }}</span>
</el-avatar>
<span class="acct-name">{{ store.nickname || store.current }}</span>
</span>
<div class="acct-ops">
<el-tooltip content="修改密码" placement="top">
<el-button size="small" text :icon="Key" @click="pwdDlg = true" />
</el-tooltip>
<el-button size="small" round @click="logout">登出</el-button>
</div>
</div>
<div class="act-head">
<span class="sec-title">活动</span>
<span v-if="store.running" class="act-live">● 运行中</span>
</div>
<div class="act-now" :class="{ on: store.running }">
<template v-if="store.running">
<div class="an-top">
<span class="an-name">{{ runningName }}</span>
<span class="an-pct">{{ store.progress }}%</span>
</div>
<el-progress :percentage="store.progress" :show-text="false" :stroke-width="6" color="var(--primary)" />
<div class="an-tail">
<div v-for="(l, i) in tailLogs" :key="i" class="an-line">
<span class="lv" :class="'s-' + (l.level || 'INFO')">{{ l.level || 'INFO' }}</span>
<span class="an-msg">{{ l.msg }}</span>
</div>
<div v-if="!tailLogs.length" class="an-wait">等待输出…</div>
</div>
</template>
<template v-else>
<div class="an-idle">
<span class="an-idle-ic">✓</span>
<div class="an-idle-meta">
<b>当前空闲</b>
<span>{{ lastRunText }}</span>
</div>
</div>
</template>
</div>
<div class="act-head act-head-2">
<span class="sec-title">最近运行</span>
<span v-if="store.recents.length" class="count">{{ store.recents.length }}</span>
</div>
<ul class="act-list">
<li v-for="(r, i) in store.recents" :key="i" @click="openRun(r.pluginId, r.runId)">
<span class="act-dot" :class="r.ok ? 'ok' : 'err'"></span>
<div class="act-meta">
<b>{{ r.name }}</b>
<span>{{ r.ok ? '完成' : (r.error || '失败') }}</span>
</div>
<em>{{ r.time }}</em>
</li>
</ul>
<div v-if="!store.recents.length" class="act-empty">本次会话暂无运行记录</div>
</aside>
</div>
<!-- 状态栏:机器与授权事实(品牌/账号已融入左右轨;Chrome 状态也在此) -->
<footer class="statusbar">
<span v-if="chromeVis" class="sb-item chrome-sb" :class="chromeInstalled ? 'ok' : 'warn'"
:title="chromeTip" @click="onChromeClick">
<i class="sb-dot"></i>{{ chromeLabel }}
</span>
<span v-if="chromeVis" class="sb-sep"></span>
<span class="sb-item" :class="licenseCls"><i class="sb-dot"></i>{{ licenseText }}</span>
<span class="sb-sep"></span>
<span class="sb-item" :class="store.wsOn ? 'ok' : 'warn'">
<i class="sb-dot"></i>{{ store.wsOn ? '本地服务已连接' : '本地服务重连中' }}
</span>
<span class="sb-sep"></span>
<span class="sb-item mono">{{ localAddr }}</span>
<span class="sb-spacer"></span>
<span class="sb-item">壳子 {{ shellUpdate.current ? 'v' + shellUpdate.current : '未打包' }}</span>
<el-link type="primary" :underline="false" class="sb-link"
:disabled="shellChecking" @click="onShellCheck">
{{ shellChecking ? '检查中…' : '检查更新' }}
</el-link>
</footer>
</div>
<ChangePasswordDialog v-if="pwdDlg" @close="pwdDlg = false" />
<!-- 壳子更新下载进度弹窗:点击「立即下载」后弹出,可最小化到后台继续下载 -->
<el-dialog v-model="updDlg" :title="`下载更新 v${updDl.version || ''}`" width="420px"
:close-on-click-modal="false" align-center class="upd-dl-dialog">
<template v-if="updDl.status === 'downloading'">
<div class="dl-dlg-body">
<el-progress :percentage="updDl.pct || 0" :stroke-width="10" />
<span class="dl-dlg-bytes">{{ fmtBytes(updDl.received) }}{{ updDl.total ? ' / ' + fmtBytes(updDl.total) : '' }}</span>
</div>
</template>
<template v-else-if="updDl.status === 'failed'">
<div class="dl-dlg-body">
<span class="dl-dlg-err">下载失败:{{ updDl.error || '未知错误' }}</span>
</div>
</template>
<template v-else>
<div class="dl-dlg-body"><span>已下载完成</span></div>
</template>
<template #footer>
<el-button v-if="updDl.status === 'failed'" size="small" type="primary" round
:loading="downloading" @click="onShellDownload">重试</el-button>
<el-button size="small" round @click="updDlg = false">后台下载</el-button>
</template>
</el-dialog>
</template>
<script setup>
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Clock, HomeFilled, Refresh, Key, Grid } from '@element-plus/icons-vue'
import HomePage from './components/HomePage.vue'
import ScenesPage from './components/ScenesPage.vue'
import PluginPage from './components/PluginPage.vue'
import SchedulePage from './components/SchedulePage.vue'
import LoginPage from './components/LoginPage.vue'
import ChangePasswordDialog from './components/ChangePasswordDialog.vue'
import { store, handleEvent, clearLogs, log, loadAvatar, clearAvatarCache, accountAvatar } from './store'
import { connectWS, fetchMeta, adminLogout, adminMe, adminPassword, syncPlugins, getShellStatus, applyShellUpdate, checkShellUpdate, downloadShellUpdate, getChromeStatus, checkChrome, downloadChrome, installChrome } from './api'
// 场景图标:奶油系柔和渐变(与总览首页/场景页共用同一套色板)
const GRADS = [
'var(--grad-sky)', 'var(--grad-peach)', 'var(--grad-mint)',
'var(--grad-lilac)', 'var(--grad-honey)', 'var(--grad-blush)',
]
function grad(i) { return GRADS[i % GRADS.length] }
// 顶栏头像加载失败:清除缓存返回首字符兜底
function onAvatarError() {
clearAvatarCache()
}
// ===== 三栏骨架:视图路由(总览 / 运行台 / 计划)=====
function openRun(id, runId) {
store.selectedId = id
store.view = 'run'
// 活动流「最近运行」点击:直达该次运行的回看(运行台消费后清空);
// 左栏场景点击不带 runId,顺带清掉可能残留的回看意图
store.pendingReplay = runId ? { pluginId: id, runId } : null
}
function openOverview() {
store.view = 'overview'
}
function openScenes() {
store.view = 'scenes'
}
function openPlans() {
store.view = 'plans'
}
// ===== 右栏活动流 + 底栏状态:由现有 store 派生,不引入新请求 =====
// 当前运行中的场景名(run_start 已把 run_id→plugin_id 登记在 store._runPlugins)
const runningName = computed(() => {
const pid = store._runPlugins[store.currentRun] || store.selectedId
return (store.plugins.find((p) => p.id === pid) || {}).name || '正在执行'
})
// 运行中:右栏只回显最近几条日志,细节仍在运行台「运行日志」标签页
const tailLogs = computed(() => store.logs.slice(-4))
const lastRunText = computed(() => {
const r = store.recents[0]
if (!r) return '本次会话暂无运行记录'
return `上次 ${r.name} · ${r.time}`
})
const localAddr = computed(() => (typeof location !== 'undefined' ? location.host : ''))
// 授权票据概要(状态栏):后端 /api/meta 的 license 字段
const licenseText = computed(() => {
const l = store.license
if (!l || !l.status || l.status === 'missing') return '未授权'
if (l.status === 'invalid') return '授权无效'
if (l.status === 'expired') return '授权已过期'
if (l.days_left === null || l.days_left === undefined) return '授权有效'
return `授权有效 · 剩余 ${l.days_left} 天`
})
const licenseCls = computed(() => {
const s = store.license && store.license.status
if (s === 'ok') return 'ok'
if (s === 'expired' || s === 'invalid') return 'err'
return 'warn'
})
function openWS() {
if (window.__ws) window.__ws.close()
const ws = connectWS(handleEvent)
window.__ws = ws
ws.onopen = () => (store.wsOn = true)
ws.onclose = () => {
store.wsOn = false
// 仅登录态下自动重连刷新;未登录被拒(1008)时静默,避免 reload 死循环
if (store.current) setTimeout(() => (location.reload()), 2500)
}
}
onMounted(async () => {
const meta = await fetchMeta()
store.appName = meta.appName
store.platforms = meta.platforms
store.plugins = meta.plugins || []
store.authExpired = !!meta.authExpired
store.license = meta.license || null
store.selectedId = store.plugins[0]?.id || ''
clearLogs()
openWS()
await checkSession()
booting.value = false // 会话判定完成(登录/未登录/后端不可达均已定),再渲染首屏
loadAvatar()
loadShellStatus()
loadChromeStatus()
})
onUnmounted(() => {
if (shellPollTimer) { clearTimeout(shellPollTimer); shellPollTimer = null }
if (chromePollTimer) { clearTimeout(chromePollTimer); chromePollTimer = null }
})
// ===== 浏览器(Chrome)检测/下载/安装 =====
const chrome = ref({})
let chromePollTimer = null
const chromeBusy = ref(false) // 正在轮询/下载/安装(按钮 loading)
const chromeInstalled = computed(() => !!chrome.value.installed)
const chromeVisible = computed(() => {
// 下载中/已下载待安装/未安装但中心机有登记 → 显示;已装则不显示(已可用不占用空间)
return chrome.value.installed || chrome.value.downloaded || chrome.value.cloud_available
})
// 常驻显示:只要后端返回过 Chrome 状态就展示(已安装绿色版本号 / 未安装橙色入口)
const chromeVis = computed(() => 'installed' in chrome.value)
const chromeLabel = computed(() => {
const c = chrome.value
if (c.installing) return '安装中…'
if (!c.installed) {
if (c.dl?.status === 'downloading') return c.dl?.pct + '%'
if (c.downloaded) return '点击安装'
if (c.cloud_available) return '装浏览器'
return '浏览器'
}
return c.version ? 'Chrome ' + c.version : 'Chrome'
})
const chromeTip = computed(() => {
const c = chrome.value
if (c.installed) return `本机已安装 Chrome ${c.version},点击重新检测`
if (c.installing) return '正在安装 Chrome,请稍候…'
if (c.downloaded) return 'Chrome 安装包已下载,点击安装'
if (c.dl?.status === 'downloading') return '正在下载 Chrome 安装包 ' + c.dl?.pct + '%'
if (!c.cloud_available) return '中心机暂未登记浏览器安装包,点击重新检测'
return '本机未安装 Chrome,点击下载安装'
})
async function loadChromeStatus() {
try { chrome.value = await getChromeStatus() } catch (_) {}
// 未安装或操作中才轮询;已安装无需常驻
if (!chrome.value.installed || chrome.value.installing || chrome.value.dl?.status === 'downloading') {
startChromePoll()
}
}
async function refreshChromeStatus() {
try {
const s = await getChromeStatus()
chrome.value = s
if (chrome.value.installed && chrome.value.dl?.status !== 'downloading' && !chrome.value.installing) {
if (chromePollTimer) { clearTimeout(chromePollTimer); chromePollTimer = null }
return // 已装好,停止轮询
}
} catch (_) {}
chromePollTimer = setTimeout(refreshChromeStatus, 1500)
}
function startChromePoll() {
if (chromePollTimer) return
refreshChromeStatus()
}
async function onChromeClick() {
if (chromeBusy.value) return
const c = chrome.value
// 安装中:仅刷新状态
if (c.installing) { return }
// 已下载:直接安装
if (c.downloaded) {
chromeBusy.value = true
try { await installChrome(); chrome.value.installing = true; startChromePoll() }
catch (e) { ElMessage.error('安装失败:' + (e.message || e)) }
chromeBusy.value = false
return
}
// 未装且中心机有登记:下载
if (!c.installed && c.cloud_available) {
chromeBusy.value = true
try { await downloadChrome(); loadChromeStatus() }
catch (e) { ElMessage.error('开始下载失败:' + (e.message || e)) }
chromeBusy.value = false
return
}
// 其余:重新检测
chromeBusy.value = true
try { await checkChrome(); loadChromeStatus() }
catch (e) { ElMessage.error('检测失败:' + (e.message || e)) }
chromeBusy.value = false
}
const pwdDlg = ref(false)
const booting = ref(true) // 鉴权判定中:未确定会话前先显示加载骨架,避免「闪一下登录页再进首页」
const syncing = ref(false) // 首次启动/启动时:按账号权限自下载/更新插件(等待下载界面)
// ===== 壳子自动更新:检查 → 用户确认下载(带进度)→ 重启更新 =====
const shellUpdate = ref({})
const updating = ref(false)
const downloading = ref(false)
const shellChecking = ref(false) // 手动检查请求进行中(秒级)
const shellDismissed = ref(false) // 用户点了"暂不",本会话内隐藏"立即下载"提示
let shellPollTimer = null // 状态轮询(setTimeout 递归,下载中 1.2s / 常态 15s)
let lastDlStatus = '' // 上一轮下载状态,用于下载完成/失败时的一次性提示
const updDl = computed(() => shellUpdate.value.dl || {})
const updDlg = ref(false) // 下载进度弹窗(点击「立即下载」后弹出)
const updBarVisible = computed(() =>
shellUpdate.value.downloaded ||
(updDl.value.status === 'failed' && !updDlg.value) ||
(shellUpdate.value.available && !shellDismissed.value)
)
function fmtBytes(n) {
if (!n) return '0 B'
const u = ['B', 'KB', 'MB', 'GB']
let i = 0
while (n >= 1024 && i < u.length - 1) { n /= 1024; i++ }
return (n >= 100 || i === 0 ? n.toFixed(0) : n.toFixed(1)) + ' ' + u[i]
}
async function loadShellStatus() {
try { shellUpdate.value = await getShellStatus() } catch (_) {}
startShellPoll()
}
// 常驻状态轮询:驱动下载进度条与 available/downloaded 提示;下载完成/失败各提示一次
async function refreshShellStatus() {
try {
const s = await getShellStatus()
shellUpdate.value = s
const st = s.dl?.status || ''
if (lastDlStatus === 'downloading' && st === 'downloaded') {
updDlg.value = false // 弹窗开着时自动收起,顶部提示条转为「重启更新」
ElMessage.success(`新版本 v${s.new} 已下载完成,点击顶部「重启更新」完成升级`)
log('INFO', `壳子新版本 v${s.new} 已就绪,可重启更新`)
} else if (lastDlStatus === 'downloading' && st === 'failed') {
ElMessage.warning('新版本下载失败:' + (s.dl?.error || ''))
}
lastDlStatus = st
} catch (_) {}
shellPollTimer = setTimeout(refreshShellStatus, updDl.value.status === 'downloading' ? 1200 : 15000)
}
function startShellPoll() {
if (shellPollTimer) return
refreshShellStatus()
}
async function doShellUpdate() {
updating.value = true
try {
await applyShellUpdate() // 后端运行静默安装并退出进程,升级后自动重启
} catch (e) {
updating.value = false
ElMessage.error('更新失败:' + (e.message || e))
}
}
async function onShellDownload() {
if (downloading.value) return
downloading.value = true
shellDismissed.value = false
updDlg.value = true // 点击下载即弹出进度弹窗,不再用页头条展示进度
// 点击即进入"下载中"反馈(不等轮询):内网直连下载很快,若靠 15s 轮询拉状态,
// 进度条可能还没显示就已经下载完,用户会以为点了没反应
const v = shellUpdate.value.latest || ''
shellUpdate.value = { ...shellUpdate.value,
dl: { status: 'downloading', version: v, received: 0, total: 0, pct: 0, error: '' } }
lastDlStatus = 'downloading' // 兜底:即使立即下载完成,也能触发"已就绪"一次性提示
try {
await downloadShellUpdate() // 后端后台流式下载,进度经轮询展示
try { shellUpdate.value = await getShellStatus() } catch (_) {} // 抢拉真实进度,避免卡在 0%
} catch (e) {
shellUpdate.value = { ...shellUpdate.value,
dl: { status: 'failed', version: v, received: 0, total: 0, pct: 0, error: (e.message || e) } }
ElMessage.error('开始下载失败:' + (e.message || e))
}
downloading.value = false
}
// 手动"检查更新":触发秒级版本比对 → 轮询检查结束后按结果提示
async function onShellCheck() {
if (shellChecking.value) return
try { await checkShellUpdate() } catch (e) {
ElMessage.error('检查更新失败:' + (e.message || e))
return
}
shellChecking.value = true
const timer = setInterval(async () => {
try {
const s = await getShellStatus()
shellUpdate.value = s
if (s.checking) return
clearInterval(timer)
shellChecking.value = false
handleCheckResult(s)
} catch (_) {}
}, 800)
// 兜底:30s 仍未结束则停止轮询,避免无限等待
setTimeout(() => {
if (shellChecking.value) {
clearInterval(timer)
shellChecking.value = false
}
}, 30000)
}
function handleCheckResult(s) {
if (!s.current) {
ElMessage.info('当前为源码开发模式,不参与壳子自更新')
return
}
if (s.downloaded) {
ElMessage.info(`新版本 v${s.new} 已就绪,点击顶部「重启更新」完成升级`)
return
}
if (updDl.value.status === 'downloading') return // 正在下载,进度条展示中
if (s.error) {
ElMessage.warning('检查更新失败:' + s.error)
log('WARN', `检查壳子更新失败:${s.error}`)
return
}
if (s.available) {
ElMessageBox.confirm(
`发现新版本 v${s.latest},是否立即下载?${s.notes ? '\n\n更新说明:' + s.notes : ''}`,
'发现新版本',
{ confirmButtonText: '立即下载', cancelButtonText: '稍后再说', type: 'info' }
).then(() => onShellDownload()).catch(() => {})
} else {
ElMessage.info(`已是最新版本 v${s.current}`)
}
}
// ===== 插件同步:按当前账号权限重新同步(新装/更新/清理已删除),完成后刷新清单 =====
// 登录成功与手动刷新共用;同步失败也补拉清单,保证离线时沿用本地已装插件
const syncingPlugins = ref(false)
async function onPluginSync() {
if (syncingPlugins.value || store.running) return
syncingPlugins.value = true
try {
const r = await syncPlugins()
const parts = []
if (r.downloaded?.length) parts.push(`新装 ${r.downloaded.length} 个`)
if (r.updated?.length) parts.push(`更新 ${r.updated.length} 个`)
if (r.removed?.length) parts.push(`清理 ${r.removed.length} 个`)
if (r.failed?.length) parts.push(`失败 ${r.failed.length} 个`)
if (parts.length) {
ElMessage.success('插件同步完成:' + parts.join(','))
const detail = [...(r.downloaded || []), ...(r.updated || []), ...(r.removed || [])].join('、')
if (detail) log('INFO', `插件同步完成:${parts.join(',')}(${detail})`)
} else {
ElMessage.info('插件已是最新')
}
if (r.failed?.length) log('ERROR', `插件同步失败:${r.failed.join('、')}`)
} catch (e) {
ElMessage.error('插件同步失败:' + (e.message || e))
} finally {
await refreshMeta()
syncingPlugins.value = false
}
}
// 平台登录等轻量操作反馈:统一走 element-plus 全局消息
function showToast(msg, type = 'info') {
ElMessage({ message: msg, type, duration: 2200 })
}
async function checkSession() {
// 登录态一律以**后端会话 cookie** 为准(钉钉扫码/账号登录/后端重启后均从 admin/me 判定),
// 不再以 localStorage 的 cp_account 早退——否则全新扫码流程(未写过 cp_account)回跳后无法进入插件页。
try {
const me = await adminMe()
if (!me.account) {
store.current = ''; store.dept = ''; store.nickname = ''; store.avatar = ''
try { localStorage.removeItem('cp_account') } catch (_) {}
return
}
store.current = me.account
store.dept = me.dept || ''
store.nickname = me.nickname || ''
store.avatar = me.avatar || ''
try { localStorage.setItem('cp_account', me.account) } catch (_) {}
// 会话确认后:按账号权限自下载/更新插件(首次启动等待下载完成;离线/失败直接跳过)
syncing.value = true
try { await syncPlugins() } catch (_) {}
syncing.value = false
// 会话有效:补拉插件清单(未登录时 meta 不返回插件)
await refreshMeta()
} catch (_) { /* 后端 down:无法校验,保持现状(可能为登录页或本地态) */ }
}
async function refreshMeta() {
try {
const meta = await fetchMeta()
store.platforms = meta.platforms
store.plugins = meta.plugins || []
store.authExpired = !!meta.authExpired
store.license = meta.license || null
// 选中场景不存在(被同步清理/授权收回)时回落到第一个可用场景
if (!store.plugins.find((p) => p.id === store.selectedId)) {
store.selectedId = store.plugins[0]?.id || ''
}
} catch (_) {}
}
async function onLogin(ok) {
store.current = ok.account
store.dept = ok.dept || ''
store.nickname = ok.nickname || ''
store.avatar = ok.avatar || ''
try { localStorage.setItem('cp_account', ok.account) } catch (_) {}
// 登录成功后立即按该账号权限同步插件(新装机首次登录即下载授权插件),再刷新平台/清单
await onPluginSync()
openWS()
loadAvatar()
loadShellStatus() // 挂载时未登录拉不到更新状态,登录后补拉(版本显示/更新提示)
loadChromeStatus() // 浏览器状态同此
// 首次登录/钉钉自动建号的默认密码:提示立即改密
if (ok.must_change_pwd) { promptChangePwd(ok.account) }
}
async function promptChangePwd(account) {
try {
// 旧密码 = 钉钉通知下发的初始密码,必须输入校验(与个人中心改密一致)
let op = ''
try {
const { value } = await ElMessageBox.prompt(
'当前账号正使用默认密码,请输入钉钉通知中的初始密码',
'首次登录 · 身份验证',
{ inputType: 'password', inputPlaceholder: '请输入初始密码',
confirmButtonText: '下一步', cancelButtonText: '稍后再说' })
op = value
} catch (_) { return /* 用户取消 */ }
const { value: np } = await ElMessageBox.prompt(
'请设置新密码(至少 6 位),避免他人误登录',
'首次登录 · 设置新密码',
{ inputType: 'password', inputPattern: /^.{6,}$/, inputErrorMessage: '密码至少 6 位',
confirmButtonText: '设置新密码', cancelButtonText: '稍后再说' })
try {
await adminPassword({ account, old_password: op, new_password: np })
ElMessage.success('密码已更新')
} catch (e) {
ElMessage.warning('改密失败:' + (e.message || e))
}
} catch (_) { /* 用户取消 */ }
}
async function logout() {
try { await adminLogout() } catch (_) {}
store.current = ''
store.nickname = ''
store.avatar = ''
store.avatarUrl = ''
store.authExpired = false
try { localStorage.removeItem('cp_account') } catch (_) {}
}
</script>
<style scoped>
.boot {
min-height: 100vh;
display: flex; flex-direction: column; align-items: center; justify-content: center;
gap: 14px; background: var(--bg);
}
.boot-logo {
width: 54px; height: 54px; border-radius: 18px;
display: grid; place-items: center;
background: var(--primary-grad); color: var(--on-primary);
font-size: 20px; font-weight: 800;
box-shadow: 0 10px 26px -8px rgba(var(--primary-rgb),.65);
animation: bootpop .4s ease;
}
.boot-txt { font-size: 13px; color: var(--text-faint); letter-spacing: .06em; }
.boot-dots { display: flex; gap: 5px; }
.boot-dots i {
width: 6px; height: 6px; border-radius: 50%; background: var(--primary);
animation: bootblink 1s infinite ease-in-out;
}
.boot-dots i:nth-child(2) { animation-delay: .15s; }
.boot-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bootpop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bootblink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; transform: translateY(-2px); } }
.update-bar {
display: flex; align-items: center; justify-content: space-between; gap: 12px;
padding: 8px 14px; margin-bottom: 12px; flex-shrink: 0;
background: var(--primary-weak);
border: 1px solid rgba(var(--primary-rgb), .5);
border-radius: var(--radius-sm);
font-size: 13px; color: var(--text-sub);
}
.update-bar b { color: var(--primary); }
.update-bar em { font-style: normal; color: var(--text-faint); margin-left: 6px; }
.update-bar .upd-actions { display: flex; align-items: center; gap: 8px; }
/* 壳子更新下载进度弹窗 */
.dl-dlg-body { display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; }
.dl-dlg-bytes { font-size: 12px; color: var(--text-faint); text-align: right; }
.dl-dlg-err { color: var(--danger); font-size: 13px; line-height: 1.6; }
/* ---------- 左轨:品牌(原顶栏品牌区融入) ---------- */
.side-brand {
display: flex; align-items: center; gap: 9px;
padding: 2px 8px 12px;
}
.side-brand .logo {
width: 28px; height: 28px; border-radius: 8px;
display: grid; place-items: center;
background: var(--primary-grad); color: var(--on-primary);
font-size: 12px; font-weight: 800;
box-shadow: 0 4px 12px -3px rgba(var(--primary-rgb),.6);
flex-shrink: 0;
}
.side-brand strong { font-size: 13.5px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* ---------- 右轨:账号条(原顶栏账号区融入) ---------- */
.act-acct {
display: flex; align-items: center; justify-content: space-between; gap: 8px;
padding: 2px 4px 10px;
}
.act-acct {
display: flex; align-items: center; justify-content: space-between; gap: 8px;
padding: 2px 4px 10px;
min-width: 0;
}
.act-acct .acct-display {
display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1;
}
.act-acct .acct-avatar { flex-shrink: 0; }
.act-acct .acct-avatar-fb { font-size: 12px; font-weight: 700; }
.act-acct .acct-name {
font-size: 12.5px; font-weight: 600; color: var(--text);
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.act-acct .acct-ops { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.act-acct .acct-ops .el-button + .el-button { margin-left: 0; }
.auth-expired-bar {
display: flex; align-items: center; justify-content: space-between; gap: 12px;
padding: 8px 14px; margin-bottom: 12px; flex-shrink: 0;
background: var(--warn-bg);
border: 1px solid rgba(var(--warn-rgb), .45);
border-radius: var(--radius-sm);
font-size: 13px; color: var(--warn-text);
}
.auth-expired-bar .ae-txt { flex: 1; }
/* 状态栏里的 Chrome 状态:可点击(检测/下载/安装) */
.chrome-sb { cursor: pointer; }
.chrome-sb:hover { color: var(--primary); }
.body { flex: 1; display: flex; gap: 14px; min-height: 0; margin-top: 14px; }
/* 三栏骨架的结构面板:静态面板不做 hover 上浮(大面板浮动会晃) */
.rail {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow-sm);
}
.side { width: 232px; flex-shrink: 0; display: flex; flex-direction: column; padding: 14px 12px; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 10px; }
.side-head-r { display: flex; align-items: center; gap: 2px; }
.sync-btn { padding: 5px 6px; font-size: 14px; color: var(--text-faint); }
.sync-btn:hover { color: var(--primary); }
.count { font-size: 11px; color: var(--text-faint); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }
.scene-list { list-style: none; margin: 0; padding: 0; flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.scene-list li {
display: flex; align-items: center; gap: 10px;
padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer;
position: relative;
transition: background .13s, transform .13s ease;
}
.scene-list li:hover { background: var(--surface-2); transform: translateX(2px); }
.scene-list li.active { background: var(--primary-weak); }
.scene-list li.active::before {
content: ''; position: absolute; left: 0; top: 9px; bottom: 9px;
width: 3px; border-radius: 3px; background: var(--primary);
}
.scene-list li.active .scene-name { color: var(--primary); font-weight: 600; }
.scene-icon {
width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
display: grid; place-items: center; color: var(--tile-fg); font-size: 12px; font-weight: 700;
}
.scene-name { flex: 1; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scene-list em { font-style: normal; font-size: 10px; color: var(--text-faint); }
.scene-empty {
flex: 1; display: grid; place-items: center; text-align: center;
font-size: 12.5px; color: var(--text-sub); line-height: 1.9; padding: 20px 12px;
}
.scene-empty span { font-size: 11px; color: var(--text-faint); }
/* ---------- 右栏:活动流 ---------- */
.activity {
width: 268px; flex-shrink: 0;
display: flex; flex-direction: column;
padding: 14px 12px; min-height: 0;
}
.act-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 10px; }
.act-head-2 { padding-top: 14px; margin-top: 12px; border-top: 1px dashed var(--border); }
.act-live { font-size: 10.5px; color: var(--ok); animation: actBlink 1s infinite; }
@keyframes actBlink { 50% { opacity: .25; } }
.act-now {
border: 1px solid var(--border); border-radius: var(--radius-sm);
background: var(--surface-2); padding: 11px 12px;
display: flex; flex-direction: column; gap: 9px;
}
.act-now.on { background: var(--primary-tint); border-color: var(--primary-line); }
.an-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.an-name { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-pct { font-size: 12px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.an-tail { display: flex; flex-direction: column; gap: 3px; max-height: 88px; overflow: hidden; }
.an-line { display: flex; gap: 6px; font-size: 11px; line-height: 1.5; font-family: var(--mono); }
.an-line .lv { flex-shrink: 0; font-weight: 700; }
.an-line .s-INFO { color: var(--primary); }
.an-line .s-WARN { color: var(--warn); }
.an-line .s-ERROR { color: var(--err); }
.an-msg { color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-wait { font-size: 11px; color: var(--text-faint); }
.an-idle { display: flex; align-items: center; gap: 10px; }
.an-idle-ic {
width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
display: grid; place-items: center; font-size: 12px; font-weight: 700;
background: var(--ok-weak); color: var(--ok);
}
.an-idle-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.an-idle-meta b { font-size: 12.5px; color: var(--text); }
.an-idle-meta span { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-list { list-style: none; margin: 0; padding: 0; flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.act-list li {
display: flex; align-items: center; gap: 9px;
padding: 8px 9px; border-radius: var(--radius-sm); cursor: pointer;
transition: background .13s;
}
.act-list li:hover { background: var(--surface-2); }
.act-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.act-dot.ok { background: var(--ok); }
.act-dot.err { background: var(--err); }
.act-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.act-meta b { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-meta span { font-size: 10.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-list em { font-style: normal; font-size: 10px; color: var(--text-faint); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.act-empty { font-size: 11.5px; color: var(--text-faint); text-align: center; padding: 18px 8px; line-height: 1.8; }
/* ---------- 底栏:状态栏 ---------- */
.statusbar {
flex-shrink: 0; margin-top: 12px;
display: flex; align-items: center; gap: 10px;
padding: 7px 14px;
background: var(--surface); border: 1px solid var(--border);
border-radius: var(--radius-sm);
font-size: 11.5px; color: var(--text-sub);
}
.sb-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sb-item.mono { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.sb-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot-off); flex-shrink: 0; }
.sb-item.ok { color: var(--ok-text); }
.sb-item.ok .sb-dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-weak); }
.sb-item.warn { color: var(--warn-text); }
.sb-item.warn .sb-dot { background: var(--warn); }
.sb-item.err { color: var(--danger); }
.sb-item.err .sb-dot { background: var(--err); }
.sb-sep { width: 1px; height: 12px; background: var(--border); flex-shrink: 0; }
.sb-spacer { flex: 1; }
.sb-link { font-size: 11px; vertical-align: baseline; }
/* 窄窗(如分屏):收起右栏,保证中栏可用宽度 */
@media (max-width: 1240px) {
.activity { display: none; }
}
.nav-main {
display: flex; flex-direction: column; gap: 2px;
padding: 0 4px 12px; margin-bottom: 10px;
border-bottom: 1px dashed var(--border);
}
.nav-item {
display: flex; align-items: center; gap: 10px;
padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer;
color: var(--text-sub); font-size: 13px; position: relative;
transition: background .13s, transform .13s ease;
}
.nav-item:hover { background: var(--surface-2); transform: translateX(2px); }
.nav-item.active { background: var(--primary-weak); color: var(--primary); font-weight: 600; }
.nav-item.active::before {
content: ''; position: absolute; left: 0; top: 9px; bottom: 9px;
width: 3px; border-radius: 3px; background: var(--primary);
}
.nav-item .el-icon { font-size: 15px; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
/* 中栏上下文区:视图自己决定是否填满(总览/计划自然高度并整体滚动,运行台填满内部滚) */
.page-scroll { flex: 1; min-height: 0; padding: 20px 24px; overflow: auto; display: flex; flex-direction: column; }
</style>
+172
View File
@@ -0,0 +1,172 @@
// 与 FastAPI 后端交互 + WebSocket 实时流
const WS_BASE = (location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host
async function j(url, opts) {
const res = await fetch(url, opts)
if (!res.ok) {
let msg = `HTTP ${res.status}`
try { msg = (await res.json()).detail || msg } catch (e) {}
throw new Error(msg)
}
return res.json()
}
export async function fetchMeta() {
return j('/api/meta')
}
export async function syncPlugins() {
return j('/api/plugins/sync', { method: 'POST' })
}
// ===== 插件回滚(升级前自动备份上一版,坏包可回退) =====
export async function listRollbacks() {
return j('/api/plugins/rollback')
}
export async function rollbackPlugin(id) {
return j(`/api/plugins/rollback/${encodeURIComponent(id)}`, { method: 'POST' })
}
// ===== 场景配置方案(多配置,SQLite 存储) =====
export async function listPluginConfigs(pluginId) {
return j(`/api/plugin-configs?plugin_id=${encodeURIComponent(pluginId)}`)
}
export async function savePluginConfig(pluginId, name, fields) {
return j('/api/plugin-configs', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ plugin_id: pluginId, name, fields }),
})
}
export async function deletePluginConfig(pluginId, cfgId) {
return j(`/api/plugin-configs/${encodeURIComponent(pluginId)}/${encodeURIComponent(cfgId)}`, { method: 'DELETE' })
}
export async function getShellStatus() {
return j('/api/shell/update-status')
}
export async function checkShellUpdate() {
return j('/api/shell/check', { method: 'POST' })
}
export async function downloadShellUpdate() {
return j('/api/shell/download', { method: 'POST' })
}
export async function applyShellUpdate() {
return j('/api/shell/apply', { method: 'POST' })
}
// ===== 浏览器(Chrome)安装 =====
export async function getChromeStatus() {
return j('/api/chrome/status')
}
export async function checkChrome() {
return j('/api/chrome/check', { method: 'POST' })
}
export async function downloadChrome() {
return j('/api/chrome/download', { method: 'POST' })
}
export async function installChrome() {
return j('/api/chrome/install', { method: 'POST' })
}
export async function loginPlatform(id) {
return j(`/api/platforms/${id}/login`, { method: 'POST' })
}
export async function logoutPlatform(id) {
return j(`/api/platforms/${id}/logout`, { method: 'POST' })
}
// 当前账号的平台状态(个人中心):在线态 + 是否已配置个人账号密码 + 已存用户名
export async function getPlatformStatus() {
return j('/api/platforms/status')
}
// 保存当前账号的 HR/OA 账号密码(本机加密);pass 留空表示保留原密码
export async function savePlatformCreds(payload) {
return j('/api/platforms/creds', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
})
}
export async function startRun(pluginId, fields) {
return j('/api/runs', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ plugin_id: pluginId, fields }),
})
}
export async function getRun(runId) {
return j(`/api/runs/${runId}`)
}
// 运行历史列表(当前账号,新的在前):执行台「历史运行」数据源
export async function fetchRuns(limit = 30) {
return j(`/api/runs?limit=${limit}`)
}
// ===== 定时任务(壳子内置定时,配置自动备份中心机) =====
export async function listSchedules() {
return j('/api/schedules')
}
export async function createSchedule(body) {
return j('/api/schedules', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
})
}
export async function updateSchedule(sid, body) {
return j(`/api/schedules/${sid}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
})
}
export async function deleteSchedule(sid) {
return j(`/api/schedules/${sid}`, { method: 'DELETE' })
}
export async function toggleSchedule(sid, enabled) {
return j(`/api/schedules/${sid}/toggle`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ enabled }),
})
}
export function connectWS(onEvent) {
const ws = new WebSocket(WS_BASE + '/ws')
ws.onmessage = (e) => {
try { onEvent(JSON.parse(e.data)) } catch (_) {}
}
return ws
}
// ===== 统一账户登录/会话(底座仅保留认证与个人密码,管理走中心机控制面) =====
export async function adminMe() {
return j('/api/admin/me')
}
export async function adminLogin(account, password) {
return j('/api/admin/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ account, password }) })
}
// v3 钉钉直连接登录:生成钉钉授权 URL(redirect_uri=本机 /auth/done),前端当前窗口跳转到该 URL
export async function authDingtalk() {
return j('/api/auth/dingtalk')
}
export async function adminLogout() {
return j('/api/admin/logout', { method: 'POST' })
}
export async function adminPassword(body) {
return j('/api/admin/password', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) })
}
export async function adminAvatarUpload(file) {
const fd = new FormData()
fd.append('file', file)
return j('/api/avatar', { method: 'POST', body: fd })
}
@@ -0,0 +1,76 @@
<template>
<el-dialog v-model="visible" title="修改密码" width="380px" align-center @close="emit('close')">
<el-form label-position="top" :model="form" :rules="rules" ref="formRef" class="pwd-form">
<el-form-item label="旧密码" prop="oldPwd">
<el-input v-model="form.oldPwd" type="password" show-password placeholder="请输入旧密码" @keyup.enter="changePwd" />
</el-form-item>
<el-form-item label="新密码" prop="newPwd">
<el-input v-model="form.newPwd" type="password" show-password placeholder="至少 6 位,不与原密码相同" @keyup.enter="changePwd" />
</el-form-item>
<el-form-item label="确认新密码" prop="newPwd2">
<el-input v-model="form.newPwd2" type="password" show-password placeholder="再次输入新密码" @keyup.enter="changePwd" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" :loading="pwdBusy" @click="changePwd">
{{ pwdBusy ? '提交中…' : '保存新密码' }}
</el-button>
</template>
</el-dialog>
</template>
<script setup>
import { ref, reactive } from 'vue'
import { ElMessage } from 'element-plus'
import { store } from '../store'
import { adminPassword } from '../api'
const emit = defineEmits(['close'])
const visible = ref(true)
const formRef = ref()
const form = reactive({ oldPwd: '', newPwd: '', newPwd2: '' })
const rules = {
oldPwd: [{ required: true, message: '请输入原密码', trigger: 'blur' }],
newPwd: [
{ required: true, message: '请输入新密码', trigger: 'blur' },
{ min: 6, message: '新密码至少 6 位', trigger: 'blur' },
{
validator: (_, v, cb) => (v && v === form.oldPwd
? cb(new Error('新密码不能与原密码相同')) : cb()),
trigger: 'blur'
},
],
newPwd2: [
{ required: true, message: '请再次输入新密码', trigger: 'blur' },
{
validator: (_, v, cb) => (v !== form.newPwd
? cb(new Error('两次输入的密码不一致')) : cb()),
trigger: 'blur'
},
],
}
const pwdBusy = ref(false)
async function changePwd() {
await formRef.value.validate().catch(() => Promise.reject())
pwdBusy.value = true
try {
await adminPassword({
account: store.current,
old_password: form.oldPwd,
new_password: form.newPwd,
})
ElMessage.success('密码已修改,下次登录请使用新密码')
visible.value = false
} catch (e) {
ElMessage.error('修改失败:' + (e.message || e))
} finally {
pwdBusy.value = false
}
}
</script>
<style scoped>
.pwd-form :deep(.el-form-item__label) { color: var(--text-sub); font-weight: 500; }
</style>
@@ -0,0 +1,242 @@
<template>
<div class="home">
<!-- 指标行:压缩首屏信息密度(替代问候区与统计卡) -->
<section class="kpis">
<div class="kpi">
<b>{{ store.plugins.length }}<em> 场景</em></b>
<span>可用场景</span>
</div>
<div class="kpi">
<b>{{ scheduleCount }}<em> 任务</em></b>
<span>定时任务</span>
</div>
<div class="kpi" :class="onlineCount ? 'ok' : ''">
<b>{{ onlineCount }}<em>/{{ store.platforms.length }}</em></b>
<span>平台在线</span>
</div>
<div class="kpi" :class="lastOk === null ? '' : (lastOk ? 'ok' : 'err')">
<b>{{ lastOk === null ? '—' : (lastOk ? '成功' : '失败') }}</b>
<span>{{ lastRunTime || '暂无运行' }}</span>
</div>
</section>
<!-- 平台账号(当前登录人的 HR/OA 账号与登录状态,登录后场景按本人身份执行) -->
<section class="block">
<div class="block-head">
<span class="sec-title">平台账号</span>
<span class="rec-note">配置你自己的 HR/OA 账号</span>
</div>
<PlatformAccounts />
</section>
<!-- 常用场景(只放前 6 个快捷入口,全部走「场景」视图) -->
<section class="block">
<div class="block-head">
<span class="sec-title">常用场景</span>
<el-button v-if="store.plugins.length > 6" text size="small" class="more" @click="goScenes">
全部场景 {{ store.plugins.length }} <el-icon><ArrowRight /></el-icon>
</el-button>
</div>
<div v-if="store.plugins.length" class="scenes" :style="{ '--n': Math.min(4, store.plugins.length) }">
<button
v-for="(p, i) in store.plugins.slice(0, 6)" :key="p.id" class="sc card"
:class="{ running: store.running && store.selectedId === p.id }"
@click="openPlugin(p.id)"
>
<span class="sc-ic" :style="{ background: grad(i) }">{{ p.name.slice(0, 1) }}</span>
<span class="sc-body">
<b>{{ p.name }}</b>
<span class="sc-meta">
v{{ p.version }}
<template v-if="p.platform">
<i class="sep-dot"></i>{{ platformLabel(p.platform) }}
<em class="plat-state" :class="{ on: platformOnline(p.platform) }">
{{ platformOnline(p.platform) ? '已登录' : '未登录' }}
</em>
</template>
</span>
</span>
<span class="sc-go">
<template v-if="store.running && store.selectedId === p.id">{{ store.progress }}%</template>
<template v-else>执行</template>
</span>
</button>
</div>
<div v-else class="empty card">
<span class="empty-emoji">🤍</span>
<div>
<b>当前账号暂无可用场景</b>
<span>请联系管理员在控制面进行授权,授权后点击右上角刷新</span>
</div>
<el-button size="small" round type="primary" plain @click="goScenes">去同步</el-button>
</div>
</section>
<!-- 最近动态 -->
<section class="block" v-if="store.recents.length">
<div class="block-head">
<span class="sec-title">最近动态</span>
<span class="rec-note">最近 {{ store.recents.length }} 次执行</span>
</div>
<div class="recent card">
<button v-for="(r, i) in store.recents" :key="i" class="rec" @click="openPlugin(r.pluginId, r.runId)">
<span class="rec-ic" :class="r.ok ? 'ok' : 'err'">{{ r.ok ? '✓' : '✕' }}</span>
<span class="rec-name">{{ r.name }}</span>
<span class="rec-msg" :class="r.ok ? 'ok' : 'err'">{{ r.ok ? '执行完成' : (r.error || '执行失败') }}</span>
<span class="rec-time">{{ r.time }}</span>
</button>
</div>
</section>
</div>
</template>
<script setup>
import { computed, onMounted, ref } from 'vue'
import { ArrowRight } from '@element-plus/icons-vue'
import { store } from '../store'
import { listSchedules } from '../api'
import PlatformAccounts from './PlatformAccounts.vue'
const GRADS = [
'var(--grad-sky)', 'var(--grad-peach)', 'var(--grad-mint)',
'var(--grad-lilac)', 'var(--grad-honey)', 'var(--grad-blush)',
]
function grad(i) { return GRADS[i % GRADS.length] }
const scheduleCount = ref(0)
onMounted(async () => {
try {
const r = await listSchedules()
scheduleCount.value = (r.schedules || []).length
} catch (_) { scheduleCount.value = 0 }
})
const onlineCount = computed(() => (store.platforms || []).filter((p) => p.online).length)
const lastOk = computed(() => (store.lastResult ? !!store.lastResult.ok : null))
const lastRunTime = computed(() => {
const r = store.recents[0]
return r ? r.time : ''
})
function platformLabel(id) {
return (store.platforms.find((p) => p.id === id) || {}).label || id
}
function platformOnline(id) {
return !!(store.platforms.find((p) => p.id === id) || {}).online
}
function openPlugin(id, runId) {
store.selectedId = id
store.view = 'run'
// 最近动态点击:直达该次运行的回看(运行台消费后清空);普通场景点击清掉残留意图
store.pendingReplay = runId ? { pluginId: id, runId } : null
}
function goScenes() {
store.view = 'scenes'
}
</script>
<style scoped>
.home { display: flex; flex-direction: column; gap: 20px; padding: 4px 2px 10px; flex-shrink: 0; }
/* ---------- 指标行(紧凑,替代问候区/统计卡) ---------- */
.kpis { display: flex; gap: 10px; flex-wrap: wrap; }
.kpi {
flex: 1; min-width: 150px;
display: flex; align-items: baseline; gap: 8px;
padding: 10px 14px;
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
}
.kpi b { font-size: 17px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi b em { font-style: normal; font-size: 11px; color: var(--text-faint); font-weight: 500; }
.kpi span { margin-left: auto; font-size: 11px; color: var(--text-faint); white-space: nowrap; }
.kpi.ok b { color: var(--ok); }
.kpi.err b { color: var(--err); }
/* ---------- 分节 ---------- */
.block { display: flex; flex-direction: column; gap: 10px; container-type: inline-size; }
.block-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px; }
.more { color: var(--text-faint); }
.more:hover { color: var(--primary); }
.rec-note { font-size: 11px; color: var(--text-faint); }
/* ---------- 场景卡:列数 = min(4, 场景数),按实际数量均分并占满整行;
间隔数随列数变化,2 个场景即 2 列(与上方 2 列平台账号完全对齐);
容器变窄时先降为 2 列、再降 1 列,避免卡片过窄 ---------- */
.scenes {
--max: 4;
display: grid;
grid-template-columns: repeat(min(var(--max), var(--n, 1)), 1fr);
gap: 10px;
}
@container (max-width: 620px) { .scenes { --max: 2; } }
@container (max-width: 380px) { .scenes { --max: 1; } }
.sc {
display: flex; align-items: center; gap: 10px;
padding: 11px 13px; text-align: left;
cursor: pointer; font-family: inherit;
transition: border-color .15s ease, box-shadow .15s ease;
}
.sc:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.sc:active { transform: scale(.99); }
.sc.running { border-color: rgba(var(--primary-rgb), .55); background: var(--surface-glow); }
.sc-ic {
width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
display: grid; place-items: center; color: var(--tile-fg);
font-size: 13px; font-weight: 700;
}
.sc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sc-body b { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-meta { font-size: 10.5px; color: var(--text-faint); display: flex; align-items: center; gap: 5px; font-style: normal; white-space: nowrap; }
.sep-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--dot-muted); }
.plat-state { font-style: normal; color: var(--text-muted-warm); }
.plat-state.on { color: var(--ok); }
.sc-go {
flex-shrink: 0;
font-size: 11px; font-weight: 600;
color: var(--primary); background: var(--primary-weak);
border: 1px solid rgba(var(--primary-rgb), .35);
padding: 4px 10px; border-radius: 999px;
transition: all .15s ease;
}
.sc:hover .sc-go { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.sc.running .sc-go { color: var(--on-primary); background: var(--primary); border-color: transparent; font-variant-numeric: tabular-nums; }
.empty {
display: flex; align-items: center; gap: 14px;
padding: 22px 20px; color: var(--text-sub);
}
.empty-emoji { font-size: 26px; }
.empty b { display: block; font-size: 13.5px; color: var(--text); margin-bottom: 3px; font-weight: 600; }
.empty span { font-size: 12px; color: var(--text-faint); }
.empty .el-button { margin-left: auto; }
/* ---------- 最近动态 ---------- */
.recent { padding: 4px 8px; }
.rec {
display: flex; align-items: center; gap: 11px;
width: 100%; padding: 8px; text-align: left;
background: transparent; border: none; border-radius: 8px;
cursor: pointer; font-family: inherit;
transition: background .13s;
}
.rec:hover { background: var(--surface-2); }
.rec-ic {
width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
display: grid; place-items: center; font-size: 10px; font-weight: 700;
}
.rec-ic.ok { background: var(--ok-weak); color: var(--ok); }
.rec-ic.err { background: var(--err-weak); color: var(--err); }
.rec-name { font-size: 12.5px; font-weight: 600; color: var(--text); min-width: 110px; }
.rec-msg { flex: 1; font-size: 12px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-msg.ok { color: var(--ok); }
.rec-msg.err { color: var(--err); }
.rec-time { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) {
.kpis { flex-direction: column; }
}
</style>
@@ -0,0 +1,173 @@
<template>
<div class="log-wrap">
<div class="log-head">
<div class="log-title">
<i v-if="!isStatic" class="status" :class="store.wsOn ? 'on' : 'off'" :title="store.wsOn ? '实时连接正常' : '连接已中断'"></i>
<span>{{ isStatic ? '历史回看' : '运行日志' }}</span>
<span v-if="store.running && !isStatic" class="live">● LIVE</span>
<span v-else-if="visibleLogs.length" class="count">{{ visibleLogs.length }} 条</span>
</div>
<div class="log-tools">
<el-radio-group v-model="level" size="small">
<el-radio-button v-for="l in LEVELS" :key="l" :value="l">{{ l }}</el-radio-button>
</el-radio-group>
<el-button size="small" :icon="CopyDocument" circle title="复制日志" :disabled="!visibleLogs.length"
@click="copy" />
<el-button size="small" :icon="pause ? VideoPlay : VideoPause" circle :title="pause ? '继续滚动' : '暂停滚动'"
@click="pause = !pause" />
<el-button v-if="!isStatic" size="small" plain :disabled="!store.logs.length" @click="confirmClear">清空</el-button>
</div>
</div>
<div ref="box" class="log-box">
<div v-if="!visibleLogs.length" class="log-empty">
<template v-if="isStatic">该次运行没有日志记录</template>
<template v-else-if="store.logs.length">当前级别无日志</template>
<template v-else>暂无日志,点击「一键执行」开始</template>
</div>
<div v-for="(l, i) in visibleLogs" :key="i" class="log-line">
<span class="t">{{ l.time || l.t || '' }}</span>
<span class="lv" :class="'s-' + (l.level || 'INFO')">[{{ l.level || 'INFO' }}]</span>
<span>{{ l.msg }}</span>
</div>
</div>
</div>
</template>
<script setup>
import { nextTick, ref, watch, computed } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { CopyDocument, VideoPause, VideoPlay } from '@element-plus/icons-vue'
import { store, clearLogs } from '../store'
const props = defineProps({
// 历史回看模式:传入后显示该次运行的静态日志(替代 store.logs),并隐藏清空/LIVE
staticLogs: { type: Array, default: null },
})
const isStatic = computed(() => Array.isArray(props.staticLogs))
const LEVELS = ['全部', 'INFO', 'WARN', 'ERROR']
const level = ref('全部')
const pause = ref(false)
const box = ref(null)
const visibleLogs = computed(() => {
const src = isStatic.value ? props.staticLogs : store.logs
if (level.value === '全部') return src
return src.filter((l) => l.level === level.value)
})
// 日志变化或过滤切换时,若未暂停则自动滚到最新
watch(
[() => store.logs.length, () => props.staticLogs?.length, level],
async () => {
if (pause.value) return
await nextTick()
if (box.value) box.value.scrollTop = box.value.scrollHeight
},
{ immediate: true }
)
function confirmClear() {
ElMessageBox.confirm('确认清空全部运行日志?', '清空日志', {
confirmButtonText: '清空',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => { clearLogs(); ElMessage.success('日志已清空') })
.catch(() => { })
}
async function copy() {
const text = visibleLogs.value.map((l) => `[${l.time}] [${l.level || 'INFO'}] ${l.msg}`).join('\n')
try {
await navigator.clipboard.writeText(text)
ElMessage.success(`已复制 ${visibleLogs.value.length} 条日志`)
} catch (_) {
ElMessage.error('复制失败')
}
}
</script>
<style scoped>
.log-wrap {
display: flex;
flex-direction: column;
flex: 1 1 auto; /* 由父级(运行台「运行日志」标签页)给高度 */
min-height: 0;
overflow: hidden;
position: relative;
}
.log-head {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 14px 10px 18px;
border-bottom: 1px solid var(--border);
gap: 10px;
}
.log-title {
display: flex;
align-items: center;
gap: 9px;
font-size: 13.5px;
font-weight: 600;
color: var(--text);
white-space: nowrap;
}
.log-tools {
display: flex;
align-items: center;
gap: 6px;
}
.log-tools .el-button+.el-button {
margin-left: 0;
}
.status {
width: 9px;
height: 9px;
border-radius: 50%;
flex-shrink: 0;
}
.status.on {
background: var(--ok);
box-shadow: 0 0 0 3px var(--ok-weak);
}
.status.off {
background: var(--dot-off);
}
.live {
color: var(--ok);
font-size: 10px;
animation: blink 1s infinite;
letter-spacing: .04em;
}
.count {
font-size: 11px;
color: var(--text-faint);
font-weight: 500;
}
@keyframes blink {
50% {
opacity: .2;
}
}
.log-empty {
color: var(--text-faint);
padding: 14px;
font-family: var(--mono);
font-size: 12px;
}
</style>
@@ -0,0 +1,653 @@
<template>
<div class="login">
<!-- 巨大 37:节点阵列 -->
<div class="ghost" aria-hidden="true">37</div>
<!-- 基线管道:流程节点 -->
<div class="pipeline" aria-hidden="true">
<i></i><i></i><i></i>
</div>
<!-- 顶部:品牌 + 系统状态 -->
<header class="topbar">
<div class="brand">
<span class="mark">37</span>
<span class="name">{{ appName || '37du 自动化工作台' }}</span>
</div>
<div class="sys">
<button class="doodle-toggle" :class="{ off: !doodlesOn }"
:title="doodlesOn ? '关闭涂鸦装饰' : '开启涂鸦装饰'" aria-label="涂鸦装饰开关"
@click="toggleDoodles">
<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.8"
stroke-linecap="round" stroke-linejoin="round">
<path d="M12 3c.6 4.6 3.4 7.4 8 8-4.6.6-7.4 3.4-8 8-.6-4.6-3.4-7.4-8-8 4.6-.6 7.4-3.4 8-8Z" />
</svg>
</button>
<span class="dot" aria-hidden="true"></span>
<span>引擎运行中</span>
</div>
</header>
<!-- 中央:接入终端 -->
<main class="panel">
<span class="core-mark">37 CORE · AUTOMATION</span>
<h1>自动化工作台</h1>
<p class="sub">使用统一账号或钉钉扫码,进入你的流程中心</p>
<el-form label-position="top" class="form" @submit.prevent="doLogin">
<el-form-item label="员工账号">
<el-input v-model="account" placeholder="请输入账号" autocomplete="username" size="large" clearable
@keyup.enter="doLogin" />
</el-form-item>
<el-form-item label="密码">
<el-input v-model="password" type="password" placeholder="请输入密码" autocomplete="current-password" size="large"
show-password @keyup.enter="doLogin" />
</el-form-item>
<el-button type="primary" size="large" class="primary" :loading="busy" @click="doLogin">
{{ busy ? '进 入 中 …' : '进 入 工 作 台' }}
</el-button>
</el-form>
<div class="divider"><span>或</span></div>
<el-button size="large" class="dingtalk" :loading="dingBusy" :icon="ChatDotRound" @click="openDing">
钉钉扫码接入
</el-button>
</main>
<!-- 底部:流程状态 -->
<footer class="footbar">
<div class="flows">
<span>接入终端就绪</span>
<span class="f-blocks" aria-hidden="true">
<i></i><i></i><i></i><i></i><i></i>
</span>
</div>
<span class="copyright">© 37du 自动化工作台</span>
</footer>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import { ChatDotRound } from '@element-plus/icons-vue'
import { adminLogin, authDingtalk } from '../api'
defineProps({ appName: { type: String, default: '' } })
const emit = defineEmits(['ok'])
// 涂鸦装饰层开关(与 main.js 的 initDoodles 同源:localStorage['37du.doodles'])
const doodlesOn = ref(true)
try { doodlesOn.value = (localStorage.getItem('37du.doodles') || 'on') !== 'off' } catch (_) {}
onMounted(() => { document.documentElement.classList.toggle('no-doodles', !doodlesOn.value) })
function toggleDoodles() {
doodlesOn.value = !doodlesOn.value
document.documentElement.classList.toggle('no-doodles', !doodlesOn.value)
try { localStorage.setItem('37du.doodles', doodlesOn.value ? 'on' : 'off') } catch (_) {}
}
const account = ref('')
const password = ref('')
const busy = ref(false)
const dingBusy = ref(false)
async function doLogin() {
if (busy.value) return
if (!account.value.trim() || !password.value) { ElMessage.warning('请输入账号和密码'); return }
busy.value = true
try {
const r = await adminLogin(account.value, password.value)
ElMessage.success('登录成功')
emit('ok', {
account: account.value.trim(),
dept: r.dept || '',
must_change_pwd: !!r.must_change_pwd,
nickname: r.nickname || '',
avatar: r.avatar || ''
})
} catch (e) {
ElMessage.error('登录失败:' + (e.message || e))
} finally {
busy.value = false
}
}
// 钉钉扫码登录:壳后端直接生成授权 URL,当前窗口跳转钉钉;扫码后浏览器自动跳回 /auth/done
async function openDing() {
if (dingBusy.value) return
dingBusy.value = true
try {
const r = await authDingtalk()
if (r && r.url) {
window.location.href = r.url
return
}
ElMessage.error('钉钉登录未配置,请联系管理员')
} catch (e) {
ElMessage.error('钉钉登录不可用:' + (e.message || e))
}
dingBusy.value = false
}
</script>
<style scoped>
/* ============================================================
奶油极简治愈风登录页(Soft Minimal Cream)
- 奶油米白画布(--bg)+ 浅天蓝强调 + 手绘涂鸦点缀
- 全量走设计令牌,换肤只改 style.css 的 [data-skin] 块
============================================================ */
/* ---------- 画布 ---------- */
.login {
position: relative;
min-height: 100vh;
min-height: 100dvh;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
padding: 110px 24px 170px;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family: var(--font-body, "Inter", -apple-system, "Segoe UI", "PingFang SC", sans-serif);
}
/* 奶油点阵:边缘径向淡出(浅天蓝极淡点) */
.login::before {
content: '';
position: absolute;
inset: 0;
z-index: 0;
background-image: radial-gradient(rgba(var(--primary-rgb), .16) 1.2px, transparent 1.3px);
background-size: 30px 30px;
-webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 18%, transparent 76%);
mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 18%, transparent 76%);
pointer-events: none;
}
/* 顶部柔光:浅天蓝辉光 */
.login::after {
content: '';
position: absolute;
inset: 0;
z-index: 0;
background: radial-gradient(660px 480px at 50% 38%, rgba(var(--primary-rgb), .12), transparent 68%);
pointer-events: none;
}
/* ---------- 巨大 37:奶油点阵 ---------- */
.ghost {
position: absolute;
left: 50%;
bottom: -0.12em;
transform: translateX(-50%);
font-family: 'Helvetica Neue', 'Arial Narrow', Arial, sans-serif;
font-size: clamp(280px, 74vw, 640px);
font-weight: 800;
line-height: .72;
letter-spacing: -.08em;
white-space: nowrap;
pointer-events: none;
user-select: none;
z-index: 1;
color: rgba(var(--primary-rgb), .10);
animation: breathe 7s ease-in-out infinite;
}
@keyframes breathe {
0%, 100% { opacity: .8; }
50% { opacity: 1; }
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
.ghost {
color: transparent;
background-image: radial-gradient(circle at 1px 1px,
rgba(var(--primary-rgb), .30) 1px, transparent 1.9px);
background-size: 9px 9px;
-webkit-background-clip: text;
background-clip: text;
}
}
/* ---------- 基线管道 ---------- */
.pipeline {
position: absolute;
left: 50%;
bottom: 0;
transform: translateX(-50%);
width: min(920px, 92vw);
height: 1px;
background: linear-gradient(90deg,
transparent, rgba(var(--text-rgb), .10) 18%,
rgba(var(--text-rgb), .10) 82%, transparent);
z-index: 1;
pointer-events: none;
}
.pipeline i {
position: absolute;
top: -2px;
width: 5px;
height: 5px;
border-radius: 50%;
background: var(--primary);
box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .14);
}
.pipeline i:nth-child(1) { left: 22%; }
.pipeline i:nth-child(2) { left: 50%; animation: blip 3.6s ease-in-out infinite; }
.pipeline i:nth-child(3) { left: 78%; }
@keyframes blip {
0%, 100% { opacity: .35; transform: scale(.85); }
50% { opacity: 1; transform: scale(1.1); }
}
/* ---------- 顶部栏 ---------- */
.topbar {
position: absolute;
top: 40px;
left: 48px;
right: 48px;
display: flex;
align-items: center;
justify-content: space-between;
z-index: 3;
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark {
width: 28px;
height: 28px;
flex: none;
display: grid;
place-items: center;
border-radius: 10px;
background: var(--primary-grad);
color: var(--on-primary);
font-size: 11px;
font-weight: 800;
letter-spacing: .01em;
font-family: 'Helvetica Neue', Arial, sans-serif;
box-shadow: 0 4px 10px -4px rgba(var(--primary-rgb), .65);
}
.name {
font-size: 12.5px;
font-weight: 500;
letter-spacing: .04em;
color: var(--text-sub);
}
.sys {
display: flex;
align-items: center;
gap: 8px;
font-size: 10.5px;
letter-spacing: .12em;
color: var(--text-warm-faint);
}
/* 涂鸦开关:小圆钮 */
.doodle-toggle {
display: grid;
place-items: center;
width: 24px;
height: 24px;
margin-right: 2px;
padding: 0;
border: 1px solid var(--border-warm);
border-radius: 50%;
background: var(--surface);
color: var(--primary);
cursor: pointer;
transition: all .18s ease;
}
.doodle-toggle:hover { transform: translateY(-1px) rotate(8deg); box-shadow: 0 4px 10px -4px rgba(var(--primary-rgb), .5); border-color: var(--primary-line); }
.doodle-toggle.off { color: var(--text-disabled); }
.doodle-toggle.off:hover { color: var(--primary); border-color: var(--primary-line); }
.dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--primary);
animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
0% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), .45); }
70% { box-shadow: 0 0 0 7px rgba(var(--primary-rgb), 0); }
100% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0); }
}
.sep { color: var(--sep-warm); }
/* ---------- 中央:接入终端(白底奶油卡) ---------- */
.panel {
position: relative;
z-index: 2;
width: 100%;
max-width: 420px;
padding: 46px 42px 42px;
background: var(--surface);
border: 1px solid var(--border-warm-2);
border-radius: 22px;
box-shadow:
0 1px 0 rgba(var(--on-primary-rgb), .95) inset,
0 24px 48px -28px rgba(var(--text-rgb), .24);
animation: rise .45s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes rise {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: none; }
}
/* 卡片内元素依次点亮 */
@keyframes seq {
from { opacity: 0; transform: translateY(7px); }
to { opacity: 1; transform: none; }
}
.core-mark { animation: seq .5s .05s both; }
.panel h1 { animation: seq .5s .10s both; }
.panel .sub { animation: seq .5s .15s both; }
.form { animation: seq .55s .20s both; }
.divider { animation: seq .5s .26s both; }
.dingtalk { animation: seq .5s .32s both; }
/* 卡片底部纹理:极淡 */
.panel::after {
content: '';
position: absolute;
left: 42px;
right: 42px;
bottom: 0;
height: 3px;
background-image: repeating-linear-gradient(to right,
rgba(var(--border-strong-rgb), .5) 0 8px,
transparent 8px 12px);
pointer-events: none;
}
.core-mark {
display: block;
margin-bottom: 20px;
font-family: 'Helvetica Neue', Arial, sans-serif;
font-size: 10px;
font-weight: 700;
letter-spacing: .18em;
color: var(--primary-strong);
}
.panel h1 {
margin: 0 0 8px;
font-size: 31px;
font-weight: 600;
line-height: 1.25;
letter-spacing: .01em;
color: var(--text);
font-family: var(--font-doodle, "Segoe Script", "Comic Sans MS", "KaiTi", cursive);
}
.panel .sub {
margin: 0 0 36px;
font-size: 13.5px;
line-height: 1.6;
color: var(--text-sub);
}
/* ---------- 表单:奶油圆角输入 ---------- */
.form :deep(.el-form-item) {
position: relative;
padding-left: 16px;
margin-bottom: 28px;
}
.form :deep(.el-form-item__content) {
position: relative;
line-height: normal;
}
/* 左侧指示点 */
.form :deep(.el-form-item__content)::before {
content: '';
position: absolute;
left: -16px;
top: 50%;
transform: translateY(-50%);
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--switch-off);
transition: background .2s, box-shadow .2s;
}
.form :deep(.el-form-item:focus-within .el-form-item__content)::before {
background: var(--primary);
box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .16);
}
.form :deep(.el-form-item__label) {
padding-bottom: 6px;
font-size: 12px;
font-weight: 500;
letter-spacing: .02em;
line-height: 1.4;
color: var(--text-sub);
}
/* 圆角白底输入框 */
.form :deep(.el-input__wrapper) {
padding: 0 14px;
background: var(--surface-3);
border-radius: 12px;
border: 1px solid var(--border-warm);
box-shadow: inset 0 1px 2px rgba(var(--text-rgb), .03);
transition: border-color .2s, box-shadow .2s;
}
.form :deep(.el-input__wrapper:hover) { border-color: var(--border-hover); }
.form :deep(.el-input__wrapper.is-focus) {
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .14);
}
.form :deep(.el-input__inner) {
height: 48px;
padding: 0;
font-size: 15px;
color: var(--text);
caret-color: var(--primary);
}
/* 覆盖 Chrome 自动填充的浅蓝底(登录框带 autocomplete,记住密码后会被刷成蓝底白字) */
.form :deep(.el-input__wrapper input:-webkit-autofill),
.form :deep(.el-input__wrapper input:-webkit-autofill:hover),
.form :deep(.el-input__wrapper input:-webkit-autofill:focus) {
-webkit-box-shadow: 0 0 0 1000px var(--surface-3) inset !important;
-webkit-text-fill-color: var(--text) !important;
caret-color: var(--primary);
transition: background-color 9999s ease-out;
}
.form :deep(.el-input__inner::placeholder) { color: var(--placeholder); }
.form :deep(.el-input__suffix),
.form :deep(.el-input__prefix),
.form :deep(.el-input__suffix-inner) { color: var(--placeholder); }
.form :deep(.el-input__suffix-inner .el-input__icon:hover) { color: var(--text-sub); }
/* ---------- 主按钮:浅天蓝 ---------- */
.primary.el-button {
width: 100%;
height: 50px;
margin-top: 6px;
border: none;
border-radius: 14px;
background: var(--primary-grad-2);
color: var(--on-primary);
font-size: 14px;
font-weight: 600;
letter-spacing: .12em;
box-shadow: 0 12px 26px -14px rgba(var(--primary-rgb), .75);
transition: background-color .15s, opacity .15s, transform .12s ease, box-shadow .15s ease;
}
.primary.el-button:hover,
.primary.el-button:focus {
background: var(--primary-hover);
color: var(--on-primary);
transform: translateY(-1px);
box-shadow: 0 15px 30px -14px rgba(var(--primary-rgb), .85);
}
.primary.el-button:active {
background: var(--primary-strong);
transform: translateY(1px) scale(.99);
box-shadow: 0 6px 16px -12px rgba(var(--primary-rgb), .8);
}
.primary.el-button.is-disabled,
.primary.el-button.is-loading {
background: var(--primary-soft);
opacity: .55;
}
/* ---------- 分隔线 ---------- */
.divider {
display: flex;
align-items: center;
gap: 14px;
margin: 28px 0 16px;
font-size: 11.5px;
letter-spacing: .04em;
color: var(--text-faint);
}
.divider::before,
.divider::after {
content: '';
flex: 1;
height: 1px;
background: var(--border-warm);
}
/* ---------- 钉钉按钮:白底奶卡 ---------- */
.dingtalk.el-button {
width: 100%;
height: 50px;
border-radius: 14px;
background: var(--surface);
border: 1px solid var(--border-warm);
color: var(--text-warm-sub);
font-size: 14px;
font-weight: 500;
letter-spacing: .08em;
box-shadow: 0 6px 16px -12px rgba(var(--text-rgb), .16);
transition: all .18s ease;
}
.dingtalk.el-button:hover,
.dingtalk.el-button:focus {
color: var(--primary-strong);
border-color: var(--primary-line);
background: var(--primary-tint);
transform: translateY(-1px);
box-shadow: 0 10px 22px -14px rgba(var(--primary-rgb), .55);
}
.dingtalk.el-button:active { transform: translateY(1px) scale(.99); }
.dingtalk.el-button.is-disabled,
.dingtalk.el-button.is-loading { background: var(--surface-2); color: var(--text-disabled); opacity: .8; }
.dingtalk.el-button :deep(.el-icon) { color: var(--primary); }
/* ---------- 键盘可达 ---------- */
.primary.el-button:focus-visible,
.dingtalk.el-button:focus-visible {
outline: 2px solid var(--primary);
outline-offset: 3px;
}
/* ---------- 底部:流程状态 ---------- */
.footbar {
position: absolute;
bottom: 40px;
left: 48px;
right: 48px;
display: flex;
align-items: center;
justify-content: space-between;
z-index: 3;
}
.flows {
display: flex;
align-items: center;
gap: 10px;
font-size: 10.5px;
letter-spacing: .12em;
color: var(--text-warm-faint);
}
.f-blocks { display: flex; gap: 3px; }
.f-blocks i {
width: 12px;
height: 4px;
border-radius: 2px;
background: var(--switch-off);
}
.copyright {
font-size: 10.5px;
letter-spacing: .1em;
color: var(--text-faint);
}
/* ---------- 自适应 ---------- */
@media (max-width: 720px) {
.login { padding: 96px 20px 140px; }
.topbar { top: 24px; left: 24px; right: 24px; }
.footbar { bottom: 24px; left: 24px; right: 24px; }
.panel { padding: 32px 24px 30px; }
.panel h1 { font-size: 24px; }
.panel::after { left: 24px; right: 24px; }
.copyright { display: none; }
}
@media (max-height: 680px) {
.login {
align-items: flex-start;
overflow-x: hidden;
overflow-y: auto;
padding: 80px 24px 120px;
}
.footbar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
.dot,
.pipeline i,
.ghost {
animation: none;
}
.panel { animation: none; }
.core-mark,
.panel h1,
.panel .sub,
.form,
.divider,
.dingtalk {
animation: none;
}
* { transition-duration: .01ms !important; }
}
</style>
@@ -0,0 +1,163 @@
<template>
<div class="paccs">
<div v-for="p in platStatus" :key="p.id" class="pacc card">
<div class="p-top">
<span class="p-dot" :class="{ on: p.online }"></span>
<span class="p-name">{{ p.label }}</span>
<span class="p-state" :class="{ on: p.online }">{{ p.online ? '已登录' : '未登录' }}</span>
</div>
<div class="p-user" :class="{ none: !p.has_creds }">{{ p.has_creds ? p.user : '未配置个人账号' }}</div>
<div class="p-acts">
<el-button v-if="!p.online" size="small" :loading="busy === p.id" @click="login(p.id)">
{{ busy === p.id ? '登录中…' : '登录' }}
</el-button>
<el-button v-else size="small" plain type="danger" :disabled="!!busy" @click="logout(p.id)">
登出
</el-button>
<el-button size="small" text @click="openEdit(p)">配置账号</el-button>
</div>
</div>
<p class="p-hint">账号密码仅本机加密保存;登录后场景按<b>你的身份</b>执行。</p>
<!-- 账号配置弹窗 -->
<el-dialog v-model="dlg" :title="`配置 ${editLabel} 账号`" width="380px" align-center class="pacc-dlg">
<el-form label-width="72px" @submit.prevent>
<el-form-item label="登录账号">
<el-input v-model="form.user" placeholder="平台登录账号" maxlength="64" />
</el-form-item>
<el-form-item label="登录密码">
<el-input v-model="form.pass" type="password" show-password
:placeholder="hasCreds ? '新密码(留空表示不修改)' : '平台登录密码'" maxlength="64" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="dlg = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="save">保存</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { reactive, ref, onMounted, computed } from 'vue'
import { ElMessage } from 'element-plus'
import { store, log } from '../store'
import { loginPlatform, logoutPlatform, getPlatformStatus, savePlatformCreds } from '../api'
// 当前账号的平台状态(按账号隔离:各自 HR/OA 账号密码 + 各自会话)
const platStatus = ref([]) // [{id, label, online, has_creds, user}]
const dlg = ref(false) // 配置弹窗开关
const editing = ref(null) // 正在配置的平台对象
const form = reactive({ user: '', pass: '' })
const busy = ref('')
const saving = ref(false)
const editLabel = computed(() => (editing.value ? editing.value.label : ''))
const hasCreds = computed(() => !!(editing.value && editing.value.has_creds))
async function refresh() {
try {
const r = await getPlatformStatus()
platStatus.value = (r && r.platforms) || []
// 同步全局平台在线态(首页统计/场景徽章按当前账号展示)
for (const ps of platStatus.value) {
const p = store.platforms.find((x) => x.id === ps.id)
if (p) p.online = ps.online
}
} catch (_) { /* 静默 */ }
}
onMounted(refresh)
function openEdit(p) {
editing.value = p
form.user = p.user || ''
form.pass = ''
dlg.value = true
}
async function save() {
saving.value = true
try {
await savePlatformCreds({ [editing.value.id]: { user: form.user, pass: form.pass } })
ElMessage.success(`已保存 ${editing.value.label} 账号配置`)
dlg.value = false
await refresh()
} catch (e) {
ElMessage.error('保存失败:' + (e.message || e))
} finally {
saving.value = false
}
}
async function login(id) {
if (busy.value) return
const p = platStatus.value.find((x) => x.id === id)
if (p?.online) { ElMessage.success(`${p.label} 已登录`); return }
busy.value = id
try {
const r = await loginPlatform(id)
const ok = !!(r && r.online)
if (ok) log('INFO', `平台 ${p?.label || id} 登录成功`)
else log('ERROR', `平台 ${p?.label || id} 登录未生效:${(r && r.message) || ''}`)
ElMessage[ok ? 'success' : 'error'](
`${p?.label || id} ${ok ? '登录成功' : '登录失败:' + ((r && r.message) || '登录态未生效')}`
)
await refresh()
} catch (e) {
log('ERROR', `平台 ${p?.label || id} 登录失败:${e.message || e}`)
ElMessage.error(`登录失败:${e.message || e}`)
} finally {
busy.value = ''
}
}
async function logout(id) {
busy.value = id
try {
const r = await logoutPlatform(id)
const p = platStatus.value.find((x) => x.id === id)
if (p) p.online = !!r.online
log('INFO', `平台 ${p?.label || id} 已登出`)
ElMessage.success(`平台 ${p?.label || id} 已登出`)
await refresh()
} catch (e) {
log('ERROR', `平台 ${(platStatus.value.find((x) => x.id === id) || {}).label || id} 登出失败:${e.message || e}`)
ElMessage.error(`登出失败:${e.message || e}`)
} finally {
busy.value = ''
}
}
</script>
<style scoped>
.paccs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.pacc { padding: 13px 14px; display: flex; flex-direction: column; gap: 8px; }
.p-top { display: flex; align-items: center; gap: 8px; }
.p-dot {
flex: none; width: 8px; height: 8px; border-radius: 50%;
background: var(--sep-warm);
}
.p-dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(var(--ok-rgb), .16); }
.p-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.p-state {
margin-left: auto; font-size: 11px; color: var(--text-faint);
padding: 2px 9px; border-radius: 999px; background: var(--surface-2);
}
.p-state.on { color: var(--ok); background: var(--ok-weak); }
.p-user {
font-size: 11.5px; color: var(--text); font-variant-numeric: tabular-nums;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.p-user.none { color: var(--text-faint); }
.p-acts { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.p-acts .el-button + .el-button { margin-left: 0; }
.p-hint {
grid-column: 1 / -1;
margin: 2px 0 0; font-size: 11px; color: var(--text-faint); line-height: 1.7;
}
.p-hint b { color: var(--text-sub); }
/* 与首页常用场景共用同一容器查询断点:窄容器时同步降为 1 列,保证上下卡片始终对齐 */
@container (max-width: 380px) { .paccs { grid-template-columns: 1fr; } }
</style>
@@ -0,0 +1,685 @@
<template>
<div v-if="plugin" class="plugin-page">
<!-- Hero:场景身份 + 大执行按钮 -->
<section class="hero card">
<div class="hero-main">
<span class="avatar" :style="{ background: avatarBg }">{{ plugin.name.slice(0, 1) }}</span>
<div class="hero-meta">
<h2 class="p-name">{{ plugin.name }}
<span class="ver-tag">v{{ plugin.version }}</span>
</h2>
<p class="p-desc">{{ plugin.description || '暂无描述' }}</p>
<div class="p-badges">
<span v-if="plugin.platform" class="badge" :class="platformOnline ? 'on' : 'off'">
<i class="bdot"></i>{{ platformLabel }} {{ platformOnline ? '已登录' : '未登录' }}
</span>
<span v-if="plugin.uses_month" class="badge">
<el-select v-model="month" size="small" class="month-sel" :disabled="store.running">
<el-option v-for="m in months" :key="m" :value="m" :label="m" />
</el-select>
</span>
</div>
</div>
</div>
<div class="hero-actions">
<button class="run-btn" :class="{ running: store.running }" :disabled="store.running" @click="run">
<template v-if="store.running">
<span class="ring">
<svg viewBox="0 0 36 36" width="26" height="26">
<circle class="ring-bg" cx="18" cy="18" r="15.5" fill="none" stroke-width="3.5" />
<circle class="ring-fg" cx="18" cy="18" r="15.5" fill="none" stroke-width="3.5"
stroke-linecap="round" :stroke-dasharray="ringDash" transform="rotate(-90 18 18)" />
</svg>
</span>
<span>执行中 {{ store.progress }}%</span>
</template>
<template v-else>
<span class="play-ic">▶</span>
<span>一键执行</span>
</template>
</button>
<el-button v-if="rollbackVer" size="small" text type="warning" class="rollback-btn"
:disabled="store.running" @click="doRollback">回滚 v{{ rollbackVer }}</el-button>
<span class="hero-tip">配置与运行日志都在下方运行台</span>
</div>
</section>
<!-- 结果横幅 -->
<section v-if="store.lastResult" class="banner" :class="store.lastResult.ok ? 'ok' : 'err'">
<span class="b-ic">{{ store.lastResult.ok ? '✓' : '✕' }}</span>
<div class="b-body">
<b>{{ store.lastResult.ok ? (store.lastSummary || '执行完成') : '执行失败' }}</b>
<span v-if="!store.lastResult.ok">{{ store.lastResult.error }}</span>
</div>
<button class="b-close" @click="closeBanner" title="关闭">✕</button>
</section>
<!-- 运行台:参数 / 插件界面 / 运行日志
日志归属"本次运行"(不再是全局面板);带专属界面的插件用界面本身配置,故不并列参数表单 -->
<div class="run-tabs card">
<div class="rt-head">
<div class="rt-tabs">
<button v-for="t in tabs" :key="t.k" class="rt-tab" :class="{ on: tab === t.k }" @click="tab = t.k">
{{ t.label }}
<span v-if="t.k === 'log' && store.logs.length" class="rt-n">{{ store.logs.length }}</span>
<i v-if="t.k === 'log' && store.running" class="rt-live"></i>
</button>
</div>
<el-button v-if="tab === 'params' && fieldCount" size="small" text :disabled="store.running" :icon="RefreshLeft"
@click="resetForm">恢复默认</el-button>
</div>
<div class="rt-body">
<!-- 参数配置 -->
<section v-show="tab === 'params'" class="params">
<div class="cfg-bar">
<el-select v-model="curCfg" size="small" class="cfg-sel" placeholder="默认配置" @change="onCfgChange">
<el-option label="默认配置" value="" />
<el-option v-for="c in configs" :key="c.id" :value="c.id" :label="c.name" />
</el-select>
<el-button size="small" text :icon="FolderAdd" :disabled="store.running" @click="saveAsCfg">存为配置</el-button>
<el-button v-if="curCfg" size="small" text type="danger" :icon="Delete" :disabled="store.running" @click="delCfg">删除</el-button>
<span v-if="curCfgLabel" class="cfg-note">已套用「{{ curCfgLabel }}」,定时任务可引用</span>
</div>
<el-form label-width="auto" class="form-card">
<div class="fields">
<el-form-item v-for="f in plugin.fields" :key="f.key" :label="f.label">
<template v-if="f.type === 'int'">
<el-input-number v-model="form[f.key]" :controls="false" placeholder="0" :disabled="store.running" />
</template>
<el-input v-else-if="f.type === 'password'" v-model="form[f.key]" type="password" show-password
:placeholder="String(f.default ?? '')" :disabled="store.running">
<template v-if="f.help || f.description" #suffix>
<el-tooltip :content="f.help || f.description" placement="bottom"><el-icon class="help-ic">
<QuestionFilled />
</el-icon></el-tooltip>
</template>
</el-input>
<el-input v-else-if="f.type === 'text'" v-model="form[f.key]" :placeholder="String(f.default ?? '')"
:disabled="store.running">
<template v-if="f.help || f.description" #suffix>
<el-tooltip :content="f.help || f.description" placement="bottom"><el-icon class="help-ic">
<QuestionFilled />
</el-icon></el-tooltip>
</template>
</el-input>
<el-select v-else-if="f.type === 'multiselect'" v-model="form[f.key]" multiple filterable allow-create
default-first-option placeholder="选择或输入后回车" :disabled="store.running">
<el-option v-for="opt in (f.options || [])" :key="opt" :value="opt" :label="opt" />
</el-select>
<el-select v-else v-model="form[f.key]" :disabled="store.running">
<el-option v-for="opt in f.options" :key="opt" :value="opt" :label="opt" />
</el-select>
</el-form-item>
</div>
</el-form>
</section>
<!-- 插件专属界面(同源 iframe,自动携带会话 cookie)
sandbox 白名单加固:允许脚本/同源/表单,禁用 top 跳转与弹窗
仅一层容器承载尺寸,不再叠提示条/卡片 -->
<div v-if="plugin.ui" v-show="tab === 'ui'" class="ui-pane">
<iframe :key="plugin.id" :src="uiSrc" class="pui-frame" title="插件界面"
sandbox="allow-scripts allow-same-origin allow-forms"></iframe>
</div>
<!-- 运行日志(当前/本次运行) -->
<div v-show="tab === 'log'" class="rt-log"><LogPanel /></div>
<!-- 历史运行:本场景已完成的运行,点击回看该次日志 -->
<section v-show="tab === 'history'" class="history">
<div v-if="!replay" class="hist-view">
<div class="hist-head">
<span class="hist-title">本场景最近运行</span>
<el-button size="small" text :icon="Refresh" :loading="loadingRuns" @click="loadRuns">刷新</el-button>
</div>
<div v-if="!runs.length" class="hist-empty">
{{ loadingRuns ? '加载中…' : '该场景还没有运行记录,执行一次后这里可回看' }}
</div>
<ul v-else class="hist-list">
<li v-for="r in runs" :key="r.run_id" class="hist-item" @click="openReplay(r.run_id)">
<i class="hist-dot" :class="r.ok ? 'ok' : 'err'"></i>
<div class="hist-meta">
<b>{{ triggerLabel(r.trigger) }}</b>
<span class="hist-time">{{ fmtTime(r.started) }} · {{ durText(r.duration_sec) }}</span>
</div>
<span class="hist-state" :class="r.ok ? 'ok' : 'err'">{{ r.ok ? '成功' : '失败' }}</span>
<el-icon class="hist-arrow"><ArrowRight /></el-icon>
</li>
</ul>
</div>
<!-- 回看单次运行(结论 + 该次日志) -->
<div v-else class="hist-replay">
<div class="replay-head">
<el-button size="small" text :icon="ArrowLeft" :disabled="replayBusy" @click="replay = null">返回列表</el-button>
<div class="replay-tags">
<span class="badge" :class="replay.ok ? 'on' : 'off'"><i class="bdot"></i>{{ replay.ok ? '成功' : '失败' }}</span>
<span class="replay-tag">{{ triggerLabel(replay.trigger) }}</span>
<span class="replay-tag">{{ fmtTime(replay.started) }}</span>
<span class="replay-tag">耗时 {{ durText(replay.duration_sec) }}</span>
<span v-if="replay.summary" class="replay-sum">{{ replay.summary }}</span>
</div>
</div>
<div class="rt-log"><LogPanel :static-logs="replay.logs || []" /></div>
</div>
</section>
</div>
</div>
</div>
<div v-else-if="!store.plugins.length" class="empty-note">
<b>当前账号暂无可用场景</b><br>请联系管理员在控制面进行授权,授权后点击右上角刷新
</div>
<div v-else class="empty-note"><b>未选择场景</b></div>
</template>
<script setup>
import { computed, ref, watch } from 'vue'
import { QuestionFilled, Refresh, RefreshLeft, ArrowLeft, ArrowRight, FolderAdd, Delete } from '@element-plus/icons-vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { store, log } from '../store'
import { startRun, getRun, fetchRuns, fetchMeta, listRollbacks, rollbackPlugin, listPluginConfigs, savePluginConfig, deletePluginConfig } from '../api'
import LogPanel from './LogPanel.vue'
const GRADS = [
'var(--grad-sky)', 'var(--grad-peach)', 'var(--grad-mint)',
'var(--grad-lilac)', 'var(--grad-honey)', 'var(--grad-blush)',
]
const months = computed(() => {
const now = new Date()
const list = []
for (let off = 1; off <= 6; off++) {
const d = new Date(now.getFullYear(), now.getMonth() - off, 1)
list.push(`${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}`)
}
return list
})
const month = ref(months.value[0])
const idx = computed(() => Math.max(0, store.plugins.findIndex((p) => p.id === store.selectedId)))
const avatarBg = computed(() => GRADS[idx.value % GRADS.length])
const plugin = computed(() => store.plugins.find((p) => p.id === store.selectedId) || null)
const form = ref({})
function buildFormDefaults(p) {
const f = {}
if (p) p.fields.forEach((x) => (f[x.key] = x.default ?? (x.type === 'int' ? 0 : '')))
return f
}
watch(
() => plugin.value?.id,
(id) => {
form.value = buildFormDefaults(store.plugins.find((x) => x.id === id))
loadConfigs()
},
{ immediate: true }
)
function resetForm() {
form.value = buildFormDefaults(plugin.value)
curCfg.value = ''
}
// ===== 配置方案(多配置):把当前参数存成命名方案,运行台可一键套用、定时任务可引用 =====
const configs = ref([])
const curCfg = ref('')
const curCfgLabel = computed(() => {
if (!curCfg.value) return ''
const c = configs.value.find((x) => x.id === curCfg.value)
return c ? c.name : ''
})
async function loadConfigs() {
if (!plugin.value?.id) {
configs.value = []
curCfg.value = ''
return
}
try {
const r = await listPluginConfigs(plugin.value.id)
configs.value = r.configs || []
if (curCfg.value && !configs.value.some((c) => c.id === curCfg.value)) curCfg.value = ''
} catch (e) {
ElMessage.error('配置方案加载失败:' + (e.message || e))
}
}
function onCfgChange(id) {
const c = configs.value.find((x) => x.id === id)
if (!c) return
Object.assign(form.value, c.fields)
ElMessage.success(`已套用配置「${c.name}」`)
}
async function saveAsCfg() {
let name
try {
const r = await ElMessageBox.prompt('给这套参数起个名字(同名会覆盖旧配置)', '保存为配置', {
confirmButtonText: '保存',
cancelButtonText: '取消',
inputPattern: /\S+/,
inputErrorMessage: '名称不能为空',
inputValue: curCfgLabel.value || '',
})
name = r.value
} catch (e) {
if (e === 'cancel') return
throw e
}
try {
const r = await savePluginConfig(plugin.value.id, name, { ...form.value })
await loadConfigs()
curCfg.value = r.config.id
ElMessage.success(`配置「${r.config.name}」已保存`)
} catch (e) {
ElMessage.error(e.message || String(e))
}
}
async function delCfg() {
try {
await ElMessageBox.confirm(`确定删除配置「${curCfgLabel.value}」?`, '删除配置', {
type: 'warning',
confirmButtonText: '删除',
cancelButtonText: '取消',
})
} catch (_) { return }
try {
await deletePluginConfig(plugin.value.id, curCfg.value)
curCfg.value = ''
await loadConfigs()
ElMessage.success('已删除')
} catch (e) {
ElMessage.error('删除失败:' + (e.message || e))
}
}
// 专属界面插件:插件 UI 直接内嵌在页面主体(同源自动携带会话 cookie,不再弹窗/外跳)。
const uiSrc = computed(() => (plugin.value?.ui ? `/pui/${plugin.value.id}/` : ''))
// ===== 运行台标签页 =====
// 带专属界面的插件由界面自己配置参数,故不并列参数表单(与改造前语义一致)
const tabs = computed(() => {
const base = plugin.value?.ui
? [{ k: 'ui', label: '插件界面' }]
: [{ k: 'params', label: '参数配置' }]
return [...base, { k: 'log', label: '运行日志' }, { k: 'history', label: '历史运行' }]
})
const tab = ref('params')
const fieldCount = computed(() => (plugin.value?.fields || []).length)
watch(
() => plugin.value?.id,
(id) => {
tab.value = plugin.value?.ui ? 'ui' : 'params'
resetHistory()
consumePendingReplay()
},
{ immediate: true }
)
// ===== 历史运行 =====
const runs = ref([]) // 本场景最近运行(brief 列表)
const loadingRuns = ref(false)
const runsLoaded = ref(false) // 本场景是否已拉过(切换场景后重置)
const replay = ref(null) // 正在回看的单次运行 {brief..., logs:[...]}
const replayBusy = ref(false)
async function loadRuns() {
if (!plugin.value || loadingRuns.value) return
loadingRuns.value = true
try {
const data = await fetchRuns(60)
const mine = (data.runs || []).filter((r) => r.plugin_id === plugin.value.id)
runs.value = mine.slice(0, 30)
runsLoaded.value = true
} catch (_) { /* 历史是辅助能力,加载失败静默(列表保持上次/空) */ }
finally { loadingRuns.value = false }
}
async function openReplay(runId) {
if (!runId || replayBusy.value) return
replayBusy.value = true
try {
const data = await getRun(runId)
replay.value = { ...(data || {}), logs: (data && data.logs) || [] }
} catch (e) {
ElMessage.error('加载运行记录失败:' + (e.message || e))
} finally {
replayBusy.value = false
}
}
function resetHistory() {
runs.value = []
runsLoaded.value = false
replay.value = null
}
// 活动流「最近运行」点击 → 直达本场景回看:匹配当前场景则消费,否则等场景切换后消费
function consumePendingReplay() {
const p = store.pendingReplay
if (!p || !plugin.value || plugin.value.id !== p.pluginId) return false
store.pendingReplay = null
tab.value = 'history'
openReplay(p.runId)
return true
}
watch(() => store.pendingReplay, consumePendingReplay)
// 打开「历史运行」标签页且未拉过 → 拉取;运行结束(recents 变化)→ 若已拉过则刷新
watch(
() => tab.value,
(t) => { if (t === 'history' && !runsLoaded.value && !loadingRuns.value) loadRuns() }
)
watch(
() => store.recents.length,
() => { if (runsLoaded.value && !replay.value) loadRuns() }
)
function triggerLabel(t) {
return ({ manual: '手动执行', schedule: '定时任务' })[t] || t || '手动执行'
}
function durText(s) {
const n = parseInt(s, 10) || 0
if (n < 60) return n + 's'
const m = Math.floor(n / 60)
return m + '分' + (n % 60 ? (n % 60) + 's' : '')
}
function fmtTime(ts) {
if (!ts) return '—'
const d = new Date(ts * 1000)
if (isNaN(d.getTime())) return '—'
const p = (n) => String(n).padStart(2, '0')
return `${d.getMonth() + 1}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
}
// 执行进度环(SVG stroke-dasharray)
const RING_C = 2 * Math.PI * 15.5
const ringDash = computed(() => `${(store.progress / 100) * RING_C} ${RING_C}`)
const platformLabel = computed(() => {
const p = store.platforms.find((x) => x.id === plugin.value?.platform)
return p?.label || plugin.value?.platform || ''
})
const platformOnline = computed(() =>
!!(store.platforms.find((x) => x.id === plugin.value?.platform) || {}).online
)
// ===== 插件回滚(升级前自动备份上一版,坏包可回退) =====
const rollbackVer = ref('')
async function loadRollbackInfo() {
if (!plugin.value) return
rollbackVer.value = ''
try {
const r = await listRollbacks()
const item = (r.items || []).find((i) => i.id === plugin.value.id)
rollbackVer.value = item ? item.version : ''
} catch (_) { /* 本地能力,失败静默 */ }
}
watch(() => plugin.value?.id, loadRollbackInfo, { immediate: true })
async function doRollback() {
if (!plugin.value || !rollbackVer.value) return
try {
await ElMessageBox.confirm(
`将「${plugin.value.name}」回滚到 v${rollbackVer.value}(当前 v${plugin.value.version})。` +
'回滚后如需最新版,再次点击右上角同步即可。确定回滚?',
'插件回滚',
{ type: 'warning', confirmButtonText: '回滚', cancelButtonText: '取消' }
)
} catch (_) { return }
try {
await rollbackPlugin(plugin.value.id)
ElMessage.success(`已回滚到 v${rollbackVer.value}`)
// 刷新插件列表:版本号等元数据由 /api/meta 重新下发
const meta = await fetchMeta()
store.plugins = meta.plugins || []
rollbackVer.value = ''
} catch (e) {
ElMessage.error('回滚失败:' + (e.message || e))
}
}
async function run() {
if (!plugin.value || store.running) return
if (plugin.value.platform && !platformOnline.value) {
log('WARN', `插件「${plugin.value.name}」需要先登录平台「${platformLabel.value}」才能正确执行`)
}
store.running = true
store.progress = 0
store.currentRun = ''
store.lastResult = null
store.lastSummary = ''
const payload = { ...form.value }
if (plugin.value.uses_month) payload.ref_month = month.value // 仅月度插件注入月份
try {
const r = await startRun(plugin.value.id, payload)
store.lastRunId = r.run_id
} catch (e) {
store.running = false
store.lastResult = { ok: false, error: e.message || String(e) }
log('ERROR', `启动执行失败:${e.message || e}`)
}
}
// 完成时拉取后端摘要填充横幅
watch(
() => store.lastResult,
async (res) => {
if (res && res.ok && store.lastRunId) {
try {
const run = await getRun(store.lastRunId)
store.lastSummary = run.result?.summary || ''
} catch (e) { }
}
}
)
function closeBanner() {
store.lastResult = null
}
</script>
<style scoped>
.plugin-page {
display: flex;
flex-direction: column;
gap: 14px;
flex: 1 1 auto; /* 填满中栏上下文区,运行台内部自己滚 */
min-height: 0;
}
.card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-sm);
}
/* ---------- Hero ---------- */
.hero {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
padding: 22px 24px;
background: var(--hero-grad);
}
.hero-main { display: flex; align-items: center; gap: 16px; min-width: 0; }
.avatar {
width: 54px; height: 54px; border-radius: 16px; flex-shrink: 0;
display: grid; place-items: center; color: var(--tile-fg);
font-size: 22px; font-weight: 700;
box-shadow: 0 10px 22px -10px rgba(var(--text-rgb), .35);
}
.hero-meta { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.p-name { margin: 0; font-size: 19px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 9px; }
.ver-tag {
font-size: 10.5px; font-weight: 500; color: var(--text-faint);
background: var(--surface-2); border: 1px solid var(--border);
padding: 1px 8px; border-radius: 999px;
}
.p-desc { margin: 0; font-size: 12.5px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 560px; }
.p-badges { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.badge {
display: inline-flex; align-items: center; gap: 6px;
font-size: 11px; color: var(--badge-warm-text);
background: var(--badge-warm-bg); border: 1px solid var(--badge-warm-border);
padding: 2px 10px; border-radius: 999px;
}
.badge.on { color: var(--ok-text); background: var(--ok-weak); border-color: rgba(var(--ok-rgb), .3); }
.badge.off { color: var(--badge-off-text); }
.bdot { width: 6px; height: 6px; border-radius: 50%; background: var(--badge-dot); }
.badge.on .bdot { background: var(--ok); }
.month-sel { width: 108px; --el-component-size: 24px; }
.hero-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; flex-shrink: 0; }
.run-btn {
display: inline-flex; align-items: center; gap: 9px;
padding: 0 26px; height: 50px;
border: none; border-radius: 16px;
background: var(--primary-grad-2);
color: var(--on-primary); font-size: 15px; font-weight: 600; letter-spacing: .06em;
cursor: pointer; font-family: inherit;
box-shadow: 0 12px 26px -12px rgba(var(--primary-rgb), .85);
transition: all .16s ease;
}
.run-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 16px 30px -12px rgba(var(--primary-rgb), .95); }
.run-btn:active:not(:disabled) { transform: translateY(0) scale(.98); }
.run-btn.running { background: var(--primary-grad-3); cursor: default; min-width: 168px; font-variant-numeric: tabular-nums; }
/* 进度环用 CSS 上色(SVG 表现属性不支持 var(),故不写在 stroke="" 上) */
.ring-bg { stroke: rgba(var(--on-primary-rgb), .35); }
.ring-fg { stroke: var(--on-primary); }
.run-btn:disabled { opacity: 1; }
.play-ic { font-size: 13px; transform: translateY(-1px); }
.ring { display: inline-flex; }
.ring-fg { transition: stroke-dasharray .25s ease; }
.hero-tip { font-size: 10.5px; color: var(--text-faint); letter-spacing: .02em; }
.rollback-btn { margin-top: -3px; }
/* ---------- 结果横幅 ---------- */
.banner {
display: flex; align-items: center; gap: 11px;
padding: 12px 16px; border-radius: 14px;
animation: riseIn .3s var(--ease) both;
}
.banner.ok { background: var(--ok-weak); border: 1px solid rgba(var(--ok-rgb), .35); }
.banner.err { background: var(--err-weak); border: 1px solid rgba(var(--err-rgb), .4); }
.b-ic {
width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--on-primary);
}
.banner.ok .b-ic { background: var(--ok); }
.banner.err .b-ic { background: var(--err); }
.b-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.b-body b { font-size: 13px; color: var(--text); font-weight: 600; }
.b-body span { font-size: 12px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-close {
border: none; background: transparent; color: rgba(var(--text-rgb), .4);
cursor: pointer; font-size: 12px; padding: 4px; border-radius: 50%;
}
.b-close:hover { color: var(--text); background: rgba(var(--on-primary-rgb), .6); }
/* ---------- 运行台(标签页容器) ---------- */
.run-tabs {
flex: 1 1 auto; min-height: 300px;
display: flex; flex-direction: column; overflow: hidden;
}
.rt-head {
display: flex; align-items: center; justify-content: space-between; gap: 10px;
padding: 0 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.rt-tabs { display: flex; align-items: center; gap: 2px; }
.rt-tab {
display: inline-flex; align-items: center; gap: 6px;
border: none; background: transparent; cursor: pointer; font-family: inherit;
padding: 11px 14px; font-size: 13px; color: var(--text-sub);
border-bottom: 2px solid transparent; margin-bottom: -1px;
transition: color .13s, border-color .13s;
}
.rt-tab:hover { color: var(--text); }
.rt-tab.on { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }
.rt-n {
font-size: 10.5px; color: var(--text-faint); background: var(--surface-2);
border: 1px solid var(--border); border-radius: 999px; padding: 0 6px;
}
.rt-tab.on .rt-n { color: var(--primary); background: var(--primary-weak); border-color: var(--primary-line); }
.rt-live { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); animation: rtBlink 1s infinite; }
@keyframes rtBlink { 50% { opacity: .2; } }
.rt-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.rt-log { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
/* ---------- 专属界面插件 ---------- */
.ui-pane { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; padding: 14px 16px 16px; }
.pui-frame {
display: block; width: 100%; flex: 1 1 auto; min-height: 340px;
border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
/* ---------- 参数 ---------- */
.params { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 18px 22px 6px; }
.cfg-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.cfg-sel { width: 200px; }
.cfg-note { font-size: 11.5px; color: var(--text-faint); }
.fields { display: flex; gap: 24px; flex-wrap: wrap; }
.form-card .el-form-item { margin-bottom: 18px; }
.help-ic { color: var(--text-faint); cursor: help; }
/* ---------- 历史运行 ---------- */
.history { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.hist-view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.hist-head {
display: flex; align-items: center; justify-content: space-between; gap: 10px;
padding: 10px 16px 6px; flex-shrink: 0;
}
.hist-title { font-size: 12.5px; font-weight: 600; color: var(--text-sub); }
.hist-empty {
flex: 1 1 auto; display: grid; place-items: center;
color: var(--text-faint); font-size: 12.5px; padding: 30px 20px; text-align: center;
}
.hist-list { flex: 1 1 auto; min-height: 0; overflow: auto; list-style: none; margin: 4px 8px 10px; padding: 0; }
.hist-item {
display: flex; align-items: center; gap: 11px;
padding: 10px 12px; border-radius: 12px; cursor: pointer;
transition: background .13s ease;
}
.hist-item:hover { background: var(--surface-2); }
.hist-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.hist-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-weak); }
.hist-dot.err { background: var(--err); box-shadow: 0 0 0 3px var(--err-weak); }
.hist-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hist-meta b { font-size: 13px; color: var(--text); font-weight: 600; }
.hist-time { font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.hist-state { font-size: 12px; font-weight: 600; flex-shrink: 0; }
.hist-state.ok { color: var(--ok); }
.hist-state.err { color: var(--err); }
.hist-arrow { color: var(--text-faint); font-size: 13px; flex-shrink: 0; }
.hist-replay { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.replay-head {
display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
padding: 8px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.replay-tags { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; min-width: 0; }
.replay-tag {
font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums;
background: var(--surface-2); border: 1px solid var(--border);
padding: 1px 9px; border-radius: 999px;
}
.replay-sum {
font-size: 11.5px; color: var(--text-sub); white-space: nowrap;
overflow: hidden; text-overflow: ellipsis; max-width: 340px;
}
@keyframes riseIn {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: none; }
}
</style>
@@ -0,0 +1,124 @@
<template>
<div class="scenes-page">
<div class="head">
<div class="ident">
<span class="avatar"><el-icon><Collection /></el-icon></span>
<div class="ident-meta">
<h2>全部场景</h2>
<p>当前账号可用的 {{ store.plugins.length }} 个场景,点击行进入运行台</p>
</div>
</div>
</div>
<div class="sc-list card">
<button
v-for="(p, i) in store.plugins" :key="p.id" class="sc-row"
:class="{ running: store.running && store.selectedId === p.id }"
@click="open(p.id)"
>
<span class="sc-ic" :style="{ background: grad(i) }">{{ p.name.slice(0, 1) }}</span>
<span class="sc-body">
<span class="sc-title">
<b>{{ p.name }}</b>
<em>v{{ p.version }}</em>
</span>
<span class="sc-desc">{{ p.description || '暂无描述' }}</span>
<span v-if="p.platform" class="sc-meta">
{{ platformLabel(p.platform) }}
<i class="sep-dot"></i>
<em class="plat-state" :class="{ on: platformOnline(p.platform) }">
{{ platformOnline(p.platform) ? '已登录' : '未登录' }}
</em>
</span>
</span>
<span class="sc-go">
<template v-if="store.running && store.selectedId === p.id">{{ store.progress }}%</template>
<template v-else>执行</template>
</span>
</button>
<div v-if="!store.plugins.length" class="sc-empty">
<span class="empty-emoji">🤍</span>
<b>当前账号暂无可用场景</b>
<span>请联系管理员在控制面进行授权,授权后点左栏「同步」刷新</span>
</div>
</div>
</div>
</template>
<script setup>
import { Collection } from '@element-plus/icons-vue'
import { store } from '../store'
const GRADS = [
'var(--grad-sky)', 'var(--grad-peach)', 'var(--grad-mint)',
'var(--grad-lilac)', 'var(--grad-honey)', 'var(--grad-blush)',
]
function grad(i) { return GRADS[i % GRADS.length] }
function platformLabel(id) {
return (store.platforms.find((p) => p.id === id) || {}).label || id
}
function platformOnline(id) {
return !!(store.platforms.find((p) => p.id === id) || {}).online
}
function open(id) {
store.selectedId = id
store.view = 'run'
store.pendingReplay = null
}
</script>
<style scoped>
.scenes-page { display: flex; flex-direction: column; gap: 14px; padding: 4px 2px 10px; flex-shrink: 0; }
.head { display: flex; align-items: center; justify-content: space-between; }
.ident { display: flex; align-items: center; gap: 12px; }
.avatar {
width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
display: grid; place-items: center; color: var(--tile-fg);
background: var(--grad-sky); font-size: 15px;
}
.ident-meta h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
.ident-meta p { margin: 2px 0 0; font-size: 12px; color: var(--text-faint); }
.sc-list { display: flex; flex-direction: column; overflow: hidden; }
.sc-row {
display: flex; align-items: center; gap: 12px;
padding: 12px 16px; width: 100%; text-align: left;
border: none; border-bottom: 1px solid var(--border);
background: transparent; cursor: pointer; font-family: inherit;
transition: background .13s;
}
.sc-row:last-child { border-bottom: none; }
.sc-row:hover { background: var(--surface-2); }
.sc-row.running { background: var(--primary-tint); }
.sc-ic {
width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
display: grid; place-items: center; color: var(--tile-fg);
font-size: 14px; font-weight: 700;
}
.sc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sc-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.sc-title b { font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-title em { font-style: normal; font-size: 10.5px; color: var(--text-faint); font-family: var(--mono); flex-shrink: 0; }
.sc-desc { font-size: 12px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-meta { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text-faint); font-style: normal; }
.sep-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--dot-muted); }
.plat-state { font-style: normal; color: var(--text-muted-warm); }
.plat-state.on { color: var(--ok); }
.sc-go {
flex-shrink: 0; font-size: 12px; font-weight: 600;
color: var(--primary); background: var(--primary-weak);
border: 1px solid rgba(var(--primary-rgb), .35);
padding: 5px 14px; border-radius: 999px;
transition: all .15s ease;
}
.sc-row:hover .sc-go { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.sc-row.running .sc-go { color: var(--on-primary); background: var(--primary); border-color: transparent; font-variant-numeric: tabular-nums; }
.sc-empty {
display: flex; flex-direction: column; align-items: center; gap: 4px;
padding: 34px 20px; color: var(--text-faint); font-size: 12.5px;
}
.sc-empty .empty-emoji { font-size: 26px; }
.sc-empty b { color: var(--text-sub); font-size: 13.5px; font-weight: 600; }
</style>
@@ -0,0 +1,628 @@
<template>
<div class="sched-page">
<div class="head">
<div class="ident">
<span class="avatar"><el-icon><Clock /></el-icon></span>
<div class="ident-meta">
<h2>定时任务</h2>
<p>壳子内置定时:按 cron 到点自动执行插件,配置自动备份到中心机防丢失</p>
</div>
</div>
<el-button type="primary" :icon="Plus" @click="openCreate">新建任务</el-button>
</div>
<el-empty v-if="!list.length" description="暂无定时任务,点击右上角「新建任务」创建" />
<!-- 时间队列:按下次执行时间组织的任务行(替代生硬表格) -->
<div v-else class="sched-wrap">
<div class="sched-list card">
<div v-for="row in pagedList" :key="row.id" class="sched-row">
<div class="sr-when">
<b>{{ nextWhen(row).main }}</b>
<span>{{ nextWhen(row).sub }}</span>
</div>
<div class="sr-main">
<b>{{ row.name }}</b>
<span>{{ pluginName(row.plugin_id) }}</span>
</div>
<code class="cron-chip">{{ row.cron }}</code>
<div class="sr-last" :class="row.last_status === 'ok' ? 'ok' : (row.last_status === 'error' ? 'err' : '')">
<template v-if="row.last_run_at">
<span>上次 {{ fmtShort(row.last_run_at) }}</span>
<span class="st2">
<template v-if="row.last_status === 'ok'">✓ 成功<template v-if="row.last_duration"> · {{ row.last_duration }}s</template></template>
<template v-else-if="row.last_status === 'error'">✕ 失败</template>
</span>
</template>
<span v-else class="st2 none">从未执行</span>
</div>
<div class="sr-acts">
<el-switch :model-value="row.enabled" size="small" @change="(v) => onToggle(row, v)" />
<el-button link type="primary" @click="openEdit(row)">编辑</el-button>
<el-button link type="danger" @click="onDelete(row)">删除</el-button>
</div>
</div>
</div>
<el-pagination v-if="list.length > pageSize" class="sched-pager" small background
layout="prev, pager, next" :total="list.length" :page-size="pageSize"
:current-page="page" @current-change="(p) => page = p" />
</div>
<el-dialog v-model="dlg" :title="editing ? '编辑定时任务' : '新建定时任务'" width="min(780px, 94vw)" align-center
class="sched-dlg">
<el-form label-width="86px" class="dlg-form">
<el-form-item label="任务名称">
<el-input v-model="form.name" placeholder="如:每日考勤封存检查" maxlength="32" />
</el-form-item>
<el-form-item label="执行插件">
<el-select v-model="form.plugin_id" placeholder="选择要定时执行的插件" class="w-full" @change="onPluginChange">
<el-option v-for="p in store.plugins" :key="p.id" :value="p.id"
:label="`${p.name}(${p.id})`" />
</el-select>
</el-form-item>
<el-form-item v-if="form.plugin_id" label="使用配置">
<el-select v-model="cfgSel" class="w-full" placeholder="默认配置">
<el-option label="默认配置" value="" />
<el-option v-for="c in configs" :key="c.id" :value="c.id" :label="c.name" />
</el-select>
</el-form-item>
<el-form-item label="触发时间">
<div class="freq-zone">
<el-radio-group v-model="freq" class="freq-tabs" size="small">
<el-radio-button value="daily">每天</el-radio-button>
<el-radio-button value="weekdays">工作日</el-radio-button>
<el-radio-button value="weekly">每周</el-radio-button>
<el-radio-button value="monthly">每月</el-radio-button>
<el-radio-button value="hourly">每隔 N 小时</el-radio-button>
<el-radio-button value="advanced">高级</el-radio-button>
</el-radio-group>
<!-- 每天 / 工作日 -->
<div v-if="freq === 'daily' || freq === 'weekdays'" class="freq-row">
<span class="freq-desc">{{ freq === 'daily' ? '每天' : '周一至周五' }}</span>
<el-time-select v-model="timeStr" start="00:00" step="00:05" end="23:55"
placeholder="选择时间" class="time-sel" />
</div>
<!-- 每周:选周几 + 时间 -->
<div v-else-if="freq === 'weekly'" class="freq-row">
<span class="freq-desc">每周</span>
<el-checkbox-group v-model="weekdays" class="week-days">
<el-checkbox-button v-for="d in weekDayOpts" :key="d.v" :value="d.v">{{ d.label }}</el-checkbox-button>
</el-checkbox-group>
<el-time-select v-model="timeStr" start="00:00" step="00:05" end="23:55"
placeholder="选择时间" class="time-sel" />
</div>
<!-- 每月:选几号 + 时间 -->
<div v-else-if="freq === 'monthly'" class="freq-row">
<span class="freq-desc">每月</span>
<el-select v-model="monthDay" class="day-sel">
<el-option v-for="d in 31" :key="d" :value="d" :label="`${d} 日`" />
</el-select>
<el-time-select v-model="timeStr" start="00:00" step="00:05" end="23:55"
placeholder="选择时间" class="time-sel" />
</div>
<!-- 每隔 N 小时 -->
<div v-else-if="freq === 'hourly'" class="freq-row">
<span class="freq-desc">每隔</span>
<el-input-number v-model="hourlyStep" :min="1" :max="24" :controls="false" class="step-num" />
<span class="freq-desc">小时执行一次(整点)</span>
</div>
<!-- 高级:直接写 cron -->
<div v-else class="freq-row col">
<div class="cron-row">
<el-input v-model="advancedCron" placeholder="标准 5 段 cron,如 0 8 * * *" class="cron-input">
<template #prepend>cron</template>
</el-input>
<el-select v-model="preset" placeholder="快捷项" class="preset-sel" @change="onPreset">
<el-option v-for="p in presets" :key="p.cron" :value="p.cron" :label="p.label" />
</el-select>
</div>
<div class="cron-tip">5 段格式:分 时 日 月 周(0-59 0-23 1-31 1-12 0-6,0/7 均为周日)。最小间隔 1 小时,不支持分钟级触发</div>
</div>
<!-- 非高级模式下实时预览生成的 cron -->
<div v-if="freq !== 'advanced'" class="cron-preview">
表达式 <code>{{ form.cron }}</code>
</div>
</div>
</el-form-item>
<!-- 定时执行引用运行台保存的配置方案:不在此复刻参数字段表单(各场景字段千差万别) -->
<el-form-item label="执行配置">
<span class="params-tip">到点自动执行该场景,使用上方<b>所选配置</b>(默认 = 插件默认参数);自定义参数请在运行台「存为配置」后引用</span>
</el-form-item>
<el-form-item label="启用">
<el-switch v-model="form.enabled" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="dlg = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="onSave">保存</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { computed, ref, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Clock, Plus } from '@element-plus/icons-vue'
import { store } from '../store'
import { listSchedules, createSchedule, updateSchedule, deleteSchedule, toggleSchedule, listPluginConfigs } from '../api'
const list = ref([])
const dlg = ref(false)
const editing = ref(null)
const saving = ref(false)
const preset = ref('')
// ---- 列表分页:任务多时避免长列表刷屏 ----
const page = ref(1)
const pageSize = 8
const pagedList = computed(() => list.value.slice((page.value - 1) * pageSize, page.value * pageSize))
// 删除/清空后当前页可能超界,自动回退
watch(() => list.value.length, (n) => {
const max = Math.max(1, Math.ceil(n / pageSize))
if (page.value > max) page.value = max
})
// ---- 闹钟式触发时间选择状态 ----
// freq: daily=每天 weekdays=工作日 weekly=每周 monthly=每月 hourly=每隔N小时 advanced=高级cron
const freq = ref('daily')
const timeStr = ref('08:00')
const weekdays = ref([1])
const monthDay = ref(1)
const hourlyStep = ref(1)
const advancedCron = ref('')
const weekDayOpts = [
{ v: 1, label: '周一' }, { v: 2, label: '周二' }, { v: 3, label: '周三' },
{ v: 4, label: '周四' }, { v: 5, label: '周五' }, { v: 6, label: '周六' }, { v: 7, label: '周日' },
]
function pad2(n) { return String(n).padStart(2, '0') }
// 由可视化选择状态生成 cron 表达式(分钟/小时补齐 2 位,兼容解析)
function buildCron() {
const [h, m] = timeStr.value.split(':').map(Number)
switch (freq.value) {
case 'daily': return `${pad2(m)} ${pad2(h)} * * *`
case 'weekdays': return `${pad2(m)} ${pad2(h)} * * 1-5`
case 'weekly': {
const ds = (weekdays.value.length ? weekdays.value : [1]).slice().sort((a, b) => a - b)
return `${pad2(m)} ${pad2(h)} * * ${ds.join(',')}`
}
case 'monthly': return `${pad2(m)} ${pad2(h)} ${monthDay.value} * *`
case 'hourly': return `0 */${hourlyStep.value || 1} * * *`
default: return advancedCron.value.trim()
}
}
// 把已有 cron 反向解析为可视化选择状态;无法识别的回退到高级模式原样展示
function cronToState(cron) {
const s = String(cron || '').trim()
const parts = s.split(/\s+/)
const st = { freq: 'advanced', timeStr: '08:00', weekdays: [1], monthDay: 1, hourlyStep: 1, advancedCron: s }
if (parts.length !== 5) return st
const [m, h, dom, mon, dow] = parts
// 每隔 N 小时:0 */N * * *
if (m === '0' && /^\*\/\d+$/.test(h) && dom === '*' && mon === '*' && dow === '*') {
const step = parseInt(h.split('/')[1], 10)
if (step >= 1 && step <= 24) return { ...st, freq: 'hourly', hourlyStep: step }
}
const num = (x) => (/^\d+$/.test(x) ? parseInt(x, 10) : null)
const mn = num(m), hr = num(h)
if (mn == null || hr == null || mn < 0 || mn > 59 || hr < 0 || hr > 23) return st
const hhmm = pad2(hr) + ':' + pad2(mn)
if (dom === '*' && mon === '*') {
if (dow === '*') return { ...st, freq: 'daily', timeStr: hhmm }
if (dow === '1-5') return { ...st, freq: 'weekdays', timeStr: hhmm }
if (/^[0-7](,[0-7])*$/.test(dow)) {
const ds = [...new Set(dow.split(',').map(Number).map((x) => (x === 0 ? 7 : x)))].sort((a, b) => a - b)
return { ...st, freq: 'weekly', timeStr: hhmm, weekdays: ds }
}
return st
}
if (dow === '*' && mon === '*') {
const dd = num(dom)
if (dd != null && dd >= 1 && dd <= 31) return { ...st, freq: 'monthly', timeStr: hhmm, monthDay: dd }
}
return st
}
// 同步状态 → form.cron(打开弹窗时立即生成一次)
function syncCron() {
if (freq.value !== 'advanced') form.value.cron = buildCron()
}
// 选择状态变化时自动重写 form.cron
watch([freq, timeStr, weekdays, monthDay, hourlyStep], syncCron)
watch(advancedCron, (v) => {
if (freq.value === 'advanced') form.value.cron = v.trim()
})
const presets = [
{ label: '每天 08:00', cron: '0 8 * * *' },
{ label: '每天 12:00', cron: '0 12 * * *' },
{ label: '每天 18:00', cron: '0 18 * * *' },
{ label: '每小时整点', cron: '0 * * * *' },
{ label: '每周一 09:00', cron: '0 9 * * 1' },
{ label: '每月 1 日 09:00', cron: '0 9 1 * *' },
]
const form = ref({ name: '', plugin_id: '', cron: '', enabled: true, fields: {} })
function pluginName(id) {
return store.plugins.find((p) => p.id === id)?.name || id
}
// 下次执行时间的相对化展示(今天/明天/周几 + 日期)
function nextWhen(row) {
const s = row.next_run_at || ''
if (!s) return { main: '—', sub: '无下次触发' }
const d = new Date(String(s).replace(' ', 'T'))
if (isNaN(d.getTime())) return { main: String(s), sub: '' }
const now = new Date()
const today0 = new Date(now.getFullYear(), now.getMonth(), now.getDate())
const day0 = new Date(d.getFullYear(), d.getMonth(), d.getDate())
const diffDay = Math.round((day0 - today0) / 86400000)
const hm = pad2(d.getHours()) + ':' + pad2(d.getMinutes())
const week = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'][d.getDay()]
const md = (d.getMonth() + 1) + '-' + d.getDate()
let main
if (diffDay === 0) main = '今天 ' + hm
else if (diffDay === 1) main = '明天 ' + hm
else if (diffDay === -1) main = '昨天 ' + hm
else main = md + ' ' + hm
return { main, sub: md + ' ' + week }
}
// 最近执行时间简写(MM-DD HH:mm)
function fmtShort(s) {
if (!s) return ''
const d = new Date(String(s).replace(' ', 'T'))
if (isNaN(d.getTime())) return String(s)
return pad2(d.getMonth() + 1) + '-' + pad2(d.getDate()) + ' ' + pad2(d.getHours()) + ':' + pad2(d.getMinutes())
}
function buildFields(p) {
const f = {}
if (p) p.fields.forEach((x) => (f[x.key] = x.default ?? (x.type === 'int' ? 0 : '')))
return f
}
function onPluginChange(id) {
form.value.fields = buildFields(store.plugins.find((x) => x.id === id))
cfgSel.value = ''
loadConfigs(id)
}
// ===== 配置方案引用:运行台「存为配置」的方案可在此选用 =====
const configs = ref([])
const cfgSel = ref('')
async function loadConfigs(pluginId) {
configs.value = []
if (!pluginId) return
try {
const r = await listPluginConfigs(pluginId)
configs.value = r.configs || []
} catch (e) {
// 方案加载失败不阻塞任务编辑,静默降级为「默认配置」
}
}
// 把选中的配置方案字段应用到任务(未选 = 插件默认参数)
function applySelectedConfig() {
if (cfgSel.value) {
const c = configs.value.find((x) => x.id === cfgSel.value)
if (c) {
form.value.fields = { ...c.fields }
return
}
}
form.value.fields = buildFields(store.plugins.find((x) => x.id === form.value.plugin_id))
}
function onPreset(cron) {
advancedCron.value = cron
preset.value = ''
}
async function load() {
try {
const r = await listSchedules()
list.value = r.schedules || []
} catch (e) {
ElMessage.error('加载定时任务失败:' + (e.message || e))
}
}
function openCreate() {
editing.value = null
form.value = { name: '', plugin_id: '', cron: '', enabled: true, fields: {} }
cfgSel.value = ''
configs.value = []
// 默认:每天 08:00
freq.value = 'daily'
timeStr.value = '08:00'
weekdays.value = [1]
monthDay.value = 1
hourlyStep.value = 1
advancedCron.value = ''
syncCron()
dlg.value = true
}
function openEdit(row) {
editing.value = row
// 执行参数引用配置方案:编辑时先按「默认配置」展示,可自行改选
form.value = {
name: row.name || '',
plugin_id: row.plugin_id || '',
cron: row.cron || '',
enabled: !!row.enabled,
fields: buildFields(store.plugins.find((x) => x.id === row.plugin_id)),
}
cfgSel.value = ''
loadConfigs(row.plugin_id)
// 把已有 cron 解析回可视化选择状态
const st = cronToState(row.cron || '')
freq.value = st.freq
timeStr.value = st.timeStr
weekdays.value = st.weekdays
monthDay.value = st.monthDay
hourlyStep.value = st.hourlyStep
advancedCron.value = st.advancedCron
syncCron()
dlg.value = true
}
async function onSave() {
if (!form.value.plugin_id) { ElMessage.warning('请选择执行插件'); return }
if (!form.value.cron.trim()) { ElMessage.warning('请填写 cron 表达式'); return }
applySelectedConfig()
saving.value = true
try {
if (editing.value) {
await updateSchedule(editing.value.id, { ...form.value })
ElMessage.success('已保存')
} else {
await createSchedule({ ...form.value })
ElMessage.success('已创建,配置已备份到中心机')
}
dlg.value = false
await load()
} catch (e) {
ElMessage.error(e.message || String(e))
} finally {
saving.value = false
}
}
async function onToggle(row, v) {
try {
await toggleSchedule(row.id, v)
row.enabled = v
ElMessage.success(v ? '已启用' : '已停用')
} catch (e) {
ElMessage.error('操作失败:' + (e.message || e))
}
}
async function onDelete(row) {
try {
await ElMessageBox.confirm(`确定删除定时任务「${row.name}」?删除后其配置备份会一并移除。`, '删除确认', {
type: 'warning',
confirmButtonText: '删除',
cancelButtonText: '取消',
})
} catch (_) { return }
try {
await deleteSchedule(row.id)
ElMessage.success('已删除')
await load()
} catch (e) {
ElMessage.error('删除失败:' + (e.message || e))
}
}
load()
</script>
<style scoped>
.sched-page {
display: flex;
flex-direction: column;
gap: 18px;
flex-shrink: 0; /* 自然高度,超出由中栏上下文区整体滚动 */
}
.head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
}
.ident {
display: flex;
align-items: center;
gap: 14px;
min-width: 0;
}
.avatar {
width: 44px;
height: 44px;
border-radius: 13px;
flex-shrink: 0;
display: grid;
place-items: center;
color: var(--on-primary);
background: var(--primary-grad);
box-shadow: var(--shadow-md);
font-size: 18px;
}
.ident-meta {
display: flex;
flex-direction: column;
gap: 2px;
min-width: 0;
}
.ident-meta h2 {
margin: 0;
font-size: 17px;
}
.ident-meta p {
margin: 0;
font-size: 12px;
color: var(--text-sub);
}
/* ---------- 时间队列列表(替代表格) ---------- */
.sched-wrap { display: flex; flex-direction: column; gap: 10px; }
.sched-list { display: flex; flex-direction: column; overflow: hidden; }
.sched-row {
display: flex; align-items: center; gap: 14px;
padding: 12px 16px;
border-bottom: 1px solid var(--border);
transition: background .13s;
}
.sched-row:last-child { border-bottom: none; }
.sched-row:hover { background: var(--surface-2); }
.sr-when { width: 108px; flex-shrink: 0; }
.sr-when b { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.sr-when span { font-size: 10.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.sr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sr-main b { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-main span { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cron-chip {
flex-shrink: 0;
font-family: var(--mono); font-size: 11px; color: var(--primary);
background: var(--primary-weak); border: 1px solid rgba(var(--primary-rgb), .3);
border-radius: 6px; padding: 2px 8px;
}
.sr-last { width: 150px; flex-shrink: 0; display: flex; flex-direction: column; gap: 1px; font-size: 11px; color: var(--text-faint); }
.sr-last .st2 { font-size: 10.5px; }
.sr-last.ok .st2 { color: var(--ok); }
.sr-last.err .st2 { color: var(--err); }
.sr-last .st2.none { color: var(--text-faint); }
.sr-acts { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.sr-acts .el-button + .el-button { margin-left: 0; }
.sched-pager { justify-content: center; }
.cron-row {
display: flex;
gap: 8px;
width: 100%;
}
.cron-input {
flex: 1;
}
.preset-sel {
width: 128px;
}
.cron-tip {
font-size: 11px;
color: var(--text-faint);
margin-top: 6px;
width: 100%;
}
/* ---- 闹钟式触发时间选择 ---- */
.freq-zone {
display: flex;
flex-direction: column;
gap: 10px;
width: 100%;
}
.freq-tabs {
display: flex;
flex-wrap: wrap;
}
.freq-row {
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
width: 100%;
}
.freq-row.col {
flex-direction: column;
align-items: stretch;
}
.freq-desc {
font-size: 13px;
color: var(--text-sub);
white-space: nowrap;
}
.time-sel {
width: 130px;
}
.day-sel {
width: 110px;
}
.step-num {
width: 90px;
}
.week-days {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.cron-preview {
display: flex;
align-items: center;
gap: 8px;
font-size: 12px;
color: var(--text-faint);
}
.cron-preview code {
padding: 1px 8px;
border-radius: 6px;
background: var(--surface-2);
border: 1px solid var(--border);
font-size: 12px;
color: var(--text);
}
.params-tip {
font-size: 12.5px; color: var(--text-sub); line-height: 1.7;
background: var(--surface-2); border: 1px solid var(--border);
border-radius: 10px; padding: 9px 13px; width: 100%;
}
.params-tip b { color: var(--primary); font-weight: 600; }
.w-full {
width: 100%;
}
/* 定时任务弹窗:内容超高时弹窗内滚动,避免配置多的插件把弹窗顶出屏幕 */
:deep(.sched-dlg .el-dialog) {
max-height: 90vh;
}
:deep(.sched-dlg .el-dialog__body) {
max-height: 62vh;
overflow-y: auto;
}
</style>
@@ -0,0 +1,97 @@
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'element-plus/dist/index.css'
import App from './App.vue'
import './style.css'
const app = createApp(App)
// 全量注册图标,模板中可直接 <component :is="XxxIcon"> 使用
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
}
app.use(ElementPlus, { locale: zhCn }).mount('#app')
/* ============================================================
皮肤(skin):只切 token,不改组件。
precision = 冷灰 + 压深天蓝的精密工作台(默认)
cream = 奶油极简治愈风(旧皮肤,保留可切换)
切换:localStorage['37du.skin'] = 'precision' | 'cream'
============================================================ */
const SKIN_KEY = '37du.skin'
const SKINS = ['cream', 'precision']
function initSkin() {
let skin = 'precision'
try { skin = localStorage.getItem(SKIN_KEY) || 'precision' } catch (_) { /* 隐私模式等 */ }
if (!SKINS.includes(skin)) skin = 'precision'
document.documentElement.dataset.skin = skin
}
// 在挂载前应用,避免首屏闪一下默认皮肤
initSkin()
/* ============================================================
奶油涂鸦装饰层:fixed 浮于页面顶层,仅视觉点缀。
可开关:localStorage['37du.doodles'] = 'off'(登录页顶部 ✿ 按钮同源)
注意:涂鸦是奶油皮肤专属装饰,precision 皮肤下由 CSS 整体隐藏。
============================================================ */
const DOODLES = {
squiggle:
'<svg width="90" height="46" viewBox="0 0 90 46" fill="none">' +
'<path d="M4 34 Q 16 6 30 28 T 58 22 T 84 26" stroke="#7CC3E8" stroke-width="3" stroke-linecap="round"/>' +
'<path d="M6 41 Q 22 20 38 38 T 66 34" stroke="#E5D9C5" stroke-width="2.4" stroke-linecap="round"/></svg>',
cloud:
'<svg width="70" height="44" viewBox="0 0 70 44" fill="none">' +
'<path d="M18 36 a10 10 0 0 1-1-19.8 A13 13 0 0 1 42 14.5 a9.5 9.5 0 0 1 10 8.6 A8 8 0 0 1 51 36Z" fill="#DCEFF9" stroke="#A8D8F2" stroke-width="2"/></svg>',
sparkles:
'<svg width="80" height="60" viewBox="0 0 80 60" fill="none">' +
'<path d="M14 8 l2.6 5.4 5.4 2.6 -5.4 2.6 -2.6 5.4 -2.6 -5.4 -5.4 -2.6 5.4 -2.6Z" fill="#F2C96B"/>' +
'<path d="M62 6 l1.8 3.7 3.7 1.8 -3.7 1.8 -1.8 3.7 -1.8 -3.7 -3.7 -1.8 3.7 -1.8Z" fill="#7CC3E8"/>' +
'<path d="M40 30 l2 4 4 2 -4 2 -2 4 -2 -4 -4 -2 4 -2Z" fill="#E58B8B"/></svg>',
heart:
'<svg width="46" height="42" viewBox="0 0 46 42" fill="none">' +
'<path d="M23 38 C 10 29 3 21 3 13 A 10 10 0 0 1 23 9 A 10 10 0 0 1 43 13 C 43 21 36 29 23 38Z" fill="#FBE3E0" stroke="#E9A7A0" stroke-width="2.4"/></svg>',
plant:
'<svg width="60" height="66" viewBox="0 0 60 66" fill="none">' +
'<path d="M30 62 V 26" stroke="#9BC88F" stroke-width="3" stroke-linecap="round"/>' +
'<path d="M30 30 C 18 30 14 18 16 10 C 24 10 28 18 30 22 C 32 15 38 9 46 10 C 46 18 40 28 30 30Z" fill="#D9EED1" stroke="#9BC88F" stroke-width="2"/>' +
'<path d="M30 44 C 22 44 18 36 19 30 C 26 30 29 36 30 40 C 34 34 40 31 45 32 C 43 40 37 44 30 44Z" fill="#C6E6BB" stroke="#9BC88F" stroke-width="2"/></svg>',
sun:
'<svg width="54" height="54" viewBox="0 0 54 54" fill="none">' +
'<circle cx="27" cy="27" r="12" fill="#FFF2C9" stroke="#F2C96B" stroke-width="2.4"/>' +
'<g stroke="#F2C96B" stroke-width="2.6" stroke-linecap="round">' +
'<path d="M27 4v7M27 43v7M4 27h7M43 27h7M10 10l5 5M39 39l5 5M44 10l-5 5M15 39l-5 5"/></g></svg>',
}
function initDoodles() {
if (document.getElementById('dsh-doodles')) return
const wrap = document.createElement('div')
wrap.id = 'dsh-doodles'
// [类型, left, top, 水平翻转]
const spots = [
['squiggle', '6%', '12%', false],
['cloud', '88%', '8%', false],
['sun', '93%', '40%', false],
['sparkles', '78%', '66%', false],
['heart', '5%', '68%', false],
['plant', '13%', '36%', true],
]
for (const [name, left, top, flip] of spots) {
const el = document.createElement('span')
el.className = 'doodle'
el.style.left = left
el.style.top = top
el.innerHTML = DOODLES[name] || DOODLES.sparkles
if (flip) el.querySelector('svg').style.transform = 'scaleX(-1)'
wrap.appendChild(el)
}
document.body.appendChild(wrap)
let on = 'on'
try { on = localStorage.getItem('37du.doodles') || 'on' } catch (_) {}
document.documentElement.classList.toggle('no-doodles', on === 'off')
}
// 应用挂载后注入(body 已存在),不阻塞首屏
initDoodles()
@@ -0,0 +1,125 @@
import { reactive } from 'vue'
export const store = reactive({
appName: '',
platforms: [],
plugins: [],
selectedId: '',
logs: [], // {time, level, msg}
progress: 0,
running: false,
currentRun: '', // 当前接收日志/进度的 run_id
lastRunId: '', // 最近一次执行的 run_id
lastResult: null, // {ok, error}
lastSummary: '', // 完成时后端返回的摘要
wsOn: false,
// 个人身份信息(中心机 accounts,登录/会话校验回填)
dept: '',
nickname: '', // 真实姓名(中心机 accounts.nickname,钉钉登录时自动带入)
avatar: '', // 账号头像文件名(中心机 accounts.avatar,用户上传)
avatarUrl: '', // 在线头像(localStorage 缓存,避免每次刷新都请求)
current: (() => { try { return localStorage.getItem('cp_account') || '' } catch (_) { return '' } })(),
// 当前主视图(Run-centric 三栏:总览 / 运行台 / 计划)
// overview 总览(工作台首页)· run 运行台(单场景执行)· plans 计划(定时任务)
view: 'overview',
authExpired: false, // 授权票据已过期(最长离线 7 天),须联网刷新才能继续使用
license: null, // 授权票据概要 {status, expire_ts, expire_at, days_left}(/api/meta 下发,供状态栏展示)
recents: [], // 最近运行记录(run_done 时追加):{pluginId, runId, ok, error, time, name}
_runPlugins: {}, // run_id → plugin_id(run_start 登记,run_done 消费)
pendingReplay: null, // 活动流点击最近运行 → 运行台回看:{pluginId, runId}(PluginPage 消费后清空)
})
// ===== 在线头像:优先读缓存,无缓存时请求接口并落盘;图片加载失败时清除缓存重新拉取 =====
// 缓存按账号隔离(cp_avatar_url_<账号>),切换账号不会串用上一个人的头像
const AVATAR_API = 'https://v2.xxapi.cn/api/head'
function avatarCacheKey() {
return `cp_avatar_url_${store.current || 'anon'}`
}
export function loadAvatar() {
const key = avatarCacheKey()
try {
const cached = localStorage.getItem(key)
if (cached) { store.avatarUrl = cached; return }
} catch (_) {}
store.avatarUrl = ''
fetch(AVATAR_API, { signal: AbortSignal.timeout(4000) })
.then((r) => r.json())
.then((j) => {
if (j && j.code === 200 && j.data) {
store.avatarUrl = j.data
try { localStorage.setItem(avatarCacheKey(), j.data) } catch (_) {}
}
})
.catch(() => { /* 网络不可达/超时:保持首字符色块兜底 */ })
}
export function clearAvatarCache() {
store.avatarUrl = ''
try { localStorage.removeItem(avatarCacheKey()) } catch (_) {}
loadAvatar()
}
// 头像优先级:账号上传头像(中心机) > 外部随机头像 > 首字符兜底
export function accountAvatar() {
if (store.avatar) {
return `/api/avatar/${store.current}?v=${encodeURIComponent(store.avatar)}`
}
return store.avatarUrl
}
export function clearLogs() {
store.logs = []
store.lastResult = null
store.lastSummary = ''
}
export function log(level, msg) {
const time = new Date().toLocaleTimeString('zh-CN', { hour12: false })
store.logs.push({ time, level, msg })
if (store.logs.length > 500) store.logs.splice(0, store.logs.length - 500)
}
export function handleEvent(ev) {
switch (ev.t) {
case 'run_start':
store.currentRun = ev.run_id
store._runPlugins[ev.run_id] = ev.plugin_id || ''
// 运行态由事件驱动:定时任务触发的运行没有本地点击,必须靠 run_start 点亮
// (设备级单活,同时只会有一个 run)。日志归属本次运行,故开始时清空。
clearLogs()
store.running = true
store.progress = 0
break
case 'log':
if (ev.run_id === store.currentRun || !store.currentRun) {
log(ev.level || 'INFO', ev.msg)
}
break
case 'progress':
if (ev.run_id === store.currentRun) store.progress = ev.pct
break
case 'run_done':
store.running = false
store.progress = 100
store.lastResult = { ok: ev.ok, error: ev.error || '' }
if (ev.ok) log('INFO', '===== 执行完成 =====')
else log('ERROR', `执行失败:${ev.error}`)
store.currentRun = ''
// 最近运行记录(供总览首页展示)
const pid = store._runPlugins[ev.run_id] || ''
delete store._runPlugins[ev.run_id]
const rec = {
pluginId: pid,
runId: ev.run_id || '',
name: (store.plugins.find((p) => p.id === pid) || {}).name || pid || '未知场景',
ok: !!ev.ok,
error: ev.error || '',
time: new Date().toLocaleTimeString('zh-CN', { hour12: false }),
}
store.recents.unshift(rec)
if (store.recents.length > 8) store.recents.pop()
break
}
}
@@ -0,0 +1,429 @@
/* ============ 37du 执行机壳 · 设计令牌(token 层) ============
规则:组件内**只允许**引用这里的 token,不写字面色值(rgba 一律走 --*-rgb 变量)。
换肤只需在 [data-skin="..."] 里重映射同名 token,组件代码零改动。
默认皮肤 = cream(奶油极简治愈风,现状像素级不变)。
============================================================ */
:root {
/* ---- 基础 ---- */
--bg: #F9F7F2;
--bg-grad: radial-gradient(1200px 720px at 50% -8%, #FDFCF8 0%, #F9F7F2 55%, #F4F1EA 100%);
--surface: #ffffff;
--surface-2: #F6F3EC;
--surface-3: #FDFCF9; /* 输入框底 */
--surface-glow: #FBFDFF; /* 卡片高亮底(运行中/渐变收尾) */
--border: #EFE9DE;
--border-strong: #E0D9C9;
--border-warm: #E7E0D2; /* 登录页卡片描边 */
--border-warm-2: #F1ECE2; /* 更浅一级描边 */
--border-hover: #D6CFC0;
--row-hover: #F8F5EF; /* 日志行 hover */
--track: #EDE7DB; /* 进度条底槽 */
--scrollbar: #DED7C8;
--scrollbar-hover: #CCC4B2;
--text: #222222;
--text-sub: #666666;
--text-faint: #9C9589;
--text-warm-sub: #5B5B5B;
--text-warm-faint: #8A8377;
--text-muted-warm: #C4B89E; /* 未登录/未配置的弱提示 */
--text-disabled: #C9C2B4;
--placeholder: #B5AD9D;
--on-primary: #ffffff; /* 主色/渐变底上的前景 */
--text-rgb: 34, 34, 34;
--on-primary-rgb: 255, 255, 255;
--primary: #7CC3E8; /* 浅天蓝 · 辅助强调色 */
--primary-2: #A8D8F2;
--primary-rgb: 124, 195, 232;
--primary-grad: linear-gradient(135deg, #92D1F0 0%, #6FBAE6 100%);
--primary-grad-2: linear-gradient(135deg, #8FD0F0 0%, #6FBAE6 100%);
--primary-grad-3: linear-gradient(135deg, #9BD1EE, #7CC3E8);
--primary-strong: #5FAFD9;
--primary-hover: #6FBAE6; /* 主按钮 hover 底(纯色,与渐变收尾同色) */
--primary-soft: #9BD1EE;
--primary-line: #BFE2F4;
--primary-weak: #EFF7FC;
--primary-weak-2: #E3F1FA;
--primary-tint: #F4FAFD;
--primary-disabled: #C9E6F5;
--ok: #5BBE96;
--ok-weak: #E9F7F0;
--ok-text: #3F9E77;
--ok-text-2: #1a8f63;
--ok-rgb: 91, 190, 150;
--ok-rgb-2: 34, 176, 122;
--err: #E58B8B;
--err-weak: #FBF0F0;
--err-rgb: 229, 139, 139;
--danger: #e5484d; /* 对话框错误文案(比 --err 更重的红) */
--warn: #E0A85C;
--warn-weak: #FBF3E3;
--warn-bg: #FFF4E5;
--warn-text: #9A5B14;
--warn-rgb: 224, 122, 40;
--warn-icon-rgb: 247, 162, 58;
/* ---- 场景磁贴 / 装饰 ---- */
--tile-fg: #ffffff; /* 磁贴前景(皮肤若改用淡色底需同步改这个) */
--tile-faint-bg: #E3DED2;
--dot-off: #c6ccdc;
--dot-muted: #D0C9BA;
--sep-warm: #CFC8B8;
--switch-off: #D8D0BF;
--badge-warm-text: #A08F6F;
--badge-warm-bg: #FBF7EE;
--badge-warm-border: #EFE4CB;
--badge-off-text: #B09E7E;
--badge-dot: #C9BFA6;
--border-strong-rgb: 224, 217, 201;
--chrome-rgb: 74, 140, 247;
--chrome-icon: radial-gradient(circle at 30% 30%, #e6f2ff, #4a8cf7 55%, #2b6be0);
--chrome-icon-warn: radial-gradient(circle at 30% 30%, #fff6e6, #f7a23a 55%, #e07324);
--hero-grad: linear-gradient(120deg, #FFFFFF 0%, #FBFDFF 55%, #F7FBFE 100%);
--profile-head-grad: linear-gradient(135deg, #dfe7ff 0%, #eef2ff 55%, #f6f8ff 100%);
--surface-cool: #f6f8fd;
--surface-cool-2: #fafbfe;
/* ---- 阴影:仅极柔和浅阴影 ---- */
--shadow-sm: 0 1px 3px rgba(var(--text-rgb), .05), 0 2px 10px -4px rgba(var(--text-rgb), .06);
--shadow-md: 0 8px 24px -14px rgba(var(--text-rgb), .14);
--shadow-lift: 0 14px 34px -16px rgba(var(--text-rgb), .18);
/* ---- 圆角:全局大圆角 ---- */
--radius: 16px;
--radius-sm: 11px;
/* ---- 字体:正文无衬线 Inter;标题可用圆润手写装饰字体 ---- */
--mono: "JetBrains Mono", "Consolas", "Courier New", monospace;
--font-mono: "JetBrains Mono", "Consolas", "Courier New", monospace;
--font-body: "Inter", "Segoe UI", "Microsoft YaHei UI", "PingFang SC", -apple-system, sans-serif;
--font-doodle: "Segoe Script", "Comic Sans MS", "KaiTi", "STKaiti", "cursive";
/* ---- element-plus 主题与浅天蓝统一 ---- */
--el-color-primary: #7CC3E8;
--el-color-primary-light-3: #9BD1EE;
--el-color-primary-light-5: #BFE2F4;
--el-color-primary-light-7: #DCEFF9;
--el-color-primary-light-8: #E9F5FB;
--el-color-primary-light-9: #F4FAFD;
--el-color-primary-dark-2: #5FAFD9;
--el-border-radius-base: 12px;
--el-border-radius-small: 10px;
--el-border-radius-round: 999px;
--el-box-shadow: 0 8px 24px -16px rgba(var(--text-rgb), .14);
--el-box-shadow-light: 0 6px 18px -14px rgba(var(--text-rgb), .10);
/* ---- 产品级排版/间距/动效 ---- */
--radius-lg: 22px;
--space-1: 4px;
--space-2: 8px;
--space-3: 12px;
--space-4: 16px;
--space-5: 20px;
--space-6: 28px;
--dur: .18s;
--ease: cubic-bezier(.22, 1, .36, 1);
--grad-sky: linear-gradient(135deg, #A8D8F2, #7CC3E8);
--grad-peach: linear-gradient(135deg, #F2C9B8, #E8A98E);
--grad-mint: linear-gradient(135deg, #C9E6BB, #9BC88F);
--grad-lilac: linear-gradient(135deg, #D9C7F0, #B79AE3);
--grad-honey: linear-gradient(135deg, #F7D9A0, #EFBE6B);
--grad-blush: linear-gradient(135deg, #F2B8C6, #E48E9F);
}
/* ============================================================
皮肤 · precision(冷灰 + 压深天蓝的"精密工作台")
—— 只是 token 重映射的**首版脚手架**,用于后续「双皮肤同页对比」评审;
尚未做像素级打磨,也不改变任何组件代码。默认不启用:
启用方式 = <html data-skin="precision">(localStorage['37du.skin'])。
============================================================ */
[data-skin="precision"] {
--bg: #F4F6F9;
--bg-grad: #F4F6F9; /* 冷灰画布:去掉奶油径向渐变 */
--surface: #FFFFFF;
--surface-2: #F1F4F8;
--surface-3: #FFFFFF;
--surface-glow: #F8FAFC;
--border: #E4E9F0;
--border-strong: #CDD6E1;
--border-warm: #E4E9F0;
--border-warm-2: #EEF2F7;
--border-hover: #CDD6E1;
--row-hover: #F1F4F8;
--track: #E4E9F0;
--scrollbar: #CBD5E1;
--scrollbar-hover: #94A3B8;
--text: #182230;
--text-sub: #5A6674;
--text-faint: #7C8896;
--text-warm-sub: #5A6674;
--text-warm-faint: #7C8896;
--text-muted-warm: #7C8896;
--text-disabled: #A8B3C1;
--placeholder: #94A3B8;
--on-primary: #FFFFFF;
--text-rgb: 15, 23, 42;
--on-primary-rgb: 255, 255, 255;
--primary: #1E6FA8;
--primary-2: #3E93CF;
--primary-rgb: 30, 111, 168;
--primary-grad: #17608F; /* 皮肤可把渐变 token 设成纯色 */
--primary-grad-2: #1E6FA8;
--primary-grad-3: #3E93CF;
--primary-strong: #17608F;
--primary-hover: #1E6FA8;
--primary-soft: #3E93CF;
--primary-line: #CDD6E1;
--primary-weak: #E9F2FA;
--primary-weak-2: #E9F2FA;
--primary-tint: #E9F2FA;
--primary-disabled: #BFD8EA;
/* element-plus 主题同步(否则表单/表格等内置组件会残留奶油浅蓝) */
--el-color-primary: #1E6FA8;
--el-color-primary-light-3: #3E93CF;
--el-color-primary-light-5: #7FB4D8;
--el-color-primary-light-7: #BFD8EA;
--el-color-primary-light-8: #D9E8F4;
--el-color-primary-light-9: #E9F2FA;
--el-color-primary-dark-2: #17608F;
--ok: #1F8A4C;
--ok-weak: #E7F5EC;
--ok-text: #1F8A4C;
--ok-text-2: #1F8A4C;
--ok-rgb: 31, 138, 76;
--ok-rgb-2: 31, 138, 76;
--err: #D64545;
--err-weak: #FBEBEB;
--err-rgb: 214, 69, 69;
--danger: #D64545;
--warn: #B26B00;
--warn-weak: #FBF3E0;
--warn-bg: #FBF3E0;
--warn-text: #B26B00;
--warn-rgb: 178, 107, 0;
--warn-icon-rgb: 178, 107, 0;
/* 场景磁贴:淡色底 + 同色系前景(v2 的 tile 风格),故前景不能再用白色 */
--tile-fg: #1E6FA8;
--grad-sky: #E9F2FA;
--grad-peach: #FBF3E0;
--grad-mint: #E7F5EC;
--grad-lilac: #EFEAF7;
--grad-honey: #FBF3E0;
--grad-blush: #FBEBEB;
--tile-faint-bg: #E9EDF3;
--dot-off: #CBD5E1;
--dot-muted: #CBD5E1;
--sep-warm: #CDD6E1;
--switch-off: #CBD5E1;
--badge-warm-text: #B26B00;
--badge-warm-bg: #FBF3E0;
--badge-warm-border: #E7C88F;
--badge-off-text: #7C8896;
--badge-dot: #CBD5E1;
--border-strong-rgb: 205, 214, 225;
--chrome-rgb: 74, 140, 247;
--hero-grad: #FFFFFF;
--profile-head-grad: #F1F4F8;
--surface-cool: #F1F4F8;
--surface-cool-2: #F8FAFC;
--radius: 12px;
--radius-sm: 8px;
--radius-lg: 14px;
--shadow-sm: 0 1px 2px rgba(var(--text-rgb), .05);
--shadow-md: 0 8px 24px -12px rgba(var(--text-rgb), .14);
--shadow-lift: 0 14px 34px -16px rgba(var(--text-rgb), .18);
/* 精密工作台不用手写装饰字体 */
--font-doodle: var(--font-body);
}
/* 涂鸦层是奶油皮肤专属装饰,换肤时整体关闭(同一开关也支持手动 off) */
html[data-skin="precision"] .doodle { display: none; }
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
font-family: var(--font-body);
font-size: 13px;
color: var(--text);
background: var(--bg);
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
}
.__app {
height: 100%;
background: var(--bg-grad);
padding: 16px 18px 18px;
display: flex;
flex-direction: column;
}
/* 滚动条(柔和) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); background-clip: content-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }
/* 通用白卡:大圆角 + 极柔和阴影 + hover 轻微上浮 */
.panel {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow-sm);
transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.panel:hover {
transform: translateY(-3px);
box-shadow: var(--shadow-md);
border-color: var(--border-strong);
}
/* 分节标题 */
.sec-title {
font-size: 11px;
font-weight: 700;
letter-spacing: 0.05em;
text-transform: uppercase;
color: var(--text-faint);
}
/* 白底圆角卡(通用卡片:总览首页统计/场景/最近动态等) */
.card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow-sm);
}
/* 按钮 */
.btn {
border: 1px solid var(--border-strong);
background: var(--surface);
color: var(--text-sub);
border-radius: 12px;
padding: 7px 16px;
font-size: 13px;
font-family: inherit;
cursor: pointer;
transition: all .15s ease;
}
.btn:hover { color: var(--text); border-color: var(--border-hover); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { color: var(--text-disabled); border-color: var(--border); background: var(--surface-2); cursor: not-allowed; transform: none; }
.btn.primary {
background: var(--primary-grad);
color: var(--on-primary);
border: 1px solid transparent;
font-weight: 600;
box-shadow: 0 6px 16px -6px rgba(var(--primary-rgb), .6);
}
.btn.primary:hover:not(:disabled) { box-shadow: 0 10px 22px -8px rgba(var(--primary-rgb), .7); color: var(--on-primary); }
.btn.primary:disabled { background: var(--primary-disabled); box-shadow: none; }
/* 输入 / 选择 */
.input {
height: 34px;
border: 1px solid var(--border-strong);
border-radius: 11px;
background: var(--surface);
color: var(--text);
padding: 0 12px;
font-size: 13px;
font-family: inherit;
outline: none;
transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }
select.input { padding-right: 30px; appearance: none; cursor: pointer;
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239C9589' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
background-repeat: no-repeat; background-position: right 10px center; }
.field-label { color: var(--text-sub); font-size: 13px; }
/* 进度条 */
.progress { height: 8px; width: 180px; background: var(--track); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; border-radius: 999px;
background: var(--primary-grad);
transition: width .25s ease;
box-shadow: 0 0 6px rgba(var(--primary-rgb),.5); }
/* 日志 */
.log-box {
font-family: var(--mono);
font-size: 12px;
line-height: 1.75;
color: var(--text);
padding: 12px 14px;
overflow: auto;
white-space: pre-wrap;
word-break: break-all;
flex: 1 1 auto; /* 在 .log-wrap 里填满剩余高度并自己滚 */
min-height: 0;
}
.log-line:hover { background: var(--row-hover); }
.log-box .t { color: var(--text-faint); margin-right: 10px; user-select: none; }
.log-box .lv { margin-right: 6px; font-weight: 700; }
.log-box .s-INFO { color: var(--primary); }
.log-box .s-ERROR { color: var(--err); }
.log-box .s-WARN { color: var(--warn); }
/* 过渡 */
.fade-enter-active, .fade-leave-active { transition: opacity .18s ease, transform .18s ease; }
.fade-enter-from { opacity: 0; transform: translateY(4px); }
.fade-leave-to { opacity: 0; }
/* ============================================================
产品级通用元素:分节标题(更大更清晰)/ 空状态
============================================================ */
.page-title {
font-size: 20px;
font-weight: 700;
color: var(--text);
letter-spacing: .01em;
}
.page-sub {
font-size: 12.5px;
color: var(--text-sub);
line-height: 1.7;
}
.empty-note {
color: var(--text-faint);
text-align: center;
padding: 40px 20px;
font-size: 12.5px;
line-height: 2;
flex-shrink: 0;
}
.empty-note b { color: var(--text-sub); font-weight: 600; }
/* ============================================================
手绘涂鸦装饰层:fixed 浮于页面顶层,仅视觉点缀,
不参与流式布局、不拦截交互;html.no-doodles 整体关闭
============================================================ */
.doodle {
position: fixed;
pointer-events: none;
user-select: none;
z-index: 9999;
opacity: .55;
filter: drop-shadow(0 2px 3px rgba(var(--text-rgb), .06));
animation: doodleFloat 7s ease-in-out infinite;
}
html.no-doodles .doodle { display: none; }
@keyframes doodleFloat {
0%, 100% { transform: translateY(0) rotate(-1deg); }
50% { transform: translateY(-8px) rotate(1.5deg); }
}
@media (prefers-reduced-motion: reduce) {
.doodle { animation: none; }
}
@@ -0,0 +1,20 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// dev 时把 /api 与 /ws 代理到 FastAPI 后端,实现前后端分离开发
export default defineConfig({
plugins: [vue()],
server: {
port: 5173,
strictPort: true,
proxy: {
'/api': { target: 'http://127.0.0.1:8799', changeOrigin: true },
'/ws': { target: 'ws://127.0.0.1:8799', ws: true },
},
},
build: {
// 构建产物直接输出到壳的渲染层目录(Electron 壳/CLI 服务以此为前端根)
outDir: '../renderer/dist',
emptyOutDir: true,
},
})