dsh-tokenbank 0.1.70 → 0.1.71

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 +50 -33
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -40,8 +40,10 @@ window.__ModuleLoader__.load({
40
40
  checkinDone: '已签到',
41
41
  checkinOk: '签到成功',
42
42
  checkinStreak: '已连签 {n} 天',
43
+ checkinGain: '+0.10',
43
44
  rechargePay: '去支付',
44
45
  rechargeDone: '充值成功,余额已到账',
46
+ gainSuffix: '签到奖励',
45
47
  rechargePending: '尚未检测到支付结果,如已完成支付请稍后重试或刷新',
46
48
  rechargeWaiting: '等待支付中…',
47
49
  rechargeOpenPay: '打开支付页',
@@ -140,6 +142,7 @@ window.__ModuleLoader__.load({
140
142
  checkinDone: 'Checked in',
141
143
  checkinOk: 'Check-in success',
142
144
  checkinStreak: '{n}-day streak',
145
+ checkinGain: '+0.10',
143
146
  rechargePay: 'Pay',
144
147
  rechargeDone: 'Recharge successful',
145
148
  rechargePending: 'No payment detected yet; if you already paid, retry or refresh later',
@@ -840,6 +843,7 @@ window.__ModuleLoader__.load({
840
843
  var logoutArm = React.useState(false)
841
844
  var innerToast = React.useState(null)
842
845
  var checkinFlash = React.useState(null) // 签到成功闪现文案(复用获取免费模型按钮样式,2s 回原样)
846
+ var balanceGain = React.useState(null) // { amount } 余额旁 +$x 浮现动画,8s 自动消失
843
847
  var checkin = React.useState({ busy: false, done: false })
844
848
  var depTip = React.useState(null) // 说明板块:hover 哪个按钮就显示哪段说明('deposit'|'recharge'|'models')
845
849
  var tipSeen = React.useState({}) // 引导提示已看标记:每个按钮登录后仅第一次 hover 展示,后续不再弹
@@ -951,60 +955,73 @@ window.__ModuleLoader__.load({
951
955
  border: '1px solid var(--dsw-alias-border-l1)',
952
956
  },
953
957
  }, pageT(depTip[0] === 'recharge' ? 'rechargeTip' : depTip[0] === 'models' ? 'freeModelsTip' : 'depositManageTip')) : null,
954
- h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 } },
955
- h('div', { style: { fontSize: 16, fontWeight: 700, fontVariantNumeric: 'tabular-nums' } },
958
+ h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 } },
959
+ h('div', { style: { position: 'relative', display: 'inline-block', fontSize: 16, fontWeight: 700, fontVariantNumeric: 'tabular-nums' } },
956
960
  data.account && typeof data.account.balance_nano_usd === 'number'
957
- ? '$' + (data.account.balance_nano_usd / 1e9).toFixed(2) : '—'),
961
+ ? '$' + (data.account.balance_nano_usd / 1e9).toFixed(2) : '—',
962
+ balanceGain[0] ? h('span', {
963
+ key: 'gain-' + balanceGain[0].ts,
964
+ style: {
965
+ position: 'absolute', left: '100%', top: 0, marginLeft: 6, whiteSpace: 'nowrap',
966
+ fontSize: 12, fontWeight: 700, color: '#d03050', pointerEvents: 'none',
967
+ animation: 'tb-balance-gain 1s ease-out both',
968
+ },
969
+ }, '+' + balanceGain[0].amount) : null),
958
970
  h('span', { style: { display: 'inline-flex', gap: 6 } },
959
- (checkin[0].done || (data.account && typeof data.account.balance_nano_usd === 'number' && data.account.balance_nano_usd < 1e9)) ? null : h('button', {
960
- type: 'button', disabled: checkin[0].busy || checkin[0].done,
961
- style: Object.assign({}, buttonStyle, {
962
- height: 26, padding: '0 12px', fontSize: 12,
963
- // 边框色与「托管」按钮同口径(border-l2 浅灰弱化),已签到转绿保留
964
- color: checkin[0].done ? '#22a04a' : undefined,
965
- borderColor: checkin[0].done ? '#22a04a' : 'var(--dsw-alias-border-l2, #c9ccd1)',
966
- }),
967
- onClick: async function () {
968
- if (checkin[0].done || checkin[0].busy) return
971
+ data && data.loggedIn ? h('button', {
972
+ type: 'button', 'aria-label': pageT('depositManageTip'),
973
+ style: Object.assign({}, buttonStyle, { height: 26, padding: '0 12px', fontSize: 12, borderColor: 'var(--dsw-alias-border-l2, #c9ccd1)' }),
974
+ onMouseEnter: function () { showTipOnce('deposit') },
975
+ onClick: function () { depTip[1](null); tbStore.set({ authOpen: false }); openSettingsPage() },
976
+ }, pageT('depositManage')) : null,
977
+ h('button', {
978
+ type: 'button', disabled: checkin[0].busy,
979
+ style: Object.assign({}, primaryButtonStyle, { height: 26, padding: '0 12px', fontSize: 12 }),
980
+ // 位置固定:可签到时该按钮即「签到」,签到后同一位置变回「充值」
981
+ onMouseEnter: function () { if (!(!checkin[0].done)) showTipOnce('recharge') },
982
+ onClick: (!checkin[0].done) ? async function () {
983
+ if (checkin[0].busy) return
969
984
  checkin[1](Object.assign({}, checkin[0], { busy: true }))
970
985
  try {
971
986
  var res = await api('checkin-do')
972
987
  var ci = res && res.checkin || {}
973
988
  checkin[1]({ busy: false, done: Boolean(ci.checked_today) })
974
989
  if (ci.checked_today) {
990
+ var before = data.account && typeof data.account.balance_nano_usd === 'number' ? data.account.balance_nano_usd : null
975
991
  var fresh = await api('status').catch(function () { return null })
976
- if (fresh) { st[1](fresh); tbStore.set({ loggedIn: Boolean(fresh.loggedIn), portalUrl: fresh.portalUrl }) }
992
+ var gain = null
993
+ if (fresh && fresh.account && typeof fresh.account.balance_nano_usd === 'number') {
994
+ st[1](fresh); tbStore.set({ loggedIn: Boolean(fresh.loggedIn), portalUrl: fresh.portalUrl })
995
+ if (before != null && fresh.account.balance_nano_usd > before) gain = ((fresh.account.balance_nano_usd - before) / 1e9).toFixed(2)
996
+ }
997
+ balanceGain[1]({ amount: gain || '0.10', ts: Date.now() })
998
+ window.setTimeout(function () { balanceGain[1](null) }, 8000)
977
999
  var streakText = ci.streak > 1 ? '(' + pageT('checkinStreak').replace('{n}', String(ci.streak)) + ')' : ''
978
1000
  checkinFlash[1]({ text: pageT('checkinOk') + streakText })
979
1001
  window.setTimeout(function () { checkinFlash[1](null) }, 3000)
980
1002
  }
981
1003
  } catch (e9) {
982
- checkin[1]({ busy: false, done: false })
1004
+ checkin[1](Object.assign({}, checkin[0], { busy: false }))
983
1005
  innerToast[1]({ text: String(e9.message || e9), error: true })
984
1006
  }
985
- },
986
- }, checkin[0].done ? pageT('checkinDone') : pageT('checkin')),
987
- data && data.loggedIn ? h('button', {
988
- type: 'button', 'aria-label': pageT('depositManageTip'),
989
- style: Object.assign({}, buttonStyle, { height: 26, padding: '0 12px', fontSize: 12, borderColor: 'var(--dsw-alias-border-l2, #c9ccd1)' }),
990
- onMouseEnter: function () { showTipOnce('deposit') },
991
- onClick: function () { depTip[1](null); tbStore.set({ authOpen: false }); openSettingsPage() },
992
- }, pageT('depositManage')) : null,
993
- (checkin[0].done || (data.account && typeof data.account.balance_nano_usd === 'number' && data.account.balance_nano_usd < 1e9))
994
- ? h('button', {
995
- type: 'button',
996
- style: Object.assign({}, primaryButtonStyle, { height: 26, padding: '0 12px', fontSize: 12 }),
997
- onMouseEnter: function () { showTipOnce('recharge') },
998
- onClick: function () { depTip[1](null); rechargeOpen[1](function (v) { return !v }) },
999
- }, pageT('recharge'))
1000
- : null,
1007
+ } : function () { depTip[1](null); rechargeOpen[1](function (v) { return !v }) },
1008
+ }, (!checkin[0].done) ? (checkin[0].busy ? pageT('checkin') + '…' : pageT('checkin')) : pageT('recharge')),
1001
1009
  ),
1002
1010
  ),
