fix(view): share the same shell between static and live output

Static exports now include the View shell and dark theme; interactive toolbar and Execution Clear stay hidden, while dynamic pages show them.
This commit is contained in:
cflmy committed 2026-10-18 12:52:48 +08:00
1 parent 4757b82edd
commit 142d30ce08
2 files changed
+11 -7

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(不再空转);移除 `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
+10 -6
View File
@@ -3895,6 +3895,11 @@ 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 outline_block = if vm.outline_html.is_empty() {
String::new()
} else {
@@ -3935,11 +3940,9 @@ pub fn page_file(files: &[PathBuf], rel: &str, vm: &FileViewModel, links: &LinkM
let trace_safe = vm
.trace_json
.replace("</", "<\\/");
let notebook = if matches!(links, LinkMode::Live) {
notebook_ui().to_string()
} else {
String::new()
};
// Static exports share the same view shell. The script sees
// MARQDO_VIEW_LIVE=false and leaves the interactive controls hidden.
let notebook = notebook_ui().to_string();
let main = format!(
r#"
<script>
@@ -3956,7 +3959,7 @@ window.MARQDO_AUTO_STREAM = {auto_stream};
{structure_block}
</section>
<section class="block exec-block" id="exec-block">
<h2>Execution <button type="button" class="exec-clear" id="exec-clear">Clear</button></h2>
<h2>Execution {exec_clear}</h2>
{stdin_panel}
{stream_panel}
{plan_card}
@@ -3981,6 +3984,7 @@ window.MARQDO_AUTO_STREAM = {auto_stream};
status_label = status_label,
rel = escape(rel),
notebook = notebook,
exec_clear = exec_clear,
structure_block = structure_block,
stdin_panel = stdin_panel,
stream_panel = stream_panel,