dsh-tokenbank 0.1.63 → 0.1.65

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/lib/client.js +159 -120
  2. package/lib/index.js +12 -12
  3. 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, tap to switch',
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,151 @@ 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 (d) {
607
- if (stopped) return
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 openGlobal = function (mode, opts) {
614
- tbStore.set({ authOpen: true, authMode: mode || snap.authMode || 'login', anchor: null, startRecharge: Boolean(opts && opts.recharge) })
637
+ var openPanel = function (mode, extra) {
638
+ tbStore.set(Object.assign({ authOpen: true, authMode: mode || snap.authMode || 'login', anchor: null }, extra || {}))
639
+ }
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
+ // 找到宿主模型选择器触发按钮并点开(带重试:刚接入的 provider 需要等一拍渲染)
649
+ var openModelSwitcher = function (tries) {
650
+ var triggers = document.querySelectorAll('button[aria-haspopup="menu"]')
651
+ for (var q = 0; q < triggers.length; q++) {
652
+ var lb = triggers[q].getAttribute('aria-label') || ''
653
+ if (/选择模型|Select model/.test(lb)) { triggers[q].click(); return }
654
+ }
655
+ if (tries > 0) window.setTimeout(function () { openModelSwitcher(tries - 1) }, 120)
615
656
  }
616
- var flash = React.useState(null) // {text, models} —「已接入 n 个模型,点击去切换」
617
657
  var addModels = async function () {
618
- if (flash[0]) return
658
+ var d = data
619
659
  try {
620
- var d0 = st[0]
621
- if (!d0 || !d0.accessKey) throw new Error(pageT('loading'))
622
- var models = await api('gateway-models', { accessKey: d0.accessKey })
623
- var list = Array.isArray(models) ? models : (models.models || models.list || [])
624
- await addProviderToModels(runtimeCtx, d0.baseURL || d0.portalUrl || portal, { accessKey: d0.accessKey, list: list, protocol: models.protocol })
660
+ if (!d || !d.loggedIn) d = await api('status')
661
+ if (!d || !d.loggedIn) { openPanel('login'); return }
662
+ var models = await api('gateway-models', { accessKey: d.accessKey })
663
+ var list = (models && models.models) || []
664
+ await addProviderToModels(runtimeCtx, d.baseURL || d.portalUrl || 'https://bank.skillpie.cn', { accessKey: d.accessKey, list: list, protocol: models.protocol })
625
665
  flash[1]({ text: pageT('modelLinked').replace('{n}', String(list.length)), models: true })
626
666
  window.setTimeout(function () { flash[1](null) }, 3000)
667
+ // 不等用户点「去切换」,直接弹模型菜单
668
+ window.setTimeout(function () { openModelSwitcher(6) }, 120)
627
669
  } catch (err) {
628
670
  tbStore.set({ notify: { kind: 'error', title: String(err.message || err), detail: '' } })
629
671
  }
630
672
  }
631
673
  var data = st[0]
632
- var portal = (data && data.portalUrl) || 'https://bank.skillpie.cn'
633
674
  var loggedIn = snap.loggedIn
634
675
  if (!runtimeCtx) return null
635
676
  var smallBtn = Object.assign({}, buttonStyle, { height: 24, padding: '0 8px', fontSize: 12 })
636
677
  return h('div', {
637
678
  ref: boxRef,
638
679
  style: {
639
- margin: '4px 10px 8px', display: 'flex', flexDirection: 'column', gap: 6, width: 'calc(100% - 20px)', minWidth: 0, maxWidth: '100%', overflow: 'hidden', boxSizing: 'border-box', alignSelf: 'stretch'
680
+ margin: '4px 10px 8px', display: 'flex', flexDirection: 'column', gap: 6, width: 'calc(100% - 20px)', boxSizing: 'border-box', alignSelf: 'stretch'
640
681
  },
641
682
  },
642
- h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 6 } },
643
- h('div', { style: { display: 'inline-flex', alignItems: 'center', gap: 4 } },
644
- h('span', {
645
- className: 'tb-wordmark',
646
- style: { fontFamily: "'Frizon','FrizonLocal',sans-serif", fontSize: 14, letterSpacing: 0.5, color: '#ff4f1f', position: 'relative', top: -1, cursor: 'pointer' },
647
- onClick: function () { openGlobal('register') },
648
- }, 'TOKENBANK'),
649
- 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' } },
650
- h('svg', { viewBox: '0 0 24 24', width: 12, height: 12, fill: 'none', stroke: 'currentColor', 'stroke-width': 2, 'stroke-linecap': 'round', 'stroke-linejoin': 'round' },
651
- h('path', { d: 'M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6' }),
652
- h('path', { d: 'M15 3h6v6' }),
653
- h('path', { d: 'M10 14L21 3' })))),
654
- loggedIn
655
- ? h('button', {
656
- type: 'button', title: pageT('logout'), 'aria-label': pageT('logout'),
657
- style: sLogoutArm[0]
658
- ? Object.assign({}, buttonStyle, { height: 20, padding: '0 6px', fontSize: 11, color: '#d03050', borderColor: '#d03050', borderWidth: 1, borderStyle: 'solid' })
659
- : { border: 'none', background: 'transparent', cursor: 'pointer', padding: 2, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', color: '#d03050' },
660
- onClick: async function () {
661
- if (!sLogoutArm[0]) { sLogoutArm[1](true); return }
662
- await api('logout').catch(function () {})
663
- sLogoutArm[1](false)
664
- st[1](null)
665
- tbStore.set({ loggedIn: false })
666
- },
683
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: 4 } },
684
+ h('span', {
685
+ className: 'tb-wordmark',
686
+ style: { fontFamily: "'Frizon','FrizonLocal',sans-serif", fontSize: 14, letterSpacing: 0.5, color: '#ff4f1f', position: 'relative', top: -1, cursor: 'pointer' },
687
+ onClick: function () { window.open((data && data.portalUrl) || 'https://bank.skillpie.cn', '_blank', 'noopener') },
688
+ }, 'TOKENBANK'),
689
+ 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' } },
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 })
667
712
  },
668
- h('svg', { viewBox: '0 0 24 24', width: 13, height: 13, fill: 'none', stroke: 'currentColor', 'stroke-width': 2, 'stroke-linecap': 'round', 'stroke-linejoin': 'round' },
669
- h('path', { d: 'M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4' }),
670
- h('path', { d: 'M16 17l5-5-5-5' }),
671
- h('path', { d: 'M21 12H9' })))
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' })))
672
718
  : h('button', {
673
719
  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 () { openGlobal('register') },
676
- }, pageT('freeToken')),
677
- loggedIn ? h('div', { style: { display: 'flex', alignItems: 'baseline', gap: 6, minWidth: 0, maxWidth: '100%', overflow: 'hidden' } },
678
- h('span', { style: { fontSize: 12, fontWeight: 600, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', minWidth: 0 } },
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', flex: 1, minWidth: 0 } }, data.email || ''),
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) : '—'),
720
+ 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
+ onClick: function () { openPanel('register') },
722
+ }, pageT('freeToken'))),
723
+ loggedIn ? h('div', { style: { display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 6 } },
724
+ h('span', { style: { fontSize: 12, fontWeight: 600, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } },
725
+ (data && data.user && (data.user.display_name || data.user.name)) || (data && data.email) || ''),
726
+ h('span', { style: { fontSize: 11, color: 'var(--dsw-alias-label-secondary, #888)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, data.email || ''),
684
727
  ) : null,
685
728
  loggedIn
686
- ? h('div', { style: { display: 'flex', alignItems: 'center', gap: 6, minWidth: 0, maxWidth: '100%', overflow: 'hidden' } },
687
- h('button', { type: 'button', style: Object.assign({}, smallBtn, { borderColor: 'var(--dsw-alias-border-l2, #c9ccd1)', whiteSpace: 'nowrap', flexShrink: 0 }),
688
- onClick: function () { openSettingsPage() } }, pageT('depositManage')),
689
- h('button', { type: 'button', style: Object.assign({}, primaryButtonStyle, { height: 24, padding: '0 8px', fontSize: 12, whiteSpace: 'nowrap', flexShrink: 0 }),
690
- onClick: function () { openGlobal('login', { recharge: true }) } }, pageT('recharge')))
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 }) }))
691
748
  : null,
