dsh-reminder-notify 0.2.2 → 0.3.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/client.js ADDED
@@ -0,0 +1,364 @@
1
+ // dsh-reminder-notify —— Client 半边:插件页里的「桌面提醒」设置面板
2
+ //
3
+ // 只做一件事:在 bundle 详情页(plugins.bundle.config 槽位,key = 包名)渲染
4
+ // 分组表单,把用户改过的字段通过宿主给的 ConfigPageForm 写回去:
5
+ // values 来自 props.form.state.value(宿主已接受的那一份)
6
+ // 保存 = props.form.mutate([{ op: 'set', path: [key], value }], revision)
7
+ // 面板本身不持久化任何东西;改完由 loader 写 profile 并重启插件生效。
8
+ // 样式全部走主题 token,跟随明暗主题,不写死颜色。
9
+
10
+ window.__ModuleLoader__.load({
11
+ id: 'dsh-reminder-notify',
12
+ factory: (require) => {
13
+ const React = require('react')
14
+ const h = React.createElement
15
+
16
+ const NS = 'dsh-reminder-notify'
17
+
18
+ const zh = {
19
+ title: '桌面提醒设置',
20
+ intro: '调整弹窗停留时间、位置、提示音和卡片配色。改完点保存,插件会重启一次后生效。',
21
+ unavailable: '这个页面拿不到插件配置(可能是宿主版本较旧),请改用 cordis.patch.yml 修改。',
22
+ readonly: '当前配置由更高优先级的层覆盖,这里只能查看。',
23
+ groupBasic: '基本',
24
+ groupAudio: '提示音',
25
+ groupLook: '外观',
26
+ groupHost: '宿主与路径',
27
+ seconds: '停留秒数',
28
+ secondsHint: '2–600 秒,到点自动关闭。',
29
+ position: '弹窗位置',
30
+ positionBr: '右下角',
31
+ positionCenter: '屏幕居中',
32
+ positionTr: '右上角',
33
+ sound: '播放提示音',
34
+ soundHint: '关掉后只弹卡片不出声。',
35
+ cooldownMs: '同档位冷却(毫秒)',
36
+ cooldownHint: '防止模型在同一轮里重复弹同一种提醒。',
37
+ doneAudio: '完成(done)提示音文件',
38
+ decideAudio: '需要决定(decide)提示音文件',
39
+ rawAudio: '通用(raw)提示音文件',
40
+ audioHint: '填文件名,在下面的提示音目录里找;留空表示静音。',
41
+ audioDir: '提示音目录',
42
+ audioDirHint: '留空 = 用插件自带的 assets/提示音导入/。',
43
+ accentDone: '完成强调色',
44
+ accentDecide: '需要决定强调色',
45
+ accentRaw: '通用强调色',
46
+ hostMode: '宿主模式',
47
+ hostModeScript: '包内脚本(推荐)',
48
+ hostModeExe: '外部 exe 客户端',
49
+ scriptPath: '脚本宿主路径',
50
+ scriptPathHint: '留空 = 插件自带的 host/ReminderHost.ps1。',
51
+ powershellPath: 'PowerShell 可执行文件',
52
+ clientDir: '客户端目录(仅 exe 模式)',
53
+ empty: '(留空用默认)',
54
+ save: '保存',
55
+ saving: '保存中…',
56
+ reset: '撤销修改',
57
+ saved: '已保存,插件重启后生效。',
58
+ failed: '保存失败:',
59
+ summaryPrefix: '桌面提醒:',
60
+ soundOn: '提示音开',
61
+ soundOff: '提示音关',
62
+ secondsUnit: ' 秒',
63
+ }
64
+
65
+ const en = {
66
+ title: 'Desktop reminder settings',
67
+ intro: 'Tune the popup duration, position, sounds and card colours. Saving restarts the plugin once.',
68
+ unavailable: 'This page cannot read the plugin config (older host). Edit cordis.patch.yml instead.',
69
+ readonly: 'A higher-priority layer overrides this config; it is read-only here.',
70
+ groupBasic: 'Basics',
71
+ groupAudio: 'Sounds',
72
+ groupLook: 'Appearance',
73
+ groupHost: 'Host and paths',
74
+ seconds: 'Duration (seconds)',
75
+ secondsHint: '2–600 seconds, then it closes itself.',
76
+ position: 'Position',
77
+ positionBr: 'Bottom right',
78
+ positionCenter: 'Centred',
79
+ positionTr: 'Top right',
80
+ sound: 'Play sound',
81
+ soundHint: 'Off shows the card silently.',
82
+ cooldownMs: 'Same-kind cooldown (ms)',
83
+ cooldownHint: 'Stops the model repeating one reminder within a turn.',
84
+ doneAudio: 'Done sound file',
85
+ decideAudio: 'Decide sound file',
86
+ rawAudio: 'Raw sound file',
87
+ audioHint: 'A file name resolved inside the sound directory; empty means silent.',
88
+ audioDir: 'Sound directory',
89
+ audioDirHint: 'Empty uses the bundled assets/提示音导入/.',
90
+ accentDone: 'Done accent',
91
+ accentDecide: 'Decide accent',
92
+ accentRaw: 'Raw accent',
93
+ hostMode: 'Host mode',
94
+ hostModeScript: 'Bundled script (recommended)',
95
+ hostModeExe: 'External exe client',
96
+ scriptPath: 'Script host path',
97
+ scriptPathHint: 'Empty uses the bundled host/ReminderHost.ps1.',
98
+ powershellPath: 'PowerShell executable',
99
+ clientDir: 'Client directory (exe mode)',
100
+ empty: '(empty uses the default)',
101
+ save: 'Save',
102
+ saving: 'Saving…',
103
+ reset: 'Discard changes',
104
+ saved: 'Saved; the plugin restarts to apply it.',
105
+ failed: 'Save failed: ',
106
+ summaryPrefix: 'Desktop reminder: ',
107
+ soundOn: 'sound on',
108
+ soundOff: 'sound off',
109
+ secondsUnit: 's',
110
+ }
111
+
112
+ const CSS = `
113
+ .drn-panel { display: flex; flex-direction: column; gap: 18px; color: var(--dsw-alias-label-primary); }
114
+ .drn-head { display: flex; flex-direction: column; gap: 4px; }
115
+ .drn-head-title { font-size: 14px; font-weight: 600; }
116
+ .drn-head-intro { font-size: 12px; color: var(--dsw-alias-label-secondary); line-height: 1.5; }
117
+ .drn-group { border: 1px solid var(--dsw-alias-border-l1); border-radius: 10px; padding: 12px 14px; background: var(--dsw-alias-bg-layer-1); display: flex; flex-direction: column; gap: 12px; }
118
+ .drn-group-title { font-size: 12px; font-weight: 600; color: var(--dsw-alias-label-secondary); letter-spacing: .02em; }
119
+ .drn-row { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
120
+ .drn-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 180px; flex: 1 1 220px; }
121
+ .drn-label { font-size: 13px; }
122
+ .drn-hint { font-size: 11px; color: var(--dsw-alias-label-secondary); line-height: 1.45; }
123
+ .drn-control { flex: 0 1 260px; display: flex; justify-content: flex-end; }
124
+ .drn-input, .drn-select { width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; padding: 6px 8px; border-radius: 7px; border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); }
125
+ .drn-input:focus, .drn-select:focus { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: -1px; }
126
+ .drn-input[disabled], .drn-select[disabled] { opacity: .6; }
127
+ .drn-color { width: 56px; height: 30px; padding: 2px; border-radius: 7px; border: 1px solid var(--dsw-alias-border-l1); background: var(--dsw-alias-bg-base); }
128
+ .drn-switch { display: flex; align-items: center; gap: 8px; font-size: 13px; }
129
+ .drn-actions { display: flex; align-items: center; gap: 10px; }
130
+ .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); }
131
+ .drn-btn.primary { background: var(--dsw-alias-brand-primary); border-color: transparent; color: #fff; }
132
+ .drn-btn[disabled] { opacity: .5; cursor: default; }
133
+ .drn-msg { font-size: 12px; color: var(--dsw-alias-label-secondary); }
134
+ .drn-msg.error { color: var(--dsw-alias-state-error-primary); }
135
+ `
136
+
137
+ // 字段表:kind 决定控件类型,group 决定分组,缺省值来自宿主 config。
138
+ const FIELDS = [
139
+ { key: 'seconds', group: 'basic', kind: 'number' },
140
+ { key: 'position', group: 'basic', kind: 'select', options: ['br', 'center', 'tr'], optionLabels: ['positionBr', 'positionCenter', 'positionTr'] },
141
+ { key: 'sound', group: 'basic', kind: 'boolean' },
142
+ { key: 'cooldownMs', group: 'basic', kind: 'number' },
143
+ { key: 'doneAudio', group: 'audio', kind: 'text' },
144
+ { key: 'decideAudio', group: 'audio', kind: 'text' },
145
+ { key: 'rawAudio', group: 'audio', kind: 'text' },
146
+ { key: 'audioDir', group: 'audio', kind: 'text' },
147
+ { key: 'accentDone', group: 'look', kind: 'color' },
148
+ { key: 'accentDecide', group: 'look', kind: 'color' },
149
+ { key: 'accentRaw', group: 'look', kind: 'color' },
150
+ { key: 'hostMode', group: 'host', kind: 'select', options: ['script', 'exe'], optionLabels: ['hostModeScript', 'hostModeExe'] },
151
+ { key: 'scriptPath', group: 'host', kind: 'text' },
152
+ { key: 'powershellPath', group: 'host', kind: 'text' },
153
+ { key: 'clientDir', group: 'host', kind: 'text' },
154
+ ]
155
+
156
+ const HINTS = {
157
+ seconds: 'secondsHint',
158
+ sound: 'soundHint',
159
+ cooldownMs: 'cooldownHint',
160
+ doneAudio: 'audioHint',
161
+ audioDir: 'audioDirHint',
162
+ scriptPath: 'scriptPathHint',
163
+ }
164
+
165
+ const GROUPS = ['basic', 'audio', 'look', 'host']
166
+ const GROUP_LABELS = { basic: 'groupBasic', audio: 'groupAudio', look: 'groupLook', host: 'groupHost' }
167
+
168
+ function sameValue(a, b) {
169
+ return JSON.stringify(a) === JSON.stringify(b)
170
+ }
171
+
172
+ function ReminderConfigPanel(props) {
173
+ const t = props.t
174
+ const form = props.form
175
+ const state = form && form.state ? form.state : undefined
176
+ const values = (state && state.value) || {}
177
+ const writable = !!(state && state.writable)
178
+ const revision = state && state.revision
179
+ const [draft, setDraft] = React.useState(null)
180
+ const [busy, setBusy] = React.useState(false)
181
+ const [message, setMessage] = React.useState(null)
182
+
183
+ if (props.view === 'summary') {
184
+ const tr = typeof t === 'function' ? t : (key) => key
185
+ const posKey = values.position === 'center' ? 'positionCenter' : values.position === 'tr' ? 'positionTr' : 'positionBr'
186
+ const sound = values.sound === false ? tr('soundOff') : tr('soundOn')
187
+ return h('span', null, `${tr('summaryPrefix')}${tr(posKey)} · ${values.seconds === undefined ? 60 : values.seconds}${tr('secondsUnit')} · ${sound}`)
188
+ }
189
+
190
+ if (form === undefined || state === undefined) {
191
+ return h('div', { className: 'drn-panel' }, h('div', { className: 'drn-hint' }, typeof t === 'function' ? t('unavailable') : 'unavailable'))
192
+ }
193
+
194
+ const effective = draft === null ? values : Object.assign({}, values, draft)
195
+
196
+ function edit(key, raw, kind) {
197
+ let value = raw
198
+ if (kind === 'number') {
199
+ const n = Number(raw)
200
+ value = raw === '' || !Number.isFinite(n) ? raw : n
201
+ }
202
+ setMessage(null)
203
+ setDraft(Object.assign({}, draft || {}, { [key]: value }))
204
+ }
205
+
206
+ function changedOps() {
207
+ const ops = []
208
+ for (const field of FIELDS) {
209
+ const current = effective[field.key]
210
+ const saved = values[field.key]
211
+ if (sameValue(current, saved)) continue
212
+ ops.push({ op: 'set', path: [field.key], value: current === '' ? (field.kind === 'text' ? '' : current) : current })
213
+ }
214
+ return ops
215
+ }
216
+
217
+ const ops = changedOps()
218
+ const dirty = ops.length > 0
219
+
220
+ function save() {
221
+ if (!dirty || busy) return
222
+ setBusy(true)
223
+ setMessage(null)
224
+ Promise.resolve(form.mutate(ops, revision))
225
+ .then(() => {
226
+ setBusy(false)
227
+ setDraft(null)
228
+ setMessage({ ok: true, text: typeof t === 'function' ? t('saved') : 'saved' })
229
+ })
230
+ .catch((error) => {
231
+ setBusy(false)
232
+ const prefix = typeof t === 'function' ? t('failed') : 'failed: '
233
+ setMessage({ ok: false, text: prefix + String((error && error.message) || error) })
234
+ })
235
+ }
236
+
237
+ function control(field) {
238
+ const value = effective[field.key]
239
+ const disabled = !writable || busy
240
+ if (field.kind === 'boolean') {
241
+ return h(
242
+ 'label',
243
+ { className: 'drn-switch' },
244
+ h('input', { type: 'checkbox', checked: value !== false, disabled, onChange: (e) => edit(field.key, e.target.checked, 'boolean') }),
245
+ h('span', null, value !== false ? '✓' : '—'),
246
+ )
247
+ }
248
+ if (field.kind === 'select') {
249
+ return h(
250
+ 'select',
251
+ { className: 'drn-select', value: value === undefined ? '' : String(value), disabled, onChange: (e) => edit(field.key, e.target.value, 'select') },
252
+ field.options.map((option, index) =>
253
+ h('option', { key: option, value: option }, typeof t === 'function' ? t(field.optionLabels[index]) : option),
254
+ ),
255
+ )
256
+ }
257
+ if (field.kind === 'color') {
258
+ return h('input', {
259
+ className: 'drn-color',
260
+ type: 'color',
261
+ value: typeof value === 'string' && /^#[0-9a-fA-F]{6}$/.test(value) ? value : '#000000',
262
+ disabled,
263
+ onChange: (e) => edit(field.key, e.target.value, 'color'),
264
+ })
265
+ }
266
+ return h('input', {
267
+ className: 'drn-input',
268
+ type: field.kind === 'number' ? 'number' : 'text',
269
+ value: value === undefined || value === null ? '' : String(value),
270
+ placeholder: typeof t === 'function' ? t('empty') : '',
271
+ disabled,
272
+ onChange: (e) => edit(field.key, e.target.value, field.kind),
273
+ })
274
+ }
275
+
276
+ const groups = GROUPS.map((group) =>
277
+ h(
278
+ 'div',
279
+ { className: 'drn-group', key: group },
280
+ h('div', { className: 'drn-group-title' }, typeof t === 'function' ? t(GROUP_LABELS[group]) : group),
281
+ FIELDS.filter((field) => field.group === group).map((field) =>
282
+ h(
283
+ 'div',
284
+ { className: 'drn-row', key: field.key },
285
+ h(
286
+ 'div',
287
+ { className: 'drn-row-main' },
288
+ h('div', { className: 'drn-label' }, typeof t === 'function' ? t(field.key) : field.key),
289
+ HINTS[field.key] && typeof t === 'function'
290
+ ? h('div', { className: 'drn-hint' }, t(HINTS[field.key]))
291
+ : null,
292
+ ),
293
+ h('div', { className: 'drn-control' }, control(field)),
294
+ ),
295
+ ),
296
+ ),
297
+ )
298
+
299
+ return h(
300
+ 'div',
301
+ { className: 'drn-panel' },
302
+ h(
303
+ 'div',
304
+ { className: 'drn-head' },
305
+ h('div', { className: 'drn-head-title' }, typeof t === 'function' ? t('title') : 'Desktop reminder settings'),
306
+ h('div', { className: 'drn-head-intro' }, typeof t === 'function' ? t(writable ? 'intro' : 'readonly') : ''),
307
+ ),
308
+ groups,
309
+ h(
310
+ 'div',
311
+ { className: 'drn-actions' },
312
+ h(
313
+ 'button',
314
+ { type: 'button', className: 'drn-btn primary', disabled: !dirty || busy || !writable, onClick: save },
315
+ typeof t === 'function' ? t(busy ? 'saving' : 'save') : 'Save',
316
+ ),
317
+ h(
318
+ 'button',
319
+ { type: 'button', className: 'drn-btn', disabled: !dirty || busy, onClick: () => { setDraft(null); setMessage(null) } },
320
+ typeof t === 'function' ? t('reset') : 'Discard',
321
+ ),
322
+ message !== null
323
+ ? h('span', { className: 'drn-msg' + (message.ok ? '' : ' error') }, message.text)
324
+ : null,
325
+ ),
326
+ )
327
+ }
328
+
329
+ const name = 'dsh-reminder-notify'
330
+ const inject = ['slots', 'locale']
331
+
332
+ function apply(ctx) {
333
+ ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-reminder-notify: settings dictionaries')
334
+
335
+ ctx.effect(() => {
336
+ if (typeof document === 'undefined') return
337
+ const previous = document.getElementById('drn-panel-style')
338
+ if (previous !== null) return () => {}
339
+ const tag = document.createElement('style')
340
+ tag.id = 'drn-panel-style'
341
+ tag.dataset.plugin = NS
342
+ tag.textContent = CSS
343
+ document.head.appendChild(tag)
344
+ return () => {
345
+ tag.remove()
346
+ }
347
+ }, 'dsh-reminder-notify: panel styles')
348
+
349
+ ctx.slots.inject('plugins.bundle.config', () =>
350
+ ctx.slots.register(
351
+ {
352
+ name: 'plugins.bundle.config',
353
+ key: NS,
354
+ locale: NS,
355
+ inject: () => ({ t: ctx.locale.bind(NS) }),
356
+ },
357
+ ReminderConfigPanel,
358
+ ),
359
+ )
360
+ }
361
+
362
+ return { name, inject, apply }
363
+ },
364
+ })
package/index.js CHANGED
@@ -17,6 +17,33 @@ import { fileURLToPath } from 'node:url'
17
17
  export const name = 'dsh-reminder-notify'
