dsh-font-enhancer 1.3.0 → 1.4.3

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.
Files changed (2) hide show
  1. package/lib/client.js +156 -2
  2. package/package.json +8 -2
package/lib/client.js CHANGED
@@ -313,6 +313,9 @@ window.__ModuleLoader__.load({
313
313
  "#dsh-fe-toggle{position:fixed;left:auto;top:auto;right:18px;bottom:18px;z-index:2147483647 !important;width:54px !important;height:54px !important;border-radius:50% !important;border:0 !important;background:radial-gradient(circle at 30% 25%,rgba(255,255,255,.15),rgba(40,44,54,.95) 70%) !important;color:#eef0f4 !important;font-size:22px !important;font-weight:700 !important;cursor:grab !important;user-select:none !important;touch-action:none !important;box-shadow:0 4px 24px rgba(0,0,0,.6),inset 0 1px 0 rgba(255,255,255,.15) !important;backdrop-filter:blur(12px) !important;line-height:54px !important;text-align:center !important;display:block !important;visibility:visible !important;opacity:1 !important;transform:none !important;pointer-events:auto !important}",
314
314
  "#dsh-fe-toggle:hover{box-shadow:0 6px 32px rgba(0,0,0,.7),inset 0 1px 0 rgba(255,255,255,.2) !important;transform:scale(1.06) !important}",
315
315
  "#dsh-fe-toggle.dsh-fe-dragging{cursor:grabbing !important;transform:scale(1.12) !important;box-shadow:0 8px 40px rgba(0,0,0,.8) !important}",
316
+ "/* ── v1.4.3 orb restyle: warm gradient + 🔤 glyph(字体球独立美化,与 skill-browser 统一样式一致;幂等)── */",
317
+ "#dsh-fe-root #dsh-fe-toggle{width:46px !important;height:46px !important;line-height:46px !important;font-size:0 !important;color:transparent !important;display:flex !important;align-items:center !important;justify-content:center !important;background:linear-gradient(135deg,#ff8c42,#ffd27a) !important;box-shadow:0 4px 16px rgba(255,140,66,.35) !important}",
318
+ "#dsh-fe-root #dsh-fe-toggle::after{content:'🔤';font-size:20px;color:#fff;display:block;line-height:1}",
316
319
  "/* ── panel root — deep glass studio (position set by JS positionPanel) ── */",
317
320
  "#dsh-fe-panel{position:fixed !important;z-index:2147483647 !important;width:348px !important;max-width:calc(100vw - 36px) !important;max-height:86vh;overflow-y:auto !important;overflow-x:hidden !important;color:#e6e6e6 !important;border-radius:20px !important;padding:20px !important;font:13px/1.5 KaiTi,'Microsoft YaHei',sans-serif !important;background:rgba(16,18,22,.92) !important;border:1px solid rgba(255,255,255,.08) !important;box-shadow:0 20px 60px rgba(0,0,0,.7),inset 0 1px 0 rgba(255,255,255,.06) !important;backdrop-filter:blur(24px) !important;-webkit-backdrop-filter:blur(24px) !important;visibility:visible !important;pointer-events:auto !important}",
318
321
  "#dsh-fe-panel::-webkit-scrollbar{width:3px}",
@@ -1532,13 +1535,164 @@ window.__ModuleLoader__.load({
1532
1535
  }
1533
1536
 
1534
1537
  // ---------- entry ----------
1535
- var inject = [];
1536
- function apply() {
1538
+ // 设置页「悬浮球导航」分区(settings.section,与技能浏览器同款官方机制)。
1539
+ // 让字体球(Aa)的显隐由 font-enhancer 自己在 DSH 设置页控制,不依赖其他插件。
1540
+ var FE_BALL_VIS_KEY = "dsh-font-ball-visible";
1541
+ function feReadStore(key, def) {
1542
+ try { var v = localStorage.getItem(key); return v == null ? def : v === "1"; } catch (e) { return def; }
1543
+ }
1544
+ function feWriteStore(key, val) {
1545
+ try { localStorage.setItem(key, val ? "1" : "0"); } catch (e) {}
1546
+ }
1547
+ function feApplyBallVisibility() {
1548
+ var hidden = !feReadStore(FE_BALL_VIS_KEY, true);
1549
+ var t = document.getElementById("dsh-fe-toggle");
1550
+ if (t) t.style.setProperty("display", hidden ? "none" : "", "important");
1551
+ }
1552
+ // 监听字体球(防热重载后重建时样式/显隐丢失;低频轮询,CSS 已兜底)
1553
+ function feWatchBall() {
1554
+ var tries = 0;
1555
+ var t = setInterval(function () {
1556
+ tries++;
1557
+ try { feApplyBallVisibility(); } catch (e) {}
1558
+ if (tries > 120) clearInterval(t);
1559
+ }, 1000);
1560
+ }
1561
+
1562
+ var feReact = null;
1563
+ try {
1564
+ var feReactRaw = require("react");
1565
+ feReact = (feReactRaw && feReactRaw.default) || feReactRaw;
1566
+ } catch (e) { feReact = null; }
1567
+ if (!feReact) { try { feReact = window.React || null; } catch (e) {} }
1568
+
1569
+ // v1.4.3(2026-09-06 用户要求):分区智能让位 + UI 对齐 skill-browser 版式。
1570
+ // 探测机制:skill-browser 的 🧩 悬浮球 DOM(页面加载即建,不依赖打开设置页)。
1571
+ // 让位机制:延迟注册——skill-browser 在场则不注册分区,独立运行才注册兜底分区。
1572
+ // 独立存在时(未装 skill-browser):完整版「悬浮球导航」分区——字体球开关
1573
+ // + 🎯 一键恢复默认位置 + 推荐插件位(照片显示器 / 技能浏览器)。
1574
+
1575
+ // 恢复字体球默认位置(右下角 right:18px bottom:18px),清 bx/by 持久化。
1576
+ function feResetBallToDefault() {
1577
+ try {
1578
+ var data = loadSettings();
1579
+ data.bx = null; data.by = null;
1580
+ saveSettings(data);
1581
+ state.bx = null; state.by = null;
1582
+ } catch (e) {}
1583
+ var t = document.getElementById("dsh-fe-toggle");
1584
+ if (t) {
1585
+ t.style.left = "auto"; t.style.top = "auto";
1586
+ t.style.right = "18px"; t.style.bottom = "18px";
1587
+ }
1588
+ }
1589
+
1590
+ // skill-browser 是否已安装运行(🧩 球元素存在即算,与球显隐无关)
1591
+ function feSkillBrowserPresent() {
1592
+ try { return !!document.getElementById("dsh-skill-browser-ball"); } catch (e) { return false; }
1593
+ }
1594
+
1595
+ function FontSettingsSection(props) {
1596
+ if (!feReact) return null;
1597
+ var rows = [];
1598
+ function mkToggle(id, label, onChange) {
1599
+ return feReact.createElement("label", { key: id, style: { display: "flex", alignItems: "center", gap: "8px", fontSize: "13px", cursor: "pointer" } },
1600
+ feReact.createElement("input", { type: "checkbox", id: id, onChange: onChange }),
1601
+ feReact.createElement("span", null, label));
1602
+ }
1603
+ rows.push(feReact.createElement("div", { key: "head", style: { fontWeight: "600", marginBottom: "4px" } }, "悬浮球导航"));
1604
+ rows.push(mkToggle("fe-set-ball", "字体插件悬浮球(🔤)", function (e) {
1605
+ feWriteStore(FE_BALL_VIS_KEY, e.target.checked);
1606
+ feApplyBallVisibility();
1607
+ }));
1608
+ rows.push(feReact.createElement("button", { key: "fe-reset-pos",
1609
+ onClick: function () { try { feResetBallToDefault(); } catch (e) {} },
1610
+ style: { alignSelf: "flex-start", fontSize: "13px", cursor: "pointer",
1611
+ background: "rgba(255,210,122,.12)", border: "1px solid rgba(255,210,122,.35)",
1612
+ borderRadius: "6px", padding: "6px 12px", color: "#ffd27a" }
1613
+ }, "🎯 一键恢复悬浮球默认位置(右下角)"));
1614
+ rows.push(feReact.createElement("div", { key: "hint", style: { fontSize: "12px", color: "#8b93a8" } },
1615
+ "悬浮球可拖动;本分区就在 DSH 设置中,随时可改悬浮球显隐"));
1616
+ // ── 推荐插件(仅字体插件独立存在、未装 skill-browser 时可见——skill-browser 在场时整个分区已被 CSS 隐藏)──
1617
+ rows.push(feReact.createElement("div", { key: "fe-rec-head", style: { fontWeight: "600", marginTop: "12px", marginBottom: "4px", borderTop: "1px solid rgba(255,255,255,.08)", paddingTop: "10px" } }, "推荐插件"));
1618
+ rows.push(feReact.createElement("div", { key: "fe-rec-lightbox", "data-rec-id": "lightbox", style: { display: "flex", alignItems: "center", justifyContent: "space-between", fontSize: "13px", padding: "3px 0" } },
1619
+ feReact.createElement("span", null, "🖼️ 照片显示器 — 聊天图片灯箱(放大/下载/浏览)"),
1620
+ feReact.createElement("a", { href: "https://github.com/loyalchiiina/dsh-chat-image-lightbox", target: "_blank", rel: "noopener", style: { textDecoration: "none", fontSize: "12px", background: "rgba(255,255,255,.06)", border: "1px solid rgba(255,255,255,.12)", borderRadius: "6px", padding: "2px 8px", color: "#ffd27a", cursor: "pointer", whiteSpace: "nowrap" } }, "⭐ Star")));
1621
+ rows.push(feReact.createElement("div", { key: "fe-rec-skillbrowser", "data-rec-id": "skillbrowser", style: { display: "flex", alignItems: "center", justifyContent: "space-between", fontSize: "13px", padding: "3px 0" } },
1622
+ feReact.createElement("span", null, "🧩 技能浏览器 — 悬浮球面板浏览共享技能库 + 失效台账"),
1623
+ feReact.createElement("a", { href: "https://github.com/loyalchiiina/dsh-skill-browser", target: "_blank", rel: "noopener", style: { textDecoration: "none", fontSize: "12px", background: "rgba(255,255,255,.06)", border: "1px solid rgba(255,255,255,.12)", borderRadius: "6px", padding: "2px 8px", color: "#ffd27a", cursor: "pointer", whiteSpace: "nowrap" } }, "⭐ Star")));
1624
+ return feReact.createElement("div", { "data-fe-slot": "1", style: { display: "flex", flexDirection: "column", gap: "8px", padding: "8px 0" } }, rows);
1625
+ }
1626
+
1627
+ function registerSettings(ctx) {
1628
+ if (!ctx || !ctx.slots || !feReact) return false;
1629
+ try {
1630
+ ctx.slots.inject("settings.section", function () {
1631
+ return ctx.slots.register({
1632
+ name: "settings.section",
1633
+ id: "dsh-font-enhancer",
1634
+ order: 23,
1635
+ label: function () { return "悬浮球导航"; },
1636
+ inject: function () { return {}; }
1637
+ }, FontSettingsSection);
1638
+ });
1639
+ return true;
1640
+ } catch (e) { return false; }
1641
+ }
1642
+
1643
+ var inject = ["slots", "locale"];
1644
+ var __feSectionRegistered = false;
1645
+ // v1.4.3 延迟注册让位:skill-browser 在场则永不注册(设置页不会出现空标题分区);
1646
+ // 60s 内确认独立存在才注册完整版分区。两插件装卸都以重启为界,轮询窗口足够。
1647
+ function feDelayedRegister(ctx) {
1648
+ var tries = 0;
1649
+ var t = setInterval(function () {
1650
+ tries++;
1651
+ try {
1652
+ if (__feSectionRegistered) { clearInterval(t); return; }
1653
+ if (feSkillBrowserPresent()) {
1654
+ clearInterval(t);
1655
+ try { console.log("[dsh-font-enhancer] settings section skipped (skill-browser present)"); } catch (e) {}
1656
+ return;
1657
+ }
1658
+ if (tries >= 30) { // 60s 仍无 skill-browser → 独立运行,注册兜底分区
1659
+ clearInterval(t);
1660
+ if (registerSettings(ctx)) __feSectionRegistered = true;
1661
+ }
1662
+ } catch (e) {}
1663
+ }, 2000);
1664
+ }
1665
+ function apply(ctx) {
1666
+ try { feDelayedRegister(ctx); } catch (e) {}
1537
1667
  if (document.readyState === "loading") {
1538
1668
  document.addEventListener("DOMContentLoaded", buildUI);
1539
1669
  } else {
1540
1670
  buildUI();
1541
1671
  }
1672
+ feWatchBall();
1673
+ feApplyBallVisibility();
1674
+ // v1.4.3 推荐位安装状态徽标:对每个推荐插件探测是否已安装,
1675
+ // 未安装 → 行内注入「未安装」徽标(已安装则不动,保持干净)。
1676
+ setTimeout(function () {
1677
+ var markNotInstalled = function (recId) {
1678
+ var row = document.querySelector('[data-rec-id="' + recId + '"]');
1679
+ if (!row || row.querySelector(".fe-rec-badge")) return;
1680
+ var badge = document.createElement("span");
1681
+ badge.className = "fe-rec-badge";
1682
+ badge.textContent = "未安装";
1683
+ badge.style.cssText = "flex-shrink:0;margin-left:8px;font-size:11px;padding:2px 8px;border-radius:6px;background:rgba(255,120,120,.15);border:1px solid rgba(255,120,120,.35);color:#ffb3b3;white-space:nowrap";
1684
+ var star = row.querySelector("a");
1685
+ if (star) row.insertBefore(badge, star); else row.appendChild(badge);
1686
+ };
1687
+ // skill-browser:client 运行 = 球元素在 DOM(字体分区出现时通常未装 → 徽标显示)
1688
+ setTimeout(function () {
1689
+ try { if (!document.getElementById("dsh-skill-browser-ball")) markNotInstalled("skillbrowser"); } catch (e) {}
1690
+ }, 1500);
1691
+ // lightbox:宿主路由 /api/image-gallery/list 通 = 已安装
1692
+ try {
1693
+ fetch("/api/image-gallery/list").then(function (r) { if (!r.ok) markNotInstalled("lightbox"); }).catch(function () { markNotInstalled("lightbox"); });
1694
+ } catch (e) { markNotInstalled("lightbox"); }
1695
+ }, 800);
1542
1696
  }
1543
1697
 
1544
1698
  exports.apply = apply;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-font-enhancer",
3
- "version": "1.3.0",
3
+ "version": "1.4.3",
4
4
  "description": "DSH 字体样式 DIY 插件(搜「字体」找到我):按区域自定义中英文字体/字号/字重/斜体/颜色,框选元素创建自定义区域,全局统一控制,主题保存/切换,随机配色,支持自定义字体。DIY your DSH UI fonts & colors: per-region custom font/size/weight/italic/color, pick elements to create custom regions, unified overrides, theme save/switch, random color, custom fonts.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -64,7 +64,13 @@
64
64
  "patch": "./cordis.patch.yml"
65
65
  },
66
66
  "client": {
67
- "inject": ["@deepseek-ai/dsh-client-runtime"],
67
+ "inject": [
68
+ "@deepseek-ai/dsh-client-connection",
69
+ "@deepseek-ai/dsh-client-runtime",
70
+ "@deepseek-ai/dsh-client-ui-settings",
71
+ "@deepseek-ai/dsh-client-ui-slots",
72
+ "@deepseek-ai/dsh-client-locale"
73
+ ],
68
74
  "platform": "web"
69
75
  }
70
76
  }