@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 CHANGED
@@ -7,7 +7,7 @@
7
7
  [![dsh web plugin](https://img.shields.io/badge/dsh-web%20plugin-4f46e5?style=for-the-badge)](https://npmjs.com/package/@deepseek-ai/dsh)
8
8
  [![npm](https://img.shields.io/npm/v/%40kesike%2Fdsh-exit?style=for-the-badge&label=npm)](https://www.npmjs.com/package/@kesike/dsh-exit)
9
9
  [![Platform](https://img.shields.io/badge/platform-web-0ea5e9?style=for-the-badge)](https://github.com/KeS1Ke/dsh-exit)
10
- [![Version](https://img.shields.io/badge/version-0.2.0-64748b?style=for-the-badge)](package.json)
10
+ [![Version](https://img.shields.io/badge/version-0.2.1-64748b?style=for-the-badge)](package.json)
11
11
  [![Dependencies](https://img.shields.io/badge/runtime%20dependencies-none-16a34a?style=for-the-badge)](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
  [![dsh Web 插件](https://img.shields.io/badge/dsh-Web%20%E6%8F%92%E4%BB%B6-4f46e5?style=for-the-badge)](https://npmjs.com/package/@deepseek-ai/dsh)
8
8
  [![npm](https://img.shields.io/npm/v/%40kesike%2Fdsh-exit?style=for-the-badge&label=npm)](https://www.npmjs.com/package/@kesike/dsh-exit)
9
9
  [![平台](https://img.shields.io/badge/%E5%B9%B3%E5%8F%B0-Web-0ea5e9?style=for-the-badge)](https://github.com/KeS1Ke/dsh-exit)
10
- [![版本](https://img.shields.io/badge/%E7%89%88%E6%9C%AC-0.2.0-64748b?style=for-the-badge)](package.json)
10
+ [![版本](https://img.shields.io/badge/%E7%89%88%E6%9C%AC-0.2.1-64748b?style=for-the-badge)](package.json)
11
11
  [![依赖](https://img.shields.io/badge/%E8%BF%90%E8%A1%8C%E6%97%B6%E4%BE%9D%E8%B5%96-%E6%97%A0-16a34a?style=for-the-badge)](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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kesike/dsh-exit",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "description": "在 dsh web 界面提供退出按钮:确认后结束宿主进程并释放端口",
6
6
  "keywords": [