dsh-reminder-notify 0.5.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
@@ -47,6 +47,13 @@ window.__ModuleLoader__.load({
47
47
  cardBackgroundHint: 'png / jpg 路径(绝对路径或相对插件目录),留空 = 纯色背景。',
48
48
  cardIcon: '标题图标',
49
49
  cardIconHint: '标题左侧的小图标(png),留空 = 不显示。',
50
+ doneCardBackground: 'done 专用背景图',
51
+ decideCardBackground: 'decide 专用背景图',
52
+ rawCardBackground: 'raw 专用背景图',
53
+ doneCardIcon: 'done 专用图标',
54
+ decideCardIcon: 'decide 专用图标',
55
+ rawCardIcon: 'raw 专用图标',
56
+ perKindHint: '按档位覆盖通用设置,留空就用上面的通用背景 / 图标。',
50
57
  titleTemplate: '标题模板',
51
58
  messageTemplate: '正文模板',
52
59
  templateHint: '可用占位符 {title} {message} {kind} {time}。',
@@ -58,6 +65,9 @@ window.__ModuleLoader__.load({
58
65
  powershellPath: 'PowerShell 可执行文件',
59
66
  clientDir: '客户端目录(仅 exe 模式)',
60
67
  empty: '(留空用默认)',
68
+ browse: '浏览…',
69
+ picking: '选择中…',
70
+ pickFailed: '打开目录选择器失败:',
61
71
  save: '保存',
62
72
  saving: '保存中…',
63
73
  reset: '撤销修改',
@@ -101,6 +111,13 @@ window.__ModuleLoader__.load({
101
111
  cardBackgroundHint: 'A png / jpg path (absolute or relative to the plugin); empty keeps the solid colour.',
102
112
  cardIcon: 'Title icon',
103
113
  cardIconHint: 'A small png shown left of the title; empty hides it.',
114
+ doneCardBackground: 'Done-only background',
115
+ decideCardBackground: 'Decide-only background',
116
+ rawCardBackground: 'Raw-only background',
117
+ doneCardIcon: 'Done-only icon',
118
+ decideCardIcon: 'Decide-only icon',
119
+ rawCardIcon: 'Raw-only icon',
120
+ perKindHint: 'Overrides the shared background / icon per kind; empty falls back to the shared value.',
104
121
  titleTemplate: 'Title template',
105
122
  messageTemplate: 'Message template',
106
123
  templateHint: 'Placeholders: {title} {message} {kind} {time}.',
@@ -112,6 +129,9 @@ window.__ModuleLoader__.load({
112
129
  powershellPath: 'PowerShell executable',
113
130
  clientDir: 'Client directory (exe mode)',
114
131
  empty: '(empty uses the default)',
132
+ browse: 'Browse…',
133
+ picking: 'Choosing…',
134
+ pickFailed: 'Could not open the directory picker: ',
115
135
  save: 'Save',
116
136
  saving: 'Saving…',
117
137
  reset: 'Discard changes',
@@ -144,6 +164,9 @@ window.__ModuleLoader__.load({
144
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); }
145
165
  .drn-btn.primary { background: var(--dsw-alias-brand-primary); border-color: transparent; color: #fff; }
146
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; }
147
170
  .drn-msg { font-size: 12px; color: var(--dsw-alias-label-secondary); }
148
171
  .drn-msg.error { color: var(--dsw-alias-state-error-primary); }
149
172
  `
@@ -157,18 +180,24 @@ window.__ModuleLoader__.load({
157
180
  { key: 'doneAudio', group: 'audio', kind: 'text' },
158
181
  { key: 'decideAudio', group: 'audio', kind: 'text' },
159
182
  { key: 'rawAudio', group: 'audio', kind: 'text' },
160
- { key: 'audioDir', group: 'audio', kind: 'text' },
183
+ { key: 'audioDir', group: 'audio', kind: 'text', pick: 'directory' },
161
184
  { key: 'accentDone', group: 'look', kind: 'color' },
162
185
  { key: 'accentDecide', group: 'look', kind: 'color' },
163
186
  { key: 'accentRaw', group: 'look', kind: 'color' },
164
187
  { key: 'cardBackground', group: 'look', kind: 'text' },
165
188
  { key: 'cardIcon', group: 'look', kind: 'text' },
189
+ { key: 'doneCardBackground', group: 'look', kind: 'text' },
190
+ { key: 'decideCardBackground', group: 'look', kind: 'text' },
191
+ { key: 'rawCardBackground', group: 'look', kind: 'text' },
192
+ { key: 'doneCardIcon', group: 'look', kind: 'text' },
193
+ { key: 'decideCardIcon', group: 'look', kind: 'text' },
194
+ { key: 'rawCardIcon', group: 'look', kind: 'text' },
166
195
  { key: 'titleTemplate', group: 'look', kind: 'text' },
167
196
  { key: 'messageTemplate', group: 'look', kind: 'text' },
168
197
  { key: 'hostMode', group: 'host', kind: 'select', options: ['script', 'exe'], optionLabels: ['hostModeScript', 'hostModeExe'] },
169
198
  { key: 'scriptPath', group: 'host', kind: 'text' },
170
199
  { key: 'powershellPath', group: 'host', kind: 'text' },
171
- { key: 'clientDir', group: 'host', kind: 'text' },
200
+ { key: 'clientDir', group: 'host', kind: 'text', pick: 'directory' },
172
201
  ]
173
202
 
174
203
  const HINTS = {
@@ -179,6 +208,12 @@ window.__ModuleLoader__.load({
179
208
  audioDir: 'audioDirHint',
180
209
  cardBackground: 'cardBackgroundHint',
181
210
  cardIcon: 'cardIconHint',
211
+ doneCardBackground: 'perKindHint',
212
+ decideCardBackground: 'perKindHint',
213
+ rawCardBackground: 'perKindHint',
214
+ doneCardIcon: 'perKindHint',
215
+ decideCardIcon: 'perKindHint',
216
+ rawCardIcon: 'perKindHint',
182
217
  titleTemplate: 'templateHint',
183
218
  messageTemplate: 'templateHint',
184
219
  scriptPath: 'scriptPathHint',
@@ -200,6 +235,7 @@ window.__ModuleLoader__.load({
200
235
  const revision = state && state.revision
201
236
  const [draft, setDraft] = React.useState(null)
202
237
  const [busy, setBusy] = React.useState(false)
238
+ const [picking, setPicking] = React.useState(false)
203
239
  const [message, setMessage] = React.useState(null)
204
240
 
205
241
  if (props.view === 'summary') {
@@ -256,6 +292,26 @@ window.__ModuleLoader__.load({
256
292
  })
257
293
  }
258
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
+
259
315
  function control(field) {
260
316
  const value = effective[field.key]
261
317
  const disabled = !writable || busy
@@ -285,7 +341,7 @@ window.__ModuleLoader__.load({
285
341
  onChange: (e) => edit(field.key, e.target.value, 'color'),
286
342
  })
287
343
  }
288
- return h('input', {
344
+ const input = h('input', {
289
345
  className: 'drn-input',
290
346
  type: field.kind === 'number' ? 'number' : 'text',
291
347
  value: value === undefined || value === null ? '' : String(value),
@@ -293,6 +349,19 @@ window.__ModuleLoader__.load({
293
349
  disabled,
294
350
  onChange: (e) => edit(field.key, e.target.value, field.kind),
295
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
296
365
  }
297
366
 
298
367
  const groups = GROUPS.map((group) =>
@@ -354,6 +423,13 @@ window.__ModuleLoader__.load({
354
423
  function apply(ctx) {
355
424
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-reminder-notify: settings dictionaries')
356
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
+
357
433
  ctx.effect(() => {
358
434
  if (typeof document === 'undefined') return
359
435
  const previous = document.getElementById('drn-panel-style')
@@ -374,7 +450,7 @@ window.__ModuleLoader__.load({
374
450
  name: 'plugins.bundle.config',
375
451
  key: NS,
376
452
  locale: NS,
377
- inject: () => ({ t: ctx.locale.bind(NS) }),
453
+ inject: () => ({ t: ctx.locale.bind(NS), pickDirectory }),
378
454
  },
379
455
  ReminderConfigPanel,
380
456
  ),
package/index.js CHANGED
@@ -44,6 +44,12 @@ export const Config = z === null ? undefined : z.object({
44
44
  cooldownMs: z.number().min(0).step(100).default(1500).description('同档位提醒的最小间隔(毫秒)'),
45
45
  cardBackground: z.string().default('').description('卡片背景图路径(png / jpg),留空 = 纯色背景'),
46
46
  cardIcon: z.string().default('').description('标题左侧的小图标路径(png / ico),留空 = 不显示'),
47
+ doneCardBackground: z.string().default('').description('done 档位单独用的背景图,留空 = 用上面的通用背景'),
48
+ decideCardBackground: z.string().default('').description('decide 档位单独用的背景图,留空 = 用通用背景'),
49
+ rawCardBackground: z.string().default('').description('raw 档位单独用的背景图,留空 = 用通用背景'),
50
+ doneCardIcon: z.string().default('').description('done 档位单独用的标题图标,留空 = 用通用图标'),
51
+ decideCardIcon: z.string().default('').description('decide 档位单独用的标题图标,留空 = 用通用图标'),
52
+ rawCardIcon: z.string().default('').description('raw 档位单独用的标题图标,留空 = 用通用图标'),
47
53
  titleTemplate: z.string().default('{title}').description('标题模板,可用占位符 {title} {message} {kind} {time}'),
48
54
  messageTemplate: z.string().default('{message}').description('正文模板,可用占位符 {title} {message} {kind} {time}'),
49
55
  })
@@ -113,6 +119,12 @@ function settingsOf(config) {
113
119
  cooldownMs: Math.max(0, Math.round(num(c.cooldownMs, 1500))),
114
120
  cardBackground: str(c.cardBackground, ''),
115
121
  cardIcon: str(c.cardIcon, ''),
122
+ doneCardBackground: str(c.doneCardBackground, ''),
123
+ decideCardBackground: str(c.decideCardBackground, ''),
124
+ rawCardBackground: str(c.rawCardBackground, ''),
125
+ doneCardIcon: str(c.doneCardIcon, ''),
126
+ decideCardIcon: str(c.decideCardIcon, ''),
127
+ rawCardIcon: str(c.rawCardIcon, ''),
116
128
  titleTemplate: typeof c.titleTemplate === 'string' ? c.titleTemplate : '{title}',
117
129
  messageTemplate: typeof c.messageTemplate === 'string' ? c.messageTemplate : '{message}',
118
130
  }
@@ -154,7 +166,18 @@ function assetPath(value) {
154
166
  return fs.existsSync(full) ? full : ''
155
167
  }
156
168
 
157
- // 参数数组交给 spawn,Windows 下由 CreateProcess 的引号规则处理空格与中文;
169
+ // 档位外观:doneCardBackground / decideCardIcon 这类按档位覆盖,留空就退回通用值。
170
+ function appearanceOf(kind, settings) {
171
+ const background = str(settings[`${kind}CardBackground`], '') !== ''
172
+ ? settings[`${kind}CardBackground`]
173
+ : settings.cardBackground
174
+ const icon = str(settings[`${kind}CardIcon`], '') !== ''
175
+ ? settings[`${kind}CardIcon`]
176
+ : settings.cardIcon
177
+ return { background: assetPath(background), icon: assetPath(icon) }
178
+ }
179
+
180
+
158
181
  // PowerShell 自己还会再解析一遍 -File 之后的参数,所以这里把英文双引号替换掉,
159
182
  // 避免一条带引号的正文把后面所有参数吃掉。
160
183
  function psSafe(value) {
@@ -288,7 +311,7 @@ async function notify(kind, args, settings) {
288
311
  }
289
312
 
290
313
  async function fireScript(settings, title, message, seconds, kind, audioPath, sound, scriptPath, missingAudio) {
291
- const extras = { background: assetPath(settings.cardBackground), icon: assetPath(settings.cardIcon) }
314
+ const extras = appearanceOf(kind, settings)
292
315
  const argv = argvOfScriptHost(title, message, seconds, settings.position, accentOf(kind, settings), audioPath, sound, extras)
293
316
  argv[argv.indexOf(null)] = scriptPath
294
317
  try {
@@ -306,6 +329,8 @@ async function fireScript(settings, title, message, seconds, kind, audioPath, so
306
329
  sound: sound && audioPath !== '',
307
330
  audio: sound && audioPath !== '' ? audioPath : null,
308
331
  audioMissing: missingAudio !== '' ? missingAudio : undefined,
332
+ background: extras.background !== '' ? extras.background : null,
333
+ icon: extras.icon !== '' ? extras.icon : null,
309
334
  pid,
310
335
  host: scriptPath,
311
336
  earlyExit: early === 'running' ? null : early,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-reminder-notify",
3
- "version": "0.5.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.4.0",
52
- "publishTimestamp": 1795061969,
51
+ "version": "0.6.0",
52
+ "publishTimestamp": 1795080352,
53
53
  "source": {
54
54
  "type": "npm"
55
55
  },