Expose Ena Planner settings in panel

This commit is contained in:
Hao19911125
2026-04-02 16:10:54 +08:00
parent c75083a456
commit 69844e0693
3 changed files with 115 additions and 0 deletions

View File

@@ -445,6 +445,15 @@
在这里集中配置第二记忆模型、功能开关、细粒度参数、任务预设和面板主题。 在这里集中配置第二记忆模型、功能开关、细粒度参数、任务预设和面板主题。
</p> </p>
</div> </div>
<div class="bme-config-workspace-actions">
<button class="bme-config-launch-btn" id="bme-open-ena-planner" type="button">
<i class="fa-solid fa-wand-magic-sparkles"></i>
<span>Ena Planner 设置</span>
</button>
<div class="bme-config-launch-hint" id="bme-open-ena-planner-hint">
检测中...
</div>
</div>
</div> </div>
<div class="bme-config-nav bme-config-nav-mobile"> <div class="bme-config-nav bme-config-nav-mobile">

View File

@@ -408,6 +408,7 @@ export async function initPanel({
_bindGraphControls(); _bindGraphControls();
_bindActions(); _bindActions();
_bindConfigControls(); _bindConfigControls();
_bindPlannerLauncher();
currentTabId = currentTabId =
panelEl?.querySelector(".bme-tab-btn.active")?.dataset.tab || "dashboard"; panelEl?.querySelector(".bme-tab-btn.active")?.dataset.tab || "dashboard";
_applyWorkspaceMode(); _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() { function _applyWorkspaceMode() {
if (!panelEl) return; if (!panelEl) return;
const isConfig = currentTabId === "config"; const isConfig = currentTabId === "config";
@@ -1418,6 +1457,7 @@ function _bindActions() {
function _refreshConfigTab() { function _refreshConfigTab() {
const settings = _getSettings?.() || {}; const settings = _getSettings?.() || {};
_refreshPlannerLauncher();
_setCheckboxValue("bme-setting-enabled", settings.enabled ?? true); _setCheckboxValue("bme-setting-enabled", settings.enabled ?? true);
_setCheckboxValue( _setCheckboxValue(

View File

@@ -953,9 +953,64 @@
.bme-config-workspace-header { .bme-config-workspace-header {
padding: 20px 22px 10px; padding: 20px 22px 10px;
border-bottom: 1px solid rgba(255, 255, 255, 0.04); 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; 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-workspace-title,
.bme-config-section-title { .bme-config-section-title {
margin: 0; margin: 0;
@@ -2242,12 +2297,23 @@
/* ⑦ Config mode 移动端 */ /* ⑦ Config mode 移动端 */
.bme-config-workspace-header { .bme-config-workspace-header {
padding: 14px 14px 8px; padding: 14px 14px 8px;
flex-direction: column;
align-items: stretch;
} }
.bme-config-workspace-title { .bme-config-workspace-title {
font-size: 18px; font-size: 18px;
} }
.bme-config-workspace-actions {
align-items: stretch;
}
.bme-config-launch-hint {
max-width: none;
text-align: left;
}
.bme-config-sections { .bme-config-sections {
padding: 14px; padding: 14px;
padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));