dsh-tokenbank 0.1.63 → 0.1.64
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 +143 -118
- package/lib/index.js +12 -12
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -29,7 +29,7 @@ window.__ModuleLoader__.load({
|
|
|
29
29
|
openSite: '打开官网',
|
|
30
30
|
addFreeModels: '获取免费模型',
|
|
31
31
|
freeModelsTip: '免费使用主流收费模型,点击后自动获取,模型列表 TokenBank 中的模型任意使用。',
|
|
32
|
-
modelLinked: '已接入 {n}
|
|
32
|
+
modelLinked: '已接入 {n} 个模型',
|
|
33
33
|
reload: '刷新',
|
|
34
34
|
recharge: '充值',
|
|
35
35
|
rechargeTip: '全网最低价:¥10 ≈ 3846万 TOKEN,比官方与中转站省 10%~25%;支付宝直付秒到账,余额永不过期。',
|
|
@@ -47,9 +47,6 @@ window.__ModuleLoader__.load({
|
|
|
47
47
|
rechargeCancel: '取消',
|
|
48
48
|
composerEntry: 'TokenBank 账户',
|
|
49
49
|
officialSite: 'TokenBank 官网',
|
|
50
|
-
claimFree: '领取免费TOKEN',
|
|
51
|
-
freeToken: '免费模型',
|
|
52
|
-
modelLinked: '已接入 {n} 个模型,去切换',
|
|
53
50
|
loading: '正在连接 TokenBank…',
|
|
54
51
|
balance: '余额',
|
|
55
52
|
totalEarned: '累计收益',
|
|
@@ -69,6 +66,7 @@ window.__ModuleLoader__.load({
|
|
|
69
66
|
captchaRefresh: '换一张',
|
|
70
67
|
savePassword: '在本机记住密码(用于静默续登)',
|
|
71
68
|
register: '注册免费领TOKEN',
|
|
69
|
+
freeToken: '免费模型',
|
|
72
70
|
login: '立即登录',
|
|
73
71
|
logout: '退出登录',
|
|
74
72
|
deposits: '密钥托管',
|
|
@@ -125,7 +123,7 @@ window.__ModuleLoader__.load({
|
|
|
125
123
|
addFreeModels: 'Get free models',
|
|
126
124
|
freeModelsTip: 'Use paid-tier models for free — one click links them, and every TokenBank model in the list is available.',
|
|
127
125
|
rechargeTip: 'Best price anywhere: $1 for ¥6.50 — 10%~25% cheaper than official APIs and relays. Pay with Alipay, credited instantly, credit never expires.',
|
|
128
|
-
modelLinked: '{n} models linked
|
|
126
|
+
modelLinked: '{n} models linked',
|
|
129
127
|
reload: 'Reload',
|
|
130
128
|
recharge: 'Recharge',
|
|
131
129
|
depositManage: 'Manage keys',
|
|
@@ -142,9 +140,6 @@ window.__ModuleLoader__.load({
|
|
|
142
140
|
rechargeCancel: 'Cancel',
|
|
143
141
|
composerEntry: 'TokenBank account',
|
|
144
142
|
officialSite: 'TokenBank website',
|
|
145
|
-
claimFree: 'Claim free TOKEN',
|
|
146
|
-
freeToken: 'FREE',
|
|
147
|
-
modelLinked: 'Linked {n} models, tap to switch',
|
|
148
143
|
loading: 'Connecting to TokenBank…',
|
|
149
144
|
balance: 'Balance',
|
|
150
145
|
totalEarned: 'Total earned',
|
|
@@ -164,6 +159,7 @@ window.__ModuleLoader__.load({
|
|
|
164
159
|
captchaRefresh: 'New captcha',
|
|
165
160
|
savePassword: 'Remember password on this machine (silent re-login)',
|
|
166
161
|
register: 'Sign up for free TOKEN',
|
|
162
|
+
freeToken: 'FREE',
|
|
167
163
|
login: 'Sign in now',
|
|
168
164
|
logout: 'Sign out',
|
|
169
165
|
deposits: 'Key deposits',
|
|
@@ -329,6 +325,33 @@ window.__ModuleLoader__.load({
|
|
|
329
325
|
}
|
|
330
326
|
|
|
331
327
|
/** 输入框工具行、模型选择器左侧的紧凑入口按钮。 */
|
|
328
|
+
function ComposerEntry() {
|
|
329
|
+
var snap = useTbStore()
|
|
330
|
+
React.useEffect(function () {
|
|
331
|
+
var stopped = false
|
|
332
|
+
api('status').then(function (data) {
|
|
333
|
+
if (!stopped) tbStore.set({ loggedIn: Boolean(data.loggedIn), portalUrl: data.portalUrl })
|
|
334
|
+
}).catch(function () {})
|
|
335
|
+
return function () { stopped = true }
|
|
336
|
+
}, [])
|
|
337
|
+
var onClick = function () {
|
|
338
|
+
tbStore.set({ authOpen: true, authMode: 'register', anchor: null })
|
|
339
|
+
}
|
|
340
|
+
return h('button', {
|
|
341
|
+
type: 'button',
|
|
342
|
+
title: pageT('composerEntry'), 'aria-label': pageT('composerEntry'),
|
|
343
|
+
onClick: onClick,
|
|
344
|
+
style: {
|
|
345
|
+
display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 4,
|
|
346
|
+
height: 29, minWidth: 29, padding: '0 2px', borderRadius: 7,
|
|
347
|
+
border: 'none', background: 'transparent',
|
|
348
|
+
cursor: 'pointer', position: 'relative',
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
h(TokenBankLogo, { size: 18 }),
|
|
352
|
+
)
|
|
353
|
+
}
|
|
354
|
+
|
|
332
355
|
/** shell.overlay 轻提示:portal 到 document.body,压过设置页抽屉层级。 */
|
|
333
356
|
function NotifyOverlay() {
|
|
334
357
|
var snap = useTbStore()
|
|
@@ -589,8 +612,10 @@ window.__ModuleLoader__.load({
|
|
|
589
612
|
function SidebarCard() {
|
|
590
613
|
var snap = useTbStore()
|
|
591
614
|
var st = React.useState(null)
|
|
615
|
+
var flash = React.useState(null)
|
|
616
|
+
var sLogoutArm = React.useState(false)
|
|
617
|
+
var sLogoutTimer = { ref: null }
|
|
592
618
|
var boxRef = React.useRef(null)
|
|
593
|
-
var sLogoutArm = React.useState(false) // 两段式退出确认(参考弹窗:首次点变红描边,再点才退出)
|
|
594
619
|
React.useEffect(function () {
|
|
595
620
|
var stopped = false
|
|
596
621
|
api('status').then(function (data) {
|
|
@@ -601,136 +626,137 @@ window.__ModuleLoader__.load({
|
|
|
601
626
|
}, 60000)
|
|
602
627
|
return function () { stopped = true; clearInterval(timer) }
|
|
603
628
|
}, [])
|
|
629
|
+
// 登录态/弹窗开合变化时立即重拉 status,侧栏即时反映登录结果
|
|
604
630
|
React.useEffect(function () {
|
|
605
631
|
var stopped = false
|
|
606
|
-
api('status').then(function (
|
|
607
|
-
if (stopped)
|
|
608
|
-
st[1](d)
|
|
609
|
-
tbStore.set({ loggedIn: Boolean(d.loggedIn), portalUrl: d.portalUrl })
|
|
632
|
+
api('status').then(function (data) {
|
|
633
|
+
if (!stopped) { st[1](data); tbStore.set({ loggedIn: Boolean(data.loggedIn), portalUrl: data.portalUrl }) }
|
|
610
634
|
}).catch(function () {})
|
|
611
635
|
return function () { stopped = true }
|
|
612
636
|
}, [snap.loggedIn, snap.authOpen])
|
|
613
|
-
var
|
|
614
|
-
tbStore.set({ authOpen: true, authMode: mode || snap.authMode || 'login', anchor: null,
|
|
637
|
+
var openPanel = function (mode, extra) {
|
|
638
|
+
tbStore.set(Object.assign({ authOpen: true, authMode: mode || snap.authMode || 'login', anchor: null }, extra || {}))
|
|
639
|
+
}
|
|
640
|
+
// 找到宿主模型选择器触发按钮并点开(带重试:刚接入的 provider 需要等一拍渲染)
|
|
641
|
+
var openModelSwitcher = function (tries) {
|
|
642
|
+
var triggers = document.querySelectorAll('button[aria-haspopup="menu"]')
|
|
643
|
+
for (var q = 0; q < triggers.length; q++) {
|
|
644
|
+
var lb = triggers[q].getAttribute('aria-label') || ''
|
|
645
|
+
if (/选择模型|Select model/.test(lb)) { triggers[q].click(); return }
|
|
646
|
+
}
|
|
647
|
+
if (tries > 0) window.setTimeout(function () { openModelSwitcher(tries - 1) }, 120)
|
|
615
648
|
}
|
|
616
|
-
var flash = React.useState(null) // {text, models} —「已接入 n 个模型,点击去切换」
|
|
617
649
|
var addModels = async function () {
|
|
618
|
-
|
|
650
|
+
var d = data
|
|
619
651
|
try {
|
|
620
|
-
|
|
621
|
-
if (!
|
|
622
|
-
var models = await api('gateway-models', { accessKey:
|
|
623
|
-
var list =
|
|
624
|
-
await addProviderToModels(runtimeCtx,
|
|
652
|
+
if (!d || !d.loggedIn) d = await api('status')
|
|
653
|
+
if (!d || !d.loggedIn) { openPanel('login'); return }
|
|
654
|
+
var models = await api('gateway-models', { accessKey: d.accessKey })
|
|
655
|
+
var list = (models && models.models) || []
|
|
656
|
+
await addProviderToModels(runtimeCtx, d.baseURL || d.portalUrl || 'https://bank.skillpie.cn', { accessKey: d.accessKey, list: list, protocol: models.protocol })
|
|
625
657
|
flash[1]({ text: pageT('modelLinked').replace('{n}', String(list.length)), models: true })
|
|
626
658
|
window.setTimeout(function () { flash[1](null) }, 3000)
|
|
659
|
+
// 不等用户点「去切换」,直接弹模型菜单
|
|
660
|
+
window.setTimeout(function () { openModelSwitcher(6) }, 120)
|
|
627
661
|
} catch (err) {
|
|
628
662
|
tbStore.set({ notify: { kind: 'error', title: String(err.message || err), detail: '' } })
|
|
629
663
|
}
|
|
630
664
|
}
|
|
631
665
|
var data = st[0]
|
|
632
|
-
var portal = (data && data.portalUrl) || 'https://bank.skillpie.cn'
|
|
633
666
|
var loggedIn = snap.loggedIn
|
|
634
667
|
if (!runtimeCtx) return null
|
|
635
668
|
var smallBtn = Object.assign({}, buttonStyle, { height: 24, padding: '0 8px', fontSize: 12 })
|
|
636
669
|
return h('div', {
|
|
637
670
|
ref: boxRef,
|
|
638
671
|
style: {
|
|
639
|
-
margin: '4px 10px 8px', display: 'flex', flexDirection: 'column', gap: 6, width: 'calc(100% - 20px)',
|
|
672
|
+
margin: '4px 10px 8px', display: 'flex', flexDirection: 'column', gap: 6, width: 'calc(100% - 20px)', boxSizing: 'border-box', alignSelf: 'stretch'
|
|
640
673
|
},
|
|
641
674
|
},
|
|
642
|
-
h('div', { style: { display: 'flex', alignItems: 'center',
|
|
643
|
-
h('
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
h('
|
|
650
|
-
h('
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
sLogoutArm[1](false)
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
675
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 4 } },
|
|
676
|
+
h('span', {
|
|
677
|
+
className: 'tb-wordmark',
|
|
678
|
+
style: { fontFamily: "'Frizon','FrizonLocal',sans-serif", fontSize: 14, letterSpacing: 0.5, color: '#ff4f1f', position: 'relative', top: -1, cursor: 'pointer' },
|
|
679
|
+
onClick: function () { window.open((data && data.portalUrl) || 'https://bank.skillpie.cn', '_blank', 'noopener') },
|
|
680
|
+
}, 'TOKENBANK'),
|
|
681
|
+
h('a', { href: (data && data.portalUrl) || 'https://bank.skillpie.cn', target: '_blank', rel: 'noopener noreferrer', title: pageT('officialSite'), style: { display: 'inline-flex', color: 'var(--dsw-alias-label-secondary, #888)', textDecoration: 'none' } },
|
|
682
|
+
h('svg', { viewBox: '0 0 24 24', width: 12, height: 12, fill: 'none', stroke: 'currentColor', 'stroke-width': 2, 'stroke-linecap': 'round', 'stroke-linejoin': 'round' },
|
|
683
|
+
h('path', { d: 'M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6' }),
|
|
684
|
+
h('path', { d: 'M15 3h6v6' }),
|
|
685
|
+
h('path', { d: 'M10 14L21 3' }))),
|
|
686
|
+
loggedIn ? h('button', {
|
|
687
|
+
type: 'button', title: pageT('logout'), 'aria-label': pageT('logout'),
|
|
688
|
+
style: sLogoutArm[0]
|
|
689
|
+
? Object.assign({}, buttonStyle, { height: 20, padding: '0 6px', fontSize: 11, color: '#d03050', borderColor: '#d03050', borderWidth: 1, borderStyle: 'solid', marginLeft: 'auto' })
|
|
690
|
+
: { border: 'none', background: 'transparent', cursor: 'pointer', padding: 2, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', color: '#d03050', marginLeft: 'auto' },
|
|
691
|
+
onClick: async function () {
|
|
692
|
+
if (!sLogoutArm[0]) {
|
|
693
|
+
sLogoutArm[1](true)
|
|
694
|
+
// 10 秒不确认自动归位,避免按钮一直停在「退出登录?」态
|
|
695
|
+
clearTimeout(sLogoutTimer.ref)
|
|
696
|
+
sLogoutTimer.ref = setTimeout(function () { sLogoutArm[1](false) }, 5000)
|
|
697
|
+
return
|
|
698
|
+
}
|
|
699
|
+
clearTimeout(sLogoutTimer.ref)
|
|
700
|
+
await api('logout').catch(function () {})
|
|
701
|
+
sLogoutArm[1](false)
|
|
702
|
+
st[1](null)
|
|
703
|
+
tbStore.set({ loggedIn: false })
|
|
667
704
|
},
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
705
|
+
},
|
|
706
|
+
h('svg', { viewBox: '0 0 24 24', width: 13, height: 13, fill: 'none', stroke: 'currentColor', 'stroke-width': 2, 'stroke-linecap': 'round', 'stroke-linejoin': 'round' },
|
|
707
|
+
h('path', { d: 'M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4' }),
|
|
708
|
+
h('path', { d: 'M16 17l5-5-5-5' }),
|
|
709
|
+
h('path', { d: 'M21 12H9' })))
|
|
672
710
|
: h('button', {
|
|
673
711
|
type: 'button',
|
|
674
|
-
style: { fontSize: 10, lineHeight: 1, padding: '3px 7px', borderRadius: 999, border: 'none', cursor: 'pointer', color: '#fff', background: '#ff4f1f', fontWeight: 600, letterSpacing: 0.3 },
|
|
675
|
-
onClick: function () {
|
|
676
|
-
}, pageT('freeToken')),
|
|
677
|
-
loggedIn ? h('div', { style: { display: 'flex', alignItems: 'baseline',
|
|
678
|
-
h('span', { style: { fontSize: 12, fontWeight: 600, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap'
|
|
679
|
-
(data && data.user && (data.user.display_name || data.user.name)) || data.email || ''),
|
|
680
|
-
h('span', { style: { fontSize: 11, color: 'var(--dsw-alias-label-secondary, #888)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap'
|
|
681
|
-
h('span', { style: { fontSize: 14, fontWeight: 700, fontVariantNumeric: 'tabular-nums', flexShrink: 0 } },
|
|
682
|
-
data && data.account && typeof data.account.balance_nano_usd === 'number'
|
|
683
|
-
? '$' + (data.account.balance_nano_usd / 1e9).toFixed(2) : '—'),
|
|
712
|
+
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' },
|
|
713
|
+
onClick: function () { openPanel('register') },
|
|
714
|
+
}, pageT('freeToken'))),
|
|
715
|
+
loggedIn ? h('div', { style: { display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 6 } },
|
|
716
|
+
h('span', { style: { fontSize: 12, fontWeight: 600, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } },
|
|
717
|
+
(data && data.user && (data.user.display_name || data.user.name)) || (data && data.email) || ''),
|
|
718
|
+
h('span', { style: { fontSize: 11, color: 'var(--dsw-alias-label-secondary, #888)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, data.email || ''),
|
|
684
719
|
) : null,
|
|
685
720
|
loggedIn
|
|
686
|
-
? h('div', { style: { display: 'flex', alignItems: 'center', gap: 6
|
|
687
|
-
h('
|
|
721
|
+
? h('div', { style: { display: 'flex', alignItems: 'center', gap: 6 } },
|
|
722
|
+
h('span', { style: { fontSize: 14, fontWeight: 700, fontVariantNumeric: 'tabular-nums', flex: 1 } },
|
|
723
|
+
data && data.account && typeof data.account.balance_nano_usd === 'number'
|
|
724
|
+
? '$' + (data.account.balance_nano_usd / 1e9).toFixed(2) : '—'),
|
|
725
|
+
h('button', { type: 'button', style: Object.assign({}, smallBtn, { borderColor: 'var(--dsw-alias-border-l2, #c9ccd1)' }),
|
|
688
726
|
onClick: function () { openSettingsPage() } }, pageT('depositManage')),
|
|
689
|
-
h('button', { type: 'button', style: Object.assign({}, primaryButtonStyle, { height: 24, padding: '0 8px', fontSize: 12
|
|
690
|
-
onClick: function () {
|
|
727
|
+
h('button', { type: 'button', style: Object.assign({}, primaryButtonStyle, { height: 24, padding: '0 8px', fontSize: 12 }),
|
|
728
|
+
onClick: function () { openPanel('login', { startRecharge: true }) } }, pageT('recharge')))
|
|
691
729
|
: null,
|
|
692
730
|
loggedIn
|
|
693
|
-
? flash[0]
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
for (var q = 0; q < triggers.length; q++) {
|
|
700
|
-
var lb = triggers[q].getAttribute('aria-label') || ''
|
|
701
|
-
if (/选择模型|Select model/.test(lb)) { triggers[q].click(); return }
|
|
702
|
-
}
|
|
703
|
-
}, 80)
|
|
704
|
-
} : undefined,
|
|
705
|
-
}, flash[0].text) : h('button', { type: 'button', style: Object.assign({}, primaryButtonStyle, { height: 28, justifyContent: 'center', width: '100%' }),
|
|
706
|
-
onClick: addModels }, pageT('addFreeModels'))
|
|
731
|
+
? flash[0]
|
|
732
|
+
? h('button', { type: 'button', tabIndex: -1, disabled: true,
|
|
733
|
+
style: Object.assign({}, primaryButtonStyle, { height: 28, justifyContent: 'center', width: '100%', cursor: 'default', opacity: 0.9 }),
|
|
734
|
+
}, flash[0].text)
|
|
735
|
+
: h('button', { type: 'button', style: Object.assign({}, primaryButtonStyle, { height: 28, justifyContent: 'center', width: '100%' }),
|
|
736
|
+
onClick: addModels }, pageT('addFreeModels'))
|
|
707
737
|
: null,
|
|
708
|
-
)
|
|
738
|
+
)
|
|
709
739
|
}
|
|
710
740
|
|
|
711
|
-
/**
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
var
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
]
|
|
729
|
-
for (var i = 0; i < table.length; i++) if (table[i][0].test(d)) return table[i][1]
|
|
730
|
-
return 'https://mail.' + d
|
|
741
|
+
/** shell.overlay 账户/注册弹窗:登录态展示余额与快捷操作,未登录展示表单。 */
|
|
742
|
+
// 由邮箱地址推断其服务商网页版收件箱入口(发码后自动跳转用)
|
|
743
|
+
function mailHomeUrl(addr) {
|
|
744
|
+
var domain = String(addr || '').split('@')[1] || ''
|
|
745
|
+
domain = domain.toLowerCase()
|
|
746
|
+
var map = {
|
|
747
|
+
'qq.com': 'https://mail.qq.com', 'foxmail.com': 'https://mail.qq.com',
|
|
748
|
+
'163.com': 'https://mail.163.com', '126.com': 'https://mail.126.com',
|
|
749
|
+
'gmail.com': 'https://mail.google.com', 'googlemail.com': 'https://mail.google.com',
|
|
750
|
+
'outlook.com': 'https://outlook.live.com', 'hotmail.com': 'https://outlook.live.com', 'live.com': 'https://outlook.live.com',
|
|
751
|
+
'icloud.com': 'https://www.icloud.com/mail',
|
|
752
|
+
'sina.com': 'https://mail.sina.com.cn', 'sohu.com': 'https://mail.sohu.com',
|
|
753
|
+
'aliyun.com': 'https://mail.aliyun.com', 'yeah.net': 'https://mail.yeah.net',
|
|
754
|
+
'139.com': 'https://mail.10086.cn',
|
|
755
|
+
}
|
|
756
|
+
if (map[domain]) return map[domain]
|
|
757
|
+
return domain ? 'https://mail.' + domain : ''
|
|
731
758
|
}
|
|
732
759
|
|
|
733
|
-
/** shell.overlay 账户/注册弹窗:登录态展示余额与快捷操作,未登录展示表单。 */
|
|
734
760
|
function EntryOverlay() {
|
|
735
761
|
var snap = useTbStore()
|
|
736
762
|
var st = React.useState(null)
|
|
@@ -741,8 +767,10 @@ window.__ModuleLoader__.load({
|
|
|
741
767
|
var checkin = React.useState({ busy: false, done: false })
|
|
742
768
|
var depTip = React.useState(null) // 说明板块:hover 哪个按钮就显示哪段说明('deposit'|'recharge'|'models')
|
|
743
769
|
React.useEffect(function () {
|
|
744
|
-
if (!snap.authOpen)
|
|
745
|
-
|
|
770
|
+
if (!snap.authOpen) logoutArm[1](false)
|
|
771
|
+
}, [snap.authOpen])
|
|
772
|
+
React.useEffect(function () {
|
|
773
|
+
if (snap.authOpen) rechargeOpen[1](Boolean(snap.startRecharge))
|
|
746
774
|
}, [snap.authOpen])
|
|
747
775
|
React.useEffect(function () {
|
|
748
776
|
if (!snap.authOpen) return
|
|
@@ -762,20 +790,17 @@ window.__ModuleLoader__.load({
|
|
|
762
790
|
return function () { stopped = true; clearInterval(timer) }
|
|
763
791
|
}, [snap.authOpen])
|
|
764
792
|
if (!snap.authOpen || !runtimeCtx) return null
|
|
765
|
-
var close = function () { tbStore.set({ authOpen: false }) }
|
|
793
|
+
var close = function () { tbStore.set({ authOpen: false, startRecharge: false }) }
|
|
766
794
|
var data = st[0]
|
|
767
795
|
var portal = (data && data.portalUrl) || 'https://bank.skillpie.cn'
|
|
768
|
-
var anchor = snap.anchor ||
|
|
769
|
-
var panelWidth =
|
|
796
|
+
var anchor = snap.anchor || { right: window.innerWidth - 16, top: window.innerHeight - 80 }
|
|
797
|
+
var panelWidth = 256
|
|
770
798
|
return h('div', { style: { position: 'fixed', inset: 0, zIndex: 1999 } },
|
|
771
|
-
h('div', { style: { position: 'absolute', inset: 0, background: 'rgba(0,0,0,0.35)'
|
|
799
|
+
h('div', { style: { position: 'absolute', inset: 0, background: 'rgba(0,0,0,0.35)' }, onClick: close }),
|
|
772
800
|
h('div', {
|
|
773
801
|
style: {
|
|
774
802
|
position: 'fixed', width: panelWidth, maxWidth: 'calc(100vw - 16px)',
|
|
775
|
-
left:
|
|
776
|
-
transform: anchor ? undefined : 'translate(-50%, -50%)',
|
|
777
|
-
right: anchor ? Math.max(8, window.innerWidth - anchor.right) : undefined,
|
|
778
|
-
bottom: anchor ? window.innerHeight - anchor.top + 8 : undefined,
|
|
803
|
+
left: '50%', top: '50%', transform: 'translate(-50%, -50%)',
|
|
779
804
|
maxHeight: 520, overflow: 'auto',
|
|
780
805
|
/* 与模型选择器菜单(MenuSurface)完全一致的材质 */
|
|
781
806
|
background: 'var(--dsw-menu-surface-fill)',
|
|
@@ -946,9 +971,8 @@ window.__ModuleLoader__.load({
|
|
|
946
971
|
onAuthed: async function () {
|
|
947
972
|
tbStore.set({ authOpen: false })
|
|
948
973
|
try {
|
|
949
|
-
var fresh = await api('status')
|
|
950
|
-
if (fresh) tbStore.set({ loggedIn: Boolean(fresh.loggedIn), portalUrl: fresh.portalUrl })
|
|
951
974
|
if (!runtimeCtx.remote || !runtimeCtx.remote.settings) return
|
|
975
|
+
var fresh = await api('status')
|
|
952
976
|
if (fresh && fresh.accessKey) {
|
|
953
977
|
var models = await api('gateway-models', { accessKey: fresh.accessKey })
|
|
954
978
|
var list = Array.isArray(models) ? models : (models.models || models.list || [])
|
|
@@ -1349,9 +1373,7 @@ window.__ModuleLoader__.load({
|
|
|
1349
1373
|
await api('send-code', { email: email[0] })
|
|
1350
1374
|
sent[1](true)
|
|
1351
1375
|
var mailUrl = mailHomeUrl(email[0])
|
|
1352
|
-
if (mailUrl) api('open-external', { url: mailUrl }).catch(function (
|
|
1353
|
-
tbStore.set({ notify: { kind: 'error', title: 'open ' + mailUrl + ' failed: ' + String(e.message || e), detail: '' } })
|
|
1354
|
-
})
|
|
1376
|
+
if (mailUrl) api('open-external', { url: mailUrl }).catch(function () {})
|
|
1355
1377
|
} catch (err) { error[1](String(err.message || err)) }
|
|
1356
1378
|
busy[1](false)
|
|
1357
1379
|
},
|
|
@@ -1471,6 +1493,9 @@ window.__ModuleLoader__.load({
|
|
|
1471
1493
|
/* ── 模块②③④:选择器入口 + 弹层 + 设置页托管/状态 ── */
|
|
1472
1494
|
runtimeCtx = ctx
|
|
1473
1495
|
|
|
1496
|
+
// 输入框工具行、模型选择器左侧的紧凑入口按钮(弹账户/注册窗)
|
|
1497
|
+
// 对话框输入框入口已移除,侧栏块是唯一入口
|
|
1498
|
+
|
|
1474
1499
|
// 侧栏底部长驻块(sidebar.footer.action 是 list 槽,渲染为追加项)
|
|
1475
1500
|
ctx.slots.inject('sidebar.footer.action', function () {
|
|
1476
1501
|
return ctx.slots.register({
|
package/lib/index.js
CHANGED
|
@@ -337,18 +337,6 @@ async function dispatch(ctx, state, cfg, body) {
|
|
|
337
337
|
const identity = await requireLive()
|
|
338
338
|
return { ok: true, order: await tb.createRechargeOrder(baseUrl, identity.sessionToken, body.body ?? {}) }
|
|
339
339
|
}
|
|
340
|
-
case 'open-external': {
|
|
341
|
-
// 用系统默认浏览器打开外部 URL(仅 http/https,给发送验证码后跳邮箱首页用)
|
|
342
|
-
const raw = String(body.url ?? '')
|
|
343
|
-
let u
|
|
344
|
-
try { u = new URL(raw) } catch { throw new Error('invalid url') }
|
|
345
|
-
if (u.protocol !== 'https:' && u.protocol !== 'http:') throw new Error('invalid url')
|
|
346
|
-
const opener = process.platform === 'darwin' ? 'open' : process.platform === 'linux' ? 'xdg-open' : 'cmd'
|
|
347
|
-
const args = process.platform === 'win32' ? ['/c', 'start', '', u.toString()] : [u.toString()]
|
|
348
|
-
const { execFile } = await import('node:child_process')
|
|
349
|
-
await new Promise((resolve, reject) => execFile(opener, args, (err) => (err ? reject(err) : resolve())))
|
|
350
|
-
return { ok: true }
|
|
351
|
-
}
|
|
352
340
|
case 'recharge-open-pay': {
|
|
353
341
|
// WebView 拦新窗口且拦 blob 跳转:落地 HTML 到临时文件,用系统默认浏览器打开
|
|
354
342
|
const identity = await requireLive()
|
|
@@ -367,6 +355,18 @@ async function dispatch(ctx, state, cfg, body) {
|
|
|
367
355
|
})
|
|
368
356
|
return { ok: true, file }
|
|
369
357
|
}
|
|
358
|
+
case 'open-external': {
|
|
359
|
+
// 用系统默认浏览器打开外部链接(仅 http/https;发码后跳邮箱用)
|
|
360
|
+
const url2 = String((body.body ?? body).url ?? '')
|
|
361
|
+
if (!/^https?:\/\//i.test(url2)) throw new Error('only http(s) urls allowed')
|
|
362
|
+
const opener2 = process.platform === 'darwin' ? 'open' : process.platform === 'linux' ? 'xdg-open' : 'cmd'
|
|
363
|
+
const args3 = process.platform === 'win32' ? ['/c', 'start', '', url2] : [url2]
|
|
364
|
+
const { execFile: execFile3 } = await import('node:child_process')
|
|
365
|
+
await new Promise(function (resolve3, reject3) {
|
|
366
|
+
execFile3(opener2, args3, function (err3) { return err3 ? reject3(err3) : resolve3() })
|
|
367
|
+
})
|
|
368
|
+
return { ok: true }
|
|
369
|
+
}
|
|
370
370
|
case 'recharge-pay': {
|
|
371
371
|
const identity = await requireLive()
|
|
372
372
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-tokenbank",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.64",
|
|
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
|
+
}
|