dsh-reminder-notify 0.6.0 → 0.7.0

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/client.js CHANGED
@@ -65,6 +65,9 @@ window.__ModuleLoader__.load({
65
65
  powershellPath: 'PowerShell 可执行文件',
66
66
  clientDir: '客户端目录(仅 exe 模式)',
67
67
  empty: '(留空用默认)',
68
+ browse: '浏览…',
69
+ picking: '选择中…',
70
+ pickFailed: '打开目录选择器失败:',
68
71
  save: '保存',
69
72
  saving: '保存中…',
70
73
  reset: '撤销修改',
@@ -126,6 +129,9 @@ window.__ModuleLoader__.load({
126
129
  powershellPath: 'PowerShell executable',
127
130
  clientDir: 'Client directory (exe mode)',
128
131
  empty: '(empty uses the default)',
132
+ browse: 'Browse…',
133
+ picking: 'Choosing…',
134
+ pickFailed: 'Could not open the directory picker: ',
129
135
  save: 'Save',
130
136
  saving: 'Saving…',
131
137
  reset: 'Discard changes',
@@ -158,6 +164,9 @@ window.__ModuleLoader__.load({
158
164
  .drn-btn { font: inherit; font-size: 13px; padding: 6px 14px; border-radius: 7px; cursor: pointer; border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); }
159
165
  .drn-btn.primary { background: var(--dsw-alias-brand-primary); border-color: transparent; color: #fff; }
160
166
  .drn-btn[disabled] { opacity: .5; cursor: default; }
167
+ .drn-pick { display: flex; gap: 6px; width: 100%; align-items: center; }
168
+ .drn-pick .drn-input { flex: 1 1 auto; min-width: 0; }
169
+ .drn-btn.small { padding: 5px 10px; white-space: nowrap; }
161
170
  .drn-msg { font-size: 12px; color: var(--dsw-alias-label-secondary); }
162
171
  .drn-msg.error { color: var(--dsw-alias-state-error-primary); }
163
172
  `
@@ -171,7 +180,7 @@ window.__ModuleLoader__.load({
171
180
  { key: 'doneAudio', group: 'audio', kind: 'text' },
172
181
  { key: 'decideAudio', group: 'audio', kind: 'text' },
173
182
  { key: 'rawAudio', group: 'audio', kind: 'text' },
174
- { key: 'audioDir', group: 'audio', kind: 'text' },
183
+ { key: 'audioDir', group: 'audio', kind: 'text', pick: 'directory' },
175
184
  { key: 'accentDone', group: 'look', kind: 'color' },
176
185
  { key: 'accentDecide', group: 'look', kind: 'color' },
177
186
  { key: 'accentRaw', group: 'look', kind: 'color' },
@@ -188,7 +197,7 @@ window.__ModuleLoader__.load({
188
197
  { key: 'hostMode', group: 'host', kind: 'select', options: ['script', 'exe'], optionLabels: ['hostModeScript', 'hostModeExe'] },
189
198
  { key: 'scriptPath', group: 'host', kind: 'text' },
190
199
  { key: 'powershellPath', group: 'host', kind: 'text' },
191
- { key: 'clientDir', group: 'host', kind: 'text' },
200
+ { key: 'clientDir', group: 'host', kind: 'text', pick: 'directory' },
192
201
  ]
193
202
 
194
203
  const HINTS = {
@@ -226,6 +235,7 @@ window.__ModuleLoader__.load({
226
235
  const revision = state && state.revision
227
236
  const [draft, setDraft] = React.useState(null)
228
237
  const [busy, setBusy] = React.useState(false)
238
+ const [picking, setPicking] = React.useState(false)
229
239
  const [message, setMessage] = React.useState(null)
230
240
 
231
241
  if (props.view === 'summary') {
@@ -282,6 +292,26 @@ window.__ModuleLoader__.load({
282
292
  })
283
293
  }
284
294
 
295
+ // 目录类字段的「浏览…」:调宿主原生的目录选择器(client uiWorkspace.pickDirectory),
296
+ // 选完直接把绝对路径写进草稿;面板拿不到选择器时按钮不渲染,字段照旧手填。
297
+ function browse(key) {
298
+ const pick = props.pickDirectory
299
+ if (typeof pick !== 'function' || picking) return
300
+ setPicking(true)
301
+ setMessage(null)
302
+ Promise.resolve()
303
+ .then(() => pick())
304
+ .then((picked) => {
305
+ setPicking(false)
306
+ if (typeof picked === 'string' && picked !== '') edit(key, picked, 'text')
307
+ })
308
+ .catch((error) => {
309
+ setPicking(false)
310
+ const prefix = typeof t === 'function' ? t('pickFailed') : 'pick failed: '
311
+ setMessage({ ok: false, text: prefix + String((error && error.message) || error) })
312
+ })
313
+ }
314
+
285
315
  function control(field) {
286
316
  const value = effective[field.key]
287
317
  const disabled = !writable || busy
@@ -311,7 +341,7 @@ window.__ModuleLoader__.load({
311
341
  onChange: (e) => edit(field.key, e.target.value, 'color'),
312
342
  })
313
343
  }
314
- return h('input', {
344
+ const input = h('input', {
315
345
  className: 'drn-input',
316
346
  type: field.kind === 'number' ? 'number' : 'text',
317
347
  value: value === undefined || value === null ? '' : String(value),
@@ -319,6 +349,19 @@ window.__ModuleLoader__.load({
319
349
  disabled,
320
350
  onChange: (e) => edit(field.key, e.target.value, field.kind),
321
351
  })
352
+ if (field.pick === 'directory' && typeof props.pickDirectory === 'function') {
353
+ return h(
354
+ 'div',
355
+ { className: 'drn-pick' },
356
+ input,
357
+ h(
358
+ 'button',
359
+ { type: 'button', className: 'drn-btn small', disabled: disabled || picking, onClick: () => browse(field.key) },
360
+ typeof t === 'function' ? t(picking ? 'picking' : 'browse') : 'Browse…',
361
+ ),
362
+ )
363
+ }
364
+ return input
322
365
  }
323
366
 
324
367
  const groups = GROUPS.map((group) =>
@@ -380,6 +423,13 @@ window.__ModuleLoader__.load({
380
423
  function apply(ctx) {
381
424
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-reminder-notify: settings dictionaries')
382
425
 
426
+ // 目录选择器来自 Client 的 uiWorkspace 服务;旧宿主没有这个服务时保持 undefined,
427
+ // 面板会退化成纯手填,不影响保存。
428
+ const workspace = typeof ctx.get === 'function' ? ctx.get('uiWorkspace') : undefined
429
+ const pickDirectory = workspace && typeof workspace.pickDirectory === 'function'
430
+ ? () => workspace.pickDirectory()
431
+ : undefined
432
+
383
433
  ctx.effect(() => {
384
434
  if (typeof document === 'undefined') return
385
435
  const previous = document.getElementById('drn-panel-style')
@@ -400,7 +450,7 @@ window.__ModuleLoader__.load({
400
450
  name: 'plugins.bundle.config',
401
451
  key: NS,
402
452
  locale: NS,
403
- inject: () => ({ t: ctx.locale.bind(NS) }),
453
+ inject: () => ({ t: ctx.locale.bind(NS), pickDirectory }),
404
454
  },
405
455
  ReminderConfigPanel,
406
456
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-reminder-notify",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "DSH 桌面提醒插件:把「完成/需要决定」提醒变成 notify_user 工具(浮动卡片 + 提示音,不抢焦点,纯 PowerShell 源码宿主,仓库零 exe)",
5
5
  "author": "Jiangshuaiye1203",
6
6
  "type": "module",
@@ -48,8 +48,8 @@
48
48
  },
49
49
  "versions": [
50
50
  {
51
- "version": "0.5.0",
52
- "publishTimestamp": 1795079825,
51
+ "version": "0.6.0",
52
+ "publishTimestamp": 1795080352,
53
53
  "source": {
54
54
  "type": "npm"
55
55
  },