bnpanel 0.6.7 → 0.6.8
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/client.js +201 -36
- package/index.js +80 -8
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -205,10 +205,37 @@
|
|
|
205
205
|
.bn-docs-tabs{display:flex;gap:6px;overflow:auto;padding:8px 14px;border-bottom:1px solid var(--bn-line);flex:none}
|
|
206
206
|
.bn-docs-tabs button{border:1px solid var(--bn-line);background:transparent;color:var(--bn-ink);border-radius:99px;padding:4px 10px;font:inherit;font-size:12px;cursor:pointer;white-space:nowrap}
|
|
207
207
|
.bn-docs-tabs button.on{background:#111;color:#d4f07a;border-color:#111}
|
|
208
|
+
.bn-docs-tabs button:disabled{opacity:.4;cursor:default}
|
|
208
209
|
.bn-docs-frame{position:relative;flex:1;min-height:0;display:flex}
|
|
209
210
|
.bn-docs iframe{flex:1;width:100%;min-height:0;border:0;background:#fff}
|
|
210
211
|
.bn-docs-miss{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:28px;text-align:center;color:var(--bn-muted);background:var(--bn-surface)}
|
|
211
212
|
.bn-docs-miss .bn-btn{text-decoration:none;background:#d4f07a;color:#111;border-color:#d4f07a;font-weight:700}
|
|
213
|
+
.bn-docs-empty{flex:1;display:flex;align-items:center;justify-content:center;padding:28px;text-align:center;color:var(--bn-muted)}
|
|
214
|
+
.bn-docs-md{flex:1;min-height:0;overflow:auto;padding:16px 20px 40px;font-size:13px;line-height:1.75;color:var(--bn-ink)}
|
|
215
|
+
.bn-docs-tag{display:inline-block;margin-left:5px;padding:0 5px;border-radius:4px;background:#f0f7d4;color:#5c6b22;font-size:10px;font-style:normal;line-height:15px;vertical-align:middle}
|
|
216
|
+
.bn-docs-lock{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:40px 24px;text-align:center}
|
|
217
|
+
.bn-docs-lock b{font-size:15px}
|
|
218
|
+
.bn-docs-lock p{margin:0;max-width:360px;color:var(--bn-muted);font-size:12px;line-height:1.7}
|
|
219
|
+
.bn-docs-md h1{font-size:20px;line-height:1.35;margin:0 0 12px}
|
|
220
|
+
.bn-docs-md h2{font-size:16px;margin:22px 0 8px;padding-bottom:6px;border-bottom:1px solid var(--bn-line)}
|
|
221
|
+
.bn-docs-md h3{font-size:14px;margin:16px 0 6px}
|
|
222
|
+
.bn-docs-md h4{font-size:13px;margin:14px 0 6px}
|
|
223
|
+
.bn-docs-md p{margin:0 0 10px}
|
|
224
|
+
.bn-docs-md ul,.bn-docs-md ol{margin:0 0 12px;padding-left:22px}
|
|
225
|
+
.bn-docs-md li{margin:2px 0}
|
|
226
|
+
.bn-docs-md blockquote{margin:0 0 12px;padding:8px 12px;border-left:3px solid #d4f07a;background:rgba(0,0,0,.03);color:var(--bn-muted)}
|
|
227
|
+
.bn-docs-md code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;background:rgba(0,0,0,.06);padding:1px 5px;border-radius:4px}
|
|
228
|
+
.bn-docs-md pre{margin:0 0 12px;padding:10px 12px;background:#111;color:#e8f3c8;border-radius:8px;overflow:auto}
|
|
229
|
+
.bn-docs-md pre code{background:none;padding:0;color:inherit;font-size:12px;line-height:1.6}
|
|
230
|
+
.bn-docs-md hr{border:0;border-top:1px solid var(--bn-line);margin:18px 0}
|
|
231
|
+
.bn-docs-md a{color:#3e6b00;text-decoration:underline}
|
|
232
|
+
.bn-md-table{overflow:auto;margin:0 0 12px}
|
|
233
|
+
.bn-docs-md table{border-collapse:collapse;width:100%;font-size:12px}
|
|
234
|
+
.bn-docs-md th,.bn-docs-md td{border:1px solid var(--bn-line);padding:6px 8px;text-align:left;vertical-align:top}
|
|
235
|
+
.bn-docs-md th{background:rgba(0,0,0,.04);font-weight:600;white-space:nowrap}
|
|
236
|
+
.bn-docs-md strong{font-weight:700}
|
|
237
|
+
.bn-docs-md img{display:block;max-width:100%;height:auto;margin:6px 0 12px;border:1px solid var(--bn-line);border-radius:8px}
|
|
238
|
+
.bn-docs-md video{display:block;width:100%;max-width:760px;margin:6px 0 12px;border-radius:8px;background:#000}
|
|
212
239
|
.bn-tutor-list{display:flex;flex-direction:column;gap:8px;margin-top:8px}
|
|
213
240
|
.bn-tutor-item{display:flex;justify-content:space-between;gap:10px;align-items:center;padding:10px 0;border-top:1px solid var(--bn-line)}
|
|
214
241
|
.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}
|
|
@@ -445,6 +472,16 @@
|
|
|
445
472
|
}
|
|
446
473
|
}
|
|
447
474
|
|
|
475
|
+
const MANUAL_TABS = [
|
|
476
|
+
{ key: 'start', label: '安装/激活/升级' },
|
|
477
|
+
{ key: 'biutalk', label: 'BiuTalk' },
|
|
478
|
+
{ key: 'biureel', label: 'BiuReel' },
|
|
479
|
+
{ key: 'biuremo', label: 'BiuRemo' },
|
|
480
|
+
{ key: 'biuart', label: 'BiuArt' },
|
|
481
|
+
{ key: 'biuvibe', label: 'BiuVibe' },
|
|
482
|
+
{ key: 'diagnose', label: '号脉' },
|
|
483
|
+
];
|
|
484
|
+
|
|
448
485
|
function docOpenLabel(url) {
|
|
449
486
|
try {
|
|
450
487
|
const host = new URL(String(url || '')).hostname;
|
|
@@ -1688,8 +1725,125 @@
|
|
|
1688
1725
|
return hit && hit.description ? String(hit.description).trim() : '';
|
|
1689
1726
|
})();
|
|
1690
1727
|
const docs = state.docs || [];
|
|
1691
|
-
const
|
|
1692
|
-
|
|
1728
|
+
const manualTabs = (() => {
|
|
1729
|
+
const byKey = new Map();
|
|
1730
|
+
docs.forEach((item) => {
|
|
1731
|
+
if (item.manualKey && !byKey.has(item.manualKey)) byKey.set(item.manualKey, item);
|
|
1732
|
+
});
|
|
1733
|
+
const tabs = MANUAL_TABS.map((tab) => ({ key: tab.key, label: tab.label, doc: byKey.get(tab.key) || null }));
|
|
1734
|
+
docs.forEach((item) => { if (!item.manualKey) tabs.push({ key: 'doc:' + item.id, label: item.title, doc: item }); });
|
|
1735
|
+
return tabs;
|
|
1736
|
+
})();
|
|
1737
|
+
const activeTab = manualTabs.find((tab) => tab.key === docId && tab.doc) || null;
|
|
1738
|
+
const doc = activeTab ? activeTab.doc : null;
|
|
1739
|
+
const openDocs = () => {
|
|
1740
|
+
const first = manualTabs.find((tab) => tab.doc && !tab.doc.locked) || manualTabs.find((tab) => tab.doc);
|
|
1741
|
+
setDocId(first ? first.key : '');
|
|
1742
|
+
setDocBlocked(false);
|
|
1743
|
+
setDocsOpen(true);
|
|
1744
|
+
};
|
|
1745
|
+
const mdInline = (text, prefix) => {
|
|
1746
|
+
const nodes = [];
|
|
1747
|
+
const re = /(`[^`]+`)|(\*\*[^*]+\*\*)|!\[([^\]]*)\]\((https?:\/\/[^)\s]+)\)|\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g;
|
|
1748
|
+
let last = 0;
|
|
1749
|
+
let match;
|
|
1750
|
+
let index = 0;
|
|
1751
|
+
while ((match = re.exec(text))) {
|
|
1752
|
+
if (match.index > last) nodes.push(text.slice(last, match.index));
|
|
1753
|
+
if (match[1]) nodes.push(h('code', { key: prefix + 'c' + index++ }, match[1].slice(1, -1)));
|
|
1754
|
+
else if (match[2]) nodes.push(h('strong', { key: prefix + 'b' + index++ }, match[2].slice(2, -2)));
|
|
1755
|
+
else if (match[3] !== undefined) {
|
|
1756
|
+
const src = match[4];
|
|
1757
|
+
if (/\.(mp4|webm|mov|m4v)(\?|#|$)/i.test(src)) {
|
|
1758
|
+
nodes.push(h('video', { key: prefix + 'v' + index++, src, controls: true, playsInline: true, preload: 'metadata' }));
|
|
1759
|
+
} else {
|
|
1760
|
+
nodes.push(h('img', { key: prefix + 'i' + index++, src, alt: match[3] }));
|
|
1761
|
+
}
|
|
1762
|
+
} else if (match[5]) nodes.push(h('a', { key: prefix + 'a' + index++, href: match[6], target: '_blank', rel: 'noreferrer' }, match[5]));
|
|
1763
|
+
last = re.lastIndex;
|
|
1764
|
+
}
|
|
1765
|
+
if (last < text.length) nodes.push(text.slice(last));
|
|
1766
|
+
return nodes;
|
|
1767
|
+
};
|
|
1768
|
+
const mdBlocks = (raw) => {
|
|
1769
|
+
const lines = String(raw || '').replace(/\r\n/g, '\n').split('\n');
|
|
1770
|
+
const out = [];
|
|
1771
|
+
let i = 0;
|
|
1772
|
+
let key = 0;
|
|
1773
|
+
let para = [];
|
|
1774
|
+
const flush = () => {
|
|
1775
|
+
if (!para.length) return;
|
|
1776
|
+
const text = para.join(' ');
|
|
1777
|
+
para = [];
|
|
1778
|
+
out.push(h('p', { key: 'p' + key++ }, mdInline(text, 'p' + key + ':')));
|
|
1779
|
+
};
|
|
1780
|
+
while (i < lines.length) {
|
|
1781
|
+
const line = lines[i];
|
|
1782
|
+
const text = line.trim();
|
|
1783
|
+
if (!text) { flush(); i += 1; continue; }
|
|
1784
|
+
if (/^```/.test(text)) {
|
|
1785
|
+
flush();
|
|
1786
|
+
const buf = [];
|
|
1787
|
+
i += 1;
|
|
1788
|
+
while (i < lines.length && !/^```/.test(lines[i].trim())) { buf.push(lines[i]); i += 1; }
|
|
1789
|
+
i += 1;
|
|
1790
|
+
out.push(h('pre', { key: 'pre' + key++ }, h('code', null, buf.join('\n'))));
|
|
1791
|
+
continue;
|
|
1792
|
+
}
|
|
1793
|
+
if (/^(-{3,}|\*{3,})$/.test(text)) { flush(); out.push(h('hr', { key: 'hr' + key++ })); i += 1; continue; }
|
|
1794
|
+
const heading = text.match(/^(#{1,4})\s+(.*)$/);
|
|
1795
|
+
if (heading) {
|
|
1796
|
+
flush();
|
|
1797
|
+
const level = heading[1].length;
|
|
1798
|
+
out.push(h('h' + level, { key: 'h' + key++ }, mdInline(heading[2], 'h' + key + ':')));
|
|
1799
|
+
i += 1;
|
|
1800
|
+
continue;
|
|
1801
|
+
}
|
|
1802
|
+
if (/^>\s?/.test(text)) {
|
|
1803
|
+
flush();
|
|
1804
|
+
const buf = [];
|
|
1805
|
+
while (i < lines.length && /^>\s?/.test(lines[i].trim())) {
|
|
1806
|
+
buf.push(lines[i].trim().replace(/^>\s?/, ''));
|
|
1807
|
+
i += 1;
|
|
1808
|
+
}
|
|
1809
|
+
out.push(h('blockquote', { key: 'q' + key++ }, mdInline(buf.join(' '), 'q' + key + ':')));
|
|
1810
|
+
continue;
|
|
1811
|
+
}
|
|
1812
|
+
if (/^\|.*\|$/.test(text) && /^\|[\s:|-]+\|$/.test((lines[i + 1] || '').trim())) {
|
|
1813
|
+
flush();
|
|
1814
|
+
const cells = (row) => row.trim().replace(/^\||\|$/g, '').split('|').map((cell) => cell.trim());
|
|
1815
|
+
const head = cells(lines[i]);
|
|
1816
|
+
i += 2;
|
|
1817
|
+
const rows = [];
|
|
1818
|
+
while (i < lines.length && /^\|.*\|$/.test(lines[i].trim())) { rows.push(cells(lines[i])); i += 1; }
|
|
1819
|
+
out.push(h('div', { key: 'tw' + key++, className: 'bn-md-table' },
|
|
1820
|
+
h('table', null,
|
|
1821
|
+
h('thead', null, h('tr', null, head.map((cell, ci) => h('th', { key: ci }, mdInline(cell, 'th' + ci + ':'))))),
|
|
1822
|
+
h('tbody', null, rows.map((row, ri) => h('tr', { key: ri }, row.map((cell, ci) => h('td', { key: ci }, mdInline(cell, 'td' + ri + '-' + ci + ':')))))),
|
|
1823
|
+
)));
|
|
1824
|
+
continue;
|
|
1825
|
+
}
|
|
1826
|
+
const ordered = /^\d+\.\s+/.test(text);
|
|
1827
|
+
if (ordered || /^[-*]\s+/.test(text)) {
|
|
1828
|
+
flush();
|
|
1829
|
+
const items = [];
|
|
1830
|
+
while (i < lines.length) {
|
|
1831
|
+
const cur = lines[i].trim();
|
|
1832
|
+
const item = ordered ? cur.match(/^\d+\.\s+(.*)$/) : cur.match(/^[-*]\s+(.*)$/);
|
|
1833
|
+
if (!item) break;
|
|
1834
|
+
items.push(item[1]);
|
|
1835
|
+
i += 1;
|
|
1836
|
+
}
|
|
1837
|
+
out.push(h(ordered ? 'ol' : 'ul', { key: 'l' + key++ },
|
|
1838
|
+
items.map((item, ii) => h('li', { key: ii }, mdInline(item, 'li' + key + '-' + ii + ':')))));
|
|
1839
|
+
continue;
|
|
1840
|
+
}
|
|
1841
|
+
para.push(text);
|
|
1842
|
+
i += 1;
|
|
1843
|
+
}
|
|
1844
|
+
flush();
|
|
1845
|
+
return out;
|
|
1846
|
+
};
|
|
1693
1847
|
const licenseOn = !!(state.license && (state.license.state === 'active' || state.license.state === 'grace'));
|
|
1694
1848
|
const member = state.member || null;
|
|
1695
1849
|
const memberOn = !!(member && member.active);
|
|
@@ -1736,9 +1890,8 @@
|
|
|
1736
1890
|
const topSeg = h('div', { className: 'bn-seg' },
|
|
1737
1891
|
h('span', { className: 'on', title: (state.license && state.license.reason) || '' }, licenseOn ? '已授权' : '未授权'),
|
|
1738
1892
|
h('button', { type: 'button', onClick: openManual }, '手册'),
|
|
1739
|
-
h('button', { type: 'button', onClick: openCases }, '案例'),
|
|
1740
1893
|
);
|
|
1741
|
-
const campaigns = state.
|
|
1894
|
+
const campaigns = state.campaigns || [];
|
|
1742
1895
|
const camp = campaigns.length ? campaigns[((campIdx % campaigns.length) + campaigns.length) % campaigns.length] : null;
|
|
1743
1896
|
const campIcons = { spark: '✨', gift: '🎁', rocket: '🚀', crown: '👑', star: '⭐', bolt: '⚡', box: '📦', heart: '💛', fire: '🔥', gem: '💎', party: '🎉', tag: '🏷️' };
|
|
1744
1897
|
const campHref = camp
|
|
@@ -2690,44 +2843,56 @@
|
|
|
2690
2843
|
),
|
|
2691
2844
|
) : null,
|
|
2692
2845
|
|
|
2693
|
-
docsOpen
|
|
2846
|
+
docsOpen ? h('div', { className: 'bn-docs-back bn-layer', popover: 'manual', onClick: () => setDocsOpen(false) },
|
|
2694
2847
|
h('aside', { className: 'bn-docs', onClick: (event) => event.stopPropagation() },
|
|
2695
2848
|
h('div', { className: 'bn-docs-bar' },
|
|
2696
|
-
h('strong', null, doc.title),
|
|
2697
|
-
h('a', { className: 'bn-btn', href: doc.url, target: '_blank', rel: 'noreferrer' }, docOpenLabel(doc.url)),
|
|
2849
|
+
h('strong', null, doc ? doc.title : '使用手册'),
|
|
2850
|
+
doc && doc.url ? h('a', { className: 'bn-btn', href: doc.url, target: '_blank', rel: 'noreferrer' }, docOpenLabel(doc.url)) : null,
|
|
2698
2851
|
h('button', { type: 'button', className: 'bn-btn ghost', onClick: () => setDocsOpen(false) }, '关闭'),
|
|
2699
2852
|
),
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
key:
|
|
2853
|
+
h('div', { className: 'bn-docs-tabs' },
|
|
2854
|
+
manualTabs.map((tab) => h('button', {
|
|
2855
|
+
key: tab.key,
|
|
2703
2856
|
type: 'button',
|
|
2704
|
-
className:
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
h('iframe', {
|
|
2710
|
-
key: doc.id,
|
|
2711
|
-
title: doc.title,
|
|
2712
|
-
src: doc.url,
|
|
2713
|
-
onLoad: (event) => {
|
|
2714
|
-
const frame = event.target;
|
|
2715
|
-
window.setTimeout(() => {
|
|
2716
|
-
if (!frame.isConnected) return;
|
|
2717
|
-
try {
|
|
2718
|
-
const href = frame.contentWindow && frame.contentWindow.location && frame.contentWindow.location.href;
|
|
2719
|
-
setDocBlocked(!href || href === 'about:blank');
|
|
2720
|
-
} catch {
|
|
2721
|
-
setDocBlocked(false);
|
|
2722
|
-
}
|
|
2723
|
-
}, 700);
|
|
2724
|
-
},
|
|
2725
|
-
}),
|
|
2726
|
-
docBlocked ? h('div', { className: 'bn-docs-miss' },
|
|
2727
|
-
h('p', null, '这篇文档不允许嵌在面板里。'),
|
|
2728
|
-
h('a', { className: 'bn-btn', href: doc.url, target: '_blank', rel: 'noreferrer' }, docOpenLabel(doc.url)),
|
|
2729
|
-
) : null,
|
|
2857
|
+
className: tab.key === (activeTab ? activeTab.key : '') ? 'on' : '',
|
|
2858
|
+
disabled: !tab.doc,
|
|
2859
|
+
title: tab.doc ? tab.label : '这篇手册还没上架',
|
|
2860
|
+
onClick: () => { if (!tab.doc) return; setDocId(tab.key); setDocBlocked(false); },
|
|
2861
|
+
}, tab.label, tab.doc && tab.doc.locked ? h('i', { className: 'bn-docs-tag' }, tab.doc.access === 'pro' ? '年会员' : '会员') : null)),
|
|
2730
2862
|
),
|
|
2863
|
+
doc
|
|
2864
|
+
? (doc.locked
|
|
2865
|
+
? h('div', { className: 'bn-docs-lock', key: doc.id },
|
|
2866
|
+
h('b', null, doc.access === 'pro' ? '这篇手册是年会员专属' : '这篇手册是会员专属'),
|
|
2867
|
+
h('p', null, '开通后即可查看完整内容;已购买的用户请先在「我的授权」里激活对应产品。'),
|
|
2868
|
+
h('a', { className: 'bn-btn primary', href: memberHref, target: '_blank', rel: 'noreferrer' }, '去开通'),
|
|
2869
|
+
)
|
|
2870
|
+
: doc.content
|
|
2871
|
+
? h('div', { className: 'bn-docs-md', key: doc.id }, mdBlocks(doc.content))
|
|
2872
|
+
: h('div', { className: 'bn-docs-frame' },
|
|
2873
|
+
h('iframe', {
|
|
2874
|
+
key: doc.id,
|
|
2875
|
+
title: doc.title,
|
|
2876
|
+
src: doc.url,
|
|
2877
|
+
onLoad: (event) => {
|
|
2878
|
+
const frame = event.target;
|
|
2879
|
+
window.setTimeout(() => {
|
|
2880
|
+
if (!frame.isConnected) return;
|
|
2881
|
+
try {
|
|
2882
|
+
const href = frame.contentWindow && frame.contentWindow.location && frame.contentWindow.location.href;
|
|
2883
|
+
setDocBlocked(!href || href === 'about:blank');
|
|
2884
|
+
} catch {
|
|
2885
|
+
setDocBlocked(false);
|
|
2886
|
+
}
|
|
2887
|
+
}, 700);
|
|
2888
|
+
},
|
|
2889
|
+
}),
|
|
2890
|
+
docBlocked ? h('div', { className: 'bn-docs-miss' },
|
|
2891
|
+
h('p', null, '这篇文档不允许嵌在面板里。'),
|
|
2892
|
+
h('a', { className: 'bn-btn', href: doc.url, target: '_blank', rel: 'noreferrer' }, docOpenLabel(doc.url)),
|
|
2893
|
+
) : null,
|
|
2894
|
+
))
|
|
2895
|
+
: h('div', { className: 'bn-docs-empty' }, h('p', null, '这篇手册还没上架。')),
|
|
2731
2896
|
),
|
|
2732
2897
|
) : null,
|
|
2733
2898
|
|
package/index.js
CHANGED
|
@@ -10369,10 +10369,58 @@ function createPanelApp(options = {}) {
|
|
|
10369
10369
|
};
|
|
10370
10370
|
}
|
|
10371
10371
|
let campaignCache = { at: 0, items: [] };
|
|
10372
|
+
function ownedCampaignProducts() {
|
|
10373
|
+
const owned = /* @__PURE__ */ new Set();
|
|
10374
|
+
for (const item of license.listProducts()) {
|
|
10375
|
+
if (item.status && item.status.canExport) owned.add(item.product);
|
|
10376
|
+
}
|
|
10377
|
+
return owned;
|
|
10378
|
+
}
|
|
10379
|
+
const TIER_SINGLE = 99;
|
|
10380
|
+
const TIER_PLUS = 159;
|
|
10381
|
+
const TIER_MAX = 229;
|
|
10382
|
+
function campaignTier(item) {
|
|
10383
|
+
const explicit = Number(item.tier) || 0;
|
|
10384
|
+
if (explicit) return explicit;
|
|
10385
|
+
const price = Number(item.price) || 0;
|
|
10386
|
+
if (price >= 200) return TIER_MAX;
|
|
10387
|
+
if (price >= 130) return TIER_PLUS;
|
|
10388
|
+
return TIER_SINGLE;
|
|
10389
|
+
}
|
|
10390
|
+
function hasResellerMark() {
|
|
10391
|
+
if (resellerCode()) return true;
|
|
10392
|
+
for (const item of license.listProducts()) {
|
|
10393
|
+
const cache = license.readCache(item.product);
|
|
10394
|
+
const code = cache && cache.entitlements && cache.entitlements.resellerCode;
|
|
10395
|
+
if (code) return true;
|
|
10396
|
+
}
|
|
10397
|
+
return false;
|
|
10398
|
+
}
|
|
10399
|
+
function currentTier() {
|
|
10400
|
+
if (hasResellerMark()) return TIER_MAX;
|
|
10401
|
+
const active = license.listProducts().filter((item) => item.status && item.status.canExport);
|
|
10402
|
+
if (!active.length) return 0;
|
|
10403
|
+
if (active.some((item) => String(item.product || "").startsWith("biupro"))) return TIER_PLUS;
|
|
10404
|
+
return TIER_SINGLE;
|
|
10405
|
+
}
|
|
10406
|
+
function filterCampaigns(items) {
|
|
10407
|
+
const tier = currentTier();
|
|
10408
|
+
if (!tier) return items;
|
|
10409
|
+
if (tier >= TIER_MAX) return [];
|
|
10410
|
+
if (tier === TIER_PLUS) return items.filter((item) => campaignTier(item) >= TIER_MAX);
|
|
10411
|
+
const owned = ownedCampaignProducts();
|
|
10412
|
+
return items.filter((item) => {
|
|
10413
|
+
const level = campaignTier(item);
|
|
10414
|
+
const slugs = (item.items || []).map((entry) => entry.productSlug).filter(Boolean);
|
|
10415
|
+
if (!slugs.length) return true;
|
|
10416
|
+
if (level >= TIER_PLUS) return true;
|
|
10417
|
+
return !slugs.every((slug) => owned.has(slug));
|
|
10418
|
+
});
|
|
10419
|
+
}
|
|
10372
10420
|
async function loadPublicCampaigns() {
|
|
10373
|
-
if (
|
|
10421
|
+
if (hasResellerMark()) return [];
|
|
10374
10422
|
const now = Date.now();
|
|
10375
|
-
if (now - campaignCache.at < 6e4) return campaignCache.items;
|
|
10423
|
+
if (now - campaignCache.at < 6e4) return filterCampaigns(campaignCache.items);
|
|
10376
10424
|
const base = String(settings.licenseBaseUrl || "").replace(/\/$/, "");
|
|
10377
10425
|
if (!base) {
|
|
10378
10426
|
campaignCache = { at: now, items: [] };
|
|
@@ -10392,17 +10440,29 @@ function createPanelApp(options = {}) {
|
|
|
10392
10440
|
compareAt: Number(item.compareAt) || 0,
|
|
10393
10441
|
gradient: String(item.gradient || "lime"),
|
|
10394
10442
|
kind: item.kind === "link" ? "link" : "sale",
|
|
10395
|
-
linkUrl: String(item.linkUrl || "")
|
|
10443
|
+
linkUrl: String(item.linkUrl || ""),
|
|
10444
|
+
items: (Array.isArray(item.items) ? item.items : []).map((entry) => ({ productSlug: String(entry && entry.productSlug || "") })).filter((entry) => entry.productSlug)
|
|
10396
10445
|
})).filter((item) => item.slug && item.name);
|
|
10397
10446
|
campaignCache = { at: now, items };
|
|
10398
|
-
return items;
|
|
10447
|
+
return filterCampaigns(items);
|
|
10399
10448
|
} catch {
|
|
10400
10449
|
campaignCache = { at: now, items: campaignCache.items };
|
|
10401
|
-
return campaignCache.items;
|
|
10450
|
+
return filterCampaigns(campaignCache.items);
|
|
10402
10451
|
}
|
|
10403
10452
|
}
|
|
10404
10453
|
let showcaseCache = { at: 0, promptsEnabled: false, cases: [], tutorials: [] };
|
|
10405
10454
|
let docsCache = { at: 0, items: [] };
|
|
10455
|
+
function docsToken() {
|
|
10456
|
+
try {
|
|
10457
|
+
const active = license.listProducts().filter((item) => item.status && item.status.canExport);
|
|
10458
|
+
for (const item of active) {
|
|
10459
|
+
const token = license.tokenFor(item.product);
|
|
10460
|
+
if (token) return token;
|
|
10461
|
+
}
|
|
10462
|
+
} catch {
|
|
10463
|
+
}
|
|
10464
|
+
return "";
|
|
10465
|
+
}
|
|
10406
10466
|
async function loadPublicDocs() {
|
|
10407
10467
|
const now = Date.now();
|
|
10408
10468
|
if (now - docsCache.at < 6e4) return docsCache.items;
|
|
@@ -10412,14 +10472,22 @@ function createPanelApp(options = {}) {
|
|
|
10412
10472
|
return docsCache.items;
|
|
10413
10473
|
}
|
|
10414
10474
|
try {
|
|
10415
|
-
const
|
|
10475
|
+
const token = docsToken();
|
|
10476
|
+
const res = await fetch(`${base}/v1/docs`, {
|
|
10477
|
+
headers: token ? { "x-license-token": token } : void 0,
|
|
10478
|
+
signal: AbortSignal.timeout(4e3)
|
|
10479
|
+
});
|
|
10416
10480
|
const data = await res.json().catch(() => ({}));
|
|
10417
10481
|
if (!res.ok) throw new Error("docs unavailable");
|
|
10418
10482
|
const items = (Array.isArray(data.docs) ? data.docs : []).map((item) => ({
|
|
10419
10483
|
id: String(item.id || ""),
|
|
10420
10484
|
title: String(item.title || ""),
|
|
10421
|
-
url: String(item.url || "")
|
|
10422
|
-
|
|
10485
|
+
url: String(item.url || ""),
|
|
10486
|
+
content: String(item.content || ""),
|
|
10487
|
+
manualKey: String(item.manualKey || ""),
|
|
10488
|
+
access: item.access === "member" || item.access === "pro" ? item.access : "free",
|
|
10489
|
+
locked: !!item.locked
|
|
10490
|
+
})).filter((item) => item.id && (item.content || /^https?:\/\//i.test(item.url) || item.locked));
|
|
10423
10491
|
docsCache = { at: now, items };
|
|
10424
10492
|
return items;
|
|
10425
10493
|
} catch {
|
|
@@ -10831,6 +10899,8 @@ function createPanelApp(options = {}) {
|
|
|
10831
10899
|
if (typeof body.key !== "string") return send(res, 400, { error: "key is required" });
|
|
10832
10900
|
try {
|
|
10833
10901
|
const status = await license.activate(body.key.trim().toUpperCase(), body.product ? String(body.product) : void 0);
|
|
10902
|
+
campaignCache = { at: 0, items: campaignCache.items };
|
|
10903
|
+
docsCache = { at: 0, items: docsCache.items };
|
|
10834
10904
|
return send(res, 200, { ok: true, status, licenses: license.listProducts() });
|
|
10835
10905
|
} catch (error) {
|
|
10836
10906
|
return send(res, 400, { error: error.message });
|
|
@@ -10839,6 +10909,8 @@ function createPanelApp(options = {}) {
|
|
|
10839
10909
|
case "POST /signout": {
|
|
10840
10910
|
const body = await readJson(req).catch(() => ({}));
|
|
10841
10911
|
license.signOut(body.product ? String(body.product) : void 0);
|
|
10912
|
+
campaignCache = { at: 0, items: campaignCache.items };
|
|
10913
|
+
docsCache = { at: 0, items: docsCache.items };
|
|
10842
10914
|
return send(res, 200, { ok: true, licenses: license.listProducts() });
|
|
10843
10915
|
}
|
|
10844
10916
|
case "POST /heartbeat": {
|