dsh-usage-peak 1.4.0 → 1.4.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.1
4
+
5
+ - 修复侧栏余额/预算预警激活后,峰谷倒计时被警告文案替换、看不到「还有多久转峰/转谷」的问题:现在倒计时始终保留,前面加 `⚠` 并在 tooltip 中补充预警原因。
6
+
3
7
  ## 1.4.0
4
8
 
5
9
  - 新增项目下钻:点击项目筛选概况、小时/每日趋势、模型明细,顶部可切换或恢复全部项目;项目占比增加条形提示。
package/client.js CHANGED
@@ -388,6 +388,12 @@ window.__ModuleLoader__.load({
388
388
  return `${base}?days=${days || DEFAULT_DAYS}${project ? `&project=${encodeURIComponent(project)}` : ''}${fresh ? '&fresh=1' : ''}`;
389
389
  }
390
390
 
391
+ // Keep the peak/valley countdown visible in the pill; the warning is an
392
+ // accent plus a prefix, never a replacement for the status text.
393
+ function pillStatus(alertActive, switchText) {
394
+ return alertActive ? `⚠ ${switchText}` : switchText;
395
+ }
396
+
391
397
  // Generation guard rejects old filter responses and older same-filter reloads.
392
398
  function requestGate() {
393
399
  let key = null;
@@ -516,7 +522,7 @@ window.__ModuleLoader__.load({
516
522
  const walletTip =
517
523
  wallet && wallet.balance !== null
518
524
  ? `${t('kpi.balance')} ${yuan(wallet.balance)}${walletText ? ` · ${walletText}` : ''}`
519
- : '';
525
+ : walletText;
520
526
  const tip = data
521
527
  ? `${word} · ${t('widget.today')} ${yuan(today)} · ${tokens(data.today ? data.today.tokens : 0, t)} tokens · ${t('status.switchIn')} ${switchText}${walletTip ? ` · ${walletTip}` : ''}`
522
528
  : word;
@@ -571,7 +577,7 @@ window.__ModuleLoader__.load({
571
577
  textOverflow: 'ellipsis',
572
578
  },
573
579
  },
574
- data ? (walletAlert ? `⚠ ${alert.budgetExceeded ? t('alerts.exceeded') : runway(wallet && wallet.runwayDays, t)}` : switchText) : '',
580
+ data ? pillStatus(walletAlert, switchText) : '',
575
581
  ),
576
582
  );
577
583
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-usage-peak",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "type": "module",
5
5
  "description": "DeepSeek Harness 用量峰谷仪表盘:峰/谷时段(含节假日与调休)、今日花费与 tokens、项目下钻/模型统计、可配置预算预警、余额可撑天数、CSV 导出、7/14/30 天窗口、缓存命中、谷时更省,侧栏常驻胶囊 + 设置页详情。",
6
6
  "exports": {
@@ -10,7 +10,7 @@ function helpers(storage = {}) {
10
10
  const context = { window: { localStorage: storage, dispatchEvent: (event) => events.push(event) }, CustomEvent: class { constructor(type, options) { this.type = type; this.detail = options.detail; } }, C: { error: 'red', peak: 'amber', text3: 'gray' }, DATA_URL: '/data', DEFAULT_DAYS: 14 };
11
11
  const start = source.indexOf(" const PREFS_KEY =");
12
12
  const stop = source.indexOf(' function useFeed(', start);
13
- vm.runInNewContext(source.slice(start, stop) + '\nthis.api = { validatePrefs, readPrefs, savePrefs, alertState, feedUrl, requestGate, tint };', context);
13
+ vm.runInNewContext(source.slice(start, stop) + '\nthis.api = { validatePrefs, readPrefs, savePrefs, alertState, feedUrl, requestGate, tint, pillStatus };', context);
14
14
  return { ...context.api, events };
15
15
  }
16
16
  const plain = (value) => JSON.parse(JSON.stringify(value));
@@ -74,6 +74,12 @@ test('client data and CSV URLs encode project identity and preserve scope', () =
74
74
  assert.equal(api.feedUrl('/data', 14, ''), '/data?days=14');
75
75
  });
76
76
 
77
+ test('client alert prefix keeps the peak/valley countdown visible', () => {
78
+ const api = helpers();
79
+ assert.equal(api.pillStatus(true, '2:43 后转谷'), '⚠ 2:43 后转谷');
80
+ assert.equal(api.pillStatus(false, '2:43 后转谷'), '2:43 后转谷');
81
+ });
82
+
77
83
  test('client request generation guard rejects old filters, refreshes, and unmount results', () => {
78
84
  const gate = helpers().requestGate();
79
85
  gate.select('alpha');