692
- loggedIn
693
- ? flash[0] ? h('button', { type: 'button', tabIndex: -1,
694
- style: Object.assign({}, primaryButtonStyle, { height: 28, justifyContent: 'center', width: '100%', cursor: 'pointer', opacity: 0.9 }),
695
- onClick: flash[0].models ? function () {
696
- flash[1](null)
697
- window.setTimeout(function () {
698
- var triggers = document.querySelectorAll('button[aria-haspopup="menu"]')
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'))
749
+ loggedIn && flash[0]
750
+ ? h('div', { style: { fontSize: 11, color: 'var(--dsw-alias-label-secondary, #888)', textAlign: 'center' } }, flash[0].text)
707
751
  : null,
708
- ))
752
+ )
709
753
  }
710
754
 
711
- /** 按邮箱域名猜 webmail 首页;未知域名兜底 mail.<domain>。 */
712
- function mailHomeUrl(emailAddr) {
713
- var domain = String(emailAddr || '').split('@')[1]
714
- if (!domain) return null
715
- var d = domain.toLowerCase()
716
- var table = [
717
- [/^(qq|foxmail)\.com$/, 'https://mail.qq.com'],
718
- [/^163\.com$/, 'https://mail.163.com'],
719
- [/^126\.com$/, 'https://mail.126.com'],
720
- [/^gmail\.com$/, 'https://mail.google.com'],
721
- [/^(outlook|hotmail|live)\.(com|cn)$/, 'https://outlook.live.com'],
722
- [/^icloud\.com$/, 'https://www.icloud.com/mail'],
723
- [/^sina\.com$/, 'https://mail.sina.com.cn'],
724
- [/^sohu\.com$/, 'https://mail.sohu.com'],
725
- [/^aliyun\.com$/, 'https://mail.aliyun.com'],
726
- [/^yeah\.net$/, 'https://mail.yeah.net'],
727
- [/^139\.com$/, 'https://mail.10086.cn'],
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
755
+ /** shell.overlay 账户/注册弹窗:登录态展示余额与快捷操作,未登录展示表单。 */
756
+ // 由邮箱地址推断其服务商网页版收件箱入口(发码后自动跳转用)
757
+ function mailHomeUrl(addr) {
758
+ var domain = String(addr || '').split('@')[1] || ''
759
+ domain = domain.toLowerCase()
760
+ var map = {
761
+ 'qq.com': 'https://mail.qq.com', 'foxmail.com': 'https://mail.qq.com',
762
+ '163.com': 'https://mail.163.com', '126.com': 'https://mail.126.com',
763
+ 'gmail.com': 'https://mail.google.com', 'googlemail.com': 'https://mail.google.com',
764
+ 'outlook.com': 'https://outlook.live.com', 'hotmail.com': 'https://outlook.live.com', 'live.com': 'https://outlook.live.com',
765
+ 'icloud.com': 'https://www.icloud.com/mail',
766
+ 'sina.com': 'https://mail.sina.com.cn', 'sohu.com': 'https://mail.sohu.com',
767
+ 'aliyun.com': 'https://mail.aliyun.com', 'yeah.net': 'https://mail.yeah.net',
768
+ '139.com': 'https://mail.10086.cn',
769
+ }
770
+ if (map[domain]) return map[domain]
771
+ return domain ? 'https://mail.' + domain : ''
731
772
  }
732
773
 
733
- /** shell.overlay 账户/注册弹窗:登录态展示余额与快捷操作,未登录展示表单。 */
734
774
  function EntryOverlay() {
735
775
  var snap = useTbStore()
736
776
  var st = React.useState(null)
@@ -741,8 +781,10 @@ window.__ModuleLoader__.load({
741
781
  var checkin = React.useState({ busy: false, done: false })
742
782
  var depTip = React.useState(null) // 说明板块:hover 哪个按钮就显示哪段说明('deposit'|'recharge'|'models')
743
783
  React.useEffect(function () {
744
- if (!snap.authOpen) { logoutArm[1](false); return }
745
- rechargeOpen[1](Boolean(snap.startRecharge)) // 打开时同步「直达充值」标记(侧栏充值入口)
784
+ if (!snap.authOpen) logoutArm[1](false)
785
+ }, [snap.authOpen])
786
+ React.useEffect(function () {
787
+ if (snap.authOpen) rechargeOpen[1](Boolean(snap.startRecharge))
746
788
  }, [snap.authOpen])
747
789
  React.useEffect(function () {
748
790
  if (!snap.authOpen) return
@@ -762,20 +804,17 @@ window.__ModuleLoader__.load({
762
804
  return function () { stopped = true; clearInterval(timer) }
763
805
  }, [snap.authOpen])
764
806
  if (!snap.authOpen || !runtimeCtx) return null
765
- var close = function () { tbStore.set({ authOpen: false }) }
807
+ var close = function () { tbStore.set({ authOpen: false, startRecharge: false }) }
766
808
  var data = st[0]
767
809
  var portal = (data && data.portalUrl) || 'https://bank.skillpie.cn'
768
- var anchor = snap.anchor || null // null = 全局居中弹窗(侧栏入口)
769
- var panelWidth = 320
810
+ var anchor = snap.anchor || { right: window.innerWidth - 16, top: window.innerHeight - 80 }
811
+ var panelWidth = 256
770
812
  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)', backdropFilter: 'blur(2px)', WebkitBackdropFilter: 'blur(2px)' }, onClick: close }),
813
+ h('div', { style: { position: 'absolute', inset: 0, background: 'rgba(0,0,0,0.35)' }, onClick: close }),
772
814
  h('div', {
773
815
  style: {
774
816
  position: 'fixed', width: panelWidth, maxWidth: 'calc(100vw - 16px)',
775
- left: anchor ? undefined : '50%', top: anchor ? undefined : '50%',
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,
817
+ left: '50%', top: '50%', transform: 'translate(-50%, -50%)',
779
818
  maxHeight: 520, overflow: 'auto',
780
819
  /* 与模型选择器菜单(MenuSurface)完全一致的材质 */
781
820
  background: 'var(--dsw-menu-surface-fill)',
@@ -946,9 +985,8 @@ window.__ModuleLoader__.load({
946
985
  onAuthed: async function () {
947
986
  tbStore.set({ authOpen: false })
948
987
  try {
949
- var fresh = await api('status')
950
- if (fresh) tbStore.set({ loggedIn: Boolean(fresh.loggedIn), portalUrl: fresh.portalUrl })
951
988
  if (!runtimeCtx.remote || !runtimeCtx.remote.settings) return
989
+ var fresh = await api('status')
952
990
  if (fresh && fresh.accessKey) {
953
991
  var models = await api('gateway-models', { accessKey: fresh.accessKey })
954
992
  var list = Array.isArray(models) ? models : (models.models || models.list || [])
@@ -1349,9 +1387,7 @@ window.__ModuleLoader__.load({
1349
1387
  await api('send-code', { email: email[0] })
1350
1388
  sent[1](true)
1351
1389
  var mailUrl = mailHomeUrl(email[0])
1352
- if (mailUrl) api('open-external', { url: mailUrl }).catch(function (e) {
1353
- tbStore.set({ notify: { kind: 'error', title: 'open ' + mailUrl + ' failed: ' + String(e.message || e), detail: '' } })
1354
- })
1390
+ if (mailUrl) api('open-external', { url: mailUrl }).catch(function () {})
1355
1391
  } catch (err) { error[1](String(err.message || err)) }
1356
1392
  busy[1](false)
1357
1393
  },
@@ -1471,6 +1507,9 @@ window.__ModuleLoader__.load({
1471
1507
  /* ── 模块②③④:选择器入口 + 弹层 + 设置页托管/状态 ── */
1472
1508
  runtimeCtx = ctx
1473
1509
 
1510
+ // 输入框工具行、模型选择器左侧的紧凑入口按钮(弹账户/注册窗)
1511
+ // 对话框输入框入口已移除,侧栏块是唯一入口
1512
+
1474
1513
  // 侧栏底部长驻块(sidebar.footer.action 是 list 槽,渲染为追加项)
1475
1514
  ctx.slots.inject('sidebar.footer.action', function () {
1476
1515
  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.63",
3
+ "version": "0.1.65",
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
+ }