diff --git a/static/app.js b/static/app.js
index faef2dc..f485c5c 100644
--- a/static/app.js
+++ b/static/app.js
@@ -323,6 +323,32 @@ function dagSize() {
return dagLayout(tasks, idMap);
}
+function dagFitView() {
+ // 画布适配视口:缩放并居中,让全部节点可见
+ const s = dagState;
+ const box = $('#dag-box');
+ const {width, height} = dagSize();
+ if (!box || !s) return;
+ const bw = box.clientWidth, bh = box.clientHeight;
+ const scale = Math.max(0.25, Math.min(1, (bw - 60) / width, (bh - 60) / height));
+ s.scale = scale;
+ s.tx = (bw - width * scale) / 2;
+ s.ty = (bh - height * scale) / 2;
+ dagApplyView();
+ saveDagState();
+}
+
+function dagZoomTo(scale) {
+ // 一键回到指定比例(100% = 原始视图)
+ const s = dagState;
+ if (!s) return;
+ s.scale = scale;
+ s.tx = 0;
+ s.ty = 0;
+ dagApplyView();
+ saveDagState();
+}
+
function saveDagState() {
if (!dagState) return;
try {
@@ -340,6 +366,8 @@ function dagApplyView() {
if (!svg) return;
svg.style.transform = `translate(${s.tx}px, ${s.ty}px) scale(${s.scale})`;
svg.style.transformOrigin = '0 0';
+ const pct = $('#dag-zoom-pct');
+ if (pct) pct.textContent = Math.round(s.scale * 100) + '%';
}
function drawDag() {
@@ -364,6 +392,10 @@ function drawDag() {
+
🔍 100%
+
+
+
🗑️ 删除区0