18
18
  export const inject = ['tools']
19
19
 
20
+ // schemastery 由 dsh 安装自带(profile 的 node_modules 里就有),所以包里不声明依赖。
21
+ // 用动态 import 兜底:万一在纯裸仓库里跑(没有 dsh 的依赖树),插件本体仍可工作,
22
+ // 只是插件页没有 schema 表单 —— 不要让一个 UI 依赖把提醒功能整个弄挂。
23
+ const z = await import('@deepseek-ai/schemastery')
24
+ .then((mod) => mod.default ?? mod)
25
+ .catch(() => null)
26
+
27
+ // 插件页的设置表单由这份 schema 渲染(client.js 再在上面做分组面板)。
28
+ // 每一项的默认值与 settingsOf() 里的兜底一致:空字符串表示「用包内资源」。
29
+ export const Config = z === null ? undefined : z.object({
30
+ hostMode: z.union(['script', 'exe']).default('script').description('宿主模式:script = 包内 PowerShell 脚本(默认),exe = 老的客户端 exe'),
31
+ scriptPath: z.string().default('').description('脚本宿主路径,留空 = 包内 host/ReminderHost.ps1'),
32
+ powershellPath: z.string().default('powershell.exe').description('调 PowerShell 用的可执行文件'),
33
+ clientDir: z.string().default('').description('exe 模式下的客户端目录,留空 = 包内 assets/'),
34
+ audioDir: z.string().default('').description('提示音目录,留空 = 包内 assets/提示音导入/'),
35
+ seconds: z.number().min(2).max(600).step(1).default(60).description('弹窗停留秒数(2–600)'),
36
+ position: z.union(['br', 'center', 'tr']).default('br').description('弹窗位置:br 右下、center 居中、tr 右上'),
37
+ sound: z.boolean().default(true).description('是否播放提示音'),
38
+ doneAudio: z.string().default('完成提醒语音.wav').description('done 档位的提示音文件名(在提示音目录下)'),
39
+ decideAudio: z.string().default('需要你来决定.wav').description('decide 档位的提示音文件名'),
40
+ rawAudio: z.string().default('').description('raw 档位的提示音文件名,留空 = 静音'),
41
+ accentDone: z.string().default('#2ECC71').description('done 档位卡片强调色(#RRGGBB)'),
42
+ accentDecide: z.string().default('#F5A623').description('decide 档位卡片强调色'),
43
+ accentRaw: z.string().default('#4C8DFF').description('raw 档位卡片强调色'),
44
+ cooldownMs: z.number().min(0).step(100).default(1500).description('同档位提醒的最小间隔(毫秒)'),
45
+ })
46
+
20
47
  const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)))
21
48
  const BUNDLED_HOST_SCRIPT = path.join(PACKAGE_ROOT, 'host', 'ReminderHost.ps1')
22
49
  const BUNDLED_CLIENT_DIR = path.join(PACKAGE_ROOT, 'assets')
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "dsh-reminder-notify",
3
- "version": "0.2.2",
3
+ "version": "0.3.1",
4
4
  "description": "DSH 桌面提醒插件:把「完成/需要决定」提醒变成 notify_user 工具(浮动卡片 + 提示音,不抢焦点,纯 PowerShell 源码宿主,仓库零 exe)",
5
5
  "author": "Jiangshuaiye1203",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "exports": {
9
9
  ".": "./index.js",
10
+ "./client": "./client.js",
10
11
  "./icon": "./icon.svg",
11
12
  "./locale/*.json": "./locale/*.json",
12
13
  "./package.json": "./package.json"
@@ -14,6 +15,7 @@
14
15
  "files": [
15
16
  "index.js",
16
17
  "cordis.patch.yml",
18
+ "client.js",
17
19
  "host",
18
20
  "assets",
19
21
  "locale",
@@ -42,6 +44,13 @@
42
44
  "dsh": {
43
45
  "bundle": {
44
46
  "patch": "./cordis.patch.yml"
47
+ },
48
+ "client": {
49
+ "platform": "web",
50
+ "inject": [
51
+ "@deepseek-ai/dsh-client-locale",
52
+ "@deepseek-ai/dsh-client-ui-settings-plugins"
53
+ ]
45
54
  }
46
55
  },
47
56
  "repository": {
@@ -48,8 +48,8 @@
48
48
  },
49
49
  "versions": [
50
50
  {
51
- "version": "0.2.2",
52
- "publishTimestamp": 1795054082,
51
+ "version": "0.3.0",
52
+ "publishTimestamp": 1795058390,
53
53
  "source": {
54
54
  "type": "npm"
55
55
  },