dsh-tokenbank 0.1.65 → 0.1.67
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/lib/client.js +183 -92
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -28,6 +28,7 @@ window.__ModuleLoader__.load({
|
|
|
28
28
|
openPortal: '打开完整门户',
|
|
29
29
|
openSite: '打开官网',
|
|
30
30
|
addFreeModels: '获取免费模型',
|
|
31
|
+
getModels: '获取模型',
|
|
31
32
|
freeModelsTip: '免费使用主流收费模型,点击后自动获取,模型列表 TokenBank 中的模型任意使用。',
|
|
32
33
|
modelLinked: '已接入 {n} 个模型',
|
|
33
34
|
reload: '刷新',
|
|
@@ -121,6 +122,7 @@ window.__ModuleLoader__.load({
|
|
|
121
122
|
openPortal: 'Open full portal',
|
|
122
123
|
openSite: 'Open website',
|
|
123
124
|
addFreeModels: 'Get free models',
|
|
125
|
+
getModels: 'Get models',
|
|
124
126
|
freeModelsTip: 'Use paid-tier models for free — one click links them, and every TokenBank model in the list is available.',
|
|
125
127
|
rechargeTip: 'Best price anywhere: $1 for ¥6.50 — 10%~25% cheaper than official APIs and relays. Pay with Alipay, credited instantly, credit never expires.',
|
|
126
128
|
modelLinked: '{n} models linked',
|
|
@@ -324,6 +326,58 @@ window.__ModuleLoader__.load({
|
|
|
324
326
|
return snap[0]
|
|
325
327
|
}
|
|
326
328
|
|
|
329
|
+
/** 底部状态栏余额 pill(conversation.composer.dock,登录态显示)。 */
|
|
330
|
+
function BalancePill() {
|
|
331
|
+
var snap = useTbStore()
|
|
332
|
+
var st = React.useState(null)
|
|
333
|
+
React.useEffect(function () {
|
|
334
|
+
var stopped = false
|
|
335
|
+
api('status').then(function (data) {
|
|
336
|
+
if (!stopped) { st[1](data); tbStore.set({ loggedIn: Boolean(data.loggedIn), portalUrl: data.portalUrl }) }
|
|
337
|
+
}).catch(function () {})
|
|
338
|
+
return function () { stopped = true }
|
|
339
|
+
}, [])
|
|
340
|
+
React.useEffect(function () {
|
|
341
|
+
var stopped = false
|
|
342
|
+
if (!snap.loggedIn) return
|
|
343
|
+
api('status').then(function (data) { if (!stopped) st[1](data) }).catch(function () {})
|
|
344
|
+
return function () { stopped = true }
|
|
345
|
+
}, [snap.loggedIn, snap.authOpen])
|
|
346
|
+
var flash = React.useState(false)
|
|
347
|
+
var prev = React.useRef(false)
|
|
348
|
+
React.useEffect(function () {
|
|
349
|
+
if (snap.loggedIn && !prev.current) flash[1](true)
|
|
350
|
+
prev.current = snap.loggedIn
|
|
351
|
+
}, [snap.loggedIn])
|
|
352
|
+
var onClick = function (e) {
|
|
353
|
+
flash[1](false)
|
|
354
|
+
var rect = e && e.currentTarget && e.currentTarget.getBoundingClientRect()
|
|
355
|
+
tbStore.set({
|
|
356
|
+
authOpen: true, authMode: 'login',
|
|
357
|
+
anchor: rect ? { right: rect.right, top: rect.top } : null,
|
|
358
|
+
})
|
|
359
|
+
}
|
|
360
|
+
if (!snap.loggedIn) return null
|
|
361
|
+
var data = st[0]
|
|
362
|
+
var bal = data && data.account && typeof data.account.balance_nano_usd === 'number'
|
|
363
|
+
? '$ ' + (data.account.balance_nano_usd / 1e9).toFixed(2) : null
|
|
364
|
+
return h('button', {
|
|
365
|
+
type: 'button', id: 'tb-balance-pill', title: pageT('composerEntry'),
|
|
366
|
+
className: (flash[0] ? 'tb-balance-flash ' : '') + (snap.authOpen ? 'tb-balance-open' : ''),
|
|
367
|
+
onClick: onClick,
|
|
368
|
+
style: {
|
|
369
|
+
boxSizing: 'border-box', borderRadius: 6, maxWidth: '100%',
|
|
370
|
+
color: 'var(--dsw-alias-label-tertiary, #a0a3a8)', font: 'inherit',
|
|
371
|
+
fontVariantNumeric: 'tabular-nums', lineHeight: 'inherit', whiteSpace: 'nowrap',
|
|
372
|
+
background: 'transparent', border: 'none',
|
|
373
|
+
display: 'inline-flex', alignItems: 'center', gap: 6, padding: '3px 8px',
|
|
374
|
+
fontSize: 14, cursor: 'pointer',
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
bal || '—',
|
|
378
|
+
)
|
|
379
|
+
}
|
|
380
|
+
|
|
327
381
|
/** 输入框工具行、模型选择器左侧的紧凑入口按钮。 */
|
|
328
382
|
function ComposerEntry() {
|
|
329
383
|
var snap = useTbStore()
|
|
@@ -334,21 +388,52 @@ window.__ModuleLoader__.load({
|
|
|
334
388
|
}).catch(function () {})
|
|
335
389
|
return function () { stopped = true }
|
|
336
390
|
}, [])
|
|
337
|
-
var onClick = function () {
|
|
338
|
-
|
|
391
|
+
var onClick = function (e) {
|
|
392
|
+
var rect = e && e.currentTarget && e.currentTarget.getBoundingClientRect()
|
|
393
|
+
tbStore.set({
|
|
394
|
+
authOpen: true, authMode: 'register',
|
|
395
|
+
anchor: rect ? { right: rect.right, top: rect.top } : null,
|
|
396
|
+
})
|
|
339
397
|
}
|
|
398
|
+
var st = React.useState(null)
|
|
399
|
+
React.useEffect(function () {
|
|
400
|
+
var stopped = false
|
|
401
|
+
api('status').then(function (data) {
|
|
402
|
+
if (!stopped) { st[1](data); tbStore.set({ loggedIn: Boolean(data.loggedIn), portalUrl: data.portalUrl }) }
|
|
403
|
+
}).catch(function () {})
|
|
404
|
+
return function () { stopped = true }
|
|
405
|
+
}, [])
|
|
406
|
+
// 登录态变化(弹窗登录/退出)时刷新余额展示
|
|
407
|
+
React.useEffect(function () {
|
|
408
|
+
var stopped = false
|
|
409
|
+
if (!snap.loggedIn) return
|
|
410
|
+
api('status').then(function (data) {
|
|
411
|
+
if (!stopped) st[1](data)
|
|
412
|
+
}).catch(function () {})
|
|
413
|
+
return function () { stopped = true }
|
|
414
|
+
}, [snap.loggedIn, snap.authOpen])
|
|
415
|
+
var data = st[0]
|
|
340
416
|
return h('button', {
|
|
341
417
|
type: 'button',
|
|
418
|
+
id: 'tb-entry-btn',
|
|
419
|
+
className: snap.authOpen ? 'tb-entry-open' : '',
|
|
342
420
|
title: pageT('composerEntry'), 'aria-label': pageT('composerEntry'),
|
|
343
421
|
onClick: onClick,
|
|
344
|
-
style:
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
422
|
+
style: snap.loggedIn
|
|
423
|
+
? {
|
|
424
|
+
display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 4,
|
|
425
|
+
height: 29, padding: '0 8px', borderRadius: 7, boxSizing: 'border-box',
|
|
426
|
+
border: 'none', background: 'transparent',
|
|
427
|
+
cursor: 'pointer', position: 'relative',
|
|
428
|
+
}
|
|
429
|
+
: {
|
|
430
|
+
display: 'inline-flex', alignItems: 'center', cursor: 'pointer', position: 'relative',
|
|
431
|
+
border: 'none', background: 'transparent', padding: 0, boxSizing: 'border-box',
|
|
432
|
+
},
|
|
350
433
|
},
|
|
351
|
-
|
|
434
|
+
snap.loggedIn
|
|
435
|
+
? null
|
|
436
|
+
: h('span', { className: 'tb-free-tag', style: { fontSize: 11, lineHeight: '20px', padding: '0 8px', borderRadius: 999, color: '#fff', background: '#ff4f1f', fontWeight: 600, letterSpacing: 0.3 } }, pageT('freeToken')),
|
|
352
437
|
)
|
|
353
438
|
}
|
|
354
439
|
|
|
@@ -615,6 +700,14 @@ window.__ModuleLoader__.load({
|
|
|
615
700
|
var flash = React.useState(null)
|
|
616
701
|
var sLogoutArm = React.useState(false)
|
|
617
702
|
var sLogoutTimer = { ref: null }
|
|
703
|
+
var freeModelsUsed = React.useState(false)
|
|
704
|
+
// 登录态变化时同步一次性入口标记(退出已清 localStorage,重登后重新出现)
|
|
705
|
+
React.useEffect(function () {
|
|
706
|
+
if (!snap.loggedIn) return
|
|
707
|
+
try {
|
|
708
|
+
freeModelsUsed[1](window.localStorage.getItem('tb-free-models-used') === '1')
|
|
709
|
+
} catch (e) {}
|
|
710
|
+
}, [snap.loggedIn])
|
|
618
711
|
var boxRef = React.useRef(null)
|
|
619
712
|
React.useEffect(function () {
|
|
620
713
|
var stopped = false
|
|
@@ -637,14 +730,6 @@ window.__ModuleLoader__.load({
|
|
|
637
730
|
var openPanel = function (mode, extra) {
|
|
638
731
|
tbStore.set(Object.assign({ authOpen: true, authMode: mode || snap.authMode || 'login', anchor: null }, extra || {}))
|
|
639
732
|
}
|
|
640
|
-
// 余额行右侧的低调图标按钮(悬停有 title 提示)
|
|
641
|
-
var iconBtn = function (label, paths, onClick) {
|
|
642
|
-
return h('button', { type: 'button', title: label, 'aria-label': label,
|
|
643
|
-
style: { border: 'none', background: 'transparent', cursor: 'pointer', padding: 3, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', color: 'var(--dsw-alias-label-secondary, #666)' },
|
|
644
|
-
onClick: onClick },
|
|
645
|
-
h('svg', { viewBox: '0 0 24 24', width: 14, height: 14, fill: 'none', stroke: 'currentColor', 'stroke-width': 2, 'stroke-linecap': 'round', 'stroke-linejoin': 'round' },
|
|
646
|
-
paths.map(function (d) { return h('path', { d: d }) })))
|
|
647
|
-
}
|
|
648
733
|
// 找到宿主模型选择器触发按钮并点开(带重试:刚接入的 provider 需要等一拍渲染)
|
|
649
734
|
var openModelSwitcher = function (tries) {
|
|
650
735
|
var triggers = document.querySelectorAll('button[aria-haspopup="menu"]')
|
|
@@ -674,78 +759,34 @@ window.__ModuleLoader__.load({
|
|
|
674
759
|
var loggedIn = snap.loggedIn
|
|
675
760
|
if (!runtimeCtx) return null
|
|
676
761
|
var smallBtn = Object.assign({}, buttonStyle, { height: 24, padding: '0 8px', fontSize: 12 })
|
|
762
|
+
// 弱化的文字链按钮:无框无底色,次级灰字,悬停才显主色
|
|
763
|
+
var quietLinkStyle = {
|
|
764
|
+
border: 'none', background: 'transparent', cursor: 'pointer', padding: '2px 4px',
|
|
765
|
+
fontSize: 12, lineHeight: '20px', borderRadius: 6,
|
|
766
|
+
color: 'var(--dsw-alias-label-secondary, #888)',
|
|
767
|
+
}
|
|
677
768
|
return h('div', {
|
|
678
769
|
ref: boxRef,
|
|
770
|
+
// 整个长驻板块作为可点击区域:点击任意位置打开账户弹窗(托管等子按钮单独 stopPropagation)
|
|
771
|
+
onClick: function () { openPanel('register') },
|
|
679
772
|
style: {
|
|
773
|
+
cursor: 'pointer',
|
|
680
774
|
margin: '4px 10px 8px', display: 'flex', flexDirection: 'column', gap: 6, width: 'calc(100% - 20px)', boxSizing: 'border-box', alignSelf: 'stretch'
|
|
681
775
|
},
|
|
682
776
|
},
|
|
683
777
|
h('div', { style: { display: 'flex', alignItems: 'center', gap: 4 } },
|
|
684
778
|
h('span', {
|
|
685
779
|
className: 'tb-wordmark',
|
|
686
|
-
style: { fontFamily: "'Frizon','FrizonLocal',sans-serif", fontSize: 14, letterSpacing: 0.5, color: '#
|
|
687
|
-
onClick: function () { window.open((data && data.portalUrl) || 'https://bank.skillpie.cn', '_blank', 'noopener') },
|
|
780
|
+
style: { fontFamily: "'Frizon','FrizonLocal',sans-serif", fontSize: 14, letterSpacing: 0.5, color: '#111111', position: 'relative', top: -1 },
|
|
688
781
|
}, 'TOKENBANK'),
|
|
689
|
-
h('
|
|
690
|
-
h('svg', { viewBox: '0 0 24 24', width: 12, height: 12, fill: 'none', stroke: 'currentColor', 'stroke-width': 2, 'stroke-linecap': 'round', 'stroke-linejoin': 'round' },
|
|
691
|
-
h('path', { d: 'M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6' }),
|
|
692
|
-
h('path', { d: 'M15 3h6v6' }),
|
|
693
|
-
h('path', { d: 'M10 14L21 3' }))),
|
|
694
|
-
loggedIn ? h('button', {
|
|
695
|
-
type: 'button', title: pageT('logout'), 'aria-label': pageT('logout'),
|
|
696
|
-
style: sLogoutArm[0]
|
|
697
|
-
? Object.assign({}, buttonStyle, { height: 20, padding: '0 6px', fontSize: 11, color: '#d03050', borderColor: '#d03050', borderWidth: 1, borderStyle: 'solid', marginLeft: 'auto' })
|
|
698
|
-
: { border: 'none', background: 'transparent', cursor: 'pointer', padding: 2, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', color: '#d03050', marginLeft: 'auto' },
|
|
699
|
-
onClick: async function () {
|
|
700
|
-
if (!sLogoutArm[0]) {
|
|
701
|
-
sLogoutArm[1](true)
|
|
702
|
-
// 10 秒不确认自动归位,避免按钮一直停在「退出登录?」态
|
|
703
|
-
clearTimeout(sLogoutTimer.ref)
|
|
704
|
-
sLogoutTimer.ref = setTimeout(function () { sLogoutArm[1](false) }, 5000)
|
|
705
|
-
return
|
|
706
|
-
}
|
|
707
|
-
clearTimeout(sLogoutTimer.ref)
|
|
708
|
-
await api('logout').catch(function () {})
|
|
709
|
-
sLogoutArm[1](false)
|
|
710
|
-
st[1](null)
|
|
711
|
-
tbStore.set({ loggedIn: false })
|
|
712
|
-
},
|
|
713
|
-
},
|
|
714
|
-
h('svg', { viewBox: '0 0 24 24', width: 13, height: 13, fill: 'none', stroke: 'currentColor', 'stroke-width': 2, 'stroke-linecap': 'round', 'stroke-linejoin': 'round' },
|
|
715
|
-
h('path', { d: 'M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4' }),
|
|
716
|
-
h('path', { d: 'M16 17l5-5-5-5' }),
|
|
717
|
-
h('path', { d: 'M21 12H9' })))
|
|
718
|
-
: h('button', {
|
|
782
|
+
loggedIn ? h('span', { style: { flex: 1 } }) : h('button', {
|
|
719
783
|
type: 'button',
|
|
720
784
|
style: { fontSize: 10, lineHeight: 1, padding: '3px 7px', borderRadius: 999, border: 'none', cursor: 'pointer', color: '#fff', background: '#ff4f1f', fontWeight: 600, letterSpacing: 0.3, marginLeft: 'auto' },
|
|
721
785
|
onClick: function () { openPanel('register') },
|
|
722
|
-
}, pageT('freeToken'))
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
h('span', { style: { fontSize: 11, color: 'var(--dsw-alias-label-secondary, #888)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, data.email || ''),
|
|
727
|
-
) : null,
|
|
728
|
-
loggedIn
|
|
729
|
-
? h('div', { style: { display: 'flex', alignItems: 'center', gap: 2 } },
|
|
730
|
-
h('span', { style: { fontSize: 14, fontWeight: 700, fontVariantNumeric: 'tabular-nums', flex: 1 } },
|
|
731
|
-
data && data.account && typeof data.account.balance_nano_usd === 'number'
|
|
732
|
-
? '$' + (data.account.balance_nano_usd / 1e9).toFixed(2) : '—'),
|
|
733
|
-
iconBtn(pageT('addFreeModels'), [
|
|
734
|
-
'M20 12v9H4v-9',
|
|
735
|
-
'M2 7h20v5H2z',
|
|
736
|
-
'M12 22V7',
|
|
737
|
-
'M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7z',
|
|
738
|
-
'M12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7z',
|
|
739
|
-
], addModels),
|
|
740
|
-
iconBtn(pageT('depositManage'), [
|
|
741
|
-
'M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z',
|
|
742
|
-
], function () { openSettingsPage() }),
|
|
743
|
-
iconBtn(pageT('recharge'), [
|
|
744
|
-
'M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z',
|
|
745
|
-
'M12 8v8',
|
|
746
|
-
'M8 12h8',
|
|
747
|
-
], function () { openPanel('login', { startRecharge: true }) }))
|
|
748
|
-
: null,
|
|
786
|
+
}, pageT('freeToken')),
|
|
787
|
+
loggedIn ? h('span', { style: { fontSize: 13, fontWeight: 700, fontVariantNumeric: 'tabular-nums' } },
|
|
788
|
+
data && data.account && typeof data.account.balance_nano_usd === 'number'
|
|
789
|
+
? '$' + (data.account.balance_nano_usd / 1e9).toFixed(2) : '—') : null),
|
|
749
790
|
loggedIn && flash[0]
|
|
750
791
|
? h('div', { style: { fontSize: 11, color: 'var(--dsw-alias-label-secondary, #888)', textAlign: 'center' } }, flash[0].text)
|
|
751
792
|
: null,
|
|
@@ -780,6 +821,12 @@ window.__ModuleLoader__.load({
|
|
|
780
821
|
var checkinFlash = React.useState(null) // 签到成功闪现文案(复用获取免费模型按钮样式,2s 回原样)
|
|
781
822
|
var checkin = React.useState({ busy: false, done: false })
|
|
782
823
|
var depTip = React.useState(null) // 说明板块:hover 哪个按钮就显示哪段说明('deposit'|'recharge'|'models')
|
|
824
|
+
var tipSeen = React.useState({}) // 引导提示已看标记:每个按钮登录后仅第一次 hover 展示,后续不再弹
|
|
825
|
+
var showTipOnce = function (key) {
|
|
826
|
+
if (rechargeOpen[0] || tipSeen[0][key]) return
|
|
827
|
+
var next = Object.assign({}, tipSeen[0]); next[key] = true
|
|
828
|
+
tipSeen[1](next); depTip[1](key)
|
|
829
|
+
}
|
|
783
830
|
React.useEffect(function () {
|
|
784
831
|
if (!snap.authOpen) logoutArm[1](false)
|
|
785
832
|
}, [snap.authOpen])
|
|
@@ -810,12 +857,13 @@ window.__ModuleLoader__.load({
|
|
|
810
857
|
var anchor = snap.anchor || { right: window.innerWidth - 16, top: window.innerHeight - 80 }
|
|
811
858
|
var panelWidth = 256
|
|
812
859
|
return h('div', { style: { position: 'fixed', inset: 0, zIndex: 1999 } },
|
|
813
|
-
h('div', { style: { position: '
|
|
860
|
+
h('div', { style: { position: 'fixed', inset: 0, zIndex: -1 }, onClick: close }),
|
|
814
861
|
h('div', {
|
|
815
862
|
style: {
|
|
816
863
|
position: 'fixed', width: panelWidth, maxWidth: 'calc(100vw - 16px)',
|
|
817
|
-
|
|
818
|
-
|
|
864
|
+
right: Math.max(8, window.innerWidth - anchor.right),
|
|
865
|
+
bottom: Math.max(8, window.innerHeight - anchor.top + 8),
|
|
866
|
+
maxHeight: 420, overflow: 'auto',
|
|
819
867
|
/* 与模型选择器菜单(MenuSurface)完全一致的材质 */
|
|
820
868
|
background: 'var(--dsw-menu-surface-fill)',
|
|
821
869
|
backdropFilter: 'var(--dsw-menu-backdrop-filter)',
|
|
@@ -835,18 +883,29 @@ window.__ModuleLoader__.load({
|
|
|
835
883
|
href: portal, target: '_blank', rel: 'noopener noreferrer',
|
|
836
884
|
style: { display: 'inline-flex', alignItems: 'center', cursor: 'pointer', textDecoration: 'none' },
|
|
837
885
|
'aria-label': 'TokenBank',
|
|
838
|
-
}, h('span', { className: 'tb-wordmark', style: { fontFamily: "'Frizon','FrizonLocal',sans-serif", fontSize: 17, fontWeight: 400, letterSpacing: 0.5, lineHeight: 1, color: '#111111' } }, 'TOKENBANK')),
|
|
886
|
+
}, h('span', { className: 'tb-wordmark', style: { fontFamily: "'Frizon','FrizonLocal',sans-serif", fontSize: 17, fontWeight: 400, letterSpacing: 0.5, lineHeight: 1, color: '#111111', position: 'relative', top: -1, left: -1 } }, 'TOKENBANK')),
|
|
887
|
+
// 标题右侧紧贴的「打开外部」灰色小按钮:新开 TokenBank 官网
|
|
888
|
+
h('a', {
|
|
889
|
+
href: portal, target: '_blank', rel: 'noopener noreferrer',
|
|
890
|
+
title: pageT('openSite'), 'aria-label': pageT('openSite'),
|
|
891
|
+
style: { display: 'inline-flex', alignItems: 'center', justifyContent: 'center', width: 17, height: 17, borderRadius: 5, marginLeft: -4, position: 'relative', top: 1, color: 'var(--dsw-alias-label-secondary, #888)', background: 'transparent', border: 'none', outline: 'none', cursor: 'pointer', textDecoration: 'none' },
|
|
892
|
+
},
|
|
893
|
+
h('svg', { width: 13, height: 13, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 2.2, strokeLinecap: 'round', strokeLinejoin: 'round' },
|
|
894
|
+
h('path', { d: 'M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6' }),
|
|
895
|
+
h('polyline', { points: '15 3 21 3 21 9' }),
|
|
896
|
+
h('line', { x1: 10, y1: 14, x2: 21, y2: 3 }))),
|
|
839
897
|
h('span', { style: { flex: 1 } }),
|
|
840
898
|
data && data.loggedIn ? h('button', {
|
|
841
899
|
type: 'button', title: pageT('logout'), 'aria-label': pageT('logout'),
|
|
842
900
|
style: logoutArm[0]
|
|
843
901
|
? Object.assign({}, buttonStyle, { height: 24, padding: '0 8px', fontSize: 11, color: '#d03050', borderColor: '#d03050', borderWidth: 1, borderStyle: 'solid' })
|
|
844
|
-
: { height: 24, minWidth: 24, padding: 0, border: 'none', borderRadius: 6, background: 'transparent', cursor: 'pointer', display: 'inline-flex', alignItems: 'center', justifyContent: 'center', color: '#
|
|
902
|
+
: { height: 24, minWidth: 24, padding: 0, border: 'none', borderRadius: 6, background: 'transparent', cursor: 'pointer', display: 'inline-flex', alignItems: 'center', justifyContent: 'center', color: 'var(--dsw-alias-label-secondary, #999)' },
|
|
845
903
|
onClick: async function () {
|
|
846
904
|
if (!logoutArm[0]) { logoutArm[1](true); return }
|
|
847
905
|
await api('logout').catch(function () {})
|
|
848
906
|
logoutArm[1](false)
|
|
849
907
|
st[1](null)
|
|
908
|
+
try { window.localStorage.removeItem('tb-free-models-used') } catch (e) {}
|
|
850
909
|
tbStore.set({ loggedIn: false })
|
|
851
910
|
},
|
|
852
911
|
},
|
|
@@ -880,8 +939,9 @@ window.__ModuleLoader__.load({
|
|
|
880
939
|
type: 'button', disabled: checkin[0].busy || checkin[0].done,
|
|
881
940
|
style: Object.assign({}, buttonStyle, {
|
|
882
941
|
height: 26, padding: '0 12px', fontSize: 12,
|
|
942
|
+
// 边框色与「托管」按钮同口径(border-l2 浅灰弱化),已签到转绿保留
|
|
883
943
|
color: checkin[0].done ? '#22a04a' : undefined,
|
|
884
|
-
borderColor: checkin[0].done ? '#22a04a' :
|
|
944
|
+
borderColor: checkin[0].done ? '#22a04a' : 'var(--dsw-alias-border-l2, #c9ccd1)',
|
|
885
945
|
}),
|
|
886
946
|
onClick: async function () {
|
|
887
947
|
if (checkin[0].done || checkin[0].busy) return
|
|
@@ -906,14 +966,14 @@ window.__ModuleLoader__.load({
|
|
|
906
966
|
data && data.loggedIn ? h('button', {
|
|
907
967
|
type: 'button', 'aria-label': pageT('depositManageTip'),
|
|
908
968
|
style: Object.assign({}, buttonStyle, { height: 26, padding: '0 12px', fontSize: 12, borderColor: 'var(--dsw-alias-border-l2, #c9ccd1)' }),
|
|
909
|
-
onMouseEnter: function () {
|
|
969
|
+
onMouseEnter: function () { showTipOnce('deposit') },
|
|
910
970
|
onClick: function () { depTip[1](null); tbStore.set({ authOpen: false }); openSettingsPage() },
|
|
911
971
|
}, pageT('depositManage')) : null,
|
|
912
972
|
(checkin[0].done || (data.account && typeof data.account.balance_nano_usd === 'number' && data.account.balance_nano_usd < 1e9))
|
|
913
973
|
? h('button', {
|
|
914
974
|
type: 'button',
|
|
915
975
|
style: Object.assign({}, primaryButtonStyle, { height: 26, padding: '0 12px', fontSize: 12 }),
|
|
916
|
-
onMouseEnter: function () {
|
|
976
|
+
onMouseEnter: function () { showTipOnce('recharge') },
|
|
917
977
|
onClick: function () { depTip[1](null); rechargeOpen[1](function (v) { return !v }) },
|
|
918
978
|
}, pageT('recharge'))
|
|
919
979
|
: null,
|
|
@@ -965,7 +1025,7 @@ window.__ModuleLoader__.load({
|
|
|
965
1025
|
} : undefined,
|
|
966
1026
|
}, checkinFlash[0].text) : h('button', {
|
|
967
1027
|
type: 'button', style: Object.assign({}, primaryButtonStyle, { justifyContent: 'center' }),
|
|
968
|
-
onMouseEnter: function () {
|
|
1028
|
+
onMouseEnter: function () { showTipOnce('models') },
|
|
969
1029
|
onClick: async function () {
|
|
970
1030
|
try {
|
|
971
1031
|
var models = await api('gateway-models', { accessKey: data.accessKey })
|
|
@@ -973,6 +1033,15 @@ window.__ModuleLoader__.load({
|
|
|
973
1033
|
await addProviderToModels(runtimeCtx, data.baseURL || portal, { accessKey: data.accessKey, list: list, protocol: models.protocol })
|
|
974
1034
|
checkinFlash[1]({ text: pageT('modelLinked').replace('{n}', String(list.length)), models: true })
|
|
975
1035
|
window.setTimeout(function () { checkinFlash[1](null) }, 3000)
|
|
1036
|
+
// 模型接入成功即关弹窗,自动弹出宿主模型选择器(与签到闪现按钮同款时序)
|
|
1037
|
+
tbStore.set({ authOpen: false })
|
|
1038
|
+
window.setTimeout(function () {
|
|
1039
|
+
var triggers = document.querySelectorAll('button[aria-haspopup="menu"]')
|
|
1040
|
+
for (var q = 0; q < triggers.length; q++) {
|
|
1041
|
+
var lb = triggers[q].getAttribute('aria-label') || ''
|
|
1042
|
+
if (/选择模型|Select model/.test(lb)) { triggers[q].click(); return }
|
|
1043
|
+
}
|
|
1044
|
+
}, 80)
|
|
976
1045
|
} catch (err) {
|
|
977
1046
|
tbStore.set({ notify: { kind: 'error', title: String(err.message || err), detail: '' } })
|
|
978
1047
|
}
|
|
@@ -985,6 +1054,8 @@ window.__ModuleLoader__.load({
|
|
|
985
1054
|
onAuthed: async function () {
|
|
986
1055
|
tbStore.set({ authOpen: false })
|
|
987
1056
|
try {
|
|
1057
|
+
var me = await api('status').catch(function () { return null })
|
|
1058
|
+
if (me) tbStore.set({ loggedIn: Boolean(me.loggedIn), portalUrl: me.portalUrl })
|
|
988
1059
|
if (!runtimeCtx.remote || !runtimeCtx.remote.settings) return
|
|
989
1060
|
var fresh = await api('status')
|
|
990
1061
|
if (fresh && fresh.accessKey) {
|
|
@@ -1495,6 +1566,21 @@ window.__ModuleLoader__.load({
|
|
|
1495
1566
|
var wmCss = document.createElement('style')
|
|
1496
1567
|
wmCss.textContent = "@font-face{font-family:'FrizonLocal';src:url(data:font/woff;base64," + FRIZON_WOFF + ") format('woff')}body[data-ds-dark-theme] .tb-wordmark{color:#ffffff!important}"
|
|
1497
1568
|
document.head.appendChild(wmCss)
|
|
1569
|
+
// 余额 pill 登录闪烁 5s 提示可点击
|
|
1570
|
+
var flashCss = document.createElement('style')
|
|
1571
|
+
flashCss.textContent = '.tb-balance-flash{color:#ff7a3d!important;box-shadow:inset 0 0 0 1px #ff7a3d}#tb-balance-pill{border-radius:var(--dsw-radius-sm, 8px)}#tb-balance-pill:hover,#tb-balance-pill.tb-balance-open{background:var(--dsw-alias-interactive-bg-hover, rgba(0,0,0,.08))!important;color:var(--dsw-alias-label-secondary, #888)!important}'
|
|
1572
|
+
document.head.appendChild(flashCss)
|
|
1573
|
+
ctx.effect(function () {
|
|
1574
|
+
return function () { if (flashCss.parentNode) flashCss.parentNode.removeChild(flashCss) }
|
|
1575
|
+
}, 'dsh-tokenbank: balance flash style')
|
|
1576
|
+
// 入口按钮 hover 形态:灰底 + 箭头反转(与模型选择器 hover 一致)
|
|
1577
|
+
var entryCss = document.createElement('style')
|
|
1578
|
+
entryCss.textContent = '#tb-entry-btn:not(:has(.tb-free-tag)):hover{background:var(--dsw-alias-interactive-bg-hover, rgba(0,0,0,.05))!important;margin:1px 0;height:27px!important}.tb-entry-open .tb-entry-chevron{transition:transform .15s ease;transform:rotate(180deg)}'
|
|
1579
|
+
document.head.appendChild(entryCss)
|
|
1580
|
+
ctx.effect(function () {
|
|
1581
|
+
return function () { if (entryCss.parentNode) entryCss.parentNode.removeChild(entryCss) }
|
|
1582
|
+
}, 'dsh-tokenbank: entry hover style')
|
|
1583
|
+
|
|
1498
1584
|
}
|
|
1499
1585
|
ctx.effect(function () {
|
|
1500
1586
|
return ctx.locale.register(NS, { zh: zh, en: en })
|
|
@@ -1508,15 +1594,20 @@ window.__ModuleLoader__.load({
|
|
|
1508
1594
|
runtimeCtx = ctx
|
|
1509
1595
|
|
|
1510
1596
|
// 输入框工具行、模型选择器左侧的紧凑入口按钮(弹账户/注册窗)
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1597
|
+
ctx.slots.inject('conversation.composer.dock', function () {
|
|
1598
|
+
return ctx.slots.register({
|
|
1599
|
+
name: 'conversation.composer.dock',
|
|
1600
|
+
id: 'dsh-tokenbank-balance',
|
|
1601
|
+
order: 5,
|
|
1602
|
+
}, BalancePill)
|
|
1603
|
+
})
|
|
1604
|
+
ctx.slots.inject('conversation.input.right', function () {
|
|
1515
1605
|
return ctx.slots.register({
|
|
1516
|
-
name: '
|
|
1517
|
-
id: 'dsh-tokenbank-
|
|
1606
|
+
name: 'conversation.input.right',
|
|
1607
|
+
id: 'dsh-tokenbank-entry',
|
|
1608
|
+
order: 0,
|
|
1518
1609
|
locale: NS,
|
|
1519
|
-
},
|
|
1610
|
+
}, ComposerEntry)
|
|
1520
1611
|
})
|
|
1521
1612
|
|
|
1522
1613
|
// 同一个槽只 inject 一次:多次 inject 会互相覆盖(之前 auth 注册被
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-tokenbank",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.67",
|
|
4
4
|
"description": "DSH 免费模型:一键注册 TokenBank 领免费 APIKey 送 $5 体验金,免费 GLM 模型直接进模型列表;自带余额查询、API Key 密钥托管(临时额度转永久)、每日签到、充值入口(支付宝),获取免费模型无需自建中转。致敬 dsh-our-free-model。官网 https://bank.skillpie.cn",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,4 +48,4 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}
|