dsh-font-enhancer 1.3.0 → 1.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/lib/client.js +70 -2
- package/package.json +8 -2
package/lib/client.js
CHANGED
|
@@ -1532,13 +1532,81 @@ window.__ModuleLoader__.load({
|
|
|
1532
1532
|
}
|
|
1533
1533
|
|
|
1534
1534
|
// ---------- entry ----------
|
|
1535
|
-
|
|
1536
|
-
|
|
1535
|
+
// 设置页「悬浮球导航」分区(settings.section,与技能浏览器同款官方机制)。
|
|
1536
|
+
// 让字体球(Aa)的显隐由 font-enhancer 自己在 DSH 设置页控制,不依赖其他插件。
|
|
1537
|
+
var FE_BALL_VIS_KEY = "dsh-font-ball-visible";
|
|
1538
|
+
function feReadStore(key, def) {
|
|
1539
|
+
try { var v = localStorage.getItem(key); return v == null ? def : v === "1"; } catch (e) { return def; }
|
|
1540
|
+
}
|
|
1541
|
+
function feWriteStore(key, val) {
|
|
1542
|
+
try { localStorage.setItem(key, val ? "1" : "0"); } catch (e) {}
|
|
1543
|
+
}
|
|
1544
|
+
function feApplyBallVisibility() {
|
|
1545
|
+
var hidden = !feReadStore(FE_BALL_VIS_KEY, true);
|
|
1546
|
+
var t = document.getElementById("dsh-fe-toggle");
|
|
1547
|
+
if (t) t.style.setProperty("display", hidden ? "none" : "", "important");
|
|
1548
|
+
}
|
|
1549
|
+
// 监听字体球(防热重载后重建时样式/显隐丢失;低频轮询,CSS 已兜底)
|
|
1550
|
+
function feWatchBall() {
|
|
1551
|
+
var tries = 0;
|
|
1552
|
+
var t = setInterval(function () {
|
|
1553
|
+
tries++;
|
|
1554
|
+
try { feApplyBallVisibility(); } catch (e) {}
|
|
1555
|
+
if (tries > 120) clearInterval(t);
|
|
1556
|
+
}, 1000);
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
var feReact = null;
|
|
1560
|
+
try {
|
|
1561
|
+
var feReactRaw = require("react");
|
|
1562
|
+
feReact = (feReactRaw && feReactRaw.default) || feReactRaw;
|
|
1563
|
+
} catch (e) { feReact = null; }
|
|
1564
|
+
if (!feReact) { try { feReact = window.React || null; } catch (e) {} }
|
|
1565
|
+
|
|
1566
|
+
function FontSettingsSection(props) {
|
|
1567
|
+
if (!feReact) return null;
|
|
1568
|
+
var rows = [];
|
|
1569
|
+
function mkToggle(id, label, onChange) {
|
|
1570
|
+
return feReact.createElement("label", { key: id, style: { display: "flex", alignItems: "center", gap: "8px", fontSize: "13px", cursor: "pointer" } },
|
|
1571
|
+
feReact.createElement("input", { type: "checkbox", id: id, onChange: onChange }),
|
|
1572
|
+
feReact.createElement("span", null, label));
|
|
1573
|
+
}
|
|
1574
|
+
rows.push(feReact.createElement("div", { key: "head", style: { fontWeight: "600", marginBottom: "4px" } }, "悬浮球导航"));
|
|
1575
|
+
rows.push(mkToggle("fe-set-ball", "字体插件悬浮球(Aa)", function (e) {
|
|
1576
|
+
feWriteStore(FE_BALL_VIS_KEY, e.target.checked);
|
|
1577
|
+
feApplyBallVisibility();
|
|
1578
|
+
}));
|
|
1579
|
+
rows.push(feReact.createElement("div", { key: "hint", style: { fontSize: "12px", color: "#8b93a8" } },
|
|
1580
|
+
"悬浮球可拖动;显示/隐藏此开关"));
|
|
1581
|
+
return feReact.createElement("div", { "data-fe-slot": "1", style: { display: "flex", flexDirection: "column", gap: "8px", padding: "8px 0" } }, rows);
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
function registerSettings(ctx) {
|
|
1585
|
+
if (!ctx || !ctx.slots || !feReact) return false;
|
|
1586
|
+
try {
|
|
1587
|
+
ctx.slots.inject("settings.section", function () {
|
|
1588
|
+
return ctx.slots.register({
|
|
1589
|
+
name: "settings.section",
|
|
1590
|
+
id: "dsh-font-enhancer",
|
|
1591
|
+
order: 23,
|
|
1592
|
+
label: function () { return "字体悬浮球"; },
|
|
1593
|
+
inject: function () { return {}; }
|
|
1594
|
+
}, FontSettingsSection);
|
|
1595
|
+
});
|
|
1596
|
+
return true;
|
|
1597
|
+
} catch (e) { return false; }
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
var inject = ["slots", "locale"];
|
|
1601
|
+
function apply(ctx) {
|
|
1602
|
+
try { registerSettings(ctx); } catch (e) {}
|
|
1537
1603
|
if (document.readyState === "loading") {
|
|
1538
1604
|
document.addEventListener("DOMContentLoaded", buildUI);
|
|
1539
1605
|
} else {
|
|
1540
1606
|
buildUI();
|
|
1541
1607
|
}
|
|
1608
|
+
feWatchBall();
|
|
1609
|
+
feApplyBallVisibility();
|
|
1542
1610
|
}
|
|
1543
1611
|
|
|
1544
1612
|
exports.apply = apply;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-font-enhancer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
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": [
|
|
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
|
}
|