dsh-settings-launcher 0.0.1 → 0.0.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/package.json +2 -2
- package/src/client.js +42 -29
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-settings-launcher",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"description": "侧栏设置入口的两个独立开关:悬浮自动展开原版菜单、点击直达设置;可单选也可全开,全关即官方原样。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
package/src/client.js
CHANGED
|
@@ -153,6 +153,16 @@ window.__ModuleLoader__.load({
|
|
|
153
153
|
'background:var(--dsw-alias-bg-primary,transparent);box-sizing:border-box}',
|
|
154
154
|
'.dsd-title{font-size:14px;color:var(--dsw-alias-label-primary)}',
|
|
155
155
|
'.dsd-sub{font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}',
|
|
156
|
+
'.dsd-setting{display:inline-flex;align-items:center;gap:10px;padding:4px 0;width:auto}',
|
|
157
|
+
'.dsd-setting-text{flex:0 0 auto;min-width:0}',
|
|
158
|
+
'.dsd-setting-title{font-size:13px;font-weight:600;line-height:20px;white-space:nowrap}',
|
|
159
|
+
'.dsd-setting-desc{font-size:12px;line-height:18px;opacity:.7;margin-top:2px}',
|
|
160
|
+
'.dsd-switch{position:relative;flex:none;width:38px;height:22px;margin-left:auto;border:0;border-radius:11px;padding:0;cursor:pointer;background:rgba(127,127,127,.4);transition:background .12s ease}',
|
|
161
|
+
'.dsd-switch[aria-checked="true"]{background:#4c8dff}',
|
|
162
|
+
'.dsd-switch::after{content:"";position:absolute;top:2px;left:2px;width:18px;height:18px;border-radius:50%;background:#fff;transition:left .15s ease}',
|
|
163
|
+
'.dsd-switch[aria-checked="true"]::after{left:18px}',
|
|
164
|
+
'.dsd-switch:focus-visible{outline:2px solid rgba(76,141,255,.45);outline-offset:2px}',
|
|
165
|
+
'@media (prefers-reduced-motion:reduce){.dsd-switch,.dsd-switch::after{transition:none}}',
|
|
156
166
|
'.dsd-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:6px}',
|
|
157
167
|
'.dsd-btn{font:inherit;font-size:13px;line-height:20px;padding:6px 14px;cursor:pointer;',
|
|
158
168
|
'border-radius:var(--dsw-radius-md,8px);border:1px solid var(--dsw-alias-border-secondary,rgba(128,128,128,.3));',
|
|
@@ -161,19 +171,10 @@ window.__ModuleLoader__.load({
|
|
|
161
171
|
'.dsd-btn:disabled{opacity:.5;cursor:default}',
|
|
162
172
|
'.dsd-btn[data-tone=danger]{color:var(--dsw-alias-state-error-primary,#e5484d);',
|
|
163
173
|
'border-color:var(--dsw-alias-state-error-primary,#e5484d)}',
|
|
164
|
-
'.dsd-note{font-size:12px;line-height:1.5;color:var(--dsw-alias-label-
|
|
174
|
+
'.dsd-note{font-size:12px;line-height:1.5;color:var(--dsw-alias-label-primary,#111)}',
|
|
165
175
|
// The plugin page's form: two independent rows, each its own checkbox.
|
|
166
176
|
'.dsd-form{display:flex;flex-direction:column;gap:8px}',
|
|
167
|
-
'.dsd-choice{display:flex;flex-direction:
|
|
168
|
-
'.dsd-option{display:flex;align-items:flex-start;gap:10px;cursor:pointer;',
|
|
169
|
-
'border:1px solid var(--dsw-alias-border-secondary,rgba(128,128,128,.18));',
|
|
170
|
-
'border-radius:var(--dsw-radius-md,8px);padding:10px 12px;background:transparent}',
|
|
171
|
-
'.dsd-option[data-selected=true]{border-color:var(--dsw-alias-state-business-primary,#4a6cf7);',
|
|
172
|
-
'background:var(--dsw-alias-interactive-bg-hover)}',
|
|
173
|
-
'.dsd-option input{margin:2px 0 0;flex:none}',
|
|
174
|
-
'.dsd-optionText{display:flex;flex-direction:column;gap:2px;min-width:0}',
|
|
175
|
-
'.dsd-optionTitle{font-size:13px;color:var(--dsw-alias-label-primary)}',
|
|
176
|
-
'.dsd-optionHint{font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}',
|
|
177
|
+
'.dsd-choice{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;gap:8px 28px;border:0;margin:0;padding:0}',
|
|
177
178
|
].join('')
|
|
178
179
|
|
|
179
180
|
function ensureStyle() {
|
|
@@ -206,38 +207,45 @@ window.__ModuleLoader__.load({
|
|
|
206
207
|
return h('span', { className: 'dsd-note' }, flagsSummary(flags))
|
|
207
208
|
}
|
|
208
209
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
onChange: (event) => writeFlags({ ...flags, [key]: event.target.checked === true }),
|
|
217
|
-
}),
|
|
210
|
+
// One switch per row: the copy on the left, the control on the right. Same
|
|
211
|
+
// shape the session components use, so the three settings pages read alike.
|
|
212
|
+
const row = (key, title, hint) => {
|
|
213
|
+
const on = flags[key] === true
|
|
214
|
+
return h(
|
|
215
|
+
'div',
|
|
216
|
+
{ key, className: 'dsd-setting' },
|
|
218
217
|
h(
|
|
219
|
-
'
|
|
220
|
-
{ className: 'dsd-
|
|
221
|
-
h('
|
|
222
|
-
h('
|
|
218
|
+
'div',
|
|
219
|
+
{ className: 'dsd-setting-text' },
|
|
220
|
+
h('div', { className: 'dsd-setting-title' }, title),
|
|
221
|
+
hint === '' || hint === undefined ? null : h('div', { className: 'dsd-setting-desc' }, hint),
|
|
223
222
|
),
|
|
223
|
+
h('button', {
|
|
224
|
+
type: 'button',
|
|
225
|
+
role: 'switch',
|
|
226
|
+
className: 'dsd-switch',
|
|
227
|
+
'aria-checked': on ? 'true' : 'false',
|
|
228
|
+
'aria-label': title,
|
|
229
|
+
onClick: () => writeFlags({ ...flags, [key]: !on }),
|
|
230
|
+
}),
|
|
224
231
|
)
|
|
232
|
+
}
|
|
225
233
|
|
|
226
234
|
return h(
|
|
227
235
|
'div',
|
|
228
236
|
{ className: 'dsd-form' },
|
|
229
237
|
h(
|
|
230
|
-
'
|
|
231
|
-
{ className: 'dsd-choice', 'aria-label': '
|
|
238
|
+
'div',
|
|
239
|
+
{ className: 'dsd-choice', role: 'group', 'aria-label': '侧栏设置入口的交互' },
|
|
232
240
|
row(
|
|
233
241
|
FLAG_HOVER,
|
|
234
242
|
'悬浮展开菜单',
|
|
235
|
-
'
|
|
243
|
+
'',
|
|
236
244
|
),
|
|
237
245
|
row(
|
|
238
246
|
FLAG_DIRECT,
|
|
239
247
|
'点击进设置',
|
|
240
|
-
'
|
|
248
|
+
'',
|
|
241
249
|
),
|
|
242
250
|
h('span', { className: 'dsd-note' }, flagsSummary(flags)),
|
|
243
251
|
),
|
|
@@ -596,7 +604,7 @@ window.__ModuleLoader__.load({
|
|
|
596
604
|
if (flags.direct && openSettings === null) {
|
|
597
605
|
console.warn(
|
|
598
606
|
'[dsh-settings-launcher] 拿不到 shortcuts 服务的 registry.invoke,' +
|
|
599
|
-
'
|
|
607
|
+
'「点击进设置」这次不生效,设置入口保持官方行为。',
|
|
600
608
|
)
|
|
601
609
|
}
|
|
602
610
|
|
|
@@ -832,6 +840,11 @@ window.__ModuleLoader__.load({
|
|
|
832
840
|
|
|
833
841
|
return {
|
|
834
842
|
inject: ['slots', 'remote.account'],
|
|
843
|
+
// The switches are also readable from outside this bundle: the aggregator
|
|
844
|
+
// that vendors this file renders the same card (never a copy) and injects
|
|
845
|
+
// the same stylesheet, so the two surfaces cannot drift.
|
|
846
|
+
__settings: { SwitchCard },
|
|
847
|
+
__ui: { pluginId: NS, css: () => CSS },
|
|
835
848
|
apply(ctx) {
|
|
836
849
|
// ctx.effect 要的是一个 cleanup 函数;ensureStyle() 返回的是 <style>
|
|
837
850
|
// 元素,直接返回会让 Cordis 在激活时拿到非函数值而把 fiber 判为 failed。
|