@kesike/dsh-exit 0.2.0 → 0.2.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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/lib/client.js +44 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://npmjs.com/package/@deepseek-ai/dsh)
|
|
8
8
|
[](https://www.npmjs.com/package/@kesike/dsh-exit)
|
|
9
9
|
[](https://github.com/KeS1Ke/dsh-exit)
|
|
10
|
-
[](package.json)
|
|
11
11
|
[](package.json)
|
|
12
12
|
|
|
13
13
|
[简体中文](https://github.com/KeS1Ke/dsh-exit/blob/main/README.zh-CN.md)
|
package/README.zh-CN.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://npmjs.com/package/@deepseek-ai/dsh)
|
|
8
8
|
[](https://www.npmjs.com/package/@kesike/dsh-exit)
|
|
9
9
|
[](https://github.com/KeS1Ke/dsh-exit)
|
|
10
|
-
[](package.json)
|
|
11
11
|
[](package.json)
|
|
12
12
|
|
|
13
13
|
**简体中文** | [English](https://github.com/KeS1Ke/dsh-exit/blob/main/README.md)
|
package/lib/client.js
CHANGED
|
@@ -37,6 +37,10 @@ window.__ModuleLoader__.load({
|
|
|
37
37
|
".dshExitSettingsButton:hover:not(:disabled){filter:brightness(1.08)}",
|
|
38
38
|
".dshExitSettingsButton:focus-visible{outline:2px solid " + ERROR_RED + ";outline-offset:2px}",
|
|
39
39
|
".dshExitSettingsButton:disabled{cursor:default;opacity:.6}",
|
|
40
|
+
".dshExitNavCell{color:" + ERROR_RED + " !important}",
|
|
41
|
+
".dshExitNavCell .dshExitNavLabel{color:" + ERROR_RED + " !important;font-weight:650}",
|
|
42
|
+
".dshExitNavIcon{box-sizing:border-box;width:16px;height:16px;display:grid;place-items:center;flex:none;color:" + ERROR_RED + "}",
|
|
43
|
+
".dshExitNavIcon svg{width:16px;height:16px}",
|
|
40
44
|
".dshExitOverlay{position:fixed;inset:0;z-index:2147483000;display:flex;align-items:center;justify-content:center;background:rgba(15,20,25,.45);animation:dshExitFade .12s ease-out}",
|
|
41
45
|
"@keyframes dshExitFade{from{opacity:0}}",
|
|
42
46
|
".dshExitModal{box-sizing:border-box;width:min(380px,calc(100vw - 48px));border-radius:16px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-button-elevated-fill);box-shadow:0 24px 64px rgba(0,0,0,.35);padding:24px;display:flex;flex-direction:column;gap:12px;animation:dshExitPop .14s ease-out}",
|
|
@@ -127,6 +131,40 @@ window.__ModuleLoader__.load({
|
|
|
127
131
|
return typeof t === "function" ? t(key) : DICT.zh[key] ?? key;
|
|
128
132
|
}
|
|
129
133
|
|
|
134
|
+
/** dsh 的设置壳层为未知 section 使用齿轮图标;给本插件的导航项换成 power 图标。 */
|
|
135
|
+
function decorateExitNav(t) {
|
|
136
|
+
const labels = new Set(["退出", "Exit", textOf(t, "nav")]);
|
|
137
|
+
for (const cell of document.querySelectorAll("nav button")) {
|
|
138
|
+
const label = [...cell.querySelectorAll("span")].find((candidate) => labels.has(candidate.textContent.trim()));
|
|
139
|
+
if (label === undefined) continue;
|
|
140
|
+
cell.dataset.dshExitNav = "true";
|
|
141
|
+
cell.classList.add("dshExitNavCell");
|
|
142
|
+
label.classList.add("dshExitNavLabel");
|
|
143
|
+
if (cell.querySelector(".dshExitNavIcon") !== null) continue;
|
|
144
|
+
const originalIcon = cell.firstElementChild;
|
|
145
|
+
const icon = document.createElement("span");
|
|
146
|
+
icon.className = "dshExitNavIcon";
|
|
147
|
+
icon.innerHTML = ICON_SVG;
|
|
148
|
+
if (originalIcon !== null && originalIcon !== label) {
|
|
149
|
+
originalIcon.dataset.dshExitOriginalIcon = "true";
|
|
150
|
+
originalIcon.style.display = "none";
|
|
151
|
+
cell.insertBefore(icon, originalIcon);
|
|
152
|
+
} else {
|
|
153
|
+
cell.insertBefore(icon, label);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function clearDecoratedExitNav() {
|
|
159
|
+
for (const cell of document.querySelectorAll("[data-dsh-exit-nav='true']")) {
|
|
160
|
+
cell.querySelector(".dshExitNavIcon")?.remove();
|
|
161
|
+
cell.querySelector("[data-dsh-exit-original-icon='true']")?.style.removeProperty("display");
|
|
162
|
+
cell.querySelector(".dshExitNavLabel")?.classList.remove("dshExitNavLabel");
|
|
163
|
+
cell.classList.remove("dshExitNavCell");
|
|
164
|
+
delete cell.dataset.dshExitNav;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
130
168
|
function ExitSettingsSection({ ctx, t }) {
|
|
131
169
|
return h("section", {
|
|
132
170
|
className: "dshExitSettings",
|
|
@@ -247,6 +285,10 @@ window.__ModuleLoader__.load({
|
|
|
247
285
|
injectCss();
|
|
248
286
|
ctx.effect(() => ctx.locale.register(NS, DICT), "dsh-exit: settings dictionaries");
|
|
249
287
|
const t = ctx.locale.bind(NS);
|
|
288
|
+
const decorate = () => decorateExitNav(t);
|
|
289
|
+
decorate();
|
|
290
|
+
const navObserver = document.body === null ? null : new MutationObserver(decorate);
|
|
291
|
+
navObserver?.observe(document.body, { childList: true, subtree: true, characterData: true });
|
|
250
292
|
const SettingsSection = (props) => h(ExitSettingsSection, { ...props, ctx });
|
|
251
293
|
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
252
294
|
name: "settings.section",
|
|
@@ -259,6 +301,8 @@ window.__ModuleLoader__.load({
|
|
|
259
301
|
const remote = ctx.get("remote");
|
|
260
302
|
if (remote !== undefined) disposeRemote = await remote.$mount(EXIT_REMOTE);
|
|
261
303
|
return async () => {
|
|
304
|
+
navObserver?.disconnect();
|
|
305
|
+
clearDecoratedExitNav();
|
|
262
306
|
closeModal();
|
|
263
307
|
disposeRemote();
|
|
264
308
|
};
|