dsh-plugin-greeting-bubble 1.5.2 → 1.5.3

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/README.md +1 -0
  2. package/client.js +14 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -40,6 +40,7 @@
40
40
  - 今日消费金额只显示金额(`≈ ¥x.xx`);口径是基准余额 − 当前余额,优先用**昨天最后一次读到的余额**(≈ 0 点余额),没有昨天数据则用**今天第一次读到的余额**;充值会使基准同步抬高,不计入消费。
41
41
  - **安装插件之前、或 DSH 未运行期间**的消费无法统计,所以这是“自基准时间起”的估算,不是平台账单。
42
42
  - 详情里可以**隐藏金额(隐私模式)**:金额变为 `••••` 并记住,适合截图/录屏。
43
+ - 金额显示按平台口径**截断到分**(4.618 显示 4.61),与官方页面一致,不做四舍五入。
43
44
  - 未登录、账号服务不可用或请求失败时显示 `--`,不影响其他功能。
44
45
  - 展开后用右侧的 **×** 关闭;关闭只对当前页面生效,**刷新页面后会再次出现**。
45
46
  - **按住机器人或卡片可以拖动**:光标变成抓手,拖到任意位置松手即可;位置按“距右下角的偏移”记录,所以窗口缩放、最大化后会继续贴着右下角,不会跑到屏幕外。
package/client.js CHANGED
@@ -104,15 +104,23 @@ window.__ModuleLoader__.load({
104
104
  return currency + ' ';
105
105
  }
106
106
 
107
- /** Display a Platform decimal string with two fraction digits. */
108
- const AMOUNT_FORMAT = new Intl.NumberFormat(undefined, {
109
- minimumFractionDigits: 2,
110
- maximumFractionDigits: 2,
111
- });
107
+ /** Whole-yuan grouping for truncated amounts. */
108
+ const WHOLE_FORMAT = new Intl.NumberFormat(undefined, { maximumFractionDigits: 0 });
112
109
 
110
+ /**
111
+ * Display a Platform amount the way the Platform does: truncate to two
112
+ * fraction digits instead of rounding, so 4.618 shows 4.61 (not 4.62).
113
+ */
113
114
  function formatAmount(value) {
114
115
  const amount = Number(value);
115
- return Number.isFinite(amount) ? AMOUNT_FORMAT.format(amount) : value;
116
+ if (!Number.isFinite(amount)) return value;
117
+ // Round away binary noise at the 1e-9 scale, then truncate to cents.
118
+ const cents = Math.trunc(Math.round(amount * 1e9) / 1e7);
119
+ const sign = cents < 0 ? '-' : '';
120
+ const abs = Math.abs(cents);
121
+ const whole = WHOLE_FORMAT.format(Math.floor(abs / 100));
122
+ const fraction = String(abs % 100).padStart(2, '0');
123
+ return sign + whole + '.' + fraction;
116
124
  }
117
125
 
118
126
  /** Format a wallet list, e.g. "¥11.77 / $1.00"; null when empty. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-greeting-bubble",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "Shows a “你好,腾盛” speech bubble in the bottom-right corner of the DeepSeek Harness Web GUI.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {