dsh-quick-phrases 0.3.5 → 0.4.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/README.md +21 -3
- package/client.js +263 -13
- package/docs/ARCHITECTURE.md +22 -3
- package/docs/DETAIL.en.md +17 -3
- package/docs/DETAIL.md +18 -4
- package/docs/images/README.md +32 -0
- package/docs/images/above-composer-dark.png +0 -0
- package/docs/images/folded-dark.png +0 -0
- package/docs/images/manager-dark.png +0 -0
- package/docs/images/manager-light.png +0 -0
- package/docs/images/row-dark.png +0 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
- **一排短语按钮**:显示名称与发送内容分离,默认四条:继续 / 提交 / 推送 / 发版。
|
|
19
19
|
- **点按行为可选**:默认「直接发送」——输入框为空时一次点按就发出;输入框里已有文字或附件时,任何模式都改为插到光标处,不会覆盖正在写的内容。
|
|
20
20
|
- **显示位置可选**:输入框下方(默认)、输入框上方、工具行右侧,切换即时生效。
|
|
21
|
+
- **可以收起**:行尾一个「收起」动作;也可以让输入框一有内容就自动收起(默认),整排缩成一个小胶囊,点一下临时展开,不挡住正在写的字。
|
|
22
|
+
- **单条短语可隐藏**:管理页每张卡片有一个眼睛开关,隐藏后这条按钮从短语行消失,卡片仍留在管理页并标注「已隐藏」。
|
|
21
23
|
- **管理页**:拖动手柄排序、直接在卡片上改名、实时按钮预览与字数、两步确认删除、一键恢复默认。
|
|
22
24
|
- **零依赖**:纯前端一个 `client.js`,不联网、不读写文件、不引入 npm 包,数据只存在本机 `localStorage`。
|
|
23
25
|
|
|
@@ -63,27 +65,43 @@ Plugins → Add plugin → 选择本仓库目录;或让 DSH 里的 agent 执
|
|
|
63
65
|
|
|
64
66
|
### 管理页
|
|
65
67
|
|
|
66
|
-
设置 →
|
|
68
|
+
设置 → **快捷短语**:上面四项决定位置、点按行为、短语行是否显示、以及输入框有内容时怎么收起;下面一条短语一张卡片。
|
|
67
69
|
|
|
68
70
|

|
|
69
71
|
|
|
70
72
|
- 拖动左侧 `⠿` 手柄排序,或用 `↑` / `↓` 一格一格挪;列表顺序就是按钮的从左到右顺序。
|
|
71
73
|
- 卡片顶部那行是**显示名称**,直接点进去改;下面大框是**发送内容**。
|
|
72
74
|
- 卡片底部实时显示按钮预览和字数,名称太长一眼就能看出来。
|
|
75
|
+
- 每张卡片右上角的**眼睛**开关这条短语的显隐:关掉后按钮从短语行消失,卡片留在管理页并标上「已隐藏」,再点一次恢复。
|
|
73
76
|
- `✕` 第一次只进入「确认」态(4 秒后自动撤回),再点一次才真正删除。
|
|
74
77
|
- **新增短语**会追加空卡片并聚焦名称;**恢复默认**在左侧,点一次进入确认态,再点一次恢复内置四条。
|
|
75
78
|
|
|
76
79
|
英文界面同样可用(跟随 DSH 界面语言)。
|
|
77
80
|
|
|
81
|
+
### 收起与隐藏
|
|
82
|
+
|
|
83
|
+
短语行占地方,但不该挡着打字。两种收起方式:
|
|
84
|
+
|
|
85
|
+
- 点行尾的 **收起**(`收起 ▾`)—— 立刻收成一个小胶囊,再点胶囊临时展开;
|
|
86
|
+
- 设置里把「输入框有内容时」保持默认的 **自动收起**:输入框里一有文字或附件,整排自动缩成胶囊;也可以改成「保持显示」。
|
|
87
|
+
|
|
88
|
+
收起后只留一个小胶囊 `▸ 快捷短语`,点一下就能展开;带草稿时展开点按钮仍然插到光标处,不会覆盖你写的内容。
|
|
89
|
+
|
|
90
|
+

