dsh-tokenbank 0.1.66 → 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.
Files changed (2) hide show
  1. package/lib/client.js +69 -11
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -326,6 +326,58 @@ window.__ModuleLoader__.load({
326
326
  return snap[0]
327
327
  }
328
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
+
329
381
  /** 输入框工具行、模型选择器左侧的紧凑入口按钮。 */
330
382
  function ComposerEntry() {
331
383
  var snap = useTbStore()
@@ -380,16 +432,8 @@ window.__ModuleLoader__.load({
380
432
  },
381
433
  },
382
434
  snap.loggedIn
383
- ? h('span', { style: { fontSize: 13, fontVariantNumeric: 'tabular-nums', color: 'var(--dsw-alias-label-secondary, #888)' } },
384
- data && data.account && typeof data.account.balance_nano_usd === 'number'
385
- ? '$' + (data.account.balance_nano_usd / 1e9).toFixed(2) : '')
386
- : h('span', {
387
- style: { fontSize: 12, lineHeight: '25px', padding: '0 10px', borderRadius: 999, color: '#fff', background: '#ff4f1f', fontWeight: 600, letterSpacing: 0.3 },
388
- }, pageT('freeToken')),
389
- snap.loggedIn
390
- ? h('svg', { viewBox: '0 0 24 24', className: 'tb-entry-chevron', width: 14, height: 14, fill: 'none', stroke: 'currentColor', 'stroke-width': 2, 'stroke-linecap': 'round', 'stroke-linejoin': 'round', style: { color: 'var(--dsw-alias-label-tertiary, #a0a3a8)', flex: 'none' } },
391
- h('path', { d: 'm6 9 6 6 6-6' }))
392
- : null,
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')),
393
437
  )
394
438
  }
395
439
 
@@ -1522,9 +1566,16 @@ window.__ModuleLoader__.load({
1522
1566
  var wmCss = document.createElement('style')
1523
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}"
1524
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')
1525
1576
  // 入口按钮 hover 形态:灰底 + 箭头反转(与模型选择器 hover 一致)
1526
1577
  var entryCss = document.createElement('style')
1527
- entryCss.textContent = '#tb-entry-btn: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)}'
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)}'
1528
1579
  document.head.appendChild(entryCss)
1529
1580
  ctx.effect(function () {
1530
1581
  return function () { if (entryCss.parentNode) entryCss.parentNode.removeChild(entryCss) }
@@ -1543,6 +1594,13 @@ window.__ModuleLoader__.load({
1543
1594
  runtimeCtx = ctx
1544
1595
 
1545
1596
  // 输入框工具行、模型选择器左侧的紧凑入口按钮(弹账户/注册窗)
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
+ })
1546
1604
  ctx.slots.inject('conversation.input.right', function () {
1547
1605
  return ctx.slots.register({
1548
1606
  name: 'conversation.input.right',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tokenbank",
3
- "version": "0.1.66",
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",