@wenbin_wb/dsh-bridge 2.10.14 → 2.11.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/CHANGELOG.md CHANGED
@@ -4,6 +4,40 @@
4
4
 
5
5
  ---
6
6
 
7
+ ## [v2.11.0] - 2026-09-28
8
+
9
+ > 本版为客户端架构升级与环境解耦:支持桌面端宿主(如 Tauri)将设置面板作为独立组件嵌入并动态管理设置页入口;同时为 Android 移动壳及第三方自适应插件引入环境自适应让位与多级特性开关,消除界面冲突与遮挡。
10
+
11
+ ### ✨ 新功能
12
+
13
+ - **客户端宿主接入面(对齐 #51)**:在客户端入口暴露 Cordis 反射服务 `ctx.provide('dsh-bridge', { version: 1, render, setSettingsVisible, settingsVisible, configureFeatures, getFeatures })`。桌面端宿主(如 DSH Desktop / Tauri)可调用 `render()` 将 `BridgePanel` 现构造嵌入自定义侧栏或扩展容器,支持 `preferredTab` 指定默认停靠页并保持动态响应;收编后可调用 `setSettingsVisible(false)` 动态撤下全局设置页中的重复条目。老宿主环境下平稳降级。
14
+ - **设置页左侧导航栏图标定制**:新增 `client/settings-nav-icon.js`,通过 CSS mask 将设置中心原生回退的通用小齿轮(gear)替换为「远程访问 / 手机无线连接」专属矢量图标,颜色自动跟随 `currentColor` 保持原生悬停与激活态一致。
15
+ - **移动端多级特性开关与排障支持(对齐 #52)**:新增 `client/mobile-yield.js`,支持通过 URL 查询参数(如 `?dsh_bridge_tweaks=0` 全局禁用、`?dsh_mobile_header=0` 仅禁用顶栏)、宿主全局配置(`window.__DSH_BRIDGE_CONFIG__`)、运行时反射服务或本地存储细粒度控制移动端 UI 特性。
16
+
17
+ ### 🐞 修复
18
+
19
+ - **Android 移动壳/已有自适应插件下的界面冲突与顶栏遮挡(#52)**:在 Android 原生 WebView 壳(如 `com.dsharnessmobile.shell`)或已加载移动自适应插件(如 `@dsh-android/dsh-client-ui-responsive`)的环境下,插件主动避让自建 body 级顶栏与全局覆盖样式,杜绝双重顶栏重叠、设置页错位与触控遮挡失效。
20
+
21
+ ### 🧪 测试
22
+
23
+ - 新增 `test/mobile-yield.test.mjs`(11 条)、`test/client-provide.test.mjs`(6 条)与 `test/settings-nav-icon.test.mjs`(3 条),全量 337 项测试 100% 通过。
24
+
25
+ > ⚠️ 生效说明:纯前端改动,刷新页面即可生效,无需重启 dsh。
26
+
27
+ ---
28
+
29
+ ## [v2.10.15] - 2026-09-25
30
+
31
+ > 本版为设置页关闭按钮的可用性微调:手机上「✕」更容易点中。
32
+
33
+ ### 🐞 修复
34
+
35
+ - **设置页「✕」触控区偏小**:宿主原生为 28px(本插件移动端曾放到 32px),低于移动端推荐的可点尺寸。现放大到 **40×40**,并把 `top/right` 调整为 4px 使按钮中心与标题/返回行的文字中心基本重合(实测相差 1px);标题右侧 52px 留白仍完整覆盖按钮 44px 的占位,长标题与不可折行超长 token 都不会钻到按钮下面。
36
+
37
+ > ⚠️ 生效说明:纯前端样式调整,刷新页面即可生效,无需重启 dsh。
38
+
39
+ ---
40
+
7
41
  ## [v2.10.14] - 2026-09-25
8
42
 
9
43
  > 本版为移动端设置页的体验修复:解决内容被静默裁切、窄屏菜单拥挤、弹窗「✕」位置错乱,以及插件市场的安装确认框被设置弹窗盖住(点「安装」没反应)/ 矮屏下超出屏幕点不到按钮等问题。纯前端样式与交互调整,刷新页面即生效。
package/client/client.js CHANGED
@@ -958,10 +958,12 @@ var MOBILE_STYLES_CSS = `
958
958
  \u628A\u4E24\u8005\u62C9\u56DE\u540C\u4E00\u884C\u7684\u529E\u6CD5\u3002 */
959
959
  html[data-dshbr-drilldown="ready"] button[class*="VOzbGW_close"] {
960
960
  position: absolute !important;
961
- top: 9px !important;
962
- right: 9px !important;
963
- width: 32px !important;
964
- height: 32px !important;
961
+ /* 40\xD740 \u89E6\u63A7\u533A\uFF08\u5BBF\u4E3B\u539F\u4E3A 28px\uFF09\uFF1A\u914D top/right 4px \u540E\u4E2D\u5FC3\u843D\u5728 y=24\uFF0C
962
+ \u4E0E\u6807\u9898\u6587\u5B57\u4E2D\u5FC3\uFF08\u7EA6 23\uFF09\u57FA\u672C\u91CD\u5408\uFF1B\u53F3\u4FA7 4+40=44px \u7684\u5360\u4F4D\u4ECD\u5728\u6807\u9898 52px \u7559\u767D\u4E4B\u5185\u3002 */
963
+ top: 4px !important;
964
+ right: 4px !important;
965
+ width: 40px !important;
966
+ height: 40px !important;
965
967
  z-index: 5 !important;
966
968
  }
967
969
 
@@ -1372,6 +1374,166 @@ function shouldYieldToOfficialPicker(facts) {
1372
1374
  return Boolean(facts?.local) && Boolean(facts?.officialPicker);
1373
1375
  }
1374
1376
 
1377
+ // client/mobile-yield.js
1378
+ var FEATURES = {
1379
+ MOBILE_HEADER: "mobileHeader",
1380
+ MOBILE_STYLES: "mobileStyles",
1381
+ COMPOSER_COLLAPSE: "composerCollapse"
1382
+ };
1383
+ var runtimeFeatureOverrides = {};
1384
+ function setRuntimeFeatureOverrides(overrides) {
1385
+ if (overrides && typeof overrides === "object") {
1386
+ runtimeFeatureOverrides = { ...runtimeFeatureOverrides, ...overrides };
1387
+ }
1388
+ }
1389
+ function getRuntimeFeatureOverrides() {
1390
+ return { ...runtimeFeatureOverrides };
1391
+ }
1392
+ function detectMobileShellOrResponsivePlugin() {
1393
+ if (typeof window === "undefined") return false;
1394
+ if (window.__DSH_MOBILE_SHELL__ || window.__TAURI__ || window.__DSH_DESKTOP__) {
1395
+ return true;
1396
+ }
1397
+ if (window.__DSH_CLIENT_UI_RESPONSIVE__) {
1398
+ return true;
1399
+ }
1400
+ if (typeof document !== "undefined") {
1401
+ if (document.querySelector("[data-dsh-responsive-mobile]") || document.querySelector("[data-dsh-mobile-shell]")) {
1402
+ return true;
1403
+ }
1404
+ }
1405
+ return false;
1406
+ }
1407
+ function isFeatureEnabled(featureName, defaultDetector) {
1408
+ if (typeof window === "undefined") {
1409
+ return typeof defaultDetector === "function" ? defaultDetector() : true;
1410
+ }
1411
+ try {
1412
+ if (window.location && window.location.search) {
1413
+ const params = new URLSearchParams(window.location.search);
1414
+ const tweaksVal = params.get("dsh_bridge_tweaks") ?? params.get("dsh_mobile_tweaks");
1415
+ if (tweaksVal === "0" || tweaksVal === "false" || tweaksVal === "off") {
1416
+ return false;
1417
+ }
1418
+ if (tweaksVal === "1" || tweaksVal === "true" || tweaksVal === "on") {
1419
+ return true;
1420
+ }
1421
+ const kebabName = featureName.replace(/[A-Z]/g, (m) => `_${m.toLowerCase()}`);
1422
+ const specificVal = params.get(`dsh_${kebabName}`) ?? params.get(`dsh_${featureName}`);
1423
+ if (specificVal === "0" || specificVal === "false" || specificVal === "off") {
1424
+ return false;
1425
+ }
1426
+ if (specificVal === "1" || specificVal === "true" || specificVal === "on") {
1427
+ return true;
1428
+ }
1429
+ }
1430
+ } catch {
1431
+ }
1432
+ try {
1433
+ const hostConfig = window.__DSH_BRIDGE_CONFIG__;
1434
+ if (hostConfig && typeof hostConfig === "object") {
1435
+ if (hostConfig.disablePageTweaks === true || hostConfig.disableMobileTweaks === true) {
1436
+ return false;
1437
+ }
1438
+ if (typeof hostConfig[featureName] === "boolean") {
1439
+ return hostConfig[featureName];
1440
+ }
1441
+ }
1442
+ } catch {
1443
+ }
1444
+ if (typeof runtimeFeatureOverrides[featureName] === "boolean") {
1445
+ return runtimeFeatureOverrides[featureName];
1446
+ }
1447
+ try {
1448
+ if (window.localStorage) {
1449
+ const stored = window.localStorage.getItem(`dsh_bridge:feature:${featureName}`);
1450
+ if (stored === "0" || stored === "false") return false;
1451
+ if (stored === "1" || stored === "true") return true;
1452
+ }
1453
+ } catch {
1454
+ }
1455
+ if (typeof defaultDetector === "function") {
1456
+ return defaultDetector();
1457
+ }
1458
+ return true;
1459
+ }
1460
+ function shouldYieldMobileHeader() {
1461
+ return !isFeatureEnabled(FEATURES.MOBILE_HEADER, () => {
1462
+ return !detectMobileShellOrResponsivePlugin();
1463
+ });
1464
+ }
1465
+ function shouldYieldMobileStyles() {
1466
+ return !isFeatureEnabled(FEATURES.MOBILE_STYLES, () => {
1467
+ return !detectMobileShellOrResponsivePlugin();
1468
+ });
1469
+ }
1470
+ function shouldYieldComposerCollapse() {
1471
+ return !isFeatureEnabled(FEATURES.COMPOSER_COLLAPSE, () => {
1472
+ return !detectMobileShellOrResponsivePlugin();
1473
+ });
1474
+ }
1475
+
1476
+ // client/settings-nav-icon.js
1477
+ var SETTINGS_NAV_MARKER = "data-dsh-bridge-settings-nav";
1478
+ var REMOTE_NAV_SVG = `<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect width='10' height='16' x='3' y='4' rx='2'/><path d='M7 16h2'/><path d='M17 8a4 4 0 0 1 0 8'/><path d='M20 5a8 8 0 0 1 0 14'/></svg>`;
1479
+ function getNavIconCss(customSvg = REMOTE_NAV_SVG) {
1480
+ const maskUrl = `data:image/svg+xml,${encodeURIComponent(customSvg)}`;
1481
+ return `
1482
+ [${SETTINGS_NAV_MARKER}] > svg:first-child {
1483
+ display: none !important;
1484
+ }
1485
+ [${SETTINGS_NAV_MARKER}]::before {
1486
+ content: '';
1487
+ flex: none;
1488
+ width: 16px;
1489
+ height: 16px;
1490
+ background-color: currentColor;
1491
+ -webkit-mask: url("${maskUrl}") center / contain no-repeat;
1492
+ mask: url("${maskUrl}") center / contain no-repeat;
1493
+ }
1494
+ `;
1495
+ }
1496
+ function registerSettingsNavIcon(resolveLabel = () => "\u8FDC\u7A0B\u8BBF\u95EE") {
1497
+ if (typeof document === "undefined") return () => {
1498
+ };
1499
+ const styleId = "dsh-bridge-settings-nav-icon-style";
1500
+ if (!document.getElementById(styleId)) {
1501
+ const style = document.createElement("style");
1502
+ style.id = styleId;
1503
+ style.dataset.plugin = "@wenbin_wb/dsh-bridge";
1504
+ style.dataset.pluginCss = "@wenbin_wb/dsh-bridge/settings-nav-icon";
1505
+ style.textContent = getNavIconCss();
1506
+ document.head.appendChild(style);
1507
+ }
1508
+ let disposed = false;
1509
+ const sync = () => {
1510
+ if (disposed) return;
1511
+ const currentLabel = typeof resolveLabel === "function" ? resolveLabel().trim() : "\u8FDC\u7A0B\u8BBF\u95EE";
1512
+ const buttons = document.querySelectorAll('[role="dialog"] nav button, div[class*="VOzbGW_nav"] button');
1513
+ for (const button of buttons) {
1514
+ const text = button.textContent?.trim() || "";
1515
+ if (currentLabel.length > 0 && (text === currentLabel || text.includes(currentLabel))) {
1516
+ button.setAttribute(SETTINGS_NAV_MARKER, "");
1517
+ } else if (button.hasAttribute(SETTINGS_NAV_MARKER)) {
1518
+ button.removeAttribute(SETTINGS_NAV_MARKER);
1519
+ }
1520
+ }
1521
+ };
1522
+ sync();
1523
+ let observer = null;
1524
+ if (typeof MutationObserver !== "undefined") {
1525
+ observer = new MutationObserver(sync);
1526
+ observer.observe(document.body, { childList: true, subtree: true, characterData: true });
1527
+ }
1528
+ return () => {
1529
+ disposed = true;
1530
+ if (observer) observer.disconnect();
1531
+ document.querySelectorAll(`[${SETTINGS_NAV_MARKER}]`).forEach((el) => el.removeAttribute(SETTINGS_NAV_MARKER));
1532
+ const styleEl = document.getElementById(styleId);
1533
+ if (styleEl) styleEl.remove();
1534
+ };
1535
+ }
1536
+
1375
1537
  // lib/bridge-rpc-constants.js
1376
1538
  var BRIDGE_RPC_CHANNEL = "/dsh-bridge";
1377
1539
  var BRIDGE_ENDPOINTS = {
@@ -4858,10 +5020,13 @@ function TabBar({ active, onChange, dots }) {
4858
5020
  })
4859
5021
  );
4860
5022
  }
4861
- function BridgePanel({ rpcCall }) {
5023
+ function BridgePanel({ rpcCall, preferredTab }) {
4862
5024
  const [status, setStatus] = React.useState(null);
4863
5025
  const [err, setErr] = React.useState(null);
4864
- const [activeTab, setActiveTab] = React.useState("lan");
5026
+ const [activeTab, setActiveTab] = React.useState(preferredTab || "lan");
5027
+ React.useEffect(() => {
5028
+ if (preferredTab) setActiveTab(preferredTab);
5029
+ }, [preferredTab]);
4865
5030
  const [platforms, setPlatforms] = React.useState(null);
4866
5031
  const [selectedPlatform, setSelectedPlatform] = React.useState("wechat");
4867
5032
  const [copiedUrl, setCopiedUrl] = React.useState("");
@@ -5643,6 +5808,7 @@ function BridgePanel({ rpcCall }) {
5643
5808
  }
5644
5809
  function injectMobileStyles() {
5645
5810
  if (typeof document === "undefined") return;
5811
+ if (shouldYieldMobileStyles()) return;
5646
5812
  if (document.getElementById("dsh-bridge-mobile-styles")) return;
5647
5813
  const style = document.createElement("style");
5648
5814
  style.id = "dsh-bridge-mobile-styles";
@@ -5701,6 +5867,7 @@ function setupSettingsDrilldown() {
5701
5867
  function setupMobileExperience(rpcCall, ctx) {
5702
5868
  if (typeof document === "undefined" || typeof window === "undefined") return;
5703
5869
  injectMobileStyles();
5870
+ if (shouldYieldMobileHeader()) return;
5704
5871
  let header = document.querySelector(".dsh-mobile-app-header");
5705
5872
  let titleEl = document.querySelector(".dsh-mobile-header-title");
5706
5873
  if (!header) {
@@ -6657,8 +6824,9 @@ function setupIosKeyboardAdapter() {
6657
6824
  });
6658
6825
  }
6659
6826
  function setupComposerCollapse() {
6660
- if (typeof window === "undefined" || typeof document === "undefined") return;
6827
+ if (typeof window === "undefined" || typeof document === "undefined" || typeof MutationObserver === "undefined") return;
6661
6828
  if (window.innerWidth > MOBILE_MAX_WIDTH) return;
6829
+ if (shouldYieldComposerCollapse()) return;
6662
6830
  const LS_KEY = "dsh-composer-fold";
6663
6831
  let bar = null;
6664
6832
  let busy = false;
@@ -6791,6 +6959,11 @@ function setupComposerCollapse() {
6791
6959
  function apply(ctx) {
6792
6960
  window.__dshClientCtx = ctx;
6793
6961
  setupSettingsDrilldown();
6962
+ if (typeof ctx.effect === "function") {
6963
+ ctx.effect(() => registerSettingsNavIcon(() => "\u8FDC\u7A0B\u8BBF\u95EE"), "dsh-bridge: settings nav icon");
6964
+ } else {
6965
+ registerSettingsNavIcon(() => "\u8FDC\u7A0B\u8BBF\u95EE");
6966
+ }
6794
6967
  const rpcCall = (endpoint, payload, signal) => ctx.connection.rpc.call(BRIDGE_RPC_CHANNEL, endpoint, payload, signal);
6795
6968
  window.__dshOpenRemoteWorkspaceModal = (onAdded, onPickDirect, onCancel) => showRemoteWorkspaceDialog(rpcCall, onAdded, ctx, onPickDirect, onCancel);
6796
6969
  setupIosKeyboardAdapter();
@@ -6822,19 +6995,74 @@ function apply(ctx) {
6822
6995
  );
6823
6996
  })
6824
6997
  );
6825
- ctx.slots.inject(
6826
- "settings.section",
6827
- () => ctx.slots.register(
6828
- {
6829
- name: "settings.section",
6830
- id: "dsh-bridge",
6831
- order: 10,
6832
- label: () => "\u8FDC\u7A0B\u8BBF\u95EE",
6833
- inject: () => ({ rpcCall })
6834
- },
6835
- BridgePanel
6836
- )
6837
- );
6998
+ let settingsVisible = true;
6999
+ let sectionRegistration = null;
7000
+ const ensureSectionRegistered = () => {
7001
+ if (!settingsVisible || sectionRegistration) return;
7002
+ try {
7003
+ sectionRegistration = ctx.slots.register(
7004
+ {
7005
+ name: "settings.section",
7006
+ id: "dsh-bridge",
7007
+ order: 10,
7008
+ label: () => "\u8FDC\u7A0B\u8BBF\u95EE",
7009
+ inject: () => ({ rpcCall })
7010
+ },
7011
+ BridgePanel
7012
+ );
7013
+ } catch {
7014
+ }
7015
+ };
7016
+ const ensureSectionUnregistered = () => {
7017
+ if (!sectionRegistration) return;
7018
+ try {
7019
+ if (typeof sectionRegistration === "function") {
7020
+ sectionRegistration();
7021
+ } else if (typeof sectionRegistration.dispose === "function") {
7022
+ sectionRegistration.dispose();
7023
+ }
7024
+ } catch {
7025
+ }
7026
+ sectionRegistration = null;
7027
+ };
7028
+ const sectionGate = {
7029
+ visible: () => settingsVisible,
7030
+ setVisible: (visible) => {
7031
+ const next = !!visible;
7032
+ if (settingsVisible === next) return;
7033
+ settingsVisible = next;
7034
+ if (next) {
7035
+ ensureSectionRegistered();
7036
+ } else {
7037
+ ensureSectionUnregistered();
7038
+ }
7039
+ }
7040
+ };
7041
+ ctx.slots.inject("settings.section", () => {
7042
+ if (settingsVisible) {
7043
+ ensureSectionRegistered();
7044
+ }
7045
+ });
7046
+ const bridgeControl = {
7047
+ version: 1,
7048
+ /** 把插件自己的面板交给宿主渲染(返回 React element) */
7049
+ render: (props = {}) => {
7050
+ return React.createElement(BridgePanel, {
7051
+ rpcCall,
7052
+ preferredTab: props.preferredTab,
7053
+ ...props
7054
+ });
7055
+ },
7056
+ /** 宿主收编面板后,撤下设置页那条重复入口 */
7057
+ setSettingsVisible: (visible) => sectionGate.setVisible(visible),
7058
+ settingsVisible: () => sectionGate.visible(),
7059
+ /** 运行时动态特性开关配置 (Issue #52) */
7060
+ configureFeatures: (flags) => setRuntimeFeatureOverrides(flags),
7061
+ getFeatures: () => getRuntimeFeatureOverrides()
7062
+ };
7063
+ if (typeof ctx.provide === "function") {
7064
+ ctx.provide("dsh-bridge", bridgeControl);
7065
+ }
6838
7066
  }
6839
7067
 
6840
7068
  return module.exports;
package/client/index.js CHANGED
@@ -5,6 +5,14 @@ import {
5
5
  fetchLoopbackTokenOnce,
6
6
  } from './unlock-manager.js'
7
7
  import { hasOfficialDirectoryPicker, shouldYieldToOfficialPicker } from './picker-yield.js'
8
+ import {
9
+ shouldYieldMobileHeader,
10
+ shouldYieldMobileStyles,
11
+ shouldYieldComposerCollapse,
12
+ setRuntimeFeatureOverrides,
13
+ getRuntimeFeatureOverrides,
14
+ } from './mobile-yield.js'
15
+ import { registerSettingsNavIcon } from './settings-nav-icon.js'
8
16
  // dsh-bridge 客户端插件:设置页「远程访问」面板
9
17
 
10
18
  // 兼容非 HTTPS 环境(如手机局域网 HTTP 访问):为非安全上下文补齐 crypto.randomUUID
@@ -3081,10 +3089,13 @@ function TabBar({ active, onChange, dots }) {
3081
3089
 
3082
3090
  // ---- 主面板 ----
3083
3091
 
3084
- function BridgePanel({ rpcCall }) {
3092
+ function BridgePanel({ rpcCall, preferredTab }) {
3085
3093
  const [status, setStatus] = React.useState(null);
3086
3094
  const [err, setErr] = React.useState(null);
3087
- const [activeTab, setActiveTab] = React.useState('lan');
3095
+ const [activeTab, setActiveTab] = React.useState(preferredTab || 'lan');
3096
+ React.useEffect(() => {
3097
+ if (preferredTab) setActiveTab(preferredTab);
3098
+ }, [preferredTab]);
3088
3099
  // 平台列表和连接状态
3089
3100
  const [platforms, setPlatforms] = React.useState(null);
3090
3101
  const [selectedPlatform, setSelectedPlatform] = React.useState('wechat');
@@ -3819,6 +3830,7 @@ function BridgePanel({ rpcCall }) {
3819
3830
 
3820
3831
  function injectMobileStyles() {
3821
3832
  if (typeof document === 'undefined') return;
3833
+ if (shouldYieldMobileStyles()) return;
3822
3834
  if (document.getElementById('dsh-bridge-mobile-styles')) return;
3823
3835
 
3824
3836
  const style = document.createElement('style');
@@ -3915,6 +3927,7 @@ function setupSettingsDrilldown() {
3915
3927
  function setupMobileExperience(rpcCall, ctx) {
3916
3928
  if (typeof document === 'undefined' || typeof window === 'undefined') return;
3917
3929
  injectMobileStyles();
3930
+ if (shouldYieldMobileHeader()) return;
3918
3931
 
3919
3932
  // 1. 创建顶部 DeepSeek App 风格导航条 (Header: 左侧双横线,中间当前会话标题,右侧(+))
3920
3933
  let header = document.querySelector('.dsh-mobile-app-header');
@@ -5067,8 +5080,9 @@ function setupIosKeyboardAdapter() {
5067
5080
  // 中间消息可视区很小。折叠后 composer 隐藏、消息 viewArea 自动伸展全高,阅读区显著增大。
5068
5081
  // 折叠态记忆到 localStorage(dsh-composer-fold),跨会话保持用户偏好。
5069
5082
  function setupComposerCollapse() {
5070
- if (typeof window === 'undefined' || typeof document === 'undefined') return;
5083
+ if (typeof window === 'undefined' || typeof document === 'undefined' || typeof MutationObserver === 'undefined') return;
5071
5084
  if (window.innerWidth > MOBILE_MAX_WIDTH) return; // 仅移动端
5085
+ if (shouldYieldComposerCollapse()) return;
5072
5086
  const LS_KEY = 'dsh-composer-fold';
5073
5087
 
5074
5088
  let bar = null; // 折叠态底部"点击输入"细条
@@ -5197,6 +5211,12 @@ function apply(ctx) {
5197
5211
  // 放在最前:交互层先就绪,后续任何初始化抛异常都不会留下「CSS 生效但监听器缺失」
5198
5212
  // 的状态(CSS 6.2 块另有 <html> 就绪开关双重兜底)。
5199
5213
  setupSettingsDrilldown();
5214
+ // 设置页左侧导航栏图标定制:将原生通用齿轮替换为远程访问专属图标
5215
+ if (typeof ctx.effect === 'function') {
5216
+ ctx.effect(() => registerSettingsNavIcon(() => '远程访问'), 'dsh-bridge: settings nav icon');
5217
+ } else {
5218
+ registerSettingsNavIcon(() => '远程访问');
5219
+ }
5200
5220
  const rpcCall = (endpoint, payload, signal) =>
5201
5221
  ctx.connection.rpc.call(BRIDGE_RPC_CHANNEL, endpoint, payload, signal);
5202
5222
 
@@ -5245,18 +5265,80 @@ function apply(ctx) {
5245
5265
  }),
5246
5266
  );
5247
5267
 
5248
- ctx.slots.inject('settings.section', () =>
5249
- ctx.slots.register(
5250
- {
5251
- name: 'settings.section',
5252
- id: 'dsh-bridge',
5253
- order: 10,
5254
- label: () => '远程访问',
5255
- inject: () => ({ rpcCall }),
5256
- },
5257
- BridgePanel,
5258
- ),
5259
- );
5268
+ // 设置页条目动态门控与可见性管理 (Issue #51)
5269
+ let settingsVisible = true;
5270
+ let sectionRegistration = null;
5271
+
5272
+ const ensureSectionRegistered = () => {
5273
+ if (!settingsVisible || sectionRegistration) return;
5274
+ try {
5275
+ sectionRegistration = ctx.slots.register(
5276
+ {
5277
+ name: 'settings.section',
5278
+ id: 'dsh-bridge',
5279
+ order: 10,
5280
+ label: () => '远程访问',
5281
+ inject: () => ({ rpcCall }),
5282
+ },
5283
+ BridgePanel,
5284
+ );
5285
+ } catch {}
5286
+ };
5287
+
5288
+ const ensureSectionUnregistered = () => {
5289
+ if (!sectionRegistration) return;
5290
+ try {
5291
+ if (typeof sectionRegistration === 'function') {
5292
+ sectionRegistration();
5293
+ } else if (typeof sectionRegistration.dispose === 'function') {
5294
+ sectionRegistration.dispose();
5295
+ }
5296
+ } catch {}
5297
+ sectionRegistration = null;
5298
+ };
5299
+
5300
+ const sectionGate = {
5301
+ visible: () => settingsVisible,
5302
+ setVisible: (visible) => {
5303
+ const next = !!visible;
5304
+ if (settingsVisible === next) return;
5305
+ settingsVisible = next;
5306
+ if (next) {
5307
+ ensureSectionRegistered();
5308
+ } else {
5309
+ ensureSectionUnregistered();
5310
+ }
5311
+ },
5312
+ };
5313
+
5314
+ ctx.slots.inject('settings.section', () => {
5315
+ if (settingsVisible) {
5316
+ ensureSectionRegistered();
5317
+ }
5318
+ });
5319
+
5320
+ // 暴露客户端反射控制面 (Issue #51)
5321
+ const bridgeControl = {
5322
+ version: 1,
5323
+ /** 把插件自己的面板交给宿主渲染(返回 React element) */
5324
+ render: (props = {}) => {
5325
+ return React.createElement(BridgePanel, {
5326
+ rpcCall,
5327
+ preferredTab: props.preferredTab,
5328
+ ...props,
5329
+ });
5330
+ },
5331
+ /** 宿主收编面板后,撤下设置页那条重复入口 */
5332
+ setSettingsVisible: (visible) => sectionGate.setVisible(visible),
5333
+ settingsVisible: () => sectionGate.visible(),
5334
+ /** 运行时动态特性开关配置 (Issue #52) */
5335
+ configureFeatures: (flags) => setRuntimeFeatureOverrides(flags),
5336
+ getFeatures: () => getRuntimeFeatureOverrides(),
5337
+ };
5338
+
5339
+ if (typeof ctx.provide === 'function') {
5340
+ ctx.provide('dsh-bridge', bridgeControl);
5341
+ }
5260
5342
  }
5261
5343
 
5262
5344
  export { name, inject, apply };
@@ -927,10 +927,12 @@ export const MOBILE_STYLES_CSS = `
927
927
  把两者拉回同一行的办法。 */
928
928
  html[data-dshbr-drilldown="ready"] button[class*="VOzbGW_close"] {
929
929
  position: absolute !important;
930
- top: 9px !important;
931
- right: 9px !important;
932
- width: 32px !important;
933
- height: 32px !important;
930
+ /* 40×40 触控区(宿主原为 28px):配 top/right 4px 后中心落在 y=24,
931
+ 与标题文字中心(约 23)基本重合;右侧 4+40=44px 的占位仍在标题 52px 留白之内。 */
932
+ top: 4px !important;
933
+ right: 4px !important;
934
+ width: 40px !important;
935
+ height: 40px !important;
934
936
  z-index: 5 !important;
935
937
  }
936
938