bnpanel 0.5.8 → 0.5.9

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.
Files changed (3) hide show
  1. package/client.js +305 -15
  2. package/index.js +81 -14
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -43,7 +43,7 @@
43
43
  --bn-toast-bg:#34302c; --bn-toast-fg:#f6f3ec;
44
44
  }
45
45
  }
46
- .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}
46
+ .bn-root{position:relative;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}
47
47
  .bn-root *{box-sizing:border-box}
48
48
  .bn-rail{display:flex;flex-direction:column;gap:2px;min-height:0;overflow:auto;padding:16px 10px;border-right:1px solid var(--bn-line);background:var(--bn-surface-2)}
49
49
  .bn-logo{display:flex;align-items:center;gap:9px;padding:2px 8px 16px;font-weight:680;letter-spacing:-.01em}
@@ -93,6 +93,14 @@
93
93
  .bn-wx .bn-btn{height:30px;padding:0 12px;background:var(--bn-solid);color:var(--bn-on-solid);border-color:var(--bn-solid)}
94
94
  .bn-manual{display:flex;align-items:center;justify-content:center;width:100%;margin-top:14px;height:36px;text-decoration:none;box-sizing:border-box}
95
95
  .bn-main{overflow:auto;overflow-x:hidden;padding:22px 26px 40px;min-width:0;max-width:100%}
