From 69844e06931ebb77c5c4d5ad0f4787f402c887db Mon Sep 17 00:00:00 2001 From: Hao19911125 <99091644+Hao19911125@users.noreply.github.com> Date: Thu, 2 Apr 2026 16:10:54 +0800 Subject: [PATCH] Expose Ena Planner settings in panel --- panel.html | 9 ++++++++ panel.js | 40 +++++++++++++++++++++++++++++++++ style.css | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) diff --git a/panel.html b/panel.html index b94409a..5af06f7 100644 --- a/panel.html +++ b/panel.html @@ -445,6 +445,15 @@ 在这里集中配置第二记忆模型、功能开关、细粒度参数、任务预设和面板主题。

+
+ +
+ 检测中... +
+
diff --git a/panel.js b/panel.js index 062c1ef..4bebba8 100644 --- a/panel.js +++ b/panel.js @@ -408,6 +408,7 @@ export async function initPanel({ _bindGraphControls(); _bindActions(); _bindConfigControls(); + _bindPlannerLauncher(); currentTabId = panelEl?.querySelector(".bme-tab-btn.active")?.dataset.tab || "dashboard"; _applyWorkspaceMode(); @@ -736,6 +737,44 @@ function _switchTab(tabId) { } } +function _getPlannerApi() { + return globalThis?.stBmeEnaPlanner || null; +} + +function _refreshPlannerLauncher() { + const button = document.getElementById("bme-open-ena-planner"); + const hint = document.getElementById("bme-open-ena-planner-hint"); + if (!button || !hint) return; + + const plannerApi = _getPlannerApi(); + const ready = typeof plannerApi?.openSettings === "function"; + + button.disabled = !ready; + button.classList.toggle("is-runtime-disabled", !ready); + hint.textContent = ready + ? "已加载,可打开独立的 Ena Planner 设置页。" + : "未检测到 Ena Planner 模块,请重载 ST-BME 后再试。"; +} + +function _bindPlannerLauncher() { + const button = document.getElementById("bme-open-ena-planner"); + if (!button || button.dataset.bmeBound === "true") { + _refreshPlannerLauncher(); + return; + } + + button.addEventListener("click", () => { + const plannerApi = _getPlannerApi(); + if (typeof plannerApi?.openSettings === "function") { + plannerApi.openSettings(); + } + _refreshPlannerLauncher(); + }); + + button.dataset.bmeBound = "true"; + _refreshPlannerLauncher(); +} + function _applyWorkspaceMode() { if (!panelEl) return; const isConfig = currentTabId === "config"; @@ -1418,6 +1457,7 @@ function _bindActions() { function _refreshConfigTab() { const settings = _getSettings?.() || {}; + _refreshPlannerLauncher(); _setCheckboxValue("bme-setting-enabled", settings.enabled ?? true); _setCheckboxValue( diff --git a/style.css b/style.css index a1767b1..9ea007a 100644 --- a/style.css +++ b/style.css @@ -953,9 +953,64 @@ .bme-config-workspace-header { padding: 20px 22px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 16px; flex-shrink: 0; } +.bme-config-workspace-actions { + display: flex; + flex-direction: column; + align-items: flex-end; + gap: 8px; + flex-shrink: 0; +} + +.bme-config-launch-btn { + display: inline-flex; + align-items: center; + gap: 8px; + min-height: 38px; + padding: 0 14px; + border-radius: 12px; + border: 1px solid rgba(255, 255, 255, 0.08); + background: rgba(255, 255, 255, 0.04); + color: var(--bme-on-surface); + cursor: pointer; + transition: + border-color 0.2s ease, + background 0.2s ease, + color 0.2s ease, + transform 0.2s ease; +} + +.bme-config-launch-btn:hover { + border-color: var(--bme-primary); + color: var(--bme-primary); + background: var(--bme-primary-dim); + transform: translateY(-1px); +} + +.bme-config-launch-btn:disabled, +.bme-config-launch-btn.is-runtime-disabled { + opacity: 0.5; + cursor: not-allowed; + color: var(--bme-on-surface-dim); + border-color: rgba(255, 255, 255, 0.06); + background: rgba(255, 255, 255, 0.02); + transform: none; +} + +.bme-config-launch-hint { + font-size: 12px; + line-height: 1.4; + color: var(--bme-on-surface-dim); + text-align: right; + max-width: 220px; +} + .bme-config-workspace-title, .bme-config-section-title { margin: 0; @@ -2242,12 +2297,23 @@ /* ⑦ Config mode 移动端 */ .bme-config-workspace-header { padding: 14px 14px 8px; + flex-direction: column; + align-items: stretch; } .bme-config-workspace-title { font-size: 18px; } + .bme-config-workspace-actions { + align-items: stretch; + } + + .bme-config-launch-hint { + max-width: none; + text-align: left; + } + .bme-config-sections { padding: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));