dsh-opencode-status 0.1.3 → 0.1.5

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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.5
4
+
5
+ - 消除点击弹窗中的重复进度条展示:用量进度条与倒计时全部由 220ms 悬浮微卡呈现(免点即看),点击按钮直达「⚙ OpenCode GO 连接配置」管理卡片(配置 Base URL、设置 API Key、清除 Key 与强制同步)。
6
+
7
+ ## 0.1.4
8
+
9
+ - 增加侧边栏鼠标悬停(Hover 220ms)3 维用量卡片预览:5h 滚动窗口、周窗口、月窗口实时用量条与重置倒计时鼠标悬停即看,免去频繁点击与关闭的交互负担。
10
+
11
+ ## 0.1.3
12
+
13
+ - 优化 README 安装命令为官方 npm 源优先。
14
+
3
15
  ## 0.1.2
4
16
 
5
17
  - 修复自定义 `keyRef` 配置下凭据读取、写入与清除目标不一致的问题
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-opencode-status",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "OpenCode GO quota and plan status panel for DeepSeek Harness: sidebar health light, quota bars, countdown timers, and in-app key management",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
package/src/client.js CHANGED
@@ -153,9 +153,11 @@ window.__ModuleLoader__.load({
153
153
  } catch {}
154
154
  }
155
155
 
