fix(view): keep static buttons with a no-live notice

Static pages now render the same toolbar and Execution Clear button as live view. Clicking any execution control shows a static-export notice instead of hiding controls or pretending to run.
This commit is contained in:
cflmy committed 2026-10-18 12:55:07 +08:00
1 parent 142d30ce08
commit ad3ebf243a
2 files changed
+23 -16

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@
### Added
- **foreign 拥有视图会话**:新增 `foreign.session kernels= cells=`,返回 foreign 会话句柄;`view` 只消费 `会话` 绑定,不再识别 `内核表` / `会话表` 保留名。没有 `会话` 时,view cells 使用无状态一次性执行,不创建内核。清除输出已接通 `/api/session/clear`,普通 view 与 foreign cells 共用,并由 Execution 面板的 Clear 按钮清除页面输出;无 `会话` 的 view 在 Run All 时执行整个文档并回写 Execution(不再空转);静态导出与动态 view 共用同一套 View 外壳,静态只隐藏交互控件;移除 `In []` / `Out []` 与 Notebook 品牌;没有新增 CLI 或第二个交互模式。
- **foreign 拥有视图会话**:新增 `foreign.session kernels= cells=`,返回 foreign 会话句柄;`view` 只消费 `会话` 绑定,不再识别 `内核表` / `会话表` 保留名。没有 `会话` 时,view cells 使用无状态一次性执行,不创建内核。清除输出已接通 `/api/session/clear`,普通 view 与 foreign cells 共用,并由 Execution 面板的 Clear 按钮清除页面输出;无 `会话` 的 view 在 Run All 时执行整个文档并回写 Execution(不再空转);静态导出与动态 view 共用同一套 View 外壳和按钮布局;静态页面执行按钮点击显示“静态页面无法真实执行”,不伪造成功;移除 `In []` / `Out []` 与 Notebook 品牌;没有新增 CLI 或第二个交互模式。
### Fixed
+22 -15
View File
@@ -1663,15 +1663,7 @@ pub fn layout(title: &str, nav: &str, main: &str) -> String {
var body = card.querySelector(".code-body code");
// Narrative ```text``` cards have no Run chrome — leave as-is.
if (!btn) return;
if (!live) {{
// Static: hide fake Run (view-static-interactive D5 / view-prose-annot-gaps P4).
if (foot) foot.hidden = true;
else {{
btn.hidden = true;
if (cmd) cmd.hidden = true;
}}
return;
}}
if (!live) return; // static actions are bound to the view-shell notice
if (!out || !body) return;
btn.addEventListener("click", function () {{
btn.disabled = true;
@@ -3517,7 +3509,7 @@ body.notebook-page .stdin-form button {
var savedTheme = "dark";
try { savedTheme = localStorage.getItem(THEME_KEY) || "dark"; } catch (e) {}
applyTheme(savedTheme);
if (!window.MARQDO_VIEW_LIVE) return;
var live = !!window.MARQDO_VIEW_LIVE;
var path = window.MARQDO_FILE_PATH || "";
if (!path) return;
var state = { open: false, persistent: false, kernels: [], cells: {} };
@@ -3701,6 +3693,25 @@ body.notebook-page .stdin-form button {
foot.remove();
}
});
if (!live) {
var staticBar = document.getElementById("notebook-bar");
if (staticBar) staticBar.hidden = false;
function staticNotice() {
status("静态页面无法真实执行 / static export: no live execution");
}
["nb-run-all", "nb-restart", "nb-step", "nb-state", "nb-journal",
"nb-clear", "nb-reload", "nb-debug", "exec-clear"].forEach(function (id) {
bind(id, staticNotice);
});
document.querySelectorAll(".code-run").forEach(function (btn) {
btn.addEventListener("click", function (e) {
e.preventDefault();
staticNotice();
});
});
status("static export · preview only");
return;
}
bind("nb-run-all", function () { runAll(false); });
bind("nb-restart", function () { runAll(true); });
bind("nb-step", function () {
@@ -3895,11 +3906,7 @@ pub fn page_file(files: &[PathBuf], rel: &str, vm: &FileViewModel, links: &LinkM
LinkMode::Live => "true",
LinkMode::Static { .. } => "false",
};
let exec_clear = if matches!(links, LinkMode::Live) {
r#"<button type="button" class="exec-clear" id="exec-clear">Clear</button>"#
} else {
""
};
let exec_clear = r#"<button type="button" class="exec-clear" id="exec-clear">Clear</button>"#;
let outline_block = if vm.outline_html.is_empty() {
String::new()
} else {