1003
1011
  rechargeOpen[0] ? h(InlineRecharge, {
1004
1012
  onPaid: async function () {
1005
1013
  rechargeOpen[1](false)
1014
+ var before = data.account && typeof data.account.balance_nano_usd === 'number' ? data.account.balance_nano_usd : null
1006
1015
  var fresh = await api('status').catch(function () { return null })
1007
- if (fresh) { st[1](fresh); tbStore.set({ loggedIn: Boolean(fresh.loggedIn), portalUrl: fresh.portalUrl }) }
1016
+ var gain = null
1017
+ if (fresh) {
1018
+ st[1](fresh); tbStore.set({ loggedIn: Boolean(fresh.loggedIn), portalUrl: fresh.portalUrl })
1019
+ if (before != null && fresh.account && fresh.account.balance_nano_usd > before) gain = ((fresh.account.balance_nano_usd - before) / 1e9).toFixed(2)
1020
+ }
1021
+ if (gain) {
1022
+ balanceGain[1]({ amount: gain, ts: Date.now() })
1023
+ window.setTimeout(function () { balanceGain[1](null) }, 8000)
1024
+ }
1008
1025
  tbStore.set({ notify: { kind: 'success', title: pageT('rechargeDone'), detail: '' } })
1009
1026
  },
1010
1027
  }) : null,
@@ -1632,7 +1649,7 @@ window.__ModuleLoader__.load({
1632
1649
  }, 'dsh-tokenbank: balance flash style')
1633
1650
  // 入口按钮 hover 形态:灰底 + 箭头反转(与模型选择器 hover 一致)
1634
1651
  var entryCss = document.createElement('style')
1635
- 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)}'
1652
+ entryCss.textContent = '@keyframes tb-balance-gain{0%{opacity:0;transform:translateY(4px)}25%{opacity:1;transform:translateY(0)}75%{opacity:1}100%{opacity:0;transform:translateY(-6px)}}' + '#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)}'
1636
1653
  document.head.appendChild(entryCss)
1637
1654
  ctx.effect(function () {
1638
1655
  return function () { if (entryCss.parentNode) entryCss.parentNode.removeChild(entryCss) }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tokenbank",
3
- "version": "0.1.70",
3
+ "version": "0.1.71",
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",