96
+ .bn-main.has-note{padding-bottom:108px}
97
+ .bn-foot-note{position:absolute;z-index:4;left:208px;bottom:16px;margin:0;padding-left:26px;max-width:min(460px,calc(100% - 208px - 86px));display:flex;flex-direction:column;gap:3px;color:var(--bn-faint);font-size:12px;line-height:1.65;pointer-events:none}
98
+ .bn-cs{position:absolute;z-index:5;right:18px;bottom:16px;width:46px;height:46px;padding:0;border:0;border-radius:50%;display:grid;place-items:center;cursor:pointer;background:#111;color:#d4f07a;box-shadow:0 10px 24px rgba(0,0,0,.18),inset 0 0 0 2px #d4f07a}
99
+ .bn-cs svg{animation:bn-cs-breathe 2.2s ease-in-out infinite}
100
+ .bn-cs:hover{transform:translateY(-1px)}
101
+ .bn-cs.on{box-shadow:0 10px 24px rgba(0,0,0,.18),inset 0 0 0 2px #d4f07a,0 0 0 4px rgba(212,240,122,.28)}
102
+ @keyframes bn-cs-breathe{0%,100%{transform:scale(1)}50%{transform:scale(1.14)}}
103
+ @media (prefers-reduced-motion:reduce){.bn-cs svg{animation:none}}
96
104
  .bn-head{display:flex;align-items:flex-start;gap:12px;margin-bottom:20px}
97
105
  .bn-h1{font-size:19px;font-weight:680;letter-spacing:-.015em;margin:0}
98
106
  .bn-sub{color:var(--bn-muted);font-size:12px;margin-top:3px}
@@ -140,6 +148,53 @@
140
148
  .bn-player-count{flex:none;color:rgba(244,241,234,.55);font-size:12px;font-variant-numeric:tabular-nums}
141
149
  .bn-player-bar .bn-btn{background:#1c1c1c;color:#f4f1ea;border-color:#333}
142
150
  .bn-player-bar .bn-btn.ghost{background:transparent;color:#f4f1ea;border-color:transparent}
151
+ .bn-player.has-script video{max-height:calc(90vh - 196px)}
152
+ .bn-player-dock{flex:none;display:flex;flex-direction:column;gap:10px;padding:14px 16px 12px;background:#111;color:#f4f1ea}
153
+ .bn-player-top{display:flex;align-items:center;gap:12px;min-width:0}
154
+ .bn-player-top strong{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px;font-weight:700;letter-spacing:-.01em}
155
+ .bn-player-dock .bn-player-count{color:rgba(244,241,234,.48)}
156
+ .bn-player-quote{margin:0;padding:10px 12px;border-radius:10px;background:#1c1c1c;color:rgba(244,241,234,.9);font-size:13px;line-height:1.55;max-height:4.65em;overflow:auto;white-space:pre-wrap}
157
+ .bn-player-quote.quiet{color:rgba(244,241,234,.62)}
158
+ .bn-player-quote.lock{color:#d4f07a;background:rgba(212,240,122,.08);box-shadow:inset 0 0 0 1px rgba(212,240,122,.32)}
159
+ .bn-player-foot{display:flex;align-items:center;gap:8px;min-width:0}
160
+ .bn-player-nav{display:flex;gap:6px;flex:none}
161
+ .bn-player-actions{display:flex;gap:8px;align-items:center;margin-left:auto}
162
+ .bn-player-dock .bn-btn{height:30px;padding:0 12px;background:#1c1c1c;color:#f4f1ea;border-color:#2c2c2c}
163
+ .bn-player-dock .bn-btn.play{background:#d4f07a;color:#111;border-color:#d4f07a;font-weight:700}
164
+ .bn-player-dock .bn-btn.ghost{background:transparent;border-color:transparent;color:rgba(244,241,234,.72);padding:0 4px}
165
+ .bn-market-back{position:fixed;inset:0;z-index:2147483000;background:rgba(10,10,10,.46);display:grid;place-items:center;padding:calc(28px + env(titlebar-area-height, 0px)) 28px 28px;width:auto;height:auto;max-width:none;max-height:none;margin:0;border:0;overflow:visible;color:inherit}
166
+ @supports selector(:popover-open){
167
+ .bn-market-back[popover]:popover-open{display:grid}
168
+ }
169
+ .bn-market{width:min(1080px,calc(100vw - 48px));max-height:min(820px,calc(100vh - 64px));display:flex;flex-direction:column;overflow:hidden;background:var(--bn-bg);color:var(--bn-ink);border:1px solid var(--bn-line);border-radius:22px;box-shadow:var(--bn-shadow-hover)}
170
+ .bn-market-head{position:relative;flex:none;padding:22px 24px 16px;border-bottom:1px solid var(--bn-line);background:radial-gradient(560px 180px at 100% 0%,rgba(212,240,122,.55),transparent 72%),var(--bn-surface)}
171
+ .bn-market-kicker{font-size:11px;letter-spacing:.14em;text-transform:uppercase;color:var(--bn-muted);font-weight:650}
172
+ .bn-market-head h2{margin:4px 70px 0 0;font-size:22px;line-height:1.2;letter-spacing:-.03em;font-weight:680}
173
+ .bn-market-head p{margin:6px 70px 0 0;color:var(--bn-muted);font-size:12.5px}
174
+ .bn-market-x{position:absolute;top:16px;right:16px;width:32px;height:32px;border:0;border-radius:10px;background:transparent;color:var(--bn-muted);font-size:20px;line-height:1;cursor:pointer}
175
+ .bn-market-x:hover{background:var(--bn-line);color:var(--bn-ink)}
176
+ .bn-market-filters{display:flex;flex-wrap:wrap;gap:6px;margin-top:14px}
177
+ .bn-market-filters button{border:1px solid var(--bn-line);background:var(--bn-surface);color:var(--bn-muted);border-radius:999px;padding:5px 12px;font:inherit;font-size:12px;font-weight:650;cursor:pointer}
178
+ .bn-market-filters button:hover{color:var(--bn-ink);border-color:var(--bn-line-strong)}
179
+ .bn-market-filters button.on{background:#111;color:#d4f07a;border-color:#111}
180
+ .bn-market-body{min-height:0;max-height:min(640px,calc(100vh - 230px));overflow:auto;padding:18px 22px 24px}
181
+ .bn-market-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:14px}
182
+ .bn-case{display:flex;flex-direction:column;width:100%;padding:0;overflow:hidden;text-align:left;color:inherit;font:inherit;cursor:pointer;background:var(--bn-surface);border:1px solid var(--bn-line);border-radius:16px;box-shadow:var(--bn-shadow)}
183
+ .bn-case:hover{box-shadow:var(--bn-shadow-hover);border-color:var(--bn-line-strong)}
184
+ .bn-case-cover{position:relative;aspect-ratio:16/9;background:#141414}
185
+ .bn-case-cover img{width:100%;height:100%;object-fit:cover;display:block}
186
+ .bn-case-fallback{width:100%;height:100%;display:grid;place-items:center;background:radial-gradient(120px 80px at 80% 20%,rgba(212,240,122,.45),transparent 70%),#141414;color:#d4f07a;font-weight:700;letter-spacing:.08em;font-size:13px}
187
+ .bn-case-play{position:absolute;right:10px;bottom:10px;width:34px;height:34px;border-radius:999px;display:grid;place-items:center;background:#d4f07a;color:#111;box-shadow:0 6px 16px rgba(0,0,0,.28)}
188
+ .bn-case-lock{position:absolute;left:10px;top:10px;padding:3px 8px;border-radius:999px;background:rgba(17,17,17,.78);color:#d4f07a;font-size:11px;font-weight:700;letter-spacing:.04em}
189
+ .bn-case-body{padding:12px 12px 14px}
190
+ .bn-case-title{font-weight:680;font-size:14px;letter-spacing:-.01em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
191
+ .bn-case-blurb{margin-top:4px;color:var(--bn-muted);font-size:12px;line-height:1.45;min-height:2.9em;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
192
+ .bn-case-meta{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
193
+ .bn-case-meta span{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--bn-muted);background:var(--bn-line);border-radius:999px;padding:2px 8px}
194
+ @media (prefers-color-scheme:dark){
195
+ .bn-market-head{background:radial-gradient(560px 180px at 100% 0%,rgba(212,240,122,.16),transparent 72%),var(--bn-surface)}
196
+ .bn-case-fallback{background:radial-gradient(120px 80px at 80% 20%,rgba(212,240,122,.2),transparent 70%),#111}
197
+ }
143
198
  .bn-docs-back{position:fixed;inset:0;z-index:2147483000;background:rgba(10,10,10,.28);width:auto;height:auto;max-width:none;max-height:none;margin:0;border:0;padding:0;overflow:visible;color:inherit}
144
199
  @supports selector(:popover-open){
145
200
  .bn-docs-back[popover]:popover-open{display:block}
@@ -597,6 +652,13 @@
597
652
  const [contactOpen, setContactOpen] = useState(false);
598
653
  const [campIdx, setCampIdx] = useState(0);
599
654
  const [reelIdx, setReelIdx] = useState(0);
655
+ const [marketOpen, setMarketOpen] = useState(false);
656
+ const [marketFilter, setMarketFilter] = useState('all');
657
+ const [unlocked, setUnlocked] = useState({});
658
+ const [promptBusy, setPromptBusy] = useState('');
659
+ const [promptError, setPromptError] = useState({});
660
+ const [caseSeed, setCaseSeed] = useState(null);
661
+ const [seedNonce, setSeedNonce] = useState(0);
600
662
  const [player, setPlayer] = useState(null);
601
663
  const [playerRatio, setPlayerRatio] = useState(16 / 9);
602
664
  const [docsOpen, setDocsOpen] = useState(false);
@@ -656,7 +718,7 @@
656
718
  } catch (err) { /* 节点已经卸下 */ }
657
719
  });
658
720
  };
659
- }, [docsOpen, caseOpen]);
721
+ }, [docsOpen, caseOpen, marketOpen]);
660
722
 
661
723
  const openContact = async () => {
662
724
  setContactOpen(true);
@@ -774,13 +836,55 @@
774
836
  setPlayer(null);
775
837
  };
776
838
 
839
+ const closeMarket = () => {
840
+ setMarketOpen(false);
841
+ closePlayer();
842
+ };
843
+
844
+ const primePrompt = (item) => {
845
+ if (!promptsOn || !item || item.access !== 'licensed' || !holdsProduct(item.agent)) return;
846
+ if (Object.prototype.hasOwnProperty.call(unlocked, item.id) || promptBusy === item.id) return;
847
+ setPromptBusy(item.id);
848
+ setPromptError((cur) => {
849
+ const next = { ...cur };
850
+ delete next[item.id];
851
+ return next;
852
+ });
853
+ api('/showcase/prompt', { method: 'POST', body: { id: item.id } })
854
+ .then((got) => {
855
+ setUnlocked((cur) => ({ ...cur, [item.id]: String((got && got.prompt) || '') }));
856
+ })
857
+ .catch((err) => {
858
+ setPromptError((cur) => ({ ...cur, [item.id]: err.message || '暂时无法获取提示词' }));
859
+ })
860
+ .finally(() => setPromptBusy((cur) => (cur === item.id ? '' : cur)));
861
+ };
862
+
777
863
  const openPlayer = (item) => {
778
864
  if (!item || !item.videoUrl) return;
779
865
  setPlayerRatio(16 / 9);
780
866
  setPlayer(item);
867
+ primePrompt(item);
781
868
  };
782
869
 
783
- const playerRows = () => ((state && state.showcase && state.showcase.cases) || []);
870
+ const promptsOn = !!(state && state.showcase && state.showcase.promptsEnabled);
871
+ const AGENT_ORDER = ['biureel', 'biuremtion', 'biuvibe', 'biutalk'];
872
+ const AGENT_FALLBACK = { biureel: 'BiuReel', biuremtion: 'BiuRemo', biuvibe: 'BiuVibe', biutalk: 'BiuTalk' };
873
+ const agentName = (slug) => {
874
+ const hit = ((state && state.store) || []).find((item) => item.slug === slug);
875
+ if (hit && hit.name) return hit.name;
876
+ return AGENT_FALLBACK[slug] || slug || '这个 Agent';
877
+ };
878
+ const holdsProduct = (slug) => {
879
+ const row = ((state && state.licenses) || []).find((item) => item.product === slug);
880
+ return !!(row && row.status && row.status.canExport);
881
+ };
882
+ const caseRows = () => ((state && state.showcase && state.showcase.cases) || []);
883
+ const playerRows = () => {
884
+ const rows = caseRows();
885
+ if (!promptsOn || marketFilter === 'all') return rows;
886
+ return rows.filter((row) => row.agent === marketFilter);
887
+ };
784
888
 
785
889
  const movePlayer = (delta) => {
786
890
  const rows = playerRows();
@@ -790,6 +894,7 @@
790
894
  setPlayerRatio(16 / 9);
791
895
  setPlayer(rows[nextAt]);
792
896
  setReelIdx(nextAt);
897
+ primePrompt(rows[nextAt]);
793
898
  };
794
899
 
795
900
  useEffect(() => {
@@ -803,24 +908,72 @@
803
908
  };
804
909
  window.addEventListener('keydown', onKey);
805
910
  return () => window.removeEventListener('keydown', onKey);
806
- }, [player, state]);
911
+ }, [player, state, marketFilter]);
807
912
 
808
- const shootLike = (item) => {
913
+ useEffect(() => {
914
+ if (!marketOpen || player) return undefined;
915
+ const onKey = (ev) => { if (ev.key === 'Escape') closeMarket(); };
916
+ window.addEventListener('keydown', onKey);
917
+ return () => window.removeEventListener('keydown', onKey);
918
+ }, [marketOpen, player]);
919
+
920
+ const goActivate = (slug) => {
921
+ closeMarket();
922
+ setProductInput(slug || 'biutalk');
923
+ setTab('account');
924
+ setToast({ text: '请激活「' + agentName(slug) + '」后查看提示词并做同款' });
925
+ };
926
+
927
+ const copyPrompt = async (text) => {
928
+ const value = String(text || '').trim();
929
+ if (!value) return;
930
+ try {
931
+ await navigator.clipboard.writeText(value);
932
+ setToast({ text: '提示词已复制' });
933
+ } catch {
934
+ setToast({ text: '复制失败,请手动选择提示词', bad: true });
935
+ }
936
+ };
937
+
938
+ const shootLike = async (item) => {
809
939
  const slug = item && item.agent;
810
940
  if (!slug) return;
941
+ if (promptsOn && item.access === 'licensed' && !holdsProduct(slug)) {
942
+ goActivate(slug);
943
+ return;
944
+ }
811
945
  const hit = (state.store || []).find((s) => s.slug === slug);
812
946
  const installed = (state.agents || []).find((a) => a.id === slug || a.product === slug) || (hit && hit.agent);
813
947
  if (!installed) {
814
948
  setToast({ text: '请先安装对应 Agent,再使用同款开拍', bad: true });
815
949
  return;
816
950
  }
817
- const query = item.style ? 'style=' + encodeURIComponent(item.style) : '';
818
- closePlayer();
819
- return openStudio(installed.id, query);
951
+ let prompt = '';
952
+ if (promptsOn && item.access === 'licensed') {
953
+ try {
954
+ const got = await api('/showcase/prompt', { method: 'POST', body: { id: item.id } });
955
+ prompt = String((got && got.prompt) || '');
956
+ setUnlocked((cur) => ({ ...cur, [item.id]: prompt }));
957
+ } catch (err) {
958
+ setToast({ text: err.message || '暂时无法获取提示词', bad: true });
959
+ return;
960
+ }
961
+ } else if (promptsOn) {
962
+ prompt = item.prompt || '';
963
+ }
964
+ const nonce = seedNonce + 1;
965
+ setSeedNonce(nonce);
966
+ const parts = [];
967
+ if (item.style) parts.push('style=' + encodeURIComponent(item.style));
968
+ if (item.id) parts.push('case=' + encodeURIComponent(item.id));
969
+ parts.push('seed=' + nonce);
970
+ closeMarket();
971
+ return openStudio(installed.id, parts.join('&'), prompt ? { id: item.id, prompt, style: item.style || '' } : null);
820
972
  };
821
973
 
822
- const openStudio = async (id, query) => {
974
+ const openStudio = async (id, query, seed) => {
823
975
  setStudioQuery(query || '');
976
+ setCaseSeed(seed || null);
824
977
  const agent = (state.agents || []).find((a) => a.id === id);
825
978
  if (agent && agent.needsPermissionAck && !agent.permissionsAck) {
826
979
  setPendingPerm(agent);
@@ -956,8 +1109,13 @@
956
1109
  setToast({ text: '还没有案例', bad: true });
957
1110
  return;
958
1111
  }
959
- const at = ((reelIdx % cases.length) + cases.length) % cases.length;
960
- openPlayer(cases[at]);
1112
+ if (!promptsOn) {
1113
+ const at = ((reelIdx % cases.length) + cases.length) % cases.length;
1114
+ openPlayer(cases[at]);
1115
+ return;
1116
+ }
1117
+ setMarketFilter('all');
1118
+ setMarketOpen(true);
961
1119
  };
962
1120
  const topSeg = h('div', { className: 'bn-seg' },
963
1121
  h('span', { className: 'on', title: (state.license && state.license.reason) || '' }, licenseOn ? '已授权' : '未授权'),
@@ -1009,7 +1167,7 @@
1009
1167
  h('div', { className: 'bn-mono', style: { marginTop: 4 } }, licenses.length ? (licenses.length + ' 产品授权') : state.license.state),
1010
1168
  ),
1011
1169
  ),
1012
- h('main', { className: 'bn-main' },
1170
+ h('main', { className: 'bn-main' + (tab === 'agents' ? ' has-note' : '') },
1013
1171
  tab !== 'studio' ? h('div', { className: 'bn-head' },
1014
1172
  h('div', null,
1015
1173
  h('h1', { className: 'bn-h1' }, tab === 'agents' ? '今天就出片' : tab === 'tasks' ? '任务' : tab === 'account' ? '我的授权' : '设置'),
@@ -1101,6 +1259,24 @@
1101
1259
  title: studioAgent.name,
1102
1260
  src: studioAgent.studioUrl + (studioQuery ? (String(studioAgent.studioUrl).indexOf('?') >= 0 ? '&' : '?') + studioQuery : ''),
1103
1261
  allow: 'clipboard-read; clipboard-write; fullscreen',
1262
+ onLoad: (event) => {
1263
+ const frame = event.target;
1264
+ const seed = caseSeed;
1265
+ if (!seed || !seed.prompt || !frame.contentWindow) return;
1266
+ const send = () => {
1267
+ try {
1268
+ frame.contentWindow.postMessage({
1269
+ type: 'bn-case-prompt',
1270
+ prompt: seed.prompt,
1271
+ style: seed.style || '',
1272
+ caseId: seed.id || '',
1273
+ }, '*');
1274
+ } catch { /* Studio 还没挂上 */ }
1275
+ };
1276
+ send();
1277
+ window.setTimeout(send, 500);
1278
+ window.setTimeout(send, 1500);
1279
+ },
1104
1280
  }),
1105
1281
  )
1106
1282
  : h('div', { className: 'bn-empty' },
@@ -1267,6 +1443,26 @@
1267
1443
  ) : null,
1268
1444
  ),
1269
1445
 
1446
+ tab === 'agents' ? h('p', { className: 'bn-foot-note' },
1447
+ h('span', null, '开了新任务,到左侧聊天窗口看进度。'),
1448
+ h('span', null, '开拍前,在聊天窗口给 DSH 全部权限。'),
1449
+ h('span', null, '其他问题,点右下角客服。'),
1450
+ ) : null,
1451
+ h('button', {
1452
+ type: 'button',
1453
+ className: 'bn-cs' + (contactOpen ? ' on' : ''),
1454
+ 'aria-label': '在线客服',
1455
+ title: '在线客服',
1456
+ onClick: () => { void openContact(); },
1457
+ },
1458
+ h('svg', { width: 22, height: 22, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true },
1459
+ h('path', { d: 'M4 13a8 8 0 0 1 16 0' }),
1460
+ h('path', { d: 'M4 13v3a2 2 0 0 0 2 2h1.5v-7H6a2 2 0 0 0-2 2z' }),
1461
+ h('path', { d: 'M20 13v3a2 2 0 0 1-2 2h-1.5v-7H18a2 2 0 0 1 2 2z' }),
1462
+ h('path', { d: 'M12 20h2.5a2 2 0 0 0 2-2' }),
1463
+ ),
1464
+ ),
1465
+
1270
1466
  contactOpen ? h('div', { className: 'bn-modal-back', onClick: (e) => { if (e.target === e.currentTarget) setContactOpen(false); } },
1271
1467
  h('div', { className: 'bn-modal bn-contact', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': 'bn-contact-title' },
1272
1468
  h('div', { className: 'bn-contact-head' },
@@ -1384,12 +1580,81 @@
1384
1580
  ),
1385
1581
  ) : null,
1386
1582
 
1583
+ marketOpen ? (() => {
1584
+ const rows = caseRows();
1585
+ const slugs = [];
1586
+ AGENT_ORDER.forEach((slug) => { if (rows.some((row) => row.agent === slug)) slugs.push(slug); });
1587
+ rows.forEach((row) => { if (row.agent && slugs.indexOf(row.agent) < 0) slugs.push(row.agent); });
1588
+ const visible = marketFilter === 'all' ? rows : rows.filter((row) => row.agent === marketFilter);
1589
+ return h('div', { className: 'bn-market-back bn-layer', popover: 'manual', onClick: (event) => { if (event.target === event.currentTarget) closeMarket(); } },
1590
+ h('div', { className: 'bn-market', role: 'dialog', 'aria-modal': 'true', 'aria-label': '案例' },
1591
+ h('div', { className: 'bn-market-head' },
1592
+ h('div', { className: 'bn-market-kicker' }, rows.length + ' 条成片'),
1593
+ h('h2', null, '看成品,拿提示词去拍'),
1594
+ h('p', null, '公开的可以直接复制或做同款。标了专享的,要先激活对应的 Agent。'),
1595
+ h('button', { type: 'button', className: 'bn-market-x', onClick: closeMarket, 'aria-label': '关闭' }, '×'),
1596
+ h('div', { className: 'bn-market-filters' },
1597
+ h('button', { type: 'button', className: marketFilter === 'all' ? 'on' : '', 'aria-pressed': marketFilter === 'all', onClick: () => setMarketFilter('all') }, '全部'),
1598
+ slugs.map((slug) => h('button', {
1599
+ key: slug,
1600
+ type: 'button',
1601
+ className: marketFilter === slug ? 'on' : '',
1602
+ 'aria-pressed': marketFilter === slug,
1603
+ onClick: () => setMarketFilter(slug),
1604
+ }, agentName(slug))),
1605
+ ),
1606
+ ),
1607
+ h('div', { className: 'bn-market-body' },
1608
+ visible.length
1609
+ ? h('div', { className: 'bn-market-grid' }, visible.map((item) => h('button', {
1610
+ key: item.id,
1611
+ type: 'button',
1612
+ className: 'bn-case',
1613
+ onClick: () => openPlayer(item),
1614
+ },
1615
+ h('div', { className: 'bn-case-cover' },
1616
+ item.coverUrl
1617
+ ? h('img', { src: item.coverUrl, alt: '' })
1618
+ : h('div', { className: 'bn-case-fallback' }, agentName(item.agent)),
1619
+ item.access === 'licensed' ? h('span', { className: 'bn-case-lock' }, '专享') : null,
1620
+ h('span', { className: 'bn-case-play', 'aria-hidden': true },
1621
+ h('svg', { width: 12, height: 12, viewBox: '0 0 24 24' }, h('path', { d: 'M8 5v14l11-7z', fill: 'currentColor' })),
1622
+ ),
1623
+ ),
1624
+ h('div', { className: 'bn-case-body' },
1625
+ h('div', { className: 'bn-case-title' }, item.title),
1626
+ h('div', { className: 'bn-case-blurb' }, item.blurb || (item.access === 'licensed' ? '激活后可查看提示词,并一键做同款。' : '看完这条,就可以按同样的提示词再拍一条。')),
1627
+ h('div', { className: 'bn-case-meta' },
1628
+ item.agent ? h('span', null, agentName(item.agent)) : null,
1629
+ item.style ? h('span', null, item.style) : null,
1630
+ ),
1631
+ ),
1632
+ )))
1633
+ : h('div', { className: 'bn-empty' },
1634
+ h('h3', null, '这个 Agent 还没有案例'),
1635
+ h('p', null, '换一个筛选,或者等新的成片上架。'),
1636
+ ),
1637
+ ),
1638
+ ),
1639
+ );
1640
+ })() : null,
1641
+
1387
1642
  player ? (() => {
1388
1643
  const rows = playerRows();
1389
1644
  const at = Math.max(0, rows.findIndex((row) => row.id === player.id));
1390
1645
  const many = rows.length > 1;
1646
+ const licensed = player.access === 'licensed';
1647
+ const owned = holdsProduct(player.agent);
1648
+ const known = Object.prototype.hasOwnProperty.call(unlocked, player.id);
1649
+ const text = licensed ? (known ? unlocked[player.id] : '') : (player.prompt || '');
1650
+ const waiting = promptsOn && licensed && owned && !known && !promptError[player.id];
1651
+ const failed = promptsOn && licensed && owned && promptError[player.id];
1652
+ const locked = promptsOn && licensed && !owned;
1653
+ const shoot = player.agent
1654
+ ? h('button', { type: 'button', className: 'bn-btn play', onClick: () => { void shootLike(player); } }, locked ? '去激活' : '用同款开拍')
1655
+ : null;
1391
1656
  return h('div', { className: 'bn-player-back bn-layer', popover: 'manual', onClick: (event) => { if (event.target === event.currentTarget) closePlayer(); } },
1392
- h('div', { id: 'bn-player', className: 'bn-player', style: { '--ar': String(playerRatio) }, role: 'dialog' },
1657
+ h('div', { id: 'bn-player', className: 'bn-player' + (promptsOn ? ' has-script' : ''), style: { '--ar': String(playerRatio) }, role: 'dialog', 'aria-label': player.title },
1393
1658
  h('video', {
1394
1659
  key: player.id,
1395
1660
  id: 'bn-player-video',
@@ -1403,11 +1668,36 @@
1403
1668
  if (node.videoWidth && node.videoHeight) setPlayerRatio(node.videoWidth / node.videoHeight);
1404
1669
  },
1405
1670
  }),
1406
- h('div', { className: 'bn-player-bar' },
1671
+ promptsOn ? h('div', { className: 'bn-player-dock' },
1672
+ h('div', { className: 'bn-player-top' },
1673
+ h('strong', null, player.title),
1674
+ many ? h('span', { className: 'bn-player-count' }, (at + 1) + ' / ' + rows.length) : null,
1675
+ h('button', { type: 'button', className: 'bn-btn ghost', onClick: closePlayer }, '关闭'),
1676
+ ),
1677
+ locked
1678
+ ? h('p', { className: 'bn-player-quote lock' }, '激活 ' + agentName(player.agent) + ' 后可查看提示词并做同款')
1679
+ : h('p', { className: 'bn-player-quote' + (text ? '' : ' quiet') },
1680
+ waiting ? '正在打开这条提示词…'
1681
+ : failed ? promptError[player.id]
1682
+ : text || '这条还没有提示词。做同款会按它的风格模板开拍。'),
1683
+ h('div', { className: 'bn-player-foot' },
1684
+ many ? h('div', { className: 'bn-player-nav' },
1685
+ h('button', { type: 'button', className: 'bn-btn', onClick: () => movePlayer(-1) }, '上一条'),
1686
+ h('button', { type: 'button', className: 'bn-btn', onClick: () => movePlayer(1) }, '下一条'),
1687
+ ) : null,
1688
+ h('div', { className: 'bn-player-actions' },
1689
+ text ? h('button', { type: 'button', className: 'bn-btn', onClick: () => { void copyPrompt(text); } }, '复制') : null,
1690
+ failed ? h('button', { type: 'button', className: 'bn-btn', onClick: () => { setPromptError((cur) => { const next = { ...cur }; delete next[player.id]; return next; }); primePrompt(player); } }, '重试') : null,
1691
+ locked
1692
+ ? h('button', { type: 'button', className: 'bn-btn play', onClick: () => goActivate(player.agent) }, '去激活')
1693
+ : shoot,
1694
+ ),
1695
+ ),
1696
+ ) : h('div', { className: 'bn-player-bar' },
1407
1697
  many ? h('button', { type: 'button', className: 'bn-btn', onClick: () => movePlayer(-1) }, '上一条') : null,
1408
1698
  h('span', { className: 'bn-player-count' }, '案例' + (many ? ' ' + (at + 1) + ' / ' + rows.length : '')),
1409
1699
  h('strong', null, player.title),
1410
- player.agent ? h('button', { type: 'button', className: 'bn-btn play', onClick: () => shootLike(player) }, '用同款开拍') : null,
1700
+ shoot,
1411
1701
  many ? h('button', { type: 'button', className: 'bn-btn', onClick: () => movePlayer(1) }, '下一条') : null,
1412
1702
  h('button', { type: 'button', className: 'bn-btn ghost', onClick: closePlayer }, '关闭'),
1413
1703
  ),
package/index.js CHANGED
@@ -9559,7 +9559,7 @@ function createPanelApp(options = {}) {
9559
9559
  licenseBaseUrl: settings.licenseBaseUrl,
9560
9560
  trialRuns,
9561
9561
  campaigns: [],
9562
- showcase: { cases: [], tutorials: [] },
9562
+ showcase: { promptsEnabled: false, cases: [], tutorials: [] },
9563
9563
  docs: [],
9564
9564
  storeError: null,
9565
9565
  tasks: queue.list(),
@@ -9607,7 +9607,7 @@ function createPanelApp(options = {}) {
9607
9607
  return campaignCache.items;
9608
9608
  }
9609
9609
  }
9610
- let showcaseCache = { at: 0, cases: [], tutorials: [] };
9610
+ let showcaseCache = { at: 0, promptsEnabled: false, cases: [], tutorials: [] };
9611
9611
  let docsCache = { at: 0, items: [] };
9612
9612
  async function loadPublicDocs() {
9613
9613
  const now = Date.now();
@@ -9638,31 +9638,88 @@ function createPanelApp(options = {}) {
9638
9638
  if (now - showcaseCache.at < 6e4) return showcaseCache;
9639
9639
  const base = String(settings.licenseBaseUrl || "").replace(/\/$/, "");
9640
9640
  if (!base) {
9641
- showcaseCache = { at: now, cases: [], tutorials: [] };
9641
+ showcaseCache = { at: now, promptsEnabled: false, cases: [], tutorials: [] };
9642
9642
  return showcaseCache;
9643
9643
  }
9644
9644
  try {
9645
9645
  const res = await fetch(`${base}/v1/showcase`, { signal: AbortSignal.timeout(4e3) });
9646
9646
  const data = await res.json().catch(() => ({}));
9647
9647
  if (!res.ok) throw new Error("showcase unavailable");
9648
- const mapItem = (item) => ({
9649
- id: String(item.id || ""),
9650
- title: String(item.title || ""),
9651
- blurb: String(item.blurb || ""),
9652
- agent: String(item.agent || ""),
9653
- style: String(item.style || ""),
9654
- coverUrl: String(item.coverUrl || ""),
9655
- videoUrl: String(item.videoUrl || "")
9656
- });
9648
+ const promptsEnabled = data.promptsEnabled === true;
9649
+ const mapItem = (item) => {
9650
+ const access = item.access === "licensed" ? "licensed" : "public";
9651
+ return {
9652
+ id: String(item.id || ""),
9653
+ title: String(item.title || ""),
9654
+ blurb: String(item.blurb || ""),
9655
+ agent: String(item.agent || ""),
9656
+ style: String(item.style || ""),
9657
+ coverUrl: String(item.coverUrl || ""),
9658
+ videoUrl: String(item.videoUrl || ""),
9659
+ access,
9660
+ locked: promptsEnabled && access === "licensed",
9661
+ prompt: promptsEnabled && access !== "licensed" ? String(item.prompt || "") : ""
9662
+ };
9663
+ };
9657
9664
  const cases = (Array.isArray(data.cases) ? data.cases : []).map(mapItem).filter((item) => item.id && item.videoUrl);
9658
9665
  const tutorials = (Array.isArray(data.tutorials) ? data.tutorials : []).map(mapItem).filter((item) => item.id && item.videoUrl);
9659
- showcaseCache = { at: now, cases, tutorials };
9666
+ showcaseCache = { at: now, promptsEnabled, cases, tutorials };
9660
9667
  return showcaseCache;
9661
9668
  } catch {
9662
- showcaseCache = { at: now, cases: showcaseCache.cases, tutorials: showcaseCache.tutorials };
9669
+ showcaseCache = {
9670
+ at: now,
9671
+ promptsEnabled: showcaseCache.promptsEnabled,
9672
+ cases: showcaseCache.cases,
9673
+ tutorials: showcaseCache.tutorials
9674
+ };
9663
9675
  return showcaseCache;
9664
9676
  }
9665
9677
  }
9678
+ async function fetchCasePrompt(id) {
9679
+ const showcase = await loadPublicShowcase();
9680
+ const item = (showcase.cases || []).find((row) => row.id === id);
9681
+ if (!item) {
9682
+ const err = new Error("\u627E\u4E0D\u5230\u8FD9\u4E2A\u6848\u4F8B");
9683
+ err.status = 404;
9684
+ throw err;
9685
+ }
9686
+ if (!showcase.promptsEnabled) {
9687
+ const err = new Error("\u63D0\u793A\u8BCD\u672A\u5F00\u653E");
9688
+ err.status = 404;
9689
+ throw err;
9690
+ }
9691
+ if (item.access !== "licensed") {
9692
+ return { prompt: item.prompt || "", style: item.style || "", agent: item.agent || "" };
9693
+ }
9694
+ if (!license.canUseProduct(item.agent)) {
9695
+ const err = new Error("\u8BF7\u5148\u6FC0\u6D3B\u5BF9\u5E94 Agent");
9696
+ err.status = 403;
9697
+ throw err;
9698
+ }
9699
+ const token = license.tokenFor(item.agent);
9700
+ const base = String(settings.licenseBaseUrl || "").replace(/\/$/, "");
9701
+ if (!token || !base) {
9702
+ const err = new Error("\u8BF7\u5148\u6FC0\u6D3B\u5BF9\u5E94 Agent");
9703
+ err.status = 403;
9704
+ throw err;
9705
+ }
9706
+ const res = await fetch(`${base}/v1/showcase/${encodeURIComponent(id)}/prompt`, {
9707
+ headers: { authorization: `Bearer ${token}` },
9708
+ signal: AbortSignal.timeout(8e3)
9709
+ });
9710
+ const data = await res.json().catch(() => ({}));
9711
+ if (!res.ok) {
9712
+ const msg = data?.error?.message;
9713
+ const err = new Error(typeof msg === "string" && msg ? msg : "\u6682\u65F6\u65E0\u6CD5\u83B7\u53D6\u63D0\u793A\u8BCD");
9714
+ err.status = res.status || 502;
9715
+ throw err;
9716
+ }
9717
+ return {
9718
+ prompt: String(data.prompt || ""),
9719
+ style: String(data.style || item.style || ""),
9720
+ agent: String(data.agent || item.agent || "")
9721
+ };
9722
+ }
9666
9723
  async function loadPublicContact() {
9667
9724
  const base = String(settings.licenseBaseUrl || "").replace(/\/$/, "");
9668
9725
  if (!base) return { wechatId: "", hasQr: false, configured: false };
@@ -9708,6 +9765,16 @@ function createPanelApp(options = {}) {
9708
9765
  switch (route) {
9709
9766
  case "GET /state":
9710
9767
  return send(res, 200, await stateAsync());
9768
+ case "POST /showcase/prompt": {
9769
+ try {
9770
+ const body = await readJson(req);
9771
+ const id = String(body.id || "").trim();
9772
+ if (!id) return send(res, 400, { error: "\u627E\u4E0D\u5230\u8FD9\u4E2A\u6848\u4F8B" });
9773
+ return send(res, 200, await fetchCasePrompt(id));
9774
+ } catch (error) {
9775
+ return send(res, error.status || 502, { error: error.message || "\u6682\u65F6\u65E0\u6CD5\u83B7\u53D6\u63D0\u793A\u8BCD" });
9776
+ }
9777
+ }
9711
9778
  case "GET /contact": {
9712
9779
  try {
9713
9780
  return send(res, 200, { contact: await loadPublicContact() });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bnpanel",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "type": "module",
5
5
  "description": "无需AI生图/生视频,本机低配置即可运行的‘解说、动效、风格化’视频创作工厂。",
6
6
  "license": "UNLICENSED",