bnpanel 0.0.0-stage → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -2
- package/assets/icons/README.md +23 -0
- package/assets/icons/app.png +0 -0
- package/assets/icons/app.svg +11 -0
- package/assets/icons/biureel.svg +8 -0
- package/assets/icons/biutalk.svg +6 -0
- package/assets/icons/icon.svg +11 -0
- package/client.js +1279 -0
- package/cordis.patch.yml +3 -0
- package/index.js +9941 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +53 -4
package/client.js
ADDED
|
@@ -0,0 +1,1279 @@
|
|
|
1
|
+
/* BN 面板 client half. Loaded by the harness module loader in DSH Desktop and
|
|
2
|
+
* by the local dev server through window.BnPanelUI.
|
|
3
|
+
*
|
|
4
|
+
* Plain JS on purpose: the panel must run inside the harness page without a
|
|
5
|
+
* build step, so components are written with a small `h` helper. */
|
|
6
|
+
(function () {
|
|
7
|
+
const BASE = '/panel-api';
|
|
8
|
+
const BRAND = 'BN 面板';
|
|
9
|
+
/** 跨 Panel 重挂载保留:同一开拍只自动切入一次,避免回 BN 面板又被踢回会话 */
|
|
10
|
+
const revealedKickoffs = new Set();
|
|
11
|
+
const KICKOFF_AUTO_REVEAL_MS = 90_000;
|
|
12
|
+
|
|
13
|
+
const CSS = `
|
|
14
|
+
:root{
|
|
15
|
+
/* Biunow design tokens(与 BiunowFactory 同源:黑墨 + 柠檬绿 + 纸面) */
|
|
16
|
+
--bn-bg:#f3f3f1; --bn-surface:#ffffff; --bn-surface-2:#fafaf8;
|
|
17
|
+
--bn-ink:#000000; --bn-ink-2:#1a1a1a; --bn-muted:#6b6b6b; --bn-faint:#9a9a9a;
|
|
18
|
+
--bn-line:#e2e2df; --bn-line-strong:#d0d0cc;
|
|
19
|
+
--bn-accent:#d4f07a; --bn-accent-deep:#b8d94a; --bn-accent-soft:#eef8c4;
|
|
20
|
+
--bn-ok:#2f6b4f; --bn-ok-soft:rgba(47,107,79,.12);
|
|
21
|
+
--bn-warn:#96650a; --bn-warn-soft:rgba(150,101,10,.12);
|
|
22
|
+
--bn-bad:#c23b2e; --bn-bad-soft:rgba(194,59,46,.10);
|
|
23
|
+
--bn-shadow:0 1px 2px rgba(0,0,0,.04),0 12px 36px rgba(0,0,0,.06);
|
|
24
|
+
--bn-shadow-hover:0 2px 4px rgba(0,0,0,.05),0 16px 40px rgba(0,0,0,.12);
|
|
25
|
+
--bn-r:16px; --bn-r-sm:10px;
|
|
26
|
+
--bn-font:'Plus Jakarta Sans',ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"PingFang SC","Microsoft YaHei",sans-serif;
|
|
27
|
+
--bn-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
|
|
28
|
+
}
|
|
29
|
+
@media (prefers-color-scheme:dark){
|
|
30
|
+
:root{
|
|
31
|
+
--bn-bg:#131211; --bn-surface:#1b1a18; --bn-surface-2:#211f1d;
|
|
32
|
+
--bn-ink:#f3efe8; --bn-ink-2:#d6d1c8; --bn-muted:#9a938a; --bn-faint:#736d64;
|
|
33
|
+
--bn-line:rgba(243,239,232,.10); --bn-line-strong:rgba(243,239,232,.18);
|
|
34
|
+
--bn-accent:#d4f07a; --bn-accent-deep:#b8d94a; --bn-accent-soft:rgba(212,240,122,.14);
|
|
35
|
+
--bn-ok:#4fc38d; --bn-ok-soft:rgba(79,195,141,.14);
|
|
36
|
+
--bn-warn:#e0b45c; --bn-warn-soft:rgba(224,180,92,.14);
|
|
37
|
+
--bn-bad:#ff7a6b; --bn-bad-soft:rgba(255,122,107,.14);
|
|
38
|
+
--bn-shadow:0 1px 2px rgba(0,0,0,.4),0 10px 30px rgba(0,0,0,.35);
|
|
39
|
+
--bn-shadow-hover:0 2px 6px rgba(0,0,0,.45),0 18px 44px rgba(0,0,0,.45);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
.bn-root{display:grid;grid-template-columns:minmax(0,208px) minmax(0,1fr);height:100%;min-height:520px;width:100%;max-width:100%;min-width:0;overflow:hidden;background:var(--bn-bg);color:var(--bn-ink);font:13px/1.55 var(--bn-font);-webkit-font-smoothing:antialiased}
|
|
43
|
+
.bn-root *{box-sizing:border-box}
|
|
44
|
+
.bn-rail{display:flex;flex-direction:column;gap:2px;padding:16px 10px;border-right:1px solid var(--bn-line);background:var(--bn-surface-2)}
|
|
45
|
+
.bn-logo{display:flex;align-items:center;gap:9px;padding:2px 8px 16px;font-weight:680;letter-spacing:-.01em}
|
|
46
|
+
.bn-logo .dot{width:22px;height:22px;border-radius:7px;background:var(--bn-ink);box-shadow:inset 0 0 0 2.5px var(--bn-accent),0 2px 8px rgba(0,0,0,.18);overflow:hidden}
|
|
47
|
+
.bn-logo .dot img{width:100%;height:100%;object-fit:cover;display:block}
|
|
48
|
+
.bn-tile img{width:100%;height:100%;object-fit:cover;display:block;border-radius:inherit}
|
|
49
|
+
.bn-nav{display:flex;flex-direction:column;gap:2px}
|
|
50
|
+
.bn-nav button{display:flex;align-items:center;gap:9px;width:100%;border:0;background:transparent;color:var(--bn-muted);padding:8px 10px;border-radius:8px;cursor:pointer;font:inherit;text-align:left;transition:background .12s,color .12s}
|
|
51
|
+
.bn-nav button:hover{background:var(--bn-line);color:var(--bn-ink-2)}
|
|
52
|
+
.bn-nav button.on{background:var(--bn-line);color:var(--bn-ink);font-weight:600}
|
|
53
|
+
.bn-nav .count{margin-left:auto;font-size:11px;color:var(--bn-faint)}
|
|
54
|
+
.bn-rail-support{margin-top:auto}
|
|
55
|
+
.bn-rail-foot{margin-top:0;padding:8px 8px 4px;font-size:11px;color:var(--bn-faint);line-height:1.4}
|
|
56
|
+
.bn-contact{width:min(380px,100%);padding:0;overflow:hidden}
|
|
57
|
+
.bn-contact-head{display:flex;align-items:flex-start;gap:12px;padding:18px 16px 16px;text-align:left;border-bottom:1px solid var(--bn-line);background:radial-gradient(280px 120px at 100% 0%,var(--bn-accent-soft),transparent 72%),var(--bn-surface)}
|
|
58
|
+
.bn-contact-mark{width:36px;height:36px;border-radius:11px;flex:none;display:grid;place-items:center;background:var(--bn-ink);color:var(--bn-accent);font-weight:700;font-size:15px;box-shadow:inset 0 0 0 2px var(--bn-accent)}
|
|
59
|
+
.bn-contact-head h3{margin:1px 0 0;font-size:16px;letter-spacing:-.01em}
|
|
60
|
+
.bn-contact-head .hint{margin:3px 0 0;color:var(--bn-muted);font-size:12px;line-height:1.45}
|
|
61
|
+
.bn-contact-x{margin-left:auto;width:28px;height:28px;border:0;border-radius:8px;background:transparent;color:var(--bn-muted);font-size:18px;line-height:1;cursor:pointer;flex:none}
|
|
62
|
+
.bn-contact-x:hover{background:var(--bn-line);color:var(--bn-ink)}
|
|
63
|
+
.bn-contact-body{padding:18px 18px 20px}
|
|
64
|
+
.bn-contact-body .bn-sub{margin:0}
|
|
65
|
+
.bn-qr-frame{width:208px;margin:0 auto 14px;padding:12px;border-radius:18px;background:#fff;border:1px solid var(--bn-line);box-shadow:0 10px 28px rgba(0,0,0,.06)}
|
|
66
|
+
.bn-qr{width:100%;height:auto;margin:0;padding:0;border:0;border-radius:8px;background:#fff;object-fit:contain;display:block}
|
|
67
|
+
.bn-wx{display:flex;align-items:center;justify-content:space-between;gap:12px;border:1px solid var(--bn-line);border-radius:12px;padding:10px 10px 10px 12px;text-align:left;background:var(--bn-surface-2)}
|
|
68
|
+
.bn-wx .label{font-size:11px;color:var(--bn-muted)}
|
|
69
|
+
.bn-wx code{display:block;margin-top:2px;font-family:var(--bn-mono);font-size:14px;color:var(--bn-ink);letter-spacing:.01em}
|
|
70
|
+
.bn-wx .bn-btn{height:30px;padding:0 12px;background:var(--bn-ink);color:var(--bn-accent);border-color:var(--bn-ink)}
|
|
71
|
+
.bn-manual{display:flex;align-items:center;justify-content:center;width:100%;margin-top:14px;height:36px;text-decoration:none;box-sizing:border-box}
|
|
72
|
+
.bn-main{overflow:auto;overflow-x:hidden;padding:22px 26px 40px;min-width:0;max-width:100%}
|
|
73
|
+
.bn-head{display:flex;align-items:flex-start;gap:12px;margin-bottom:20px}
|
|
74
|
+
.bn-h1{font-size:19px;font-weight:680;letter-spacing:-.015em;margin:0}
|
|
75
|
+
.bn-sub{color:var(--bn-muted);font-size:12px;margin-top:3px}
|
|
76
|
+
.bn-head-actions{margin-left:auto;display:flex;gap:8px;align-items:center}
|
|
77
|
+
.bn-btn{display:inline-flex;align-items:center;gap:6px;flex:0 0 auto;white-space:nowrap;border:1px solid var(--bn-line-strong);background:var(--bn-surface);color:var(--bn-ink);border-radius:8px;padding:6px 11px;font:inherit;font-size:12px;cursor:pointer;transition:transform .08s,box-shadow .12s,background .12s,opacity .12s}
|
|
78
|
+
.bn-btn:hover{box-shadow:var(--bn-shadow)}
|
|
79
|
+
.bn-btn:active{transform:translateY(1px)}
|
|
80
|
+
.bn-btn.primary{background:var(--bn-ink);color:var(--bn-accent);border-color:var(--bn-ink)}
|
|
81
|
+
.bn-btn.ghost{border-color:transparent;background:transparent;color:var(--bn-muted)}
|
|
82
|
+
.bn-btn.ghost:hover{background:var(--bn-line);color:var(--bn-ink)}
|
|
83
|
+
.bn-btn.danger{color:var(--bn-bad);border-color:var(--bn-bad);background:transparent}
|
|
84
|
+
.bn-btn:disabled{opacity:.42;cursor:not-allowed;box-shadow:none;transform:none}
|
|
85
|
+
.bn-chip{display:inline-flex;align-items:center;gap:6px;border-radius:999px;padding:3px 9px;font-size:11px;font-weight:550;border:1px solid transparent}
|
|
86
|
+
.bn-chip.ok{background:var(--bn-ok-soft);color:var(--bn-ok)}
|
|
87
|
+
.bn-chip.warn{background:var(--bn-warn-soft);color:var(--bn-warn)}
|
|
88
|
+
.bn-chip.bad{background:var(--bn-bad-soft);color:var(--bn-bad)}
|
|
89
|
+
.bn-chip.dim{background:var(--bn-line);color:var(--bn-muted)}
|
|
90
|
+
.bn-chip .pulse{width:5px;height:5px;border-radius:50%;background:currentColor}
|
|
91
|
+
.bn-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,280px),1fr));gap:14px;width:100%;min-width:0}
|
|
92
|
+
.bn-card{position:relative;min-width:0;max-width:100%;overflow:hidden;background:var(--bn-surface);border:1px solid var(--bn-line);border-radius:var(--bn-r);padding:16px;box-shadow:var(--bn-shadow);transition:box-shadow .16s,border-color .16s}
|
|
93
|
+
.bn-grid .bn-card{background:radial-gradient(480px 220px at 100% 0%,rgba(212,240,122,.48),rgba(212,240,122,0) 70%),var(--bn-surface)}
|
|
94
|
+
.bn-card:hover{box-shadow:var(--bn-shadow-hover);border-color:var(--bn-line-strong)}
|
|
95
|
+
.bn-card-top{display:flex;gap:12px;align-items:flex-start;min-width:0;padding-right:88px}
|
|
96
|
+
.bn-card.has-un .bn-card-top{padding-right:152px}
|
|
97
|
+
.bn-un{height:22px;padding:0 8px;border-radius:999px;border:1px solid var(--bn-line);background:color-mix(in srgb,var(--bn-surface) 82%,transparent);color:var(--bn-muted);font:inherit;font-size:11px;line-height:1;cursor:pointer}
|
|
98
|
+
.bn-un:hover{color:var(--bn-bad);border-color:transparent;background:var(--bn-bad-soft)}
|
|
99
|
+
.bn-un:disabled{opacity:.42;cursor:not-allowed}
|
|
100
|
+
.bn-tile{width:40px;height:40px;border-radius:11px;display:grid;place-items:center;font-weight:700;font-size:15px;color:var(--bn-accent);background:var(--bn-ink);flex:0 0 auto}
|
|
101
|
+
.bn-name{font-weight:640;font-size:14px;letter-spacing:-.01em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
102
|
+
.bn-meta{color:var(--bn-muted);font-size:11.5px;margin-top:1px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
103
|
+
.bn-card .status{position:absolute;top:14px;right:14px;z-index:1;display:flex;align-items:center;gap:6px;max-width:none}
|
|
104
|
+
@media (prefers-color-scheme:dark){
|
|
105
|
+
.bn-grid .bn-card{background:radial-gradient(480px 220px at 100% 0%,rgba(212,240,122,.2),rgba(212,240,122,0) 70%),var(--bn-surface)}
|
|
106
|
+
}
|
|
107
|
+
.bn-desc{color:var(--bn-muted);font-size:12px;margin:12px 0 0;min-height:34px;overflow-wrap:anywhere}
|
|
108
|
+
.bn-facts{display:flex;flex-wrap:wrap;gap:6px;margin-top:12px;min-width:0}
|
|
109
|
+
.bn-fact{font-size:11px;color:var(--bn-muted);background:var(--bn-line);border-radius:6px;padding:2px 7px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
110
|
+
.bn-card-actions{display:flex;gap:6px;margin-top:14px;padding-top:12px;border-top:1px solid var(--bn-line);flex-wrap:wrap;min-width:0;width:100%;align-items:center}
|
|
111
|
+
.bn-card-actions .bn-btn{flex:0 1 auto;min-width:0;max-width:100%}
|
|
112
|
+
.bn-card-actions .bn-btn.ghost{flex:0 0 auto;margin-left:0}
|
|
113
|
+
.bn-card-progress{margin-top:12px;padding-top:10px;border-top:1px dashed var(--bn-line)}
|
|
114
|
+
.bn-card-progress .bn-meta{margin-bottom:6px}
|
|
115
|
+
.bn-live-tasks{display:flex;flex-direction:column;gap:8px;margin-bottom:16px}
|
|
116
|
+
.bn-live-task{background:var(--bn-surface);border:1px solid var(--bn-line);border-left:3px solid var(--bn-accent-deep);border-radius:10px;padding:10px 12px}
|
|
117
|
+
.bn-empty{border:1px dashed var(--bn-line-strong);border-radius:var(--bn-r);padding:44px 24px;text-align:center;background:var(--bn-surface)}
|
|
118
|
+
.bn-empty h3{margin:14px 0 4px;font-size:14px}
|
|
119
|
+
.bn-empty p{margin:0;color:var(--bn-muted);font-size:12.5px}
|
|
120
|
+
.bn-empty .art{width:74px;height:74px;margin:0 auto;border-radius:20px;display:grid;place-items:center;background:var(--bn-accent-soft);color:var(--bn-ink)}
|
|
121
|
+
.bn-panel{background:var(--bn-surface);border:1px solid var(--bn-line);border-radius:var(--bn-r);padding:18px;box-shadow:var(--bn-shadow);margin-bottom:16px}
|
|
122
|
+
.bn-panel h2{font-size:12px;text-transform:uppercase;letter-spacing:.07em;color:var(--bn-muted);margin:0 0 12px;font-weight:600}
|
|
123
|
+
.bn-field{display:flex;flex-direction:column;gap:5px;margin-bottom:10px}
|
|
124
|
+
.bn-field label{font-size:11.5px;color:var(--bn-muted)}
|
|
125
|
+
.bn-input,.bn-select{width:100%;border:1px solid var(--bn-line-strong);background:var(--bn-surface-2);color:var(--bn-ink);border-radius:var(--bn-r-sm);padding:8px 10px;font:inherit;font-size:12.5px;transition:border-color .12s,box-shadow .12s}
|
|
126
|
+
.bn-input:focus,.bn-select:focus{outline:none;border-color:var(--bn-ink);box-shadow:0 0 0 3px var(--bn-accent)}
|
|
127
|
+
.bn-dd{position:relative;z-index:1}
|
|
128
|
+
.bn-dd.open{z-index:40}
|
|
129
|
+
.bn-dd-trigger{display:flex;align-items:center;gap:8px;width:100%;border:1px solid var(--bn-line-strong);background:var(--bn-surface-2);color:var(--bn-ink);border-radius:var(--bn-r-sm);padding:8px 10px;font:inherit;font-size:12.5px;cursor:pointer;text-align:left;transition:border-color .12s,box-shadow .12s}
|
|
130
|
+
.bn-dd-trigger:hover{border-color:var(--bn-ink)}
|
|
131
|
+
.bn-dd.open .bn-dd-trigger{border-color:var(--bn-ink);box-shadow:0 0 0 3px var(--bn-accent)}
|
|
132
|
+
.bn-dd-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
133
|
+
.bn-dd-caret{flex:0 0 auto;color:var(--bn-faint)}
|
|
134
|
+
/* 不用 createPortal:DSH 插件页挂到 document.body 会整页白屏 */
|
|
135
|
+
.bn-dd-pop{position:absolute;left:0;right:0;top:calc(100% + 6px);z-index:60;max-height:min(280px,50vh);overflow:auto;background:var(--bn-surface);border:1px solid var(--bn-line);border-radius:12px;box-shadow:var(--bn-shadow-hover);padding:5px;animation:bn-dd-in .14s ease}
|
|
136
|
+
.bn-dd-pop.up{top:auto;bottom:calc(100% + 6px);animation:bn-dd-in-up .14s ease}
|
|
137
|
+
@keyframes bn-dd-in{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
|
|
138
|
+
@keyframes bn-dd-in-up{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
|
|
139
|
+
.bn-dd-item{display:flex;align-items:center;gap:8px;width:100%;border:0;background:transparent;color:var(--bn-ink-2);padding:7px 9px;border-radius:8px;font:inherit;font-size:12.5px;cursor:pointer;text-align:left;transition:background .1s,color .1s}
|
|
140
|
+
.bn-dd-item:hover{background:var(--bn-accent-soft);color:var(--bn-ink)}
|
|
141
|
+
.bn-dd-item.on{background:var(--bn-accent-soft);color:var(--bn-ink);font-weight:600}
|
|
142
|
+
.bn-dd-item-label{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
143
|
+
.bn-dd-hint{margin-left:auto;font-size:11px;color:var(--bn-faint)}
|
|
144
|
+
.bn-dd-item.on .bn-dd-hint{color:var(--bn-muted)}
|
|
145
|
+
.bn-dd-check{flex:0 0 auto;color:var(--bn-ink);margin-left:auto}
|
|
146
|
+
.bn-dd-hint + .bn-dd-check{margin-left:0}
|
|
147
|
+
.bn-dd-ico{width:22px;height:22px;min-width:22px;max-width:22px;min-height:22px;max-height:22px;border-radius:6px;overflow:hidden;flex:0 0 22px;background:var(--bn-ink);color:var(--bn-accent);display:grid;place-items:center;font-size:11px;font-weight:700}
|
|
148
|
+
.bn-dd-ico img{width:22px;height:22px;max-width:22px;max-height:22px;object-fit:cover;display:block}
|
|
149
|
+
.bn-dd-item.rich{align-items:center;padding:8px 9px}
|
|
150
|
+
.bn-dd-copy{flex:1;min-width:0;display:flex;flex-direction:column;gap:1px}
|
|
151
|
+
.bn-dd-item.rich .bn-dd-item-label{flex:none;font-weight:600}
|
|
152
|
+
.bn-dd-detail{font-size:11px;font-weight:400;color:var(--bn-faint);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
153
|
+
.bn-panel > .bn-sec-head{display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:12px;width:100%;margin:0 0 14px;position:relative;z-index:2}
|
|
154
|
+
.bn-panel > .bn-sec-head > h2{margin:0;width:auto;flex:1 1 auto;min-width:0}
|
|
155
|
+
.bn-panel > .bn-sec-head > .bn-sec-actions{margin-left:auto;display:flex;gap:8px;align-items:center;flex:0 0 auto}
|
|
156
|
+
.bn-lic .status{display:flex;align-items:center;gap:4px;max-width:none}
|
|
157
|
+
.bn-lic .bn-card-top{padding-right:168px}
|
|
158
|
+
.bn-lic .status .bn-btn{height:26px;padding:0 8px;font-size:12px}
|
|
159
|
+
.bn-lic .bn-desc{min-height:0;margin-top:10px}
|
|
160
|
+
.bn-activate{display:flex;gap:10px;align-items:center;margin-top:16px;flex-wrap:nowrap}
|
|
161
|
+
.bn-activate .bn-dd{flex:0 1 280px;width:280px;min-width:180px;max-width:320px;height:36px}
|
|
162
|
+
.bn-activate .bn-input{flex:1 1 220px;width:auto;min-width:160px;max-width:none;height:36px}
|
|
163
|
+
.bn-activate .bn-dd-trigger,.bn-activate .bn-btn{height:36px;max-height:36px;overflow:hidden}
|
|
164
|
+
@media (max-width:720px){
|
|
165
|
+
.bn-activate{flex-wrap:wrap}
|
|
166
|
+
.bn-activate .bn-dd,.bn-activate .bn-input{width:100%;max-width:none;flex:1 1 100%}
|
|
167
|
+
}
|
|
168
|
+
.bn-row{display:flex;gap:10px;align-items:flex-end}
|
|
169
|
+
.bn-form{display:flex;gap:10px;align-items:center}
|
|
170
|
+
.bn-form .bn-input{width:auto;flex:1 1 auto;min-width:0}
|
|
171
|
+
.bn-form .bn-input,.bn-form .bn-dd-trigger,.bn-form .bn-btn{height:36px;padding-top:0;padding-bottom:0}
|
|
172
|
+
.bn-form .bn-btn{padding-left:15px;padding-right:15px;font-size:12.5px}
|
|
173
|
+
.bn-kv{display:grid;grid-template-columns:120px 1fr;gap:8px 14px;font-size:12.5px}
|
|
174
|
+
.bn-kv dt{color:var(--bn-muted)}
|
|
175
|
+
.bn-kv dd{margin:0;word-break:break-all}
|
|
176
|
+
.bn-mono{font-family:var(--bn-mono);font-size:11.5px}
|
|
177
|
+
.bn-task{display:flex;align-items:center;gap:12px;padding:10px 0;border-bottom:1px solid var(--bn-line)}
|
|
178
|
+
.bn-task:last-child{border-bottom:0}
|
|
179
|
+
.bn-task .title{font-weight:540;font-size:12.5px}
|
|
180
|
+
.bn-task .time{color:var(--bn-faint);font-size:11px}
|
|
181
|
+
.bn-progress{flex:1;height:5px;background:var(--bn-line);border-radius:3px;overflow:hidden;min-width:80px}
|
|
182
|
+
.bn-progress i{display:block;height:100%;background:var(--bn-accent);border-radius:3px;transition:width .3s ease}
|
|
183
|
+
.bn-task.done .bn-progress i{background:var(--bn-ok)}
|
|
184
|
+
.bn-task.failed .bn-progress i{background:var(--bn-bad)}
|
|
185
|
+
.bn-toast{position:fixed;left:50%;bottom:22px;transform:translateX(-50%);background:var(--bn-ink);color:var(--bn-accent);padding:9px 14px;border-radius:10px;font-size:12.5px;box-shadow:var(--bn-shadow-hover);z-index:50}
|
|
186
|
+
.bn-toast.bad{background:var(--bn-bad);color:#fff}
|
|
187
|
+
.bn-modal-back{position:fixed;inset:0;background:rgba(10,10,10,.42);display:grid;place-items:center;z-index:40;padding:20px}
|
|
188
|
+
.bn-modal{width:min(460px,100%);background:var(--bn-surface);border-radius:16px;border:1px solid var(--bn-line);box-shadow:var(--bn-shadow-hover);padding:20px}
|
|
189
|
+
.bn-modal h3{margin:0 0 4px;font-size:15px}
|
|
190
|
+
.bn-modal .hint{color:var(--bn-muted);font-size:12px;margin-bottom:14px}
|
|
191
|
+
.bn-actions-end{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}
|
|
192
|
+
.bn-skel{height:118px;border-radius:var(--bn-r);background:linear-gradient(90deg,var(--bn-line) 25%,transparent 37%,var(--bn-line) 63%);background-size:400% 100%;animation:bn-sh 1.4s ease infinite}
|
|
193
|
+
@keyframes bn-sh{0%{background-position:100% 50%}100%{background-position:0 50%}}
|
|
194
|
+
.bn-banner{display:flex;gap:12px;align-items:center;border:1px solid var(--bn-line);border-left:3px solid var(--bn-accent-deep);background:var(--bn-accent-soft);border-radius:10px;padding:10px 13px;font-size:12.5px;margin-bottom:16px}
|
|
195
|
+
.bn-banner b{font-weight:640}
|
|
196
|
+
.bn-banner .bn-btn{margin-left:auto;background:var(--bn-surface)}
|
|
197
|
+
.bn-studio{display:flex;flex-direction:column;height:calc(100vh - 48px);min-height:520px;margin:-22px -26px -40px;background:var(--bn-bg)}
|
|
198
|
+
.bn-studio-bar{display:flex;align-items:center;gap:10px;padding:10px 14px;border-bottom:1px solid var(--bn-line);background:var(--bn-surface)}
|
|
199
|
+
.bn-studio-bar .copy{min-width:0}
|
|
200
|
+
.bn-studio-bar .title{font-weight:650;font-size:13px}
|
|
201
|
+
.bn-studio-bar .meta{color:var(--bn-muted);font-size:11.5px;max-width:520px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
202
|
+
.bn-studio iframe{flex:1;width:100%;border:0;background:#000}
|
|
203
|
+
.bn-lock{opacity:.72}
|
|
204
|
+
`;
|
|
205
|
+
|
|
206
|
+
function ico(name, size) {
|
|
207
|
+
const s = size || 15;
|
|
208
|
+
const paths = {
|
|
209
|
+
grid: 'M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z',
|
|
210
|
+
bolt: 'M13 2 4 14h6l-1 8 9-12h-6l1-8z',
|
|
211
|
+
list: 'M4 6h16M4 12h16M4 18h10',
|
|
212
|
+
gear: 'M12 15a3 3 0 100-6 3 3 0 000 6zM19.4 15a1.7 1.7 0 00.3 1.9l.1.1a2 2 0 11-2.8 2.8l-.1-.1a1.7 1.7 0 00-1.9-.3 1.7 1.7 0 00-1 1.5V21a2 2 0 11-4 0v-.1a1.7 1.7 0 00-1-1.5 1.7 1.7 0 00-1.9.3l-.1.1a2 2 0 11-2.8-2.8l.1-.1a1.7 1.7 0 00.3-1.9 1.7 1.7 0 00-1.5-1H3a2 2 0 110-4h.1a1.7 1.7 0 001.5-1 1.7 1.7 0 00-.3-1.9l-.1-.1a2 2 0 112.8-2.8l.1.1a1.7 1.7 0 001.9.3H9a1.7 1.7 0 001-1.5V3a2 2 0 114 0v.1a1.7 1.7 0 001 1.5 1.7 1.7 0 001.9-.3l.1-.1a2 2 0 112.8 2.8l-.1.1a1.7 1.7 0 00-.3 1.9V9a1.7 1.7 0 001.5 1H21a2 2 0 110 4h-.1a1.7 1.7 0 00-1.5 1z',
|
|
213
|
+
download: 'M12 3v12m0 0l-4-4m4 4l4-4M4 21h16',
|
|
214
|
+
upload: 'M12 21V9m0 0L8 13m4-4l4 4M4 3h16',
|
|
215
|
+
play: 'M7 4l13 8-13 8z',
|
|
216
|
+
stop: 'M6 6h12v12H6z',
|
|
217
|
+
refresh: 'M21 12a9 9 0 11-3-6.7M21 3v6h-6',
|
|
218
|
+
trash: 'M4 7h16M9 7V4h6v3M6 7l1 14h10l1-14',
|
|
219
|
+
check: 'M20 6L9 17l-5-5',
|
|
220
|
+
arrow: 'M5 12h14m-6-6l6 6-6 6',
|
|
221
|
+
external: 'M14 3h7v7M10 14 21 3M21 14v7H3V3h7',
|
|
222
|
+
key: 'M21 2l-2 2m-7.6 7.6a5 5 0 11-7 7 5 5 0 017-7zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3-3.5 3.5z',
|
|
223
|
+
chat: 'M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z',
|
|
224
|
+
};
|
|
225
|
+
return { tag: 'svg', props: { width: s, height: s, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true }, children: [{ tag: 'path', props: { d: paths[name] || paths.grid }, children: [] }] };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function safeManualUrl(value) {
|
|
229
|
+
try {
|
|
230
|
+
const url = new URL(String(value || '').trim());
|
|
231
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') return '';
|
|
232
|
+
if (url.username || url.password) return '';
|
|
233
|
+
return url.toString();
|
|
234
|
+
} catch {
|
|
235
|
+
return '';
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function createPanel(React, ReactDOM, dshNav) {
|
|
240
|
+
const h = React.createElement;
|
|
241
|
+
const { useState, useEffect, useRef, useCallback } = React;
|
|
242
|
+
const revealCreationSession = dshNav && typeof dshNav.revealCreationSession === 'function'
|
|
243
|
+
? dshNav.revealCreationSession
|
|
244
|
+
: null;
|
|
245
|
+
const Icon = ({ name, size }) => h(ico(name, size).tag, ico(name, size).props, h(ico(name, size).children[0].tag, ico(name, size).children[0].props));
|
|
246
|
+
|
|
247
|
+
async function api(path, options) {
|
|
248
|
+
const res = await fetch(BASE + path, {
|
|
249
|
+
headers: { 'content-type': 'application/json', ...(options && options.headers) },
|
|
250
|
+
...options,
|
|
251
|
+
body: options && options.body && typeof options.body !== 'string' ? JSON.stringify(options.body) : options && options.body,
|
|
252
|
+
});
|
|
253
|
+
const data = await res.json().catch(() => ({}));
|
|
254
|
+
if (!res.ok) {
|
|
255
|
+
const err = new Error((data && data.error) || res.statusText);
|
|
256
|
+
if (data && data.code) err.code = data.code;
|
|
257
|
+
throw err;
|
|
258
|
+
}
|
|
259
|
+
return data;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const timeAgo = (iso) => {
|
|
263
|
+
const diff = Date.now() - Date.parse(iso);
|
|
264
|
+
if (diff < 60e3) return '刚刚';
|
|
265
|
+
if (diff < 36e5) return Math.floor(diff / 60e3) + ' 分钟前';
|
|
266
|
+
if (diff < 864e5) return Math.floor(diff / 36e5) + ' 小时前';
|
|
267
|
+
return Math.floor(diff / 864e5) + ' 天前';
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
const BnDropdown = ({ value, options, onChange, style }) => {
|
|
271
|
+
const [open, setOpen] = useState(false);
|
|
272
|
+
const [up, setUp] = useState(false);
|
|
273
|
+
const anchor = useRef(null);
|
|
274
|
+
const list = Array.isArray(options) ? options : [];
|
|
275
|
+
const current = list.find((o) => o.value === value);
|
|
276
|
+
|
|
277
|
+
const toggle = (e) => {
|
|
278
|
+
if (e) e.stopPropagation();
|
|
279
|
+
if (!open && anchor.current) {
|
|
280
|
+
const r = anchor.current.getBoundingClientRect();
|
|
281
|
+
const rowH = list.some((o) => o.detail) ? 48 : 36;
|
|
282
|
+
const height = Math.min(Math.max(list.length, 1), 8) * rowH + 12;
|
|
283
|
+
setUp(r.bottom + height > window.innerHeight - 8 && r.top - 8 > height);
|
|
284
|
+
}
|
|
285
|
+
setOpen((v) => !v);
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const ddIcon = (src, label) => h('span', { className: 'bn-dd-ico', 'aria-hidden': true },
|
|
289
|
+
h('img', {
|
|
290
|
+
src: iconSrc(src),
|
|
291
|
+
alt: '',
|
|
292
|
+
onError: (e) => {
|
|
293
|
+
e.target.style.display = 'none';
|
|
294
|
+
if (e.target.parentNode) e.target.parentNode.textContent = String(label || 'BN').slice(0, 1).toUpperCase();
|
|
295
|
+
},
|
|
296
|
+
}),
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
useEffect(() => {
|
|
300
|
+
if (!open) return;
|
|
301
|
+
const onKey = (ev) => { if (ev.key === 'Escape') setOpen(false); };
|
|
302
|
+
const onDoc = (ev) => {
|
|
303
|
+
if (anchor.current && !anchor.current.contains(ev.target)) setOpen(false);
|
|
304
|
+
};
|
|
305
|
+
window.addEventListener('keydown', onKey);
|
|
306
|
+
document.addEventListener('mousedown', onDoc);
|
|
307
|
+
return () => {
|
|
308
|
+
window.removeEventListener('keydown', onKey);
|
|
309
|
+
document.removeEventListener('mousedown', onDoc);
|
|
310
|
+
};
|
|
311
|
+
}, [open]);
|
|
312
|
+
|
|
313
|
+
return h('div', { className: 'bn-dd' + (open ? ' open' : ''), ref: anchor, style },
|
|
314
|
+
h('button', { type: 'button', className: 'bn-dd-trigger', onClick: toggle, 'aria-haspopup': 'listbox', 'aria-expanded': open },
|
|
315
|
+
current && current.icon ? ddIcon(current.icon, current.label) : null,
|
|
316
|
+
h('span', { className: 'bn-dd-label' }, current ? current.label : '请选择'),
|
|
317
|
+
h('svg', { className: 'bn-dd-caret', width: 12, height: 12, viewBox: '0 0 12 12', fill: 'none', 'aria-hidden': true },
|
|
318
|
+
h('path', { d: open ? 'M3 7.5 6 4.5 9 7.5' : 'M3 4.5 6 7.5 9 4.5', stroke: 'currentColor', strokeWidth: 1.6, strokeLinecap: 'round', strokeLinejoin: 'round' })),
|
|
319
|
+
),
|
|
320
|
+
open ? h('div', { className: 'bn-dd-pop' + (up ? ' up' : ''), role: 'listbox' },
|
|
321
|
+
list.length
|
|
322
|
+
? list.map((o) => h('button', {
|
|
323
|
+
key: o.value, type: 'button', role: 'option', 'aria-selected': o.value === value,
|
|
324
|
+
className: 'bn-dd-item' + (o.detail || o.icon ? ' rich' : '') + (o.value === value ? ' on' : ''),
|
|
325
|
+
onClick: (ev) => { ev.stopPropagation(); setOpen(false); onChange(o.value); },
|
|
326
|
+
},
|
|
327
|
+
o.icon ? ddIcon(o.icon, o.label) : null,
|
|
328
|
+
o.detail
|
|
329
|
+
? h('span', { className: 'bn-dd-copy' },
|
|
330
|
+
h('span', { className: 'bn-dd-item-label' }, o.label),
|
|
331
|
+
h('span', { className: 'bn-dd-detail' }, o.detail),
|
|
332
|
+
)
|
|
333
|
+
: h('span', { className: 'bn-dd-item-label' }, o.label),
|
|
334
|
+
!o.detail && o.hint ? h('span', { className: 'bn-dd-hint' }, o.hint) : null,
|
|
335
|
+
o.value === value ? h('svg', { className: 'bn-dd-check', width: 13, height: 13, viewBox: '0 0 13 13', fill: 'none', 'aria-hidden': true },
|
|
336
|
+
h('path', { d: 'M2.5 7 5.2 9.7 10.5 3.8', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round' })) : null,
|
|
337
|
+
))
|
|
338
|
+
: h('div', { className: 'bn-sub', style: { padding: '8px 10px' } }, '暂无产品'),
|
|
339
|
+
) : null,
|
|
340
|
+
);
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const LicenseChip = ({ license }) => {
|
|
344
|
+
const map = {
|
|
345
|
+
active: ['ok', '已授权'],
|
|
346
|
+
grace: ['warn', '宽限期'],
|
|
347
|
+
readonly: ['bad', '只读'],
|
|
348
|
+
revoked: ['bad', '已吊销'],
|
|
349
|
+
unlicensed: ['dim', '未激活'],
|
|
350
|
+
};
|
|
351
|
+
const [cls, text] = map[license.state] || map.unlicensed;
|
|
352
|
+
return h('span', { className: 'bn-chip ' + cls, title: license.reason || '' }, h('i', { className: 'pulse' }), text);
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
const iconSrc = (ref) => {
|
|
356
|
+
if (!ref) return BASE + '/icons/app.svg';
|
|
357
|
+
if (String(ref).startsWith('icon://')) return BASE + '/icons/' + String(ref).slice(7) + '.svg';
|
|
358
|
+
if (String(ref).startsWith('http') || String(ref).startsWith('/')) return ref;
|
|
359
|
+
return BASE + '/icons/' + ref;
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
const AgentIcon = ({ agent, item }) => {
|
|
363
|
+
const rawCatalog = item && item.icon ? String(item.icon) : '';
|
|
364
|
+
const catalogIcon = rawCatalog && (item.hasIcon || /^https?:\/\//i.test(rawCatalog) || rawCatalog.startsWith('/'))
|
|
365
|
+
? rawCatalog
|
|
366
|
+
: '';
|
|
367
|
+
const src = iconSrc(catalogIcon || (agent && agent.icon) || rawCatalog || ('icon://' + ((item && item.slug) || (agent && agent.id) || 'app')));
|
|
368
|
+
return h('div', { className: 'bn-tile', style: { padding: 0, overflow: 'hidden' } },
|
|
369
|
+
h('img', { src, alt: '', onError: (e) => { e.target.style.display = 'none'; if (e.target.parentNode) e.target.parentNode.textContent = ((agent && agent.name) || (item && item.name) || 'BN').slice(0, 2).toUpperCase(); } }),
|
|
370
|
+
);
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
const StoreCard = ({ item, onAction, onConfirm, busy, task }) => {
|
|
374
|
+
const agent = item.agent;
|
|
375
|
+
const installed = item.installed && agent;
|
|
376
|
+
const locked = installed && agent.product && !agent.entitled;
|
|
377
|
+
const trial = installed && !agent.licensed && agent.trialRemaining > 0;
|
|
378
|
+
const taskActive = task && (task.status === 'running' || task.status === 'queued');
|
|
379
|
+
const missingAll = (agent && agent.missingRuntime) || [];
|
|
380
|
+
const missingReq = (agent && agent.missingRequiredRuntime) || missingAll.filter((s) => /-npm$/i.test(String(s).split('@')[0] || ''));
|
|
381
|
+
const needRt = missingReq.length > 0;
|
|
382
|
+
const needOptionalRt = missingAll.length > 0;
|
|
383
|
+
const catalogDesc = item && item.description ? String(item.description).trim() : '';
|
|
384
|
+
const packagedDesc = agent && agent.description ? String(agent.description).trim() : '';
|
|
385
|
+
if (!installed) {
|
|
386
|
+
return h('article', { className: 'bn-card' },
|
|
387
|
+
h('div', { className: 'bn-card-top' },
|
|
388
|
+
h(AgentIcon, { item }),
|
|
389
|
+
h('div', { style: { minWidth: 0 } },
|
|
390
|
+
h('div', { className: 'bn-name' }, item.name),
|
|
391
|
+
h('div', { className: 'bn-meta' }, item.latest ? ('最新 v' + item.latest.version) : '即将上架'),
|
|
392
|
+
),
|
|
393
|
+
h('div', { className: 'status' },
|
|
394
|
+
taskActive ? h('span', { className: 'bn-chip warn' }, '安装中') : h('span', { className: 'bn-chip dim' }, '未安装')),
|
|
395
|
+
),
|
|
396
|
+
h('p', { className: 'bn-desc' }, catalogDesc || '从云端一键安装到本机。'),
|
|
397
|
+
taskActive ? h('div', { className: 'bn-card-progress' },
|
|
398
|
+
h('div', { className: 'bn-meta' }, (task.progress || 0) + '% · ' + (task.message || '处理中')),
|
|
399
|
+
h('div', { className: 'bn-progress' }, h('i', { style: { width: (task.progress || 0) + '%' } })),
|
|
400
|
+
) : null,
|
|
401
|
+
h('div', { className: 'bn-card-actions' },
|
|
402
|
+
h('button', {
|
|
403
|
+
className: 'bn-btn primary',
|
|
404
|
+
disabled: taskActive || busy || !item.installable,
|
|
405
|
+
onClick: () => onAction('store-install', item.slug),
|
|
406
|
+
}, h(Icon, { name: 'download' }), taskActive ? '安装中…' : (item.installable ? '安装' : '暂不可用')),
|
|
407
|
+
),
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
const running = agent.running;
|
|
411
|
+
return h('article', { className: 'bn-card has-un' + (locked && !trial ? ' bn-lock' : '') },
|
|
412
|
+
h('div', { className: 'bn-card-top' },
|
|
413
|
+
h(AgentIcon, { agent, item }),
|
|
414
|
+
h('div', { style: { minWidth: 0 } },
|
|
415
|
+
h('div', { className: 'bn-name' }, agent.name),
|
|
416
|
+
h('div', { className: 'bn-meta' }, 'v' + agent.version + (agent.updateAvailable ? ' · 可更新至 ' + agent.updateAvailable : '')),
|
|
417
|
+
),
|
|
418
|
+
h('div', { className: 'status' },
|
|
419
|
+
taskActive ? h('span', { className: 'bn-chip warn' }, task.kind === 'runtime' ? '装环境中' : '处理中')
|
|
420
|
+
: trial ? h('span', { className: 'bn-chip warn' }, '试用剩 ' + agent.trialRemaining + ' 次')
|
|
421
|
+
: locked ? h('span', { className: 'bn-chip bad' }, '需授权')
|
|
422
|
+
: running ? h('span', { className: 'bn-chip ok' }, '运行中') : h('span', { className: 'bn-chip dim' }, '已安装'),
|
|
423
|
+
h('button', {
|
|
424
|
+
type: 'button',
|
|
425
|
+
className: 'bn-un',
|
|
426
|
+
disabled: busy || taskActive,
|
|
427
|
+
onClick: () => onConfirm({
|
|
428
|
+
title: '卸载 ' + (agent.name || agent.id) + '?',
|
|
429
|
+
hint: '将停止并移除本机安装,工程目录保留。',
|
|
430
|
+
confirmLabel: '卸载',
|
|
431
|
+
run: () => onAction('uninstall', agent.id),
|
|
432
|
+
}),
|
|
433
|
+
}, '卸载'),
|
|
434
|
+
),
|
|
435
|
+
),
|
|
436
|
+
h('p', { className: 'bn-desc' }, catalogDesc || packagedDesc),
|
|
437
|
+
h('div', { className: 'bn-facts' },
|
|
438
|
+
h('span', { className: 'bn-fact' }, '安装于 ' + timeAgo(agent.installedAt)),
|
|
439
|
+
needRt
|
|
440
|
+
? h('span', { className: 'bn-fact', style: { color: 'var(--bn-warn)' } }, '缺少引擎依赖 ' + missingReq.join(', '))
|
|
441
|
+
: needOptionalRt
|
|
442
|
+
? (() => {
|
|
443
|
+
const optional = missingAll.filter((s) => !/-npm$/i.test(String(s).split('@')[0] || ''));
|
|
444
|
+
const label = (optional.length ? optional : missingAll).join(', ');
|
|
445
|
+
return h('span', {
|
|
446
|
+
className: 'bn-fact',
|
|
447
|
+
style: { color: 'var(--bn-muted)' },
|
|
448
|
+
title: 'ffmpeg/chromium 等需管理后台「运行时」上传后才能本地安装;未上传时可忽略,不影响 Studio 开造',
|
|
449
|
+
}, '可选组件未就绪: ' + label);
|
|
450
|
+
})()
|
|
451
|
+
: null,
|
|
452
|
+
),
|
|
453
|
+
taskActive ? h('div', { className: 'bn-card-progress' },
|
|
454
|
+
h('div', { className: 'bn-meta' }, (task.progress || 0) + '% · ' + (task.message || '处理中')),
|
|
455
|
+
h('div', { className: 'bn-progress' }, h('i', { style: { width: (task.progress || 0) + '%' } })),
|
|
456
|
+
) : null,
|
|
457
|
+
h('div', { className: 'bn-card-actions' },
|
|
458
|
+
needOptionalRt
|
|
459
|
+
? h('button', {
|
|
460
|
+
className: 'bn-btn' + (needRt ? ' primary' : ''),
|
|
461
|
+
disabled: taskActive || busy,
|
|
462
|
+
title: needRt
|
|
463
|
+
? '必需: ' + missingReq.join(', ')
|
|
464
|
+
: '可选组件未上传到商店时会跳过(ffmpeg/chromium)',
|
|
465
|
+
onClick: () => onAction('runtime-missing', agent.id),
|
|
466
|
+
}, h(Icon, { name: 'download' }), taskActive && task.kind === 'runtime' ? '安装中…' : (needRt ? '装环境' : '补环境'))
|
|
467
|
+
: null,
|
|
468
|
+
agent.studio
|
|
469
|
+
? h('button', {
|
|
470
|
+
className: 'bn-btn' + (needRt ? '' : ' primary'),
|
|
471
|
+
disabled: busy || (locked && !trial) || needRt,
|
|
472
|
+
title: needRt ? '请先安装运行环境' : '',
|
|
473
|
+
onClick: () => onAction('open', agent.id),
|
|
474
|
+
}, h(Icon, { name: 'external' }), '打开 Studio')
|
|
475
|
+
: null,
|
|
476
|
+
running
|
|
477
|
+
? h('button', {
|
|
478
|
+
className: 'bn-btn',
|
|
479
|
+
disabled: busy || taskActive,
|
|
480
|
+
title: taskActive ? '有任务进行中,请等待完成后再停止' : '',
|
|
481
|
+
onClick: () => onAction('stop', agent.id),
|
|
482
|
+
}, h(Icon, { name: 'stop' }), '停止')
|
|
483
|
+
: h('button', {
|
|
484
|
+
className: 'bn-btn',
|
|
485
|
+
disabled: busy || (locked && !trial) || needRt || taskActive,
|
|
486
|
+
title: needRt ? '请先安装运行环境' : '',
|
|
487
|
+
onClick: () => onAction('start', agent.id),
|
|
488
|
+
}, h(Icon, { name: 'play' }), '启动'),
|
|
489
|
+
locked && !trial
|
|
490
|
+
? h('button', { className: 'bn-btn', disabled: busy, onClick: () => onAction('activate-product', agent.product) }, '去授权')
|
|
491
|
+
: null,
|
|
492
|
+
agent.updateAvailable
|
|
493
|
+
? h('button', { className: 'bn-btn', disabled: busy || taskActive, onClick: () => onAction('update', agent.id) }, h(Icon, { name: 'download' }), '更新')
|
|
494
|
+
: null,
|
|
495
|
+
),
|
|
496
|
+
);
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
const TaskRow = ({ task }) => h('div', { className: 'bn-task ' + task.status },
|
|
500
|
+
h('div', { style: { flex: 1, minWidth: 0 } },
|
|
501
|
+
h('div', { className: 'title', style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, task.title),
|
|
502
|
+
h('div', { className: 'bn-meta', style: { overflowWrap: 'anywhere' } },
|
|
503
|
+
task.status === 'running' ? '进行中 · ' + task.progress + '%' + (task.message ? ' · ' + task.message : '')
|
|
504
|
+
: task.status === 'done'
|
|
505
|
+
? ('完成' + (task.message ? ' · ' + task.message : '') + (task.artifact ? ' · ' + task.artifact : ''))
|
|
506
|
+
: task.status === 'failed' ? ('失败' + (task.error ? ' · ' + task.error : ''))
|
|
507
|
+
: task.status),
|
|
508
|
+
),
|
|
509
|
+
h('div', { className: 'bn-progress' }, h('i', { style: { width: (task.status === 'done' ? 100 : task.progress) + '%' } })),
|
|
510
|
+
h('div', { className: 'time', style: { width: 64, textAlign: 'right', flex: '0 0 auto' } }, timeAgo(task.createdAt)),
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
function Panel() {
|
|
514
|
+
const [state, setState] = useState(null);
|
|
515
|
+
const [tab, setTab] = useState('agents');
|
|
516
|
+
const [busy, setBusy] = useState(false);
|
|
517
|
+
const [toast, setToast] = useState(null);
|
|
518
|
+
const [modal, setModal] = useState(null);
|
|
519
|
+
const [confirm, setConfirm] = useState(null);
|
|
520
|
+
const confirmLock = useRef(false);
|
|
521
|
+
const [keyInput, setKeyInput] = useState('');
|
|
522
|
+
const [productInput, setProductInput] = useState('biutalk');
|
|
523
|
+
const [lookupEmail, setLookupEmail] = useState('');
|
|
524
|
+
const [lookupResult, setLookupResult] = useState(null);
|
|
525
|
+
const [studioAgentId, setStudioAgentId] = useState(null);
|
|
526
|
+
const [pendingPerm, setPendingPerm] = useState(null);
|
|
527
|
+
const [contactOpen, setContactOpen] = useState(false);
|
|
528
|
+
const [contact, setContact] = useState(null);
|
|
529
|
+
const [contactStatus, setContactStatus] = useState('');
|
|
530
|
+
const [contactError, setContactError] = useState('');
|
|
531
|
+
|
|
532
|
+
const refresh = useCallback(async () => {
|
|
533
|
+
try {
|
|
534
|
+
const next = await api('/state');
|
|
535
|
+
setState(next);
|
|
536
|
+
} catch (err) {
|
|
537
|
+
setToast({ text: err.message, bad: true });
|
|
538
|
+
}
|
|
539
|
+
}, []);
|
|
540
|
+
|
|
541
|
+
useEffect(() => { refresh(); const t = setInterval(refresh, 3000); return () => clearInterval(t); }, [refresh]);
|
|
542
|
+
useEffect(() => { if (!toast) return; const t = setTimeout(() => setToast(null), toast.bad ? 12000 : 3200); return () => clearTimeout(t); }, [toast]);
|
|
543
|
+
useEffect(() => {
|
|
544
|
+
if (!contactOpen) return;
|
|
545
|
+
const onKey = (ev) => { if (ev.key === 'Escape') setContactOpen(false); };
|
|
546
|
+
window.addEventListener('keydown', onKey);
|
|
547
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
548
|
+
}, [contactOpen]);
|
|
549
|
+
|
|
550
|
+
const openContact = async () => {
|
|
551
|
+
setContactOpen(true);
|
|
552
|
+
setContact(null);
|
|
553
|
+
setContactStatus('loading');
|
|
554
|
+
setContactError('');
|
|
555
|
+
try {
|
|
556
|
+
const data = await api('/contact');
|
|
557
|
+
const c = data.contact || {};
|
|
558
|
+
setContact({
|
|
559
|
+
wechatId: c.wechatId || '',
|
|
560
|
+
qrUrl: c.hasQr ? (BASE + '/contact/qr?t=' + Date.now()) : '',
|
|
561
|
+
manualUrl: safeManualUrl(c.manualUrl),
|
|
562
|
+
configured: Boolean(c.configured || c.manualUrl),
|
|
563
|
+
});
|
|
564
|
+
setContactStatus('');
|
|
565
|
+
} catch (error) {
|
|
566
|
+
setContactStatus('error');
|
|
567
|
+
setContactError(error.message || '暂时无法获取客服信息');
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
const copyWechat = async (id) => {
|
|
572
|
+
try {
|
|
573
|
+
await navigator.clipboard.writeText(id);
|
|
574
|
+
setToast({ text: '微信号已复制' });
|
|
575
|
+
} catch {
|
|
576
|
+
setToast({ text: '复制失败,请手动选择微信号', bad: true });
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
useEffect(() => {
|
|
580
|
+
if (!confirm) return;
|
|
581
|
+
const onKey = (ev) => { if (ev.key === 'Escape') setConfirm(null); };
|
|
582
|
+
window.addEventListener('keydown', onKey);
|
|
583
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
584
|
+
}, [confirm]);
|
|
585
|
+
|
|
586
|
+
// 立项开拍成功后:仅「首次看到该开拍」时自动切入创作会话;回 BN 面板不再踢回
|
|
587
|
+
useEffect(() => {
|
|
588
|
+
const kick = state && state.dsh && state.dsh.recentKickoffs && state.dsh.recentKickoffs[0];
|
|
589
|
+
if (!kick || !kick.ok || !kick.sessionId) return;
|
|
590
|
+
const key = String(kick.sessionId) + '@' + String(kick.at || '');
|
|
591
|
+
if (revealedKickoffs.has(key)) return;
|
|
592
|
+
const atMs = kick.at ? Date.parse(kick.at) : 0;
|
|
593
|
+
if (atMs && Date.now() - atMs > KICKOFF_AUTO_REVEAL_MS) {
|
|
594
|
+
revealedKickoffs.add(key);
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
revealedKickoffs.add(key);
|
|
598
|
+
if (!revealCreationSession) return;
|
|
599
|
+
try {
|
|
600
|
+
revealCreationSession(kick.sessionId);
|
|
601
|
+
setToast({ text: '创作已开始 · 正在 DSH 对话中出片' });
|
|
602
|
+
} catch (err) {
|
|
603
|
+
setToast({ text: (err && err.message) || '无法打开创作会话', bad: true });
|
|
604
|
+
}
|
|
605
|
+
}, [state]);
|
|
606
|
+
|
|
607
|
+
useEffect(() => {
|
|
608
|
+
const onMsg = (ev) => {
|
|
609
|
+
const data = ev.data;
|
|
610
|
+
if (!data || data.source !== 'bn-studio' || data.type !== 'open-session') return;
|
|
611
|
+
let originOk = false;
|
|
612
|
+
try {
|
|
613
|
+
const host = new URL(ev.origin).hostname;
|
|
614
|
+
originOk = host === '127.0.0.1' || host === 'localhost';
|
|
615
|
+
} catch { originOk = false; }
|
|
616
|
+
if (!originOk) return;
|
|
617
|
+
const sessionId = typeof data.sessionId === 'string' ? data.sessionId.trim() : '';
|
|
618
|
+
if (!sessionId || sessionId.length > 80) return;
|
|
619
|
+
if (!revealCreationSession) {
|
|
620
|
+
setToast({ text: '当前不在 DSH 里,无法打开对话', bad: true });
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
try { revealCreationSession(sessionId); }
|
|
624
|
+
catch (err) { setToast({ text: (err && err.message) || '无法打开对话', bad: true }); }
|
|
625
|
+
};
|
|
626
|
+
window.addEventListener('message', onMsg);
|
|
627
|
+
return () => window.removeEventListener('message', onMsg);
|
|
628
|
+
}, []);
|
|
629
|
+
|
|
630
|
+
const act = async (fn, okText) => {
|
|
631
|
+
setBusy(true);
|
|
632
|
+
try { await fn(); await refresh(); if (okText) setToast({ text: okText }); }
|
|
633
|
+
catch (err) { setToast({ text: err.message, bad: true }); }
|
|
634
|
+
finally { setBusy(false); }
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
/** 长任务:不锁全局 busy,靠卡片进度条;轮询到结束 */
|
|
638
|
+
const waitTask = async (taskId, okText) => {
|
|
639
|
+
if (!taskId) return;
|
|
640
|
+
for (let i = 0; i < 1800; i++) {
|
|
641
|
+
await new Promise((r) => setTimeout(r, 800));
|
|
642
|
+
const next = await api('/state');
|
|
643
|
+
setState(next);
|
|
644
|
+
const t = (next.tasks || []).find((x) => x.id === taskId);
|
|
645
|
+
if (!t) continue;
|
|
646
|
+
if (t.status === 'done') {
|
|
647
|
+
const msg = (t.message && t.message !== 'done') ? t.message : okText;
|
|
648
|
+
if (msg) setToast({ text: msg });
|
|
649
|
+
return t;
|
|
650
|
+
}
|
|
651
|
+
if (t.status === 'failed') throw new Error(t.error || '任务失败');
|
|
652
|
+
if (t.status === 'cancelled') throw new Error('任务已取消');
|
|
653
|
+
}
|
|
654
|
+
throw new Error('任务超时,请到「任务」查看');
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
const openStudio = async (id) => {
|
|
658
|
+
const agent = (state.agents || []).find((a) => a.id === id);
|
|
659
|
+
if (agent && agent.needsPermissionAck && !agent.permissionsAck) {
|
|
660
|
+
setPendingPerm(agent);
|
|
661
|
+
setModal('permissions');
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
try {
|
|
665
|
+
setBusy(true);
|
|
666
|
+
const res = await api('/agents/open', { method: 'POST', body: { id } });
|
|
667
|
+
setStudioAgentId(id);
|
|
668
|
+
setTab('studio');
|
|
669
|
+
setToast({ text: 'Studio 已打开' });
|
|
670
|
+
await refresh();
|
|
671
|
+
if (!res.studioUrl && res.agent && res.agent.studioUrl) {
|
|
672
|
+
/* refreshed below */
|
|
673
|
+
}
|
|
674
|
+
} catch (err) {
|
|
675
|
+
if (err.message && err.message.indexOf('permissions') >= 0) {
|
|
676
|
+
const agent = (state.agents || []).find((a) => a.id === id);
|
|
677
|
+
setPendingPerm(agent || { id });
|
|
678
|
+
setModal('permissions');
|
|
679
|
+
} else if (err.message && err.message.indexOf('未授权') >= 0) {
|
|
680
|
+
setProductInput(id === 'biureel' ? 'biureel' : 'biutalk');
|
|
681
|
+
setTab('account');
|
|
682
|
+
setToast({ text: err.message, bad: true });
|
|
683
|
+
} else {
|
|
684
|
+
setToast({ text: err.message, bad: true });
|
|
685
|
+
}
|
|
686
|
+
} finally {
|
|
687
|
+
setBusy(false);
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
const onAction = (kind, id) => {
|
|
692
|
+
if (kind === 'open') return openStudio(id);
|
|
693
|
+
if (kind === 'activate-product') {
|
|
694
|
+
setProductInput(id);
|
|
695
|
+
setTab('account');
|
|
696
|
+
setToast({ text: '请激活「' + id + '」或购买授权' });
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
if (kind === 'store-install' || kind === 'runtime-missing') {
|
|
700
|
+
(async () => {
|
|
701
|
+
try {
|
|
702
|
+
const started = kind === 'store-install'
|
|
703
|
+
? await api('/agents/store-install', { method: 'POST', body: { product: id } })
|
|
704
|
+
: await api('/runtime/install-missing', { method: 'POST', body: { id } });
|
|
705
|
+
const taskId = started && started.task && started.task.id;
|
|
706
|
+
setToast({ text: kind === 'store-install' ? '已开始安装…' : '已开始安装运行环境…' });
|
|
707
|
+
await refresh();
|
|
708
|
+
if (taskId) {
|
|
709
|
+
await waitTask(taskId, kind === 'store-install' ? '安装完成' : '运行环境已安装');
|
|
710
|
+
await refresh();
|
|
711
|
+
} else if (started && started.ok) {
|
|
712
|
+
setToast({ text: kind === 'store-install' ? '安装完成' : '运行环境已安装' });
|
|
713
|
+
await refresh();
|
|
714
|
+
}
|
|
715
|
+
} catch (err) {
|
|
716
|
+
setToast({ text: err.message, bad: true });
|
|
717
|
+
await refresh();
|
|
718
|
+
}
|
|
719
|
+
})();
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
return act(async () => {
|
|
723
|
+
if (kind === 'start') {
|
|
724
|
+
try {
|
|
725
|
+
await api('/agents/start', { method: 'POST', body: { id } });
|
|
726
|
+
} catch (err) {
|
|
727
|
+
if (String(err.message || '').indexOf('permissions') >= 0) {
|
|
728
|
+
const agent = (state.agents || []).find((a) => a.id === id);
|
|
729
|
+
setPendingPerm(agent || { id });
|
|
730
|
+
setModal('permissions');
|
|
731
|
+
throw err;
|
|
732
|
+
}
|
|
733
|
+
throw err;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
if (kind === 'stop') {
|
|
737
|
+
try {
|
|
738
|
+
await api('/agents/stop', { method: 'POST', body: { id } });
|
|
739
|
+
} catch (err) {
|
|
740
|
+
if (String(err.message || '').indexOf('任务进行中') >= 0 || String(err.code || '') === 'TASKS_RUNNING') {
|
|
741
|
+
throw Object.assign(new Error('有创作任务进行中,请等待完成后再停止'), { code: 'TASKS_RUNNING' });
|
|
742
|
+
}
|
|
743
|
+
throw err;
|
|
744
|
+
}
|
|
745
|
+
if (studioAgentId === id) { setStudioAgentId(null); setTab('agents'); }
|
|
746
|
+
}
|
|
747
|
+
if (kind === 'uninstall') {
|
|
748
|
+
await api('/agents/uninstall', { method: 'POST', body: { id, keepWorkspace: true } });
|
|
749
|
+
if (studioAgentId === id) { setStudioAgentId(null); setTab('agents'); }
|
|
750
|
+
}
|
|
751
|
+
if (kind === 'update') await api('/agents/update', { method: 'POST', body: { id } });
|
|
752
|
+
}, kind === 'start' ? '已启动' : kind === 'stop' ? '已停止' : kind === 'update' ? '已更新' : '已卸载');
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
if (!state) {
|
|
756
|
+
return h('div', { className: 'bn-root' },
|
|
757
|
+
h('aside', { className: 'bn-rail' }, h('div', { className: 'bn-logo' }, h('span', { className: 'dot' }), BRAND)),
|
|
758
|
+
h('main', { className: 'bn-main' }, h('div', { className: 'bn-grid' }, h('div', { className: 'bn-skel' }), h('div', { className: 'bn-skel' }))));
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
const agents = state.agents || [];
|
|
762
|
+
const store = state.store && state.store.length ? state.store : agents.map((a) => ({
|
|
763
|
+
slug: a.id, name: a.name, description: a.description, icon: a.icon, latest: { version: a.version },
|
|
764
|
+
installable: false, installed: true, installedVersion: a.version, updateAvailable: a.updateAvailable, agent: a,
|
|
765
|
+
}));
|
|
766
|
+
const tasks = state.tasks || [];
|
|
767
|
+
const licenses = state.licenses || [];
|
|
768
|
+
const running = agents.filter((a) => a.running).length;
|
|
769
|
+
const updates = agents.filter((a) => a.updateAvailable).length;
|
|
770
|
+
const studioAgent = agents.find((a) => a.id === studioAgentId) || null;
|
|
771
|
+
const studioBlurb = (() => {
|
|
772
|
+
if (!studioAgent) return '';
|
|
773
|
+
const hit = (state.store || []).find((item) => item.slug === studioAgent.product || item.slug === studioAgent.id);
|
|
774
|
+
return hit && hit.description ? String(hit.description).trim() : '';
|
|
775
|
+
})();
|
|
776
|
+
|
|
777
|
+
return h('div', { className: 'bn-root' },
|
|
778
|
+
h('aside', { className: 'bn-rail' },
|
|
779
|
+
h('div', { className: 'bn-logo' }, h('span', { className: 'dot' }, h('img', { src: BASE + '/icons/app.svg', alt: '' })), BRAND),
|
|
780
|
+
h('nav', { className: 'bn-nav' },
|
|
781
|
+
h('button', { className: tab === 'agents' ? 'on' : '', onClick: () => setTab('agents') }, h(Icon, { name: 'grid' }), 'Agents', h('span', { className: 'count' }, String(agents.length))),
|
|
782
|
+
h('button', { className: tab === 'studio' ? 'on' : '', onClick: () => studioAgentId && setTab('studio'), disabled: !studioAgentId }, h(Icon, { name: 'external' }), 'Studio'),
|
|
783
|
+
h('button', { className: tab === 'tasks' ? 'on' : '', onClick: () => setTab('tasks') }, h(Icon, { name: 'list' }), '任务', h('span', { className: 'count' }, String(tasks.filter((t) => t.status === 'running').length || ''))),
|
|
784
|
+
h('button', { className: tab === 'account' ? 'on' : '', onClick: () => setTab('account') }, h(Icon, { name: 'key' }), '我的授权', h('span', { className: 'count' }, String(licenses.length || ''))),
|
|
785
|
+
h('button', { className: tab === 'settings' ? 'on' : '', onClick: () => setTab('settings') }, h(Icon, { name: 'gear' }), '设置'),
|
|
786
|
+
),
|
|
787
|
+
h('nav', { className: 'bn-nav bn-rail-support' },
|
|
788
|
+
h('button', { type: 'button', className: contactOpen ? 'on' : '', onClick: () => { void openContact(); } }, h(Icon, { name: 'chat' }), '联系&帮助'),
|
|
789
|
+
),
|
|
790
|
+
h('div', { className: 'bn-rail-foot' },
|
|
791
|
+
h('div', null, running + ' 个运行中'),
|
|
792
|
+
h('div', { className: 'bn-mono', style: { marginTop: 4 } }, licenses.length ? (licenses.length + ' 产品授权') : state.license.state),
|
|
793
|
+
),
|
|
794
|
+
),
|
|
795
|
+
h('main', { className: 'bn-main' },
|
|
796
|
+
tab !== 'studio' ? h('div', { className: 'bn-head' },
|
|
797
|
+
h('div', null,
|
|
798
|
+
h('h1', { className: 'bn-h1' }, tab === 'agents' ? 'Agents' : tab === 'tasks' ? '任务' : tab === 'account' ? '我的授权' : '设置'),
|
|
799
|
+
h('div', { className: 'bn-sub' }, tab === 'agents' ? '从商店一键安装,授权后可完整使用' : tab === 'tasks' ? '安装与创作进度' : tab === 'account' ? '激活码与购买' : '偏好设置'),
|
|
800
|
+
),
|
|
801
|
+
h('div', { className: 'bn-head-actions' },
|
|
802
|
+
h(LicenseChip, { license: state.license }),
|
|
803
|
+
),
|
|
804
|
+
) : null,
|
|
805
|
+
|
|
806
|
+
state.panel && state.panel.updateAvailable && tab !== 'studio' ? h('div', { className: 'bn-banner' },
|
|
807
|
+
h(Icon, { name: 'download' }),
|
|
808
|
+
h('span', null,
|
|
809
|
+
h('b', null, '面板有新版本'),
|
|
810
|
+
' · 当前 v' + (state.panel.version || '?') + ' → v' + (state.panel.latest || '?'),
|
|
811
|
+
),
|
|
812
|
+
h('button', {
|
|
813
|
+
className: 'bn-btn',
|
|
814
|
+
onClick: () => {
|
|
815
|
+
setTab('settings');
|
|
816
|
+
setToast({ text: state.panel.installHint || '请到 DSH 插件列表更新 bnpanel 后重启' });
|
|
817
|
+
},
|
|
818
|
+
}, '如何更新'),
|
|
819
|
+
) : null,
|
|
820
|
+
|
|
821
|
+
updates > 0 && tab === 'agents' ? h('div', { className: 'bn-banner' },
|
|
822
|
+
h(Icon, { name: 'download' }),
|
|
823
|
+
h('span', null, h('b', null, updates + ' 个 Agent'), ' 有新版本可用'),
|
|
824
|
+
h('button', { className: 'bn-btn', onClick: () => act(async () => { for (const a of agents.filter((x) => x.updateAvailable)) await api('/agents/update', { method: 'POST', body: { id: a.id } }); }, '已全部更新') }, '全部更新'),
|
|
825
|
+
) : null,
|
|
826
|
+
|
|
827
|
+
tab === 'agents' && tasks.some((t) => t.status === 'running' || t.status === 'queued')
|
|
828
|
+
? h('div', { className: 'bn-live-tasks' },
|
|
829
|
+
tasks.filter((t) => t.status === 'running' || t.status === 'queued').slice(0, 4).map((t) =>
|
|
830
|
+
h('div', { key: t.id, className: 'bn-live-task' },
|
|
831
|
+
h('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 8, marginBottom: 6 } },
|
|
832
|
+
h('div', { style: { fontWeight: 600 } }, t.title),
|
|
833
|
+
h('div', { className: 'bn-meta' }, (t.progress || 0) + '%'),
|
|
834
|
+
),
|
|
835
|
+
h('div', { className: 'bn-meta', style: { marginBottom: 6 } }, t.message || (t.status === 'queued' ? '排队中' : '进行中')),
|
|
836
|
+
h('div', { className: 'bn-progress' }, h('i', { style: { width: (t.status === 'queued' ? 4 : (t.progress || 0)) + '%' } })),
|
|
837
|
+
),
|
|
838
|
+
),
|
|
839
|
+
)
|
|
840
|
+
: null,
|
|
841
|
+
|
|
842
|
+
tab === 'agents' ? (
|
|
843
|
+
store.length
|
|
844
|
+
? h('div', { className: 'bn-grid' }, store.map((item) => {
|
|
845
|
+
const task = tasks.find((t) =>
|
|
846
|
+
(t.agentId === item.slug || t.agentId === (item.agent && item.agent.id))
|
|
847
|
+
&& (t.status === 'running' || t.status === 'queued'));
|
|
848
|
+
return h(StoreCard, { key: item.slug, item, busy, task, onAction, onConfirm: setConfirm });
|
|
849
|
+
}))
|
|
850
|
+
: h('div', { className: 'bn-empty' },
|
|
851
|
+
h('div', { className: 'art' }, h(Icon, { name: 'grid', size: 30 })),
|
|
852
|
+
h('h3', null, '商店暂无 Agent'),
|
|
853
|
+
h('p', null, state.storeError || '请到「设置」填写授权服务地址(如 https://dsh.biunow.cn),并确认管理后台已发布产品。'),
|
|
854
|
+
)
|
|
855
|
+
) : null,
|
|
856
|
+
|
|
857
|
+
tab === 'studio' ? (
|
|
858
|
+
studioAgent && studioAgent.studioUrl
|
|
859
|
+
? h('div', { className: 'bn-studio' },
|
|
860
|
+
h('div', { className: 'bn-studio-bar' },
|
|
861
|
+
h('button', { className: 'bn-btn ghost', onClick: () => setTab('agents') }, '← Agents'),
|
|
862
|
+
h('div', { className: 'copy' },
|
|
863
|
+
h('div', { className: 'title' }, studioAgent.name + ' Studio'),
|
|
864
|
+
studioBlurb ? h('div', { className: 'meta', title: studioBlurb }, studioBlurb) : null,
|
|
865
|
+
),
|
|
866
|
+
h('div', { style: { marginLeft: 'auto', display: 'flex', gap: 8 } },
|
|
867
|
+
h('button', { className: 'bn-btn', onClick: () => openStudio(studioAgent.id) }, h(Icon, { name: 'refresh' }), '刷新'),
|
|
868
|
+
(() => {
|
|
869
|
+
const studioBusy = (state.tasks || []).some(
|
|
870
|
+
(t) => t.agentId === studioAgent.id && (t.status === 'running' || t.status === 'queued'),
|
|
871
|
+
);
|
|
872
|
+
return h('button', {
|
|
873
|
+
className: 'bn-btn',
|
|
874
|
+
disabled: busy || studioBusy,
|
|
875
|
+
title: studioBusy ? '有任务进行中,请等待完成后再停止' : '',
|
|
876
|
+
onClick: () => onAction('stop', studioAgent.id),
|
|
877
|
+
}, h(Icon, { name: 'stop' }), '停止');
|
|
878
|
+
})(),
|
|
879
|
+
),
|
|
880
|
+
),
|
|
881
|
+
h('iframe', { title: studioAgent.name, src: studioAgent.studioUrl, allow: 'clipboard-read; clipboard-write' }),
|
|
882
|
+
)
|
|
883
|
+
: h('div', { className: 'bn-empty' },
|
|
884
|
+
h('h3', null, '尚未打开 Studio'),
|
|
885
|
+
h('p', null, '在 Agents 列表中点击「打开 Studio」。'),
|
|
886
|
+
)
|
|
887
|
+
) : null,
|
|
888
|
+
|
|
889
|
+
tab === 'tasks' ? h('section', { className: 'bn-panel' },
|
|
890
|
+
h('h2', null, '最近任务'),
|
|
891
|
+
tasks.length ? tasks.slice(0, 20).map((t) => h(TaskRow, { key: t.id, task: t })) : h('div', { className: 'bn-sub' }, '暂无任务'),
|
|
892
|
+
) : null,
|
|
893
|
+
|
|
894
|
+
tab === 'account' ? h('div', null,
|
|
895
|
+
h('section', { className: 'bn-panel' },
|
|
896
|
+
h('div', { className: 'bn-sec-head' },
|
|
897
|
+
h('h2', null, '本机已激活产品'),
|
|
898
|
+
h('div', { className: 'bn-sec-actions' },
|
|
899
|
+
licenses.length
|
|
900
|
+
? h('button', { className: 'bn-btn ghost', onClick: () => setConfirm({
|
|
901
|
+
title: '注销全部产品?',
|
|
902
|
+
hint: '本机所有产品的激活记录都会被清除。',
|
|
903
|
+
confirmLabel: '注销全部',
|
|
904
|
+
run: () => act(async () => { await api('/signout', { method: 'POST', body: {} }); }, '已注销全部产品'),
|
|
905
|
+
}) }, '注销全部')
|
|
906
|
+
: null,
|
|
907
|
+
state.buyUrl ? h('a', { className: 'bn-btn primary', href: state.buyUrl, target: '_blank', rel: 'noreferrer' }, '在线购买') : null,
|
|
908
|
+
),
|
|
909
|
+
),
|
|
910
|
+
licenses.length
|
|
911
|
+
? h('div', { className: 'bn-grid' },
|
|
912
|
+
licenses.map((row) => {
|
|
913
|
+
const cat = (state.store || []).find((s) => (s.slug || s.product) === row.product);
|
|
914
|
+
const name = (cat && cat.name) || row.product;
|
|
915
|
+
const desc = cat && cat.description ? String(cat.description).trim() : '';
|
|
916
|
+
const icon = (cat && cat.icon) || ('icon://' + row.product);
|
|
917
|
+
return h('article', { key: row.product, className: 'bn-card bn-lic' },
|
|
918
|
+
h('div', { className: 'bn-card-top' },
|
|
919
|
+
h(AgentIcon, { item: { icon, name, slug: row.product } }),
|
|
920
|
+
h('div', { style: { minWidth: 0 } },
|
|
921
|
+
h('div', { className: 'bn-name' }, name),
|
|
922
|
+
),
|
|
923
|
+
),
|
|
924
|
+
h('div', { className: 'status' },
|
|
925
|
+
h(LicenseChip, { license: row.status }),
|
|
926
|
+
h('button', { className: 'bn-btn ghost', onClick: () => setConfirm({
|
|
927
|
+
title: '注销 ' + name + '?',
|
|
928
|
+
hint: '本机该产品的激活记录会被清除,需要重新激活。',
|
|
929
|
+
confirmLabel: '注销',
|
|
930
|
+
run: () => act(async () => { await api('/signout', { method: 'POST', body: { product: row.product } }); }, '已注销 ' + name),
|
|
931
|
+
}) }, '注销'),
|
|
932
|
+
),
|
|
933
|
+
desc ? h('p', { className: 'bn-desc' }, desc) : null,
|
|
934
|
+
h('div', { className: 'bn-facts' },
|
|
935
|
+
h('span', { className: 'bn-fact' }, '至 ' + ((row.status && row.status.expiresAt) || '').slice(0, 10)),
|
|
936
|
+
h('span', { className: 'bn-fact' }, '席位 ' + ((row.status && row.status.used) || 0) + '/' + ((row.status && row.status.seats) || 0)),
|
|
937
|
+
),
|
|
938
|
+
);
|
|
939
|
+
}),
|
|
940
|
+
)
|
|
941
|
+
: h('div', { className: 'bn-sub' }, '尚未激活正式授权。安装后自带 1 次试用;购买后激活码会发到邮箱。'),
|
|
942
|
+
h('div', { className: 'bn-activate' },
|
|
943
|
+
h(BnDropdown, {
|
|
944
|
+
value: productInput,
|
|
945
|
+
onChange: (v) => setProductInput(v),
|
|
946
|
+
options: (() => {
|
|
947
|
+
const opts = [];
|
|
948
|
+
const seen = new Set();
|
|
949
|
+
const push = (value, label, description, icon) => {
|
|
950
|
+
if (!value || seen.has(value)) return;
|
|
951
|
+
seen.add(value);
|
|
952
|
+
opts.push({
|
|
953
|
+
value,
|
|
954
|
+
label: label || value,
|
|
955
|
+
detail: description ? String(description).trim() : '',
|
|
956
|
+
icon: icon || ('icon://' + value),
|
|
957
|
+
});
|
|
958
|
+
};
|
|
959
|
+
for (const s of (state.store || [])) push(s.slug || s.product, s.name, s.description, s.icon);
|
|
960
|
+
for (const row of licenses) push(row.product, row.product, '', 'icon://' + row.product);
|
|
961
|
+
if (!opts.length) {
|
|
962
|
+
push('biutalk', 'BiuTalk', '商店未连通时的兜底', 'icon://biutalk');
|
|
963
|
+
push('biureel', 'BiuReel', '商店未连通时的兜底', 'icon://biureel');
|
|
964
|
+
}
|
|
965
|
+
return opts;
|
|
966
|
+
})(),
|
|
967
|
+
}),
|
|
968
|
+
h('input', { className: 'bn-input', placeholder: '粘贴激活码 DSHP-…', value: keyInput, onChange: (e) => setKeyInput(e.target.value) }),
|
|
969
|
+
h('button', { className: 'bn-btn primary', disabled: busy, onClick: () => act(async () => { await api('/activate', { method: 'POST', body: { key: keyInput.trim(), product: productInput } }); setKeyInput(''); }, '已激活 ' + productInput) }, '激活'),
|
|
970
|
+
),
|
|
971
|
+
),
|
|
972
|
+
h('section', { className: 'bn-panel' },
|
|
973
|
+
h('h2', null, '用邮箱查询云端订单'),
|
|
974
|
+
h('div', { className: 'bn-sub', style: { marginBottom: 10 } }, '不展示完整激活码(请查邮件)。可核对订单与许可证状态。'),
|
|
975
|
+
h('div', { className: 'bn-form' },
|
|
976
|
+
h('input', { className: 'bn-input', type: 'email', placeholder: 'you@example.com', value: lookupEmail, onChange: (e) => setLookupEmail(e.target.value) }),
|
|
977
|
+
h('button', { className: 'bn-btn', disabled: busy || !lookupEmail.trim(), onClick: () => act(async () => {
|
|
978
|
+
const base = (state.licenseBaseUrl || '').replace(/\/$/, '');
|
|
979
|
+
if (!base) throw new Error('未配置 license 服务地址');
|
|
980
|
+
const res = await fetch(base + '/v1/account/lookup?email=' + encodeURIComponent(lookupEmail.trim()));
|
|
981
|
+
const data = await res.json().catch(() => ({}));
|
|
982
|
+
if (!res.ok) throw new Error((data.error && data.error.message) || data.error || res.statusText);
|
|
983
|
+
setLookupResult(data);
|
|
984
|
+
}, '已查询') }, '查询'),
|
|
985
|
+
),
|
|
986
|
+
lookupResult ? h('div', { style: { marginTop: 12 } },
|
|
987
|
+
h('div', { className: 'bn-sub' }, '许可证 ' + (lookupResult.licenses || []).length + ' · 订单 ' + (lookupResult.orders || []).length),
|
|
988
|
+
(lookupResult.licenses || []).map((l) => h('div', { key: l.id, className: 'bn-row', style: { justifyContent: 'space-between', marginTop: 6 } },
|
|
989
|
+
h('span', null, l.productName + ' · ' + l.hint),
|
|
990
|
+
h('span', { className: 'bn-sub' }, l.status + ' · 至 ' + (l.expiresAt || '').slice(0, 10)),
|
|
991
|
+
)),
|
|
992
|
+
(lookupResult.orders || []).slice(0, 5).map((o) => h('div', { key: o.id, className: 'bn-sub', style: { marginTop: 4 } },
|
|
993
|
+
o.title + ' · ¥' + o.amount + ' · ' + o.status + ' · ' + o.outTradeNo,
|
|
994
|
+
)),
|
|
995
|
+
) : null,
|
|
996
|
+
),
|
|
997
|
+
) : null,
|
|
998
|
+
|
|
999
|
+
tab === 'settings' ? h('div', null,
|
|
1000
|
+
h('section', { className: 'bn-panel' },
|
|
1001
|
+
h('h2', null, '面板版本'),
|
|
1002
|
+
h('p', { className: 'bn-sub', style: { marginBottom: 8 } },
|
|
1003
|
+
'当前 bnpanel v' + ((state.panel && state.panel.version) || '?')
|
|
1004
|
+
+ (state.panel && state.panel.latest
|
|
1005
|
+
? (state.panel.updateAvailable
|
|
1006
|
+
? ' · 可更新至 v' + state.panel.latest
|
|
1007
|
+
: ' · 已是最新(npm v' + state.panel.latest + ')')
|
|
1008
|
+
: '')
|
|
1009
|
+
+ (state.panel && state.panel.error ? ' · 检查失败:' + state.panel.error : ''),
|
|
1010
|
+
),
|
|
1011
|
+
h('div', { className: 'bn-form' },
|
|
1012
|
+
h('input', {
|
|
1013
|
+
className: 'bn-input',
|
|
1014
|
+
style: { flex: 1, minWidth: 220 },
|
|
1015
|
+
placeholder: 'https://registry.npmmirror.com',
|
|
1016
|
+
defaultValue: (state.settings && state.settings.panelNpmRegistry) || 'https://registry.npmmirror.com',
|
|
1017
|
+
key: 'panel-reg-' + ((state.settings && state.settings.panelNpmRegistry) || ''),
|
|
1018
|
+
id: 'bn-panel-registry',
|
|
1019
|
+
}),
|
|
1020
|
+
h('button', {
|
|
1021
|
+
className: 'bn-btn',
|
|
1022
|
+
disabled: busy,
|
|
1023
|
+
onClick: () => act(async () => {
|
|
1024
|
+
const el = document.getElementById('bn-panel-registry');
|
|
1025
|
+
const url = String((el && el.value) || '').trim().replace(/\/$/, '');
|
|
1026
|
+
if (!url) throw new Error('请填写 npm registry');
|
|
1027
|
+
if (!/^https?:\/\//i.test(url)) throw new Error('地址需以 http:// 或 https:// 开头');
|
|
1028
|
+
await api('/settings', { method: 'POST', body: { patch: { panelNpmRegistry: url } } });
|
|
1029
|
+
}, '检查源已保存'),
|
|
1030
|
+
}, '保存源'),
|
|
1031
|
+
h('button', {
|
|
1032
|
+
className: 'bn-btn primary',
|
|
1033
|
+
disabled: busy,
|
|
1034
|
+
onClick: () => act(async () => {
|
|
1035
|
+
const res = await api('/panel/check-update', { method: 'POST' });
|
|
1036
|
+
const p = res && res.panel;
|
|
1037
|
+
if (!p) return '已检查';
|
|
1038
|
+
if (p.error) throw new Error(p.error);
|
|
1039
|
+
if (p.updateAvailable) return '发现面板 v' + p.latest + ',请到 DSH 更新 bnpanel 后重启';
|
|
1040
|
+
return '面板已是最新 v' + (p.latest || p.current);
|
|
1041
|
+
}),
|
|
1042
|
+
}, h(Icon, { name: 'refresh' }), '检查面板更新'),
|
|
1043
|
+
),
|
|
1044
|
+
h('p', { className: 'bn-sub', style: { marginTop: 8 } },
|
|
1045
|
+
(state.panel && state.panel.installHint)
|
|
1046
|
+
|| '安装/更新:DSH → 添加插件 → 包名 bnpanel(建议中国大陆镜像)',
|
|
1047
|
+
),
|
|
1048
|
+
),
|
|
1049
|
+
h('section', { className: 'bn-panel' },
|
|
1050
|
+
h('h2', null, '授权服务'),
|
|
1051
|
+
h('div', { className: 'bn-sub', style: { marginBottom: 8 } }, '商店与激活都连这个地址。线上请填 https://dsh.biunow.cn'),
|
|
1052
|
+
h('div', { className: 'bn-form' },
|
|
1053
|
+
h('input', {
|
|
1054
|
+
className: 'bn-input',
|
|
1055
|
+
style: { flex: 1, minWidth: 220 },
|
|
1056
|
+
placeholder: 'https://dsh.biunow.cn',
|
|
1057
|
+
defaultValue: state.licenseBaseUrl || '',
|
|
1058
|
+
key: 'lic-url-' + (state.licenseBaseUrl || ''),
|
|
1059
|
+
id: 'bn-license-url',
|
|
1060
|
+
}),
|
|
1061
|
+
h('button', {
|
|
1062
|
+
className: 'bn-btn primary',
|
|
1063
|
+
disabled: busy,
|
|
1064
|
+
onClick: () => act(async () => {
|
|
1065
|
+
const el = document.getElementById('bn-license-url');
|
|
1066
|
+
const url = String((el && el.value) || '').trim().replace(/\/$/, '');
|
|
1067
|
+
if (!url) throw new Error('请填写授权服务地址');
|
|
1068
|
+
if (!/^https?:\/\//i.test(url)) throw new Error('地址需以 http:// 或 https:// 开头');
|
|
1069
|
+
await api('/settings', { method: 'POST', body: { patch: { licenseBaseUrl: url } } });
|
|
1070
|
+
}, '授权服务已保存'),
|
|
1071
|
+
}, '保存'),
|
|
1072
|
+
),
|
|
1073
|
+
h('p', { className: 'bn-sub', style: { marginTop: 8 } }, '当前:' + (state.licenseBaseUrl || '未设置')),
|
|
1074
|
+
),
|
|
1075
|
+
h('section', { className: 'bn-panel' },
|
|
1076
|
+
h('h2', null, '偏好'),
|
|
1077
|
+
h('label', { style: { display: 'flex', gap: 6, alignItems: 'center', marginTop: 4, fontSize: 13, color: 'var(--bn-muted)' } },
|
|
1078
|
+
h('input', { type: 'checkbox', checked: !!(state.settings && state.settings.autoInstallUpdates), onChange: (e) => act(async () => { await api('/settings', { method: 'POST', body: { patch: { autoInstallUpdates: e.target.checked } } }); }, '已保存') }),
|
|
1079
|
+
'有更新时自动安装(Agent 停止时)',
|
|
1080
|
+
),
|
|
1081
|
+
h('label', { style: { display: 'flex', gap: 6, alignItems: 'center', marginTop: 10, fontSize: 13, color: 'var(--bn-muted)' } },
|
|
1082
|
+
h('input', { type: 'checkbox', checked: !(state.settings && state.settings.autoKickoffInDsh === false), onChange: (e) => act(async () => { await api('/settings', { method: 'POST', body: { patch: { autoKickoffInDsh: e.target.checked } } }); }, '已保存') }),
|
|
1083
|
+
'Studio 立项后自动进入创作(接通 DSH 对话,等同导入 Agent 丢需求)',
|
|
1084
|
+
),
|
|
1085
|
+
h('label', { style: { display: 'flex', gap: 6, alignItems: 'center', marginTop: 10, fontSize: 13, color: 'var(--bn-muted)' } },
|
|
1086
|
+
h('input', { type: 'checkbox', checked: !!(state.settings && state.settings.telemetry), onChange: (e) => act(async () => { await api('/settings', { method: 'POST', body: { patch: { telemetry: e.target.checked } } }); }, '已保存') }),
|
|
1087
|
+
'匿名安装统计(仅上报已装 Agent 与版本,不含文件内容)',
|
|
1088
|
+
),
|
|
1089
|
+
state.dsh ? h('p', { className: 'bn-sub', style: { marginTop: 8 } },
|
|
1090
|
+
'DSH 接通:skill ' + (state.dsh.skills ? '已就绪' : '未注入') + ' · 会话 ' + (state.dsh.chat ? '已就绪' : '未注入') +
|
|
1091
|
+
((state.dsh.recentKickoffs && state.dsh.recentKickoffs[0])
|
|
1092
|
+
? ' · 最近 ' + (state.dsh.recentKickoffs[0].ok ? '已开拍' : '开拍失败')
|
|
1093
|
+
: ''),
|
|
1094
|
+
) : null,
|
|
1095
|
+
h('div', { style: { marginTop: 16, display: 'flex', gap: 8, flexWrap: 'wrap' } },
|
|
1096
|
+
h('button', {
|
|
1097
|
+
className: 'bn-btn',
|
|
1098
|
+
disabled: busy,
|
|
1099
|
+
onClick: () => act(async () => {
|
|
1100
|
+
const res = await api('/updates/check', { method: 'POST' });
|
|
1101
|
+
const p = res && res.panel;
|
|
1102
|
+
if (p && p.updateAvailable) return 'Agent 已检查;面板可更新至 v' + p.latest;
|
|
1103
|
+
if (p && p.error) return 'Agent 已检查;面板检查失败:' + p.error;
|
|
1104
|
+
return 'Agent / 面板更新已检查';
|
|
1105
|
+
}),
|
|
1106
|
+
}, h(Icon, { name: 'refresh' }), '检查更新'),
|
|
1107
|
+
),
|
|
1108
|
+
h('p', { className: 'bn-sub', style: { marginTop: 18 } }, '安装免费;每个 Agent 首次安装赠送 1 次试用生成。正式授权请到「我的授权」。'),
|
|
1109
|
+
),
|
|
1110
|
+
) : null,
|
|
1111
|
+
),
|
|
1112
|
+
|
|
1113
|
+
contactOpen ? h('div', { className: 'bn-modal-back', onClick: (e) => { if (e.target === e.currentTarget) setContactOpen(false); } },
|
|
1114
|
+
h('div', { className: 'bn-modal bn-contact', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': 'bn-contact-title' },
|
|
1115
|
+
h('div', { className: 'bn-contact-head' },
|
|
1116
|
+
h('div', { className: 'bn-contact-mark', 'aria-hidden': true }, 'N'),
|
|
1117
|
+
h('div', null,
|
|
1118
|
+
h('h3', { id: 'bn-contact-title' }, '联系&帮助'),
|
|
1119
|
+
h('div', { className: 'hint' }, '添加微信,或打开使用手册'),
|
|
1120
|
+
),
|
|
1121
|
+
h('button', { type: 'button', className: 'bn-contact-x', 'aria-label': '关闭', onClick: () => setContactOpen(false) }, '×'),
|
|
1122
|
+
),
|
|
1123
|
+
h('div', { className: 'bn-contact-body' },
|
|
1124
|
+
contactStatus === 'loading' ? h('p', { className: 'bn-sub' }, '正在获取…') : null,
|
|
1125
|
+
contactStatus === 'error' ? h('p', { className: 'bn-sub' }, contactError || '暂时无法获取客服信息') : null,
|
|
1126
|
+
contactStatus === '' && contact && !contact.configured && !contact.manualUrl ? h('p', { className: 'bn-sub' }, '暂未配置,请稍后再试。') : null,
|
|
1127
|
+
contact && contact.qrUrl ? h('div', { className: 'bn-qr-frame' }, h('img', { className: 'bn-qr', src: contact.qrUrl, alt: '微信二维码' })) : null,
|
|
1128
|
+
contact && contact.wechatId ? h('div', { className: 'bn-wx' },
|
|
1129
|
+
h('div', null,
|
|
1130
|
+
h('div', { className: 'label' }, '微信号'),
|
|
1131
|
+
h('code', null, contact.wechatId),
|
|
1132
|
+
),
|
|
1133
|
+
h('button', { type: 'button', className: 'bn-btn', onClick: () => { void copyWechat(contact.wechatId); } }, '复制'),
|
|
1134
|
+
) : null,
|
|
1135
|
+
contact && contact.manualUrl ? h('a', {
|
|
1136
|
+
className: 'bn-btn primary bn-manual',
|
|
1137
|
+
href: contact.manualUrl,
|
|
1138
|
+
target: '_blank',
|
|
1139
|
+
rel: 'noopener noreferrer',
|
|
1140
|
+
}, '使用手册') : null,
|
|
1141
|
+
),
|
|
1142
|
+
),
|
|
1143
|
+
) : null,
|
|
1144
|
+
|
|
1145
|
+
modal === 'permissions' && pendingPerm ? h('div', { className: 'bn-modal-back', onClick: (e) => { if (e.target === e.currentTarget) setModal(null); } },
|
|
1146
|
+
h('div', { className: 'bn-modal' },
|
|
1147
|
+
h('h3', null, '权限确认 · ' + (pendingPerm.name || pendingPerm.id)),
|
|
1148
|
+
h('div', { className: 'hint' }, '首次打开 Studio 前请确认该 Agent 声明的能力。授权失效时仅降级,不会删除你的项目。'),
|
|
1149
|
+
h('dl', { className: 'bn-kv' },
|
|
1150
|
+
h('dt', null, '文件系统'), h('dd', null, (pendingPerm.permissions && pendingPerm.permissions.fs && pendingPerm.permissions.fs.scope) || 'workspace'),
|
|
1151
|
+
h('dt', null, '启动子进程'), h('dd', null, pendingPerm.permissions && pendingPerm.permissions.process && pendingPerm.permissions.process.spawn ? '是 · ' + ((pendingPerm.permissions.process.executables || []).join(', ') || 'node') : '否'),
|
|
1152
|
+
h('dt', null, '网络出口'), h('dd', null, (pendingPerm.permissions && pendingPerm.permissions.network && (pendingPerm.permissions.network.egress || []).join(', ')) || '无(仅本机)'),
|
|
1153
|
+
h('dt', null, '产品授权'), h('dd', null, pendingPerm.product || '—'),
|
|
1154
|
+
),
|
|
1155
|
+
h('div', { className: 'bn-actions-end' },
|
|
1156
|
+
h('button', { className: 'bn-btn ghost', onClick: () => { setModal(null); setPendingPerm(null); } }, '取消'),
|
|
1157
|
+
h('button', { className: 'bn-btn primary', disabled: busy, onClick: () => act(async () => {
|
|
1158
|
+
await api('/permissions/ack', { method: 'POST', body: { id: pendingPerm.id } });
|
|
1159
|
+
setModal(null);
|
|
1160
|
+
const id = pendingPerm.id;
|
|
1161
|
+
setPendingPerm(null);
|
|
1162
|
+
await openStudio(id);
|
|
1163
|
+
}) }, '同意并打开 Studio'),
|
|
1164
|
+
),
|
|
1165
|
+
),
|
|
1166
|
+
) : null,
|
|
1167
|
+
|
|
1168
|
+
confirm ? h('div', { className: 'bn-modal-back', onClick: (e) => { if (e.target === e.currentTarget) setConfirm(null); } },
|
|
1169
|
+
h('div', { className: 'bn-modal', role: 'dialog', 'aria-modal': 'true' },
|
|
1170
|
+
h('h3', null, confirm.title),
|
|
1171
|
+
h('div', { className: 'hint' }, confirm.hint),
|
|
1172
|
+
h('div', { className: 'bn-actions-end' },
|
|
1173
|
+
h('button', { className: 'bn-btn ghost', onClick: () => setConfirm(null) }, '取消'),
|
|
1174
|
+
h('button', {
|
|
1175
|
+
className: 'bn-btn danger',
|
|
1176
|
+
disabled: busy,
|
|
1177
|
+
onClick: () => {
|
|
1178
|
+
if (confirmLock.current || busy) return;
|
|
1179
|
+
const spec = confirm;
|
|
1180
|
+
confirmLock.current = true;
|
|
1181
|
+
setConfirm(null);
|
|
1182
|
+
Promise.resolve(spec && spec.run ? spec.run() : null).finally(() => { confirmLock.current = false; });
|
|
1183
|
+
},
|
|
1184
|
+
}, confirm.confirmLabel || '确定'),
|
|
1185
|
+
),
|
|
1186
|
+
),
|
|
1187
|
+
) : null,
|
|
1188
|
+
|
|
1189
|
+
toast ? h('div', { className: 'bn-toast' + (toast.bad ? ' bad' : '') }, toast.text) : null,
|
|
1190
|
+
);
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
function SidebarIcon(props) {
|
|
1194
|
+
const size = (props && props.size) || 18;
|
|
1195
|
+
return h('svg', { width: size, height: size, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 1.7, 'aria-hidden': true },
|
|
1196
|
+
h('rect', { x: 3, y: 3, width: 7, height: 7, rx: 1.8 }),
|
|
1197
|
+
h('rect', { x: 14, y: 3, width: 7, height: 7, rx: 1.8 }),
|
|
1198
|
+
h('rect', { x: 3, y: 14, width: 7, height: 7, rx: 1.8 }),
|
|
1199
|
+
h('rect', { x: 14, y: 14, width: 7, height: 7, rx: 1.8 }),
|
|
1200
|
+
);
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
return {
|
|
1204
|
+
Panel,
|
|
1205
|
+
SidebarIcon,
|
|
1206
|
+
mount(el) {
|
|
1207
|
+
if (!ReactDOM) throw new Error('mount() needs react-dom');
|
|
1208
|
+
ReactDOM.createRoot(el).render(h(Panel));
|
|
1209
|
+
},
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
function injectStyles(doc) {
|
|
1214
|
+
if (doc.getElementById('bn-panel-css')) return;
|
|
1215
|
+
const tag = doc.createElement('style');
|
|
1216
|
+
tag.id = 'bn-panel-css';
|
|
1217
|
+
tag.textContent = CSS;
|
|
1218
|
+
doc.head.appendChild(tag);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
if (typeof window !== 'undefined' && window.__ModuleLoader__) {
|
|
1222
|
+
window.__ModuleLoader__.load({
|
|
1223
|
+
id: 'bnpanel',
|
|
1224
|
+
factory(require) {
|
|
1225
|
+
const React = require('react');
|
|
1226
|
+
return {
|
|
1227
|
+
// 仅硬依赖 slots,保证面板可加载;sessions/layout 软注入用于自动进入创作会话
|
|
1228
|
+
inject: ['slots'],
|
|
1229
|
+
apply(ctx) {
|
|
1230
|
+
injectStyles(document);
|
|
1231
|
+
const nav = {
|
|
1232
|
+
sessions: null,
|
|
1233
|
+
layout: null,
|
|
1234
|
+
};
|
|
1235
|
+
ctx.inject(['sessions', 'layout'], (navCtx) => {
|
|
1236
|
+
nav.sessions = navCtx.sessions;
|
|
1237
|
+
nav.layout = navCtx.layout;
|
|
1238
|
+
navCtx.effect(() => () => {
|
|
1239
|
+
nav.sessions = null;
|
|
1240
|
+
nav.layout = null;
|
|
1241
|
+
}, 'bnpanel: drop session nav');
|
|
1242
|
+
});
|
|
1243
|
+
const ui = createPanel(React, null, {
|
|
1244
|
+
revealCreationSession(sessionId) {
|
|
1245
|
+
if (!sessionId) return;
|
|
1246
|
+
const tryOpen = (attempt) => {
|
|
1247
|
+
try {
|
|
1248
|
+
if (nav.sessions && typeof nav.sessions.open === 'function') {
|
|
1249
|
+
nav.sessions.open(sessionId);
|
|
1250
|
+
}
|
|
1251
|
+
} catch (err) {
|
|
1252
|
+
if (attempt < 8) {
|
|
1253
|
+
setTimeout(() => tryOpen(attempt + 1), 250 * (attempt + 1));
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
console.warn('[bnpanel] sessions.open failed', err);
|
|
1257
|
+
}
|
|
1258
|
+
try {
|
|
1259
|
+
// null = 主区切回 Conversation(DSH 创作面)
|
|
1260
|
+
if (nav.layout && typeof nav.layout.selectPanel === 'function') nav.layout.selectPanel(null);
|
|
1261
|
+
} catch (err) {
|
|
1262
|
+
console.warn('[bnpanel] layout.selectPanel failed', err);
|
|
1263
|
+
}
|
|
1264
|
+
};
|
|
1265
|
+
// 等 Host 会话同步到 Client 模型后再 open
|
|
1266
|
+
setTimeout(() => tryOpen(0), 200);
|
|
1267
|
+
},
|
|
1268
|
+
});
|
|
1269
|
+
ctx.slots.inject('main', () => ctx.slots.register({ name: 'main', key: 'bnpanel' }, ui.Panel));
|
|
1270
|
+
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({ name: 'sidebar.panellist', id: 'bnpanel', order: 20, label: () => BRAND }, ui.SidebarIcon));
|
|
1271
|
+
},
|
|
1272
|
+
};
|
|
1273
|
+
},
|
|
1274
|
+
});
|
|
1275
|
+
} else if (typeof window !== 'undefined') {
|
|
1276
|
+
window.BnPanelUI = { createPanel, injectStyles, CSS };
|
|
1277
|
+
window.DshPanelUI = window.BnPanelUI;
|
|
1278
|
+
}
|
|
1279
|
+
})();
|