|
|
91
|
+
|
|
92
|
+
想彻底不看见整排,把设置里的「显示短语行」开关关掉即可,效果和收起一样;单条短语则在管理页用眼睛开关隐藏,短语行的从左到右顺序与卡片顺序保持一致。
|
|
93
|
+
|
|
78
94
|
## 数据与隐私
|
|
79
95
|
|
|
80
|
-
|
|
96
|
+
短语、位置、点按行为、收起状态与自动收起选项分别存在 `localStorage` 的五个键里:
|
|
81
97
|
|
|
82
98
|
| 键 | 内容 |
|
|
83
99
|
| --- | --- |
|
|
84
|
-
| `dsh.quick-phrases.v1` | 短语列表(`id` / `label` / `text`) |
|
|
100
|
+
| `dsh.quick-phrases.v1` | 短语列表(`id` / `label` / `text` / `hidden`) |
|
|
85
101
|
| `dsh.quick-phrases.placement.v1` | 显示位置 |
|
|
86
102
|
| `dsh.quick-phrases.click.v1` | 点按行为 |
|
|
103
|
+
| `dsh.quick-phrases.collapsed.v1` | 整排是否收起(`1` / `0`) |
|
|
104
|
+
| `dsh.quick-phrases.autohide.v1` | 输入框有内容时收起还是保持显示 |
|
|
87
105
|
|
|
88
106
|
按 DSH Web 端的站点存储隔离;换机器或清空站点数据会丢。插件没有网络请求、没有 `eval`、不读写文件,也不向 Host 注册任何服务。
|
|
89
107
|
|
package/client.js
CHANGED
|
@@ -27,6 +27,8 @@ window.__ModuleLoader__.load({
|
|
|
27
27
|
var STORAGE_KEY = 'dsh.quick-phrases.v1'
|
|
28
28
|
var PLACEMENT_KEY = 'dsh.quick-phrases.placement.v1'
|
|
29
29
|
var CLICK_KEY = 'dsh.quick-phrases.click.v1'
|
|
30
|
+
var COLLAPSE_KEY = 'dsh.quick-phrases.collapsed.v1'
|
|
31
|
+
var AUTOHIDE_KEY = 'dsh.quick-phrases.autohide.v1'
|
|
30
32
|
var SECTION_ID = 'quick-phrases'
|
|
31
33
|
var DOCK_ORDER = 5
|
|
32
34
|
var SECTION_ORDER = 26
|
|
@@ -55,13 +57,25 @@ window.__ModuleLoader__.load({
|
|
|
55
57
|
var CLICK_MODES = ['send', 'fill']
|
|
56
58
|
var DEFAULT_CLICK = 'send'
|
|
57
59
|
|
|
60
|
+
/**
|
|
61
|
+
* What happens to the row while the composer already holds text or files.
|
|
62
|
+
* `fold` pulls it down to one small pill (so a draft can still take a phrase
|
|
63
|
+
* at the caret after one click), `keep` leaves the whole row out.
|
|
64
|
+
*/
|
|
65
|
+
var AUTO_HIDE_MODES = ['fold', 'keep']
|
|
66
|
+
var DEFAULT_AUTO_HIDE = 'fold'
|
|
67
|
+
|
|
58
68
|
var DICTS = {
|
|
59
69
|
zh: {
|
|
60
70
|
'section.title': '快捷短语',
|
|
61
|
-
'section.description': '
|
|
71
|
+
'section.description': '在输入框附近放一排短语按钮。按钮上显示的是「显示名称」,发送内容单独编辑,两者可以完全不同。下面的设置决定它出现在哪里、点一下会发生什么,以及什么时候收起。',
|
|
62
72
|
'dock.manage': '管理',
|
|
63
73
|
'dock.openFailed': '请在「设置 — 快捷短语」中管理',
|
|
64
74
|
'dock.tooltip': '写入输入框',
|
|
75
|
+
'dock.collapse': '收起',
|
|
76
|
+
'dock.collapseHint': '收起这一排短语,只留一个小胶囊',
|
|
77
|
+
'dock.expand': '快捷短语',
|
|
78
|
+
'dock.expandHint': '展开快捷短语',
|
|
65
79
|
'manager.add': '新增短语',
|
|
66
80
|
'manager.phrases': '短语',
|
|
67
81
|
'manager.count': '{n} 条',
|
|
@@ -85,6 +99,15 @@ window.__ModuleLoader__.load({
|
|
|
85
99
|
'manager.clickSend': '直接发送',
|
|
86
100
|
'manager.clickInsert': '填入输入框',
|
|
87
101
|
'manager.clickHint': '「直接发送」在输入框为空时一次点按就发出这条短语;输入框里已有文字或附件时会改为插到光标处,不会覆盖你正在写的内容。',
|
|
102
|
+
'manager.visible': '显示短语行',
|
|
103
|
+
'manager.visibleHint': '关掉后输入框旁只留一个小胶囊,点一下就能重新展开。',
|
|
104
|
+
'manager.autoHide': '输入框有内容时',
|
|
105
|
+
'manager.autoHideFold': '自动收起',
|
|
106
|
+
'manager.autoHideKeep': '保持显示',
|
|
107
|
+
'manager.autoHideHint': '输入框里已有文字或附件时把短语行收成一个小胶囊;点胶囊还能临时展开,不挡正在写的内容。',
|
|
108
|
+
'manager.hide': '隐藏这条短语',
|
|
109
|
+
'manager.show': '显示这条短语',
|
|
110
|
+
'manager.hiddenBadge': '已隐藏',
|
|
88
111
|
'manager.label': '显示名称',
|
|
89
112
|
'manager.text': '发送内容',
|
|
90
113
|
'manager.labelPlaceholder': '按钮上显示的文字,例如:提交',
|
|
@@ -104,10 +127,14 @@ window.__ModuleLoader__.load({
|
|
|
104
127
|
},
|
|
105
128
|
en: {
|
|
106
129
|
'section.title': 'Quick phrases',
|
|
107
|
-
'section.description': 'A row of phrase chips next to the composer. A chip shows its display name while the text it inserts is edited separately. The
|
|
130
|
+
'section.description': 'A row of phrase chips next to the composer. A chip shows its display name while the text it inserts is edited separately. The options below decide where it lives, what a click does, and when it folds away.',
|
|
108
131
|
'dock.manage': 'Manage',
|
|
109
132
|
'dock.openFailed': 'Manage them in Settings — Quick phrases',
|
|
110
133
|
'dock.tooltip': 'Insert into the composer',
|
|
134
|
+
'dock.collapse': 'Hide',
|
|
135
|
+
'dock.collapseHint': 'Fold the row into a small pill',
|
|
136
|
+
'dock.expand': 'Quick phrases',
|
|
137
|
+
'dock.expandHint': 'Show the quick phrases',
|
|
111
138
|
'manager.add': 'Add phrase',
|
|
112
139
|
'manager.phrases': 'Phrases',
|
|
113
140
|
'manager.count': '{n}',
|
|
@@ -131,6 +158,15 @@ window.__ModuleLoader__.load({
|
|
|
131
158
|
'manager.clickSend': 'Send right away',
|
|
132
159
|
'manager.clickInsert': 'Fill the composer',
|
|
133
160
|
'manager.clickHint': '“Send right away” fires the phrase with one click while the composer is empty; when it already holds text or attachments the phrase is inserted at the caret instead, so nothing you were writing is lost.',
|
|
161
|
+
'manager.visible': 'Show the phrase row',
|
|
162
|
+
'manager.visibleHint': 'When off, only a small pill stays next to the composer; click it to bring the row back.',
|
|
163
|
+
'manager.autoHide': 'When the composer has text',
|
|
164
|
+
'manager.autoHideFold': 'Fold automatically',
|
|
165
|
+
'manager.autoHideKeep': 'Keep it visible',
|
|
166
|
+
'manager.autoHideHint': 'Folds the row into a small pill while the composer holds text or attachments; click the pill to expand it for the current draft.',
|
|
167
|
+
'manager.hide': 'Hide this phrase',
|
|
168
|
+
'manager.show': 'Show this phrase',
|
|
169
|
+
'manager.hiddenBadge': 'Hidden',
|
|
134
170
|
'manager.label': 'Display name',
|
|
135
171
|
'manager.text': 'Sent text',
|
|
136
172
|
'manager.labelPlaceholder': 'Chip caption, e.g. Commit',
|
|
@@ -176,7 +212,7 @@ window.__ModuleLoader__.load({
|
|
|
176
212
|
var text = typeof item.text === 'string' ? item.text : ''
|
|
177
213
|
if (label === '' && text === '') return null
|
|
178
214
|
var id = typeof item.id === 'string' && item.id !== '' ? item.id : 'p' + index
|
|
179
|
-
return { id: id, label: label, text: text }
|
|
215
|
+
return { id: id, label: label, text: text, hidden: item.hidden === true }
|
|
180
216
|
}
|
|
181
217
|
|
|
182
218
|
function readStorage() {
|
|
@@ -217,7 +253,7 @@ window.__ModuleLoader__.load({
|
|
|
217
253
|
|
|
218
254
|
function seededPhrases(t) {
|
|
219
255
|
return DEFAULT_SPECS.map(function (spec) {
|
|
220
|
-
return { id: spec.id, label: t(spec.label), text: t(spec.text) }
|
|
256
|
+
return { id: spec.id, label: t(spec.label), text: t(spec.text), hidden: false }
|
|
221
257
|
})
|
|
222
258
|
}
|
|
223
259
|
|
|
@@ -245,6 +281,7 @@ window.__ModuleLoader__.load({
|
|
|
245
281
|
id: current.id,
|
|
246
282
|
label: typeof patch.label === 'string' ? patch.label : current.label,
|
|
247
283
|
text: typeof patch.text === 'string' ? patch.text : current.text,
|
|
284
|
+
hidden: typeof patch.hidden === 'boolean' ? patch.hidden : current.hidden === true,
|
|
248
285
|
}
|
|
249
286
|
replacePhrases(next)
|
|
250
287
|
}
|
|
@@ -252,7 +289,7 @@ window.__ModuleLoader__.load({
|
|
|
252
289
|
function insertPhrase() {
|
|
253
290
|
if (state === null) return null
|
|
254
291
|
var id = uniqueId()
|
|
255
|
-
replacePhrases(state.concat([{ id: id, label: '', text: '' }]))
|
|
292
|
+
replacePhrases(state.concat([{ id: id, label: '', text: '', hidden: false }]))
|
|
256
293
|
return id
|
|
257
294
|
}
|
|
258
295
|
|
|
@@ -433,6 +470,93 @@ window.__ModuleLoader__.load({
|
|
|
433
470
|
return ensureClickMode()
|
|
434
471
|
}
|
|
435
472
|
|
|
473
|
+
/* ------------------------------------------------------------------ *
|
|
474
|
+
* Visibility: the row folds into a pill, and the manager can turn it off.
|
|
475
|
+
* ------------------------------------------------------------------ */
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* One localStorage-backed string toggle shared by the dock and the manager.
|
|
479
|
+
* `values` is the whitelist, so a hand-edited storage entry can never put a
|
|
480
|
+
* component into a state it does not know how to render.
|
|
481
|
+
*/
|
|
482
|
+
function makeEnumStore(key, values, fallback, label) {
|
|
483
|
+
var current = null
|
|
484
|
+
|
|
485
|
+
function isValue(value) {
|
|
486
|
+
return values.indexOf(value) >= 0
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function read() {
|
|
490
|
+
try {
|
|
491
|
+
var raw = window.localStorage.getItem(key)
|
|
492
|
+
if (raw !== null && isValue(raw)) return raw
|
|
493
|
+
} catch (error) {
|
|
494
|
+
console.warn('[quick-phrases] could not read the stored ' + label, error)
|
|
495
|
+
}
|
|
496
|
+
return fallback
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function ensure() {
|
|
500
|
+
if (current !== null) return current
|
|
501
|
+
current = read()
|
|
502
|
+
return current
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function set(next) {
|
|
506
|
+
if (!isValue(next) || next === ensure()) return
|
|
507
|
+
current = next
|
|
508
|
+
try {
|
|
509
|
+
window.localStorage.setItem(key, next)
|
|
510
|
+
} catch (error) {
|
|
511
|
+
console.warn('[quick-phrases] could not persist the ' + label, error)
|
|
512
|
+
}
|
|
513
|
+
emit()
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/** Subscribes a component to this toggle and returns the current value. */
|
|
517
|
+
function use() {
|
|
518
|
+
var tick = React.useState(0)
|
|
519
|
+
var setTick = tick[1]
|
|
520
|
+
React.useEffect(function () {
|
|
521
|
+
var unsubscribe = subscribe(function () {
|
|
522
|
+
setTick(function (value) { return value + 1 })
|
|
523
|
+
})
|
|
524
|
+
function onStorage(event) {
|
|
525
|
+
if (event.key !== key) return
|
|
526
|
+
current = read()
|
|
527
|
+
setTick(function (value) { return value + 1 })
|
|
528
|
+
}
|
|
529
|
+
window.addEventListener('storage', onStorage)
|
|
530
|
+
return function () {
|
|
531
|
+
unsubscribe()
|
|
532
|
+
window.removeEventListener('storage', onStorage)
|
|
533
|
+
}
|
|
534
|
+
}, [])
|
|
535
|
+
return ensure()
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
return { read: read, set: set, use: use }
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
var collapseStore = makeEnumStore(COLLAPSE_KEY, ['0', '1'], '0', 'collapsed state')
|
|
542
|
+
var autoHideStore = makeEnumStore(AUTOHIDE_KEY, AUTO_HIDE_MODES, DEFAULT_AUTO_HIDE, 'auto-hide mode')
|
|
543
|
+
|
|
544
|
+
function useCollapsed() {
|
|
545
|
+
return collapseStore.use() === '1'
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function setCollapsed(value) {
|
|
549
|
+
collapseStore.set(value ? '1' : '0')
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
function useAutoHide() {
|
|
553
|
+
return autoHideStore.use()
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function setAutoHide(value) {
|
|
557
|
+
autoHideStore.set(value)
|
|
558
|
+
}
|
|
559
|
+
|
|
436
560
|
/* ------------------------------------------------------------------ *
|
|
437
561
|
* Styles: local to each component, removed on unmount.
|
|
438
562
|
* ------------------------------------------------------------------ */
|
|
@@ -458,6 +582,11 @@ window.__ModuleLoader__.load({
|
|
|
458
582
|
'.dqp-chip:active{background:var(--dsw-alias-interactive-bg-hover-solid,rgba(255,255,255,.12))}' +
|
|
459
583
|
'.dqp-chip:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-brand-primary,#4c6fff));outline-offset:2px}' +
|
|
460
584
|
'.dqp-chip-manage{color:var(--dsw-alias-label-tertiary,#9a9a9a);border-style:dashed;background:transparent}' +
|
|
585
|
+
'.dqp-chip-collapse{color:var(--dsw-alias-label-caption,#7d7d7d);border-style:dashed;background:transparent}' +
|
|
586
|
+
'.dqp-chip-collapse:hover{color:var(--dsw-alias-label-secondary,#b9b9b9)}' +
|
|
587
|
+
'.dqp-pill{gap:4px;color:var(--dsw-alias-label-tertiary,#9a9a9a);border-style:dashed;background:transparent}' +
|
|
588
|
+
'.dqp-pill:hover{color:var(--dsw-alias-label-primary,#eee)}' +
|
|
589
|
+
'.dqp-caret{font-size:9px;line-height:1;opacity:.75}' +
|
|
461
590
|
'.dqp-hint{color:var(--dsw-alias-state-warn-primary,#e0a33a);white-space:nowrap}'
|
|
462
591
|
|
|
463
592
|
var MANAGER_CSS =
|
|
@@ -486,6 +615,21 @@ window.__ModuleLoader__.load({
|
|
|
486
615
|
'color:var(--dsw-alias-label-primary,#eee);font:inherit;font-size:12px;line-height:1;appearance:none;-webkit-appearance:none;cursor:pointer}' +
|
|
487
616
|
'.dqp-select:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.08))}' +
|
|
488
617
|
'.dqp-select:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-brand-primary,#4c6fff));outline-offset:1px}' +
|
|
618
|
+
'.dqp-switch{box-sizing:border-box;position:relative;flex:0 0 auto;width:36px;height:20px;padding:0;border:.5px solid var(--dsw-alias-border-l2,#494949);' +
|
|
619
|
+
'border-radius:999px;background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.06));cursor:pointer;' +
|
|
620
|
+
'transition:background-color .15s ease,border-color .15s ease}' +
|
|
621
|
+
'.dqp-switch:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(255,255,255,.1))}' +
|
|
622
|
+
'.dqp-switch:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-brand-primary,#4c6fff));outline-offset:2px}' +
|
|
623
|
+
'.dqp-switch-thumb{position:absolute;top:2px;left:2px;width:14px;height:14px;border-radius:50%;' +
|
|
624
|
+
'background:var(--dsw-alias-label-tertiary,#9a9a9a);transition:transform .15s ease,background-color .15s ease}' +
|
|
625
|
+
'.dqp-switch-on{border-color:transparent;background:var(--dsw-alias-button-primary-fill,#4c6fff)}' +
|
|
626
|
+
'.dqp-switch-on:hover{background:var(--dsw-alias-button-primary-hover,#3f5fe0)}' +
|
|
627
|
+
'.dqp-switch-on .dqp-switch-thumb{transform:translateX(16px);background:var(--dsw-alias-label-primary-foreground,#fff)}' +
|
|
628
|
+
'.dqp-row-muted .dqp-body{opacity:.55}' +
|
|
629
|
+
'.dqp-badge-hidden{margin-left:2px;border:.5px solid var(--dsw-alias-border-l2,#494949);' +
|
|
630
|
+
'background:transparent;color:var(--dsw-alias-label-secondary,#b9b9b9)}' +
|
|
631
|
+
'.dqp-eye-off{color:var(--dsw-alias-label-caption,#7d7d7d)}' +
|
|
632
|
+
'.dqp-eye-off:hover:not(:disabled){color:var(--dsw-alias-label-primary,#eee)}' +
|
|
489
633
|
'.dqp-section{display:flex;flex-direction:column;gap:10px}' +
|
|
490
634
|
'.dqp-section-head{display:flex;align-items:center;flex-wrap:wrap;gap:8px}' +
|
|
491
635
|
'.dqp-section-title{flex:1 1 auto;margin:0;font-size:13px;line-height:20px;font-weight:600}' +
|
|
@@ -610,10 +754,25 @@ window.__ModuleLoader__.load({
|
|
|
610
754
|
// hook order never depends on the phrase list or on the placement.
|
|
611
755
|
var draft = typeof props.useInput === 'function' ? props.useInput(draftOf) : ''
|
|
612
756
|
var attachments = typeof props.useInput === 'function' ? props.useInput(attachmentCountOf) : 0
|
|
757
|
+
var collapsed = useCollapsed()
|
|
758
|
+
var autoHide = useAutoHide()
|
|
759
|
+
var peekState = React.useState(false)
|
|
760
|
+
var peeked = peekState[0]
|
|
761
|
+
var setPeeked = peekState[1]
|
|
613
762
|
var showHint = React.useState(false)
|
|
614
763
|
var setShowHint = showHint[1]
|
|
615
764
|
var hintTimer = React.useRef(null)
|
|
616
|
-
var
|
|
765
|
+
var hasDraft = draft.trim() !== '' || attachments > 0
|
|
766
|
+
var folded = collapsed || (autoHide === 'fold' && hasDraft && !peeked)
|
|
767
|
+
var usable = phrases.filter(function (phrase) {
|
|
768
|
+
return phrase.text.trim() !== '' && phrase.hidden !== true
|
|
769
|
+
})
|
|
770
|
+
|
|
771
|
+
// A peek only covers the draft that asked for it: once the composer is
|
|
772
|
+
// empty again the row is back to its normal width on its own.
|
|
773
|
+
React.useEffect(function () {
|
|
774
|
+
if (!hasDraft) setPeeked(false)
|
|
775
|
+
}, [hasDraft])
|
|
617
776
|
|
|
618
777
|
React.useEffect(function () {
|
|
619
778
|
return function () {
|
|
@@ -677,9 +836,28 @@ window.__ModuleLoader__.load({
|
|
|
677
836
|
if (spec.compact) rowClass += ' dqp-dock-tool'
|
|
678
837
|
if (spec.inset) rowClass += ' dqp-dock-inset'
|
|
679
838
|
|
|
680
|
-
var children = [
|
|
681
|
-
|
|
682
|
-
|
|
839
|
+
var children = [h('style', { key: 'style' }, DOCK_CSS)]
|
|
840
|
+
if (folded) {
|
|
841
|
+
// One pill keeps the caret-insertion path reachable: opening it is a
|
|
842
|
+
// single click that does not touch the draft being written.
|
|
843
|
+
children.push(h('div', { key: 'row', className: rowClass },
|
|
844
|
+
h('button', {
|
|
845
|
+
key: 'expand',
|
|
846
|
+
type: 'button',
|
|
847
|
+
className: 'dqp-chip dqp-pill',
|
|
848
|
+
title: t('dock.expandHint'),
|
|
849
|
+
'aria-label': t('dock.expandHint'),
|
|
850
|
+
'aria-expanded': false,
|
|
851
|
+
onClick: function () {
|
|
852
|
+
setPeeked(true)
|
|
853
|
+
setCollapsed(false)
|
|
854
|
+
},
|
|
855
|
+
},
|
|
856
|
+
h('span', { className: 'dqp-caret', 'aria-hidden': true }, '\u25b8'),
|
|
857
|
+
t('dock.expand')),
|
|
858
|
+
))
|
|
859
|
+
} else {
|
|
860
|
+
children.push(h('div', { key: 'row', className: rowClass },
|
|
683
861
|
usable.map(function (phrase, index) {
|
|
684
862
|
return h('button', {
|
|
685
863
|
key: phrase.id + ':' + index,
|
|
@@ -690,14 +868,28 @@ window.__ModuleLoader__.load({
|
|
|
690
868
|
onClick: function () { activate(phrase) },
|
|
691
869
|
}, phraseCaption(phrase))
|
|
692
870
|
}),
|
|
871
|
+
h('button', {
|
|
872
|
+
key: 'collapse',
|
|
873
|
+
type: 'button',
|
|
874
|
+
className: 'dqp-chip dqp-chip-collapse',
|
|
875
|
+
title: t('dock.collapseHint'),
|
|
876
|
+
'aria-label': t('dock.collapseHint'),
|
|
877
|
+
'aria-expanded': true,
|
|
878
|
+
onClick: function () {
|
|
879
|
+
setPeeked(false)
|
|
880
|
+
setCollapsed(true)
|
|
881
|
+
},
|
|
882
|
+
},
|
|
883
|
+
t('dock.collapse'),
|
|
884
|
+
h('span', { className: 'dqp-caret', 'aria-hidden': true }, '\u25be')),
|
|
693
885
|
h('button', {
|
|
694
886
|
key: 'manage',
|
|
695
887
|
type: 'button',
|
|
696
888
|
className: 'dqp-chip dqp-chip-manage',
|
|
697
889
|
onClick: handleManage,
|
|
698
890
|
}, t('dock.manage')),
|
|
699
|
-
)
|
|
700
|
-
|
|
891
|
+
))
|
|
892
|
+
}
|
|
701
893
|
if (showHint[0]) {
|
|
702
894
|
children.push(h('div', { key: 'hint', className: 'dqp-hint' }, t('dock.openFailed')))
|
|
703
895
|
}
|
|
@@ -714,6 +906,8 @@ window.__ModuleLoader__.load({
|
|
|
714
906
|
var phrases = usePhrases(t)
|
|
715
907
|
var placementNow = usePlacement()
|
|
716
908
|
var clickNow = useClickMode()
|
|
909
|
+
var collapsed = useCollapsed()
|
|
910
|
+
var autoHideNow = useAutoHide()
|
|
717
911
|
|
|
718
912
|
var resetState = React.useState(false)
|
|
719
913
|
var isResetting = resetState[0]
|
|
@@ -774,6 +968,7 @@ window.__ModuleLoader__.load({
|
|
|
774
968
|
var deleting = pendingDelete === phrase.id
|
|
775
969
|
var isDragging = dragFrom === index
|
|
776
970
|
var isDropTarget = dragOver === index && dragFrom !== null && dragFrom !== index
|
|
971
|
+
var isHidden = phrase.hidden === true
|
|
777
972
|
// Rough height hint: one row per line, plus one per ~72 characters.
|
|
778
973
|
var textRows = phrase.text === ''
|
|
779
974
|
? 2
|
|
@@ -781,7 +976,8 @@ window.__ModuleLoader__.load({
|
|
|
781
976
|
|
|
782
977
|
return h('div', {
|
|
783
978
|
key: phrase.id,
|
|
784
|
-
className: 'dqp-row' + (isDragging ? ' dqp-row-dragging' : '') + (isDropTarget ? ' dqp-row-over' : '')
|
|
979
|
+
className: 'dqp-row' + (isDragging ? ' dqp-row-dragging' : '') + (isDropTarget ? ' dqp-row-over' : '') +
|
|
980
|
+
(isHidden ? ' dqp-row-muted' : ''),
|
|
785
981
|
onDragOver: function (event) {
|
|
786
982
|
event.preventDefault()
|
|
787
983
|
if (dragFrom !== null) setDragOver(index)
|
|
@@ -824,7 +1020,26 @@ window.__ModuleLoader__.load({
|
|
|
824
1020
|
autoFocus: focusId === phrase.id,
|
|
825
1021
|
onChange: function (event) { updatePhrase(index, { label: event.target.value }) },
|
|
826
1022
|
}),
|
|
1023
|
+
isHidden
|
|
1024
|
+
? h('span', { className: 'dqp-badge dqp-badge-hidden' }, t('manager.hiddenBadge'))
|
|
1025
|
+
: null,
|
|
827
1026
|
h('div', { className: 'dqp-row-actions' },
|
|
1027
|
+
h('button', {
|
|
1028
|
+
type: 'button',
|
|
1029
|
+
className: 'dqp-icon dqp-eye' + (isHidden ? ' dqp-eye-off' : ''),
|
|
1030
|
+
title: isHidden ? t('manager.show') : t('manager.hide'),
|
|
1031
|
+
'aria-label': isHidden ? t('manager.show') : t('manager.hide'),
|
|
1032
|
+
'aria-pressed': isHidden,
|
|
1033
|
+
onClick: function () { updatePhrase(index, { hidden: !isHidden }) },
|
|
1034
|
+
},
|
|
1035
|
+
isHidden
|
|
1036
|
+
? h('svg', { width: 14, height: 14, viewBox: '0 0 24 24', fill: 'none', 'aria-hidden': true },
|
|
1037
|
+
h('path', { d: 'M2 12s3.6-6 10-6 10 6 10 6-3.6 6-10 6S2 12 2 12Z', stroke: 'currentColor', strokeWidth: 1.7 }),
|
|
1038
|
+
h('circle', { cx: 12, cy: 12, r: 2.6, stroke: 'currentColor', strokeWidth: 1.7 }),
|
|
1039
|
+
h('path', { d: 'M4 20 20 4', stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round' }))
|
|
1040
|
+
: h('svg', { width: 14, height: 14, viewBox: '0 0 24 24', fill: 'none', 'aria-hidden': true },
|
|
1041
|
+
h('path', { d: 'M2 12s3.6-6 10-6 10 6 10 6-3.6 6-10 6S2 12 2 12Z', stroke: 'currentColor', strokeWidth: 1.7 }),
|
|
1042
|
+
h('circle', { cx: 12, cy: 12, r: 2.6, stroke: 'currentColor', strokeWidth: 1.7 }))),
|
|
828
1043
|
h('button', {
|
|
829
1044
|
type: 'button',
|
|
830
1045
|
className: 'dqp-icon',
|
|
@@ -919,6 +1134,41 @@ window.__ModuleLoader__.load({
|
|
|
919
1134
|
),
|
|
920
1135
|
)
|
|
921
1136
|
|
|
1137
|
+
var visibleOption = h('div', { className: 'dqp-option' },
|
|
1138
|
+
h('div', { className: 'dqp-option-text' },
|
|
1139
|
+
h('span', { className: 'dqp-option-label', id: 'dqp-visible-label' }, t('manager.visible')),
|
|
1140
|
+
h('span', { className: 'dqp-option-hint' }, t('manager.visibleHint')),
|
|
1141
|
+
),
|
|
1142
|
+
h('button', {
|
|
1143
|
+
type: 'button',
|
|
1144
|
+
id: 'dqp-visible',
|
|
1145
|
+
className: 'dqp-switch' + (collapsed ? '' : ' dqp-switch-on'),
|
|
1146
|
+
role: 'switch',
|
|
1147
|
+
'aria-checked': !collapsed,
|
|
1148
|
+
'aria-labelledby': 'dqp-visible-label',
|
|
1149
|
+
onClick: function () { setCollapsed(!collapsed) },
|
|
1150
|
+
}, h('span', { className: 'dqp-switch-thumb' })),
|
|
1151
|
+
)
|
|
1152
|
+
|
|
1153
|
+
var autoHideOption = h('div', { className: 'dqp-option' },
|
|
1154
|
+
h('div', { className: 'dqp-option-text' },
|
|
1155
|
+
h('label', { className: 'dqp-option-label', htmlFor: 'dqp-autohide' }, t('manager.autoHide')),
|
|
1156
|
+
h('span', { className: 'dqp-option-hint' }, t('manager.autoHideHint')),
|
|
1157
|
+
),
|
|
1158
|
+
h('div', { className: 'dqp-select-wrap' },
|
|
1159
|
+
h('select', {
|
|
1160
|
+
id: 'dqp-autohide',
|
|
1161
|
+
className: 'dqp-select',
|
|
1162
|
+
value: autoHideNow,
|
|
1163
|
+
onChange: function (event) { setAutoHide(event.target.value) },
|
|
1164
|
+
},
|
|
1165
|
+
AUTO_HIDE_MODES.map(function (value) {
|
|
1166
|
+
return h('option', { key: value, value: value }, t(value === 'fold' ? 'manager.autoHideFold' : 'manager.autoHideKeep'))
|
|
1167
|
+
}),
|
|
1168
|
+
),
|
|
1169
|
+
),
|
|
1170
|
+
)
|
|
1171
|
+
|
|
922
1172
|
return h('div', { className: 'dqp-page' },
|
|
923
1173
|
h('style', null, MANAGER_CSS),
|
|
924
1174
|
h('div', { className: 'dqp-inner' },
|
|
@@ -929,7 +1179,7 @@ window.__ModuleLoader__.load({
|
|
|
929
1179
|
),
|
|
930
1180
|
h('span', { className: 'dqp-badge' }, t('manager.count').replace('{n}', String(phrases.length))),
|
|
931
1181
|
),
|
|
932
|
-
h('div', { className: 'dqp-options' }, placementOption, clickOption),
|
|
1182
|
+
h('div', { className: 'dqp-options' }, placementOption, clickOption, visibleOption, autoHideOption),
|
|
933
1183
|
h('div', { className: 'dqp-section' },
|
|
934
1184
|
h('div', { className: 'dqp-section-head' },
|
|
935
1185
|
h('h3', { className: 'dqp-section-title' }, t('manager.phrases')),
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -52,15 +52,30 @@ return {
|
|
|
52
52
|
|
|
53
53
|
## 数据层
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
五个 store 都是模块级状态 + `localStorage`,不经过 Host:
|
|
56
56
|
|
|
57
57
|
| store | 存储键 | 读写 |
|
|
58
58
|
| --- | --- | --- |
|
|
59
59
|
| 短语列表 | `dsh.quick-phrases.v1` | `normalize()` 清洗 → `persist()` 写回 → `emit()` 通知订阅者 |
|
|
60
60
|
| 显示位置 | `dsh.quick-phrases.placement.v1` | 校验非法值,坏值回落默认 |
|
|
61
61
|
| 点按行为 | `dsh.quick-phrases.click.v1` | 同上 |
|
|
62
|
+
| 整排收起 | `dsh.quick-phrases.collapsed.v1` | `'1'` / `'0'`,缺省 `'0'` |
|
|
63
|
+
| 自动收起选项 | `dsh.quick-phrases.autohide.v1` | `'fold'` / `'keep'`,缺省 `'fold'` |
|
|
62
64
|
|
|
63
|
-
`
|
|
65
|
+
后三个用同一个工厂 `makeEnumStore(key, values, fallback, label)` 造出来:读取时白名单外的值一律回落 fallback,写入前也做同样校验,所以旧版本留下的脏值或手改的 `localStorage` 不会让界面进入未定义状态。新增一个类似开关时优先复用它,不要再手写第六份 read/ensure/set/use。
|
|
66
|
+
|
|
67
|
+
`usePhrases()` / `usePlacement()` / `useClickMode()` / `useCollapsed()` / `useAutoHide()` 是 `useState` + `subscribe` 的小包装,同时监听 `storage` 事件,多窗口之间也能同步。首次使用时按当前界面语言写入四条默认短语。
|
|
68
|
+
|
|
69
|
+
短语条目里除了 `id` / `label` / `text` 还有一个 `hidden` 布尔值(`normalize()` 缺成 `false`)。短语行渲染前会滤掉 `hidden === true` 的条目,管理页则照常渲染并用 `dqp-row-muted` 变暗、加「已隐藏」徽标。
|
|
70
|
+
|
|
71
|
+
收起逻辑也在 `DockChips` 里,先于渲染决定这次画整排还是画一个胶囊:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
hasDraft = draft.trim() !== '' || attachments > 0
|
|
75
|
+
folded = collapsed || (autoHide === 'fold' && hasDraft && !peeked)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`peeked` 是组件内部的临时状态:点胶囊时置 `true` 并同时展开(`setCollapsed(false)`),这样"临时看一眼"不会写进 `localStorage`,草稿清空后 `useEffect` 会把它清掉。手动收起(`setCollapsed(true)`)是持久状态,跨会话保留。
|
|
64
79
|
|
|
65
80
|
点按逻辑在 `DockChips` 里:
|
|
66
81
|
|
|
@@ -68,6 +83,8 @@ return {
|
|
|
68
83
|
2. 草稿非空或带附件 → `inputActions.insertText(text, inputActions.captureInsertion())`,插到光标处;
|
|
69
84
|
3. 否则按点按行为:`setDraft(text)` + `submit()`,或只 `setDraft(text)`。
|
|
70
85
|
|
|
86
|
+
折叠不影响第 1 步:胶囊展开后草稿还在,点按照样走 2。
|
|
87
|
+
|
|
71
88
|
## 样式
|
|
72
89
|
|
|
73
90
|
每个组件自带一段 `<style>`,随组件卸载消失,不污染全局。所有颜色、圆角、焦点环都走宿主 token:
|
|
@@ -89,7 +106,9 @@ margin: 0 auto;
|
|
|
89
106
|
|
|
90
107
|
## 测试
|
|
91
108
|
|
|
92
|
-
`test/smoke.mjs` 把真实的 `client.js` 放进 `vm` 沙箱,用最小假 React(按组件名分配 hook 单元)和假 ModuleLoader 跑起来,直接调组件自己的 `onClick` / `onChange`,断言落在 `localStorage`
|
|
109
|
+
`test/smoke.mjs` 把真实的 `client.js` 放进 `vm` 沙箱,用最小假 React(按组件名分配 hook 单元)和假 ModuleLoader 跑起来,直接调组件自己的 `onClick` / `onChange`,断言落在 `localStorage` 和渲染树上的结果。改行为时先改这里——它是唯一能在没有宿主的情况下验证「显示与发送分离」「位置切换」「拖动排序」「收起与隐藏」是否还成立的护栏。
|
|
110
|
+
|
|
111
|
+
与收起/隐藏相关的断言:点「收起」写入 `collapsed.v1='1'` 且只剩 `.dqp-pill`;点胶囊回到 `'0'` 并恢复六个 chip;草稿出现时默认折成胶囊、展开后点第二条仍插到光标处;`autohide` 切到 `keep` 后草稿不再折叠;`#dqp-visible` 开关往返;隐藏一条后短语行少一个 chip、管理页仍是四张卡片且第一张带 `dqp-row-muted`。
|
|
93
112
|
|
|
94
113
|
`test/preview.mjs` 把组件渲染成静态 HTML,拼上宿主主题 CSS,可用无头 Chromium 截图,用来肉眼核对深浅两套主题。`docs/images/` 下的图就是它产出的**界面示意图**(图内带「界面示意图」标题),不是真机截屏。
|
|
95
114
|
|
package/docs/DETAIL.en.md
CHANGED
|
@@ -23,14 +23,27 @@ The row can be moved at any time from the settings page; the switch applies imme
|
|
|
23
23
|
|
|
24
24
|
All three rows stay registered, but only the selected one renders — switching is a re-render, not a page reload.
|
|
25
25
|
|
|
26
|
+
## Folding and hiding
|
|
27
|
+
|
|
28
|
+
The row should never get in the way of typing, so it can fold in two ways:
|
|
29
|
+
|
|
30
|
+
- **Fold by hand**: click `收起 ▾` at the end of the row and it collapses into a small `▸ 快捷短语` pill; click the pill to expand it temporarily, and 「收起」 to fold it again.
|
|
31
|
+
- **Fold automatically** (default): with "When the composer has text" set to "Fold automatically", the row collapses into the pill as soon as the composer holds text or attachments, and expands again once the draft is cleared. Pick "Keep it visible" to keep the full row instead.
|
|
32
|
+
|
|
33
|
+
Clicking a phrase after expanding the pill behaves exactly as before: when the composer already has content the text is inserted at the caret instead of replacing it.
|
|
34
|
+
|
|
35
|
+
A single phrase can be hidden with the **eye** toggle on its card in the manager: the chip disappears from the row while the card stays in the manager marked "Hidden"; click again to bring it back. The "Show the phrase row" switch in Settings hides the whole row.
|
|
36
|
+
|
|
26
37
|
## Managing phrases
|
|
27
38
|
|
|
28
39
|
Open **Settings → Quick phrases**. The page has two layers: behaviour options on top, the phrase list below.
|
|
29
40
|
|
|
30
|
-
**Behaviour options** (
|
|
41
|
+
**Behaviour options** (applied on selection):
|
|
31
42
|
|
|
32
43
|
- **Position**: switch between the three positions above.
|
|
33
44
|
- **On click**: pick "Send right away" or "Fill the composer"; the default is sending right away.
|
|
45
|
+
- **Show the phrase row**: switch the whole row on or off. When off, a single small pill remains beside the composer; click it to expand.
|
|
46
|
+
- **When the composer has text**: pick "Fold automatically" (default) or "Keep it visible" to decide whether the row folds into the pill while a draft or attachments exist.
|
|
34
47
|
|
|
35
48
|
**Phrase list** (one card per phrase):
|
|
36
49
|
|
|
@@ -38,14 +51,15 @@ Open **Settings → Quick phrases**. The page has two layers: behaviour options
|
|
|
38
51
|
- **Label**: the top line of the card is the button caption — edit it in place.
|
|
39
52
|
- **Text**: the large field below, multi-line.
|
|
40
53
|
- **Chip preview**: each card shows the resulting chip and its character count, so a too-wide label is obvious before you send anything.
|
|
54
|
+
- **Eye**: hide or restore that phrase. A hidden phrase leaves the row while its card stays in the manager with a "Hidden" badge.
|
|
41
55
|
- **✕**: the first click only arms the delete ("Confirm"), a second click within four seconds removes the phrase.
|
|
42
56
|
- **Add phrase** appends an empty card and focuses its caption; **Restore defaults** arms on the first click and restores the four built-in phrases on the second.
|
|
43
57
|
|
|
44
|
-
Changes save and apply immediately, no restart. The list lives in local browser storage (`localStorage` key `dsh.quick-phrases.v1`; the position is `dsh.quick-phrases.placement.v1`, the click behaviour `dsh.quick-phrases.click.v1`), scoped to the DSH Web origin — a different machine or cleared site data loses it.
|
|
58
|
+
Changes save and apply immediately, no restart. The list lives in local browser storage (`localStorage` key `dsh.quick-phrases.v1`; the position is `dsh.quick-phrases.placement.v1`, the click behaviour `dsh.quick-phrases.click.v1`, the folded state `dsh.quick-phrases.collapsed.v1`, the auto-fold option `dsh.quick-phrases.autohide.v1`), scoped to the DSH Web origin — a different machine or cleared site data loses it.
|
|
45
59
|
|
|
46
60
|
## Opening it from the composer
|
|
47
61
|
|
|
48
|
-
The **Manage** chip at the end of the row jumps to the same settings page. If the settings entry is not mounted in this UI yet, it says "请在『设置 — 快捷短语』中管理" instead.
|
|
62
|
+
The **Manage** chip at the end of the row jumps to the same settings page (expand the pill first when the row is folded). If the settings entry is not mounted in this UI yet, it says "请在『设置 — 快捷短语』中管理" instead.
|
|
49
63
|
|
|
50
64
|
## Styling
|
|
51
65
|
|
package/docs/DETAIL.md
CHANGED
|
@@ -23,14 +23,27 @@
|
|
|
23
23
|
|
|
24
24
|
三条短语行都会注册,但同一时刻只渲染选中的那一条,切换是一次重渲染,不需要重载页面。
|
|
25
25
|
|
|
26
|
+
## 收起与隐藏
|
|
27
|
+
|
|
28
|
+
短语行不该挡着打字,所以有两种收起方式:
|
|
29
|
+
|
|
30
|
+
- **手动收起**:点行尾的 `收起 ▾`,整排缩成一个小胶囊 `▸ 快捷短语`;点胶囊临时展开,再点「收起」收回去。
|
|
31
|
+
- **自动收起**(默认):设置里「输入框有内容时」选「自动收起」——输入框里一有文字或附件就缩成胶囊,草稿清空后自动展开;也可以选「保持显示」,让整排常驻。
|
|
32
|
+
|
|
33
|
+
收起状态下点开胶囊再点短语,行为和展开时完全一样:输入框里已有内容时仍然插到光标处,不会覆盖草稿。
|
|
34
|
+
|
|
35
|
+
单条短语可以在管理页用每张卡片右上角的**眼睛**开关隐藏:隐藏后这条按钮不再出现在短语行,卡片仍留在管理页并标注「已隐藏」,再点一次恢复显示。也可以直接用设置里的「显示短语行」开关把整排关掉。
|
|
36
|
+
|
|
26
37
|
## 管理短语
|
|
27
38
|
|
|
28
|
-
打开 **设置 →
|
|
39
|
+
打开 **设置 → 快捷短语**。页面分两层:上面是四项行为设置,下面是短语列表。
|
|
29
40
|
|
|
30
|
-
|
|
41
|
+
**行为设置**(选中或点一下即生效):
|
|
31
42
|
|
|
32
43
|
- **显示位置**:在上面三个位置之间切换。
|
|
33
44
|
- **点按短语时**:选择「直接发送」或「填入输入框」。默认直接发送。
|
|
45
|
+
- **显示短语行**:开关整排的显示。关掉后输入框旁只留一个小胶囊,点一下就能重新展开。
|
|
46
|
+
- **输入框有内容时**:选「自动收起」(默认)或「保持显示」,决定草稿/附件出现时整排是否缩成胶囊。
|
|
34
47
|
|
|
35
48
|
**短语列表**(一条短语一张卡片):
|
|
36
49
|
|
|
@@ -38,14 +51,15 @@
|
|
|
38
51
|
- **显示名称**:卡片顶部那行就是按钮文字,直接点进去改(例如 `提交`)。
|
|
39
52
|
- **发送内容**:下面的大输入框,支持多行。
|
|
40
53
|
- **按钮预览**:每张卡片底部实时显示这个按钮长什么样、会发送多少字,方便检查名称是否太宽。
|
|
54
|
+
- **眼睛**:隐藏或恢复这一条短语。隐藏后按钮从短语行消失,卡片留在管理页并显示「已隐藏」徽标。
|
|
41
55
|
- **✕**:第一次点击只是把按钮变成「确认」,4 秒内再点一次才真正删除,避免误删。
|
|
42
56
|
- **新增短语**:追加一条空卡片并自动把光标放到名称上;**恢复默认**点一次进入确认态,再点一次恢复为内置的四条短语。
|
|
43
57
|
|
|
44
|
-
改动即时保存、即时生效,无需重启。短语保存在本机浏览器存储里(`localStorage` 键 `dsh.quick-phrases.v1`,位置存在 `dsh.quick-phrases.placement.v1`,点按行为存在 `dsh.quick-phrases.click.v1`),按 DSH 的 Web 端存储隔离,换机器或清空站点数据会丢失。
|
|
58
|
+
改动即时保存、即时生效,无需重启。短语保存在本机浏览器存储里(`localStorage` 键 `dsh.quick-phrases.v1`,位置存在 `dsh.quick-phrases.placement.v1`,点按行为存在 `dsh.quick-phrases.click.v1`,收起状态存在 `dsh.quick-phrases.collapsed.v1`,自动收起选项存在 `dsh.quick-phrases.autohide.v1`),按 DSH 的 Web 端存储隔离,换机器或清空站点数据会丢失。
|
|
45
59
|
|
|
46
60
|
## 在输入框旁直接打开
|
|
47
61
|
|
|
48
|
-
短语行最右侧的 **管理**
|
|
62
|
+
短语行最右侧的 **管理** 会跳到同一页设置(收起成胶囊时,先点胶囊展开)。如果当前界面还没装上设置入口,会提示「请在『设置 — 快捷短语』中管理」。
|
|
49
63
|
|
|
50
64
|
## 样式
|
|
51
65
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# 文档图片
|
|
2
|
+
|
|
3
|
+
这里的图**全部是界面示意图**,由 `test/preview.mjs` 把插件真实组件渲染成静态 HTML、套上宿主主题 token、再用无头 Chromium 截出来,图内自带「界面示意图」标题。
|
|
4
|
+
|
|
5
|
+
生成方式:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
ELECTRON_RUN_AS_NODE=1 "/opt/DSH NEXT/dsh-desktop-next" test/preview.mjs --shot
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
产物在 `/tmp/dqp-*.png`;裁掉多余留白后覆盖本目录对应文件即可。
|
|
12
|
+
|
|
13
|
+
## 为什么不用真机截图
|
|
14
|
+
|
|
15
|
+
真机截屏会连带把不该公开的东西一起拍进去,例如:
|
|
16
|
+
|
|
17
|
+
- 侧边栏里的会话标题、工作区/项目名(往往带客户或未发布产品名);
|
|
18
|
+
- 左下角的账号标识、头像、组织名;
|
|
19
|
+
- 输入框里正在写的草稿、附件名、路径;
|
|
20
|
+
- 状态行的 token 用量、模型名、后台任务数等运行信息。
|
|
21
|
+
|
|
22
|
+
示意图只包含本插件自己的界面和一组演示短语(继续 / 提交 / 推送 / 发版),不含任何本机数据,可以放心随仓库公开。
|
|
23
|
+
|
|
24
|
+
## 需要真机图时
|
|
25
|
+
|
|
26
|
+
确实需要真机观感时,按下面任一条做,**不要**直接 `agkit shot` 全窗截图就提交:
|
|
27
|
+
|
|
28
|
+
1. 裁剪到只有输入卡片 / 设置面板本体,去掉侧边栏、顶栏、状态行、账号区;
|
|
29
|
+
2. 或者用一份干净的演示 profile(空白工作区、没有真实会话)来截;
|
|
30
|
+
3. 提交前逐张放大确认:没有会话名、路径、账号、token、邮箱、内网地址。
|
|
31
|
+
|
|
32
|
+
审图清单也写在 `CONTRIBUTING.md` 的「截图与隐私」一节。
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/docs/images/row-dark.png
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-quick-phrases",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "DSH
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "DSH 快捷短语:输入框旁一排短语按钮,点按即发送;输入框有内容时自动收起成小胶囊,单条短语可隐藏;管理页可增删改、拖动排序,显示名称与发送内容分离,显示位置可选。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "pengtang1024",
|