156
- // ---------- 常驻入口(上下结构单行按钮) ----------
156
+ // ---------- 常驻入口(上下结构单行按钮 + 悬停微卡) ----------
157
157
  function FooterEntry(props) {
158
158
  const state = useStore()
159
+ const [hovering, setHovering] = useState(false)
160
+ const hoverTimerRef = useRef(null)
159
161
 
160
162
  useEffect(() => {
161
163
  refreshStatus(false)
@@ -163,6 +165,15 @@ window.__ModuleLoader__.load({
163
165
  return () => clearInterval(timer)
164
166
  }, [])
165
167
 
168
+ const onMouseEnter = () => {
169
+ clearTimeout(hoverTimerRef.current)
170
+ hoverTimerRef.current = setTimeout(() => setHovering(true), 220)
171
+ }
172
+ const onMouseLeave = () => {
173
+ clearTimeout(hoverTimerRef.current)
174
+ setHovering(false)
175
+ }
176
+
166
177
  const st = state.status
167
178
  let color = T.warn
168
179
  let text = '连接 OpenCode'
@@ -210,10 +221,12 @@ window.__ModuleLoader__.load({
210
221
  )
211
222
  }
212
223
 
213
- return h(
224
+ const node = h(
214
225
  'button',
215
226
  {
216
227
  className: 'oc-btn oc-footer-btn',
228
+ onMouseEnter,
229
+ onMouseLeave,
217
230
  style: {
218
231
  ...btnBase,
219
232
  display: props?.wide === false ? 'inline-flex' : 'flex',
@@ -223,6 +236,8 @@ window.__ModuleLoader__.load({
223
236
  margin: '2px 0',
224
237
  minWidth: 0,
225
238
  flexShrink: 0,
239
+ borderColor: state.open ? T.brand : T.border,
240
+ background: state.open ? 'var(--dsw-alias-interactive-bg-hover, rgba(59,130,246,.12))' : 'transparent',
226
241
  },
227
242
  onClick: () => {
228
243
  store.set({ open: !state.open, editing: false })
@@ -231,14 +246,13 @@ window.__ModuleLoader__.load({
231
246
  refreshConfig()
232
247
  }
233
248
  },
234
- title: st?.error?.message || `OpenCode GO · ${value || '点击查看详情'}`,
235
249
  },
236
250
  h('span', { className: color === T.ok ? 'oc-dot-live' : undefined, style: dotStyle(color) }),
237
251
  h(
238
252
  'span',
239
253
  { style: { display: 'inline-flex', alignItems: 'center', lineHeight: '18px', whiteSpace: 'nowrap', minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis' } },
240
254
  [
241
- h('span', { key: 't', style: { color: T.label, flexShrink: 0 } }, text),
255
+ h('span', { key: 't', style: { color: T.label, fontWeight: 500, flexShrink: 0 } }, text),
242
256
  value
243
257
  ? [
244
258
  h('span', { key: 'sep', style: { color: T.secondary, margin: '0 5px', opacity: 0.7, flexShrink: 0 } }, '·'),
@@ -248,6 +262,53 @@ window.__ModuleLoader__.load({
248
262
  ].flat().filter(Boolean),
249
263
  ),
250
264
  )
265
+
266
+ if (!hovering || state.open || !st?.ok || !st?.windows?.length) return node
267
+
268
+ return h(
269
+ 'div',
270
+ {
271
+ style: { position: 'relative', width: '100%' },
272
+ onMouseEnter,
273
+ onMouseLeave,
274
+ },
275
+ node,
276
+ h(
277
+ 'div',
278
+ {
279
+ className: 'oc-panel-enter',
280
+ style: {
281
+ position: 'absolute',
282
+ left: 0,
283
+ right: 0,
284
+ bottom: 'calc(100% + 6px)',
285
+ background: T.bg,
286
+ border: `1px solid ${T.border2}`,
287
+ borderRadius: '10px',
288
+ boxShadow: '0 8px 24px rgba(0,0,0,.18)',
289
+ padding: '12px 14px 4px 14px',
290
+ fontSize: '11px',
291
+ color: T.label,
292
+ zIndex: 100,
293
+ fontFamily: 'system-ui, -apple-system, sans-serif',
294
+ },
295
+ },
296
+ h(
297
+ 'div',
298
+ {
299
+ style: {
300
+ display: 'flex',
301
+ alignItems: 'center',
302
+ justifyContent: 'space-between',
303
+ marginBottom: 10,
304
+ },
305
+ },
306
+ h('span', { style: { fontWeight: 600, fontSize: '12px' } }, '🚀 OpenCode GO 用量概览'),
307
+ st.plan ? h('span', { style: { fontSize: '10px', color: T.brand, fontWeight: 600 } }, st.plan) : null,
308
+ ),
309
+ st.windows.map((w, i) => h(QuotaRow, { key: i, window: w })),
310
+ ),
311
+ )
251
312
  }
252
313
 
253
314
  // ---------- 配额进度条 ----------
@@ -376,7 +437,7 @@ window.__ModuleLoader__.load({
376
437
  ])
377
438
  }
378
439
 
379
- // ---------- 浮层面板 ----------
440
+ // ---------- 浮层配置面板(点击进入控制台管理,用量已在悬浮卡片展示) ----------
380
441
  function OverlayPanel() {
381
442
  const state = useStore()
382
443
  const panelRef = useRef(null)
@@ -409,7 +470,6 @@ window.__ModuleLoader__.load({
409
470
  if (phase === 'closed') return null
410
471
 
411
472
  const st = state.status
412
- const showConfig = state.editing || !st || st.mode === 'needs_config'
413
473
 
414
474
  return h(
415
475
  'div',
@@ -433,65 +493,35 @@ window.__ModuleLoader__.load({
433
493
  [
434
494
  // 头部
435
495
  h('div', { key: 'hd', style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12, borderBottom: `1px solid ${T.border}`, paddingBottom: 8 } }, [
436
- h('span', { style: { fontSize: 13, fontWeight: 600, color: T.label } }, showConfig ? '配置 OpenCode' : 'OpenCode GO 用量'),
496
+ h('span', { style: { fontSize: 13, fontWeight: 600, color: T.label } }, '⚙ OpenCode GO 连接配置'),
437
497
  h('div', { style: { display: 'flex', gap: 4, alignItems: 'center' } }, [
438
- !showConfig
439
- ? h(
440
- 'button',
441
- {
442
- className: 'oc-btn',
443
- style: {
444
- width: 26,
445
- height: 26,
446
- padding: 0,
447
- display: 'inline-flex',
448
- alignItems: 'center',
449
- justifyContent: 'center',
450
- fontSize: 14,
451
- border: 'none',
452
- borderRadius: 6,
453
- cursor: 'pointer',
454
- color: T.secondary,
455
- background: 'transparent',
456
- },
457
- onClick: async () => {
458
- store.set({ refreshing: true })
459
- await refreshStatus(true)
460
- store.set({ refreshing: false })
461
- },
462
- title: '刷新用量',
463
- },
464
- state.refreshing ? h('span', { className: 'oc-spin' }, '↻') : '↻',
465
- )
466
- : null,
467
- !showConfig
468
- ? h(
469
- 'button',
470
- {
471
- className: 'oc-btn',
472
- style: {
473
- width: 26,
474
- height: 26,
475
- padding: 0,
476
- display: 'inline-flex',
477
- alignItems: 'center',
478
- justifyContent: 'center',
479
- fontSize: 15,
480
- border: 'none',
481
- borderRadius: 6,
482
- cursor: 'pointer',
483
- color: T.secondary,
484
- background: 'transparent',
485
- },
486
- onClick: () => {
487
- store.set({ editing: true })
488
- refreshConfig()
489
- },
490
- title: '更新配置',
491
- },
492
- '⚙',
493
- )
494
- : null,
498
+ h(
499
+ 'button',
500
+ {
501
+ className: 'oc-btn',
502
+ style: {
503
+ width: 26,
504
+ height: 26,
505
+ padding: 0,
506
+ display: 'inline-flex',
507
+ alignItems: 'center',
508
+ justifyContent: 'center',
509
+ fontSize: 14,
510
+ border: 'none',
511
+ borderRadius: 6,
512
+ cursor: 'pointer',
513
+ color: T.secondary,
514
+ background: 'transparent',
515
+ },
516
+ onClick: async () => {
517
+ store.set({ refreshing: true })
518
+ await refreshStatus(true)
519
+ store.set({ refreshing: false })
520
+ },
521
+ title: '强制刷新同步',
522
+ },
523
+ state.refreshing ? h('span', { className: 'oc-spin' }, '↻') : '↻',
524
+ ),
495
525
  h(
496
526
  'button',
497
527
  {
@@ -517,14 +547,8 @@ window.__ModuleLoader__.load({
517
547
  ),
518
548
  ]),
519
549
  ]),
520
- // 内容
521
- showConfig
522
- ? h(ConfigCard)
523
- : h('div', null, [
524
- st?.error ? h('div', { key: 'err', style: { fontSize: 11, color: T.err, marginBottom: 8 } }, st.error.message) : null,
525
- ...(st?.windows ?? []).map((w) => h(QuotaRow, { key: w.id, window: w })),
526
- h('div', { key: 'tip', style: { fontSize: 10, color: T.secondary, textAlign: 'right', marginTop: 6 } }, `更新于 ${new Date(st?.fetchedAt || Date.now()).toLocaleTimeString()}`),
527
- ]),
550
+ // 内容:直接展示配置与连接管理
551
+ h(ConfigCard),
528
552
  ],
529
553
  )
530
554
  }