dsh-tokenbank 0.1.57 → 0.1.58

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 CHANGED
@@ -46,6 +46,7 @@ window.__ModuleLoader__.load({
46
46
  rechargeOpenPay: '打开支付页',
47
47
  rechargeCancel: '取消',
48
48
  composerEntry: 'TokenBank 账户',
49
+ officialSite: 'TokenBank 官网',
49
50
  loading: '正在连接 TokenBank…',
50
51
  balance: '余额',
51
52
  totalEarned: '累计收益',
@@ -137,6 +138,7 @@ window.__ModuleLoader__.load({
137
138
  rechargeOpenPay: 'Open payment page',
138
139
  rechargeCancel: 'Cancel',
139
140
  composerEntry: 'TokenBank account',
141
+ officialSite: 'TokenBank website',
140
142
  loading: 'Connecting to TokenBank…',
141
143
  balance: 'Balance',
142
144
  totalEarned: 'Total earned',
@@ -605,6 +607,63 @@ window.__ModuleLoader__.load({
605
607
  )
606
608
  }
607
609
 
610
+ /** 侧栏底部长驻卡片:登录态展示余额+快捷操作(点击经弹窗展开),未登录显注册入口。 */
611
+ function SidebarCard() {
612
+ var snap = useTbStore()
613
+ var st = React.useState(null)
614
+ var boxRef = React.useRef(null)
615
+ React.useEffect(function () {
616
+ var stopped = false
617
+ api('status').then(function (data) {
618
+ if (!stopped) { st[1](data); tbStore.set({ loggedIn: Boolean(data.loggedIn), portalUrl: data.portalUrl }) }
619
+ }).catch(function () {})
620
+ var timer = setInterval(function () {
621
+ api('status').then(function (data) { if (!stopped) st[1](data) }).catch(function () {})
622
+ }, 60000)
623
+ return function () { stopped = true; clearInterval(timer) }
624
+ }, [])
625
+ var openPanel = function (mode) {
626
+ var el = boxRef.current
627
+ var r = el ? el.getBoundingClientRect() : { top: window.innerHeight - 80, right: window.innerWidth - 16, bottom: window.innerHeight, left: window.innerWidth - 272 }
628
+ tbStore.set({ authOpen: true, authMode: mode || snap.authMode || 'login', anchor: { top: r.top, right: r.right, bottom: r.bottom, left: r.left } })
629
+ }
630
+ var data = st[0]
631
+ var loggedIn = snap.loggedIn
632
+ if (!runtimeCtx) return null
633
+ var smallBtn = Object.assign({}, buttonStyle, { height: 24, padding: '0 10px', fontSize: 12 })
634
+ return h('div', {
635
+ ref: boxRef,
636
+ style: {
637
+ margin: '4px 8px', padding: '10px 12px', borderRadius: 10,
638
+ border: '1px solid var(--dsw-alias-border-l1)',
639
+ background: 'var(--dsw-alias-bg-layer-1, #f7f7f8)',
640
+ display: 'flex', flexDirection: 'column', gap: 8,
641
+ },
642
+ },
643
+ h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 6 } },
644
+ h('span', { className: 'tb-wordmark', style: { fontFamily: "'Frizon','FrizonLocal',sans-serif", fontSize: 14, letterSpacing: 0.5, color: '#ff4f1f' } }, 'TOKENBANK'),
645
+ 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' } },
646
+ h('svg', { viewBox: '0 0 24 24', width: 13, height: 13, fill: 'none', stroke: 'currentColor', 'stroke-width': 2, 'stroke-linecap': 'round', 'stroke-linejoin': 'round' },
647
+ h('path', { d: 'M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6' }),
648
+ h('path', { d: 'M15 3h6v6' }),
649
+ h('path', { d: 'M10 14L21 3' })))),
650
+ loggedIn
651
+ ? h(React.Fragment, null,
652
+ h('div', { style: { fontSize: 15, fontWeight: 700, fontVariantNumeric: 'tabular-nums' } },
653
+ data && data.account && typeof data.account.balance_nano_usd === 'number'
654
+ ? '$' + (data.account.balance_nano_usd / 1e9).toFixed(2) : '—'),
655
+ h('div', { style: { display: 'flex', gap: 6 } },
656
+ h('button', { type: 'button', style: Object.assign({}, smallBtn, { flex: 1, borderColor: 'var(--dsw-alias-border-l2, #c9ccd1)' }),
657
+ onClick: function () { openPanel('login') } }, pageT('depositManage')),
658
+ h('button', { type: 'button', style: Object.assign({}, smallBtn, { flex: 1 }),
659
+ onClick: function () { openPanel('login') } }, pageT('recharge'))),
660
+ h('button', { type: 'button', style: Object.assign({}, primaryButtonStyle, { height: 28, justifyContent: 'center', width: '100%' }),
661
+ onClick: function () { openPanel('login') } }, pageT('addFreeModels')))
662
+ : h('button', { type: 'button', style: Object.assign({}, primaryButtonStyle, { height: 28, justifyContent: 'center', width: '100%' }),
663
+ onClick: function () { openPanel('register') } }, pageT('register')),
664
+ )
665
+ }
666
+
608
667
  /** shell.overlay 账户/注册弹窗:登录态展示余额与快捷操作,未登录展示表单。 */
609
668
  function EntryOverlay() {
610
669
  var snap = useTbStore()
@@ -1348,6 +1407,16 @@ window.__ModuleLoader__.load({
1348
1407
  }, ComposerEntry)
1349
1408
  })
1350
1409
 
1410
+ // 侧栏底部长驻卡片(sidebar.footer.action 是 list 槽,渲染为追加项)
1411
+ ctx.slots.inject('sidebar.footer.action', function () {
1412
+ return ctx.slots.register({
1413
+ name: 'sidebar.footer.action',
1414
+ id: 'dsh-tokenbank-card',
1415
+ order: 100,
1416
+ locale: NS,
1417
+ }, SidebarCard)
1418
+ })
1419
+
1351
1420
  // 同一个槽只 inject 一次:多次 inject 会互相覆盖(之前 auth 注册被
1352
1421
  // lowbalance 顶掉,菜单点击后弹窗不渲染)。三个 overlay 一次注册齐。
1353
1422
  ctx.slots.inject('shell.overlay', function () {
package/locale/en.json CHANGED
@@ -12,6 +12,7 @@
12
12
  "freeModelsEntry": "TokenBank free models",
13
13
  "addFreeModels": "Get free models",
14
14
  "composerEntry": "TokenBank account",
15
+ "officialSite": "TokenBank website",
15
16
  "reload": "Reload",
16
17
  "openSite": "Open website",
17
18
  "recharge": "Recharge",
package/locale/zh.json CHANGED
@@ -12,6 +12,7 @@
12
12
  "freeModelsEntry": "TokenBank 免费模型",
13
13
  "addFreeModels": "获取免费模型",
14
14
  "composerEntry": "TokenBank 账户",
15
+ "officialSite": "TokenBank 官网",
15
16
  "reload": "刷新",
16
17
  "openSite": "打开官网",
17
18
  "recharge": "充值",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tokenbank",
3
- "version": "0.1.57",
3
+ "version": "0.1.58",
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",