@@ -13,20 +13,39 @@ html,body{margin:0;height:100%;background:#0b0f17;color:#e8edf5;
body{display:flex;flex-direction:column;height:100%;height:100dvh}
.top{display:flex;align-items:center;gap:6px;flex:none;z-index:5;
padding:6px 10px;padding-top:calc(6px + env(safe-area-inset-top));
border-bottom:1px solid #1b2434;background:#0b0f17}
padding:6px 10px;border-bottom:1px solid #1b2434;background:#0b0f17}
/* 顶部标题条:白色,和深色编辑区区分(参考 H5 全屏预览的 fs-bar) */
.actbar{display:flex;align-items:center;gap:6px;flex:none;z-index:7;
height:calc(40px + env(safe-area-inset-top));
padding:env(safe-area-inset-top) 10px 0 12px;
background:#fff;border-bottom:1px solid #e5e7eb;color:#111827}
.abtn{height:32px;min-width:32px;padding:0 8px;border:0;border-radius:8px;
background:transparent;color:#111827;font-size:13px;line-height:1;
display:flex;align-items:center;justify-content:center;gap:6px;flex:none}
.abtn:active{background:#eef1f6}
.abtn:disabled{opacity:.4}
.abtn svg{width:18px;height:18px;display:block}
#back{font-size:16px}
.aname{flex:1;min-width:0;text-align:left;font-size:13px;font-weight:600;color:#111827;
overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.top .nav{width:36px;height:40px;font-size:20px;line-height:1;border:0;border-radius:9px;
background:#161f2e;color:#e8edf5;flex:none;padding:0}
.top .nav:disabled{opacity:.25}
.pager{min-width:48px;text-align:center;color:#9fb0c8;
font-variant-numeric:tabular-nums;flex:none}
.pager b{ color:#e8edf5 ;font-size:15 px}
/* 页码浮在图片右上角(裁切区 / 预览区共用),不占顶栏 */
.pbadge{position:absolute;right:10px;top:10px;z-index:7;padding:2px 8px;border-radius:99px;
background:rgba(4,7,12,.58); color:#c3d0e2 ;font-size:11 px;line-height:1.5;
font-variant-numeric:tabular-nums;pointer-events:none}
/* 当前模式标签:左上角,与右上角页码对称 */
.pbadge.mtag{left:10px;right:auto;color:#e8edf5}
.acts{margin-left:auto;display:flex;gap:4px;flex:none}
.ico{height:40px;width:40px;padding:0;border:0;border-radius:9px;background:#161f2e;
color:#c3d0e2;display:flex;align-items:center;justify-content:center;flex:none;gap:7px}
.ico:active{background:#22304a}
.ico:disabled{opacity:.4}
.ico.pri{background:#1f6feb;color:#fff}
.ico svg{width:20px;height:20px;display:block;flex:none}
.vi{display:flex;align-items:center;justify-content:center;flex:none}
.lbl{display:none;font-size:13px;white-space:nowrap}
/* 移动端翻页按钮:浮在图片左右两侧 */
@@ -59,17 +78,28 @@ body{display:flex;flex-direction:column;height:100%;height:100dvh}
/* 移动端只显示一个窗口:默认原图,点左上角切到预览 */
#prevwrap{display:none;flex:1 1 auto;min-height:0;flex-direction:column;
background:#0a0e16}
.pv-hd{display:flex;align-items:center;gap:8px;padding:8px 12px 0;flex:none;
font-size:12px;color:#7d8ea6}
position:relative;touch-action:none; background:#0a0e16}
#prevwrap .box{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;
padding:8px 12px 10px;overflow:hidden}
#preview{display:block;max-width:100%;max-height:100%}
/* 重新生成:放在照片区底部,避开顶部工具栏;sticky 预览模式下用 prevwrap 里的那个 */
.regen{position:absolute;left:50%;bottom:14px;transform:translateX(-50%);z-index:8;
display:inline-flex;align-items:center;justify-content:center;line-height:1;
height:38px;padding:0 18px;border:0;border-radius:19px;background:#1f6feb;color:#fff;
font-size:13px;font-weight:600;white-space:nowrap;
box-shadow:0 4px 14px rgba(0,0,0,.35)}
.regen:active{background:#1a5fd0}
.regen:disabled{opacity:.55}
@media (max-width:899.98px){
.top .nav{display:none}
body.view-prev .stage{display:none}
body.view-prev #prevwrap{display:flex}
/* 移动端只靠图标猜不出功能:图标在上、两字标签在下 */
.ico{flex-direction:column;width:54px;height:48px;gap:2px;padding:0}
.ico svg{width:18px;height:18px}
.ico .lbl{display:block;font-size:10px;line-height:1}
}
.sheet{position:fixed;inset:0;background:rgba(4,7,12,.74);display:none;
@@ -78,6 +108,10 @@ body{display:flex;flex-direction:column;height:100%;height:100dvh}
.sheet .card{background:#111826;width:100%;max-width:520px;border-radius:16px 16px 0 0;
padding:16px 16px calc(14px + env(safe-area-inset-bottom));max-height:86vh;overflow:auto}
.sheet .card h3{margin:0 0 6px;font-size:15px;font-weight:600}
.sheet .shd{display:flex;align-items:center;justify-content:space-between;margin:0 0 6px}
.sheet .shd h3{margin:0}
.sheet .shd .x{width:28px;height:28px;border:0;border-radius:50%;background:#1b2536;color:#c3d0e2;
font-size:14px;line-height:1;display:inline-flex;align-items:center;justify-content:center}
.sheet .card p{margin:0 0 10px;color:#8ea1ba;font-size:12px;line-height:1.5}
.grp{margin:14px 0 0}
.gl{font-size:12px;color:#8ea1ba;margin-bottom:6px}
@@ -101,12 +135,14 @@ body{display:flex;flex-direction:column;height:100%;height:100dvh}
/* 桌面:左原图、右预览,顶栏按钮带文字 */
@media (min-width:900px){
body{display:grid;grid-template-columns:minmax(0,1fr) 432px;
grid-template-rows:auto minmax(0,1fr) auto;height:100dvh}
.top {grid-column:1/-1;grid-row:1}
.stage {grid-row:2;grid-column:1 }
#prevwrap {grid-row:2/4 ;grid-column:2;border-left:1px solid #1b2434 }
grid-template-rows:auto auto minmax(0,1fr) auto;height:100dvh}
.actbar {grid-column:1/-1;grid-row:1}
.top {grid-column:1/-1;grid-row:2 }
.stage {grid-row:3 ;grid-column:1 }
#prevwrap{grid-row:3/5;grid-column:2;border-left:1px solid #1b2434}
#view{display:none}
.footbar{grid-row:3;grid-column:1;border-top:1px solid #1b2434;padding-bottom:6px }
#prevwrap .regen{display:none!important }
.footbar{grid-row:4;grid-column:1;border-top:1px solid #1b2434;padding-bottom:6px}
.footbar .pnav{display:none}
/* 桌面端顶栏已有翻页,底栏两侧占位保持文件名真正居中 */
.ico{width:auto;padding:0 14px}
@@ -114,43 +150,45 @@ body{display:flex;flex-direction:column;height:100%;height:100dvh}
/* 桌面端翻页在顶栏,底栏只留居中的文件名 */
.footname{font-size:13px;color:#b9c8dd}
}
/* 一键重生成:浮动主按钮。手机放在底栏上方,桌面放在预览区左侧,避免挤顶栏。 */
.fab{position:fixed;right:14px;bottom:calc(64px + env(safe-area-inset-bottom));z-index:15;
height:48px;padding:0 18px;border:0;border-radius:24px;background:#1f6feb;color:#fff;
font-size:15px;font-weight:600;box-shadow:0 6px 20px rgba(0,0,0,.45);
display:flex;align-items:center;justify-content:center}
.fab:active{background:#1a5fd0}
.fab:disabled{opacity:.55}
.fab .lbl{display:inline}
@media (min-width:900px){.fab{right:456px;bottom:76px}}
< / style >
< / head >
< body >
< div class = "actbar" >
< div class = "aname" id = "btitle" > 文档审核< / div >
< button id = "pdf" class = "abtn" title = "下载 PDF" aria-label = "下载 PDF" >
< svg viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke-width = "2" stroke-linecap = "round" stroke-linejoin = "round" > < path d = "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" > < / path > < polyline points = "7 10 12 15 17 10" > < / polyline > < line x1 = "12" y1 = "15" x2 = "12" y2 = "3" > < / line > < / svg >
< / button >
< button id = "back" class = "abtn" title = "返回会话" aria-label = "返回会话" > ✕< / button >
< / div >
< div class = "top" >
< button class = "ico" id = "view" title = "切换原图 / 预览 " aria-label = "切换视图" > < svg viewBox = "0 0 24 24 " fill = "none" stroke = "currentColor" stroke-width = "2" stroke-linecap = "round" stroke-linejoin = "round" > < path d = "M1.5 12S5.5 4.5 12 4.5 22.5 12 22.5 12 18.5 19.5 12 19.5 1.5 12 1.5 12z" / > < circle cx = "12" cy = "12" r = "3" / > < / svg > < / button >
< button class = "ico" id = "view" title = "切换视图 " aria-label = "切换视图" > < span class = "vi " id = "viewIcon" > < / span > < span class = "lbl" > 切换 < / span > < / button >
< button class = "nav" id = "navPrev" aria-label = "上一页" > ‹ < / button >
< div class = "pager" > < b id = "cur" > 1< / b > / < span id = "total" > 1< / span > < / div >
< button class = "nav" id = "navNext" aria-label = "下一页" > › < / button >
< div class = "acts" >
< button class = "ico" id = "rot" title = "旋转 90% " aria-label = "旋转" > < svg viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke-width = "2" stroke-linecap = "round" stroke-linejoin = "round" > < path d = "M21 12a9 9 0 1 1-2.64-6.36" / > < path d = "M21 3v6h-6" / > < / svg > < span class = "lbl" > 旋转 90 ° < / span > < / button >
< button class = "ico" id = "reset" title = "重置本页 " aria-label = "重置" > < svg viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke-width = "2" stroke-linecap = "round" stroke-linejoin = "round" > < path d = "M9 14L4 9l5-5" / > < path d = "M4 9h10a6 6 0 0 1 0 12h-4" / > < / svg > < span class = "lbl" > 重置本页 < / span > < / button >
< button class = "ico" id = "gear" title = "全局设置" aria-label = "全局设置" > < svg viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke-width = "2" stroke-linecap = "round" > < path d = "M4 7h16M4 12h16M4 17h16" / > < circle cx = "9" cy = "7" r = "2.1" fill = "currentColor" stroke = "none" / > < circle cx = "15" cy = "12" r = "2.1" fill = "currentColor" stroke = "none" / > < circle cx = "9" cy = "17" r = "2.1" fill = "currentColor" stroke = "none" / > < / svg > < span class = "lbl" > 全局 设置< / span > < / button >
< button class = "ico" id = "rot" title = "旋转 90° " aria-label = "旋转 90 度 " > < svg viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke-width = "2" stroke-linecap = "round" stroke-linejoin = "round" > < path d = "M21 12a9 9 0 1 1-2.64-6.36" / > < path d = "M21 3v6h-6" / > < / svg > < span class = "lbl" > 旋转< / span > < / button >
< button class = "ico" id = "reset" title = "恢复自动角点 " aria-label = "重置本页 " > < svg viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke-width = "2" stroke-linecap = "round" stroke-linejoin = "round" > < path d = "M9 14L4 9l5-5" / > < path d = "M4 9h10a6 6 0 0 1 0 12h-4" / > < / svg > < span class = "lbl" > 重置< / span > < / button >
< button class = "ico" id = "gear" title = "全局设置" aria-label = "全局设置" > < svg viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke-width = "2" stroke-linecap = "round" > < path d = "M4 7h16M4 12h16M4 17h16" / > < circle cx = "9" cy = "7" r = "2.1" fill = "currentColor" stroke = "none" / > < circle cx = "15" cy = "12" r = "2.1" fill = "currentColor" stroke = "none" / > < circle cx = "9" cy = "17" r = "2.1" fill = "currentColor" stroke = "none" / > < / svg > < span class = "lbl" > 设置< / span > < / button >
< / div >
< / div >
< div class = "stage" id = "stage" >
< div class = "pbadge mtag" > 手动定位< / div >
< div class = "pbadge" id = "stagePage" > 1/1< / div >
< canvas id = "photo" > < / canvas >
< div class = "h" id = "h0" > < / div >
< div class = "h" id = "h1" > < / div >
< div class = "h" id = "h2" > < / div >
< div class = "h" id = "h3" > < / div >
< canvas id = "loupe" > < / canvas >
< button class = "regen" type = "button" style = "display:none" > 重新生成 PDF< / button >
< / div >
< div id = "prevwrap" >
< div class = "pv-hd" > < span > 校正预览 < / span > < / div >
< div class = "pbadge mtag" > 校正预览 < / div >
< div class = "pbadge" id = "pvPage" > 1/1< / div >
< div class = "box" id = "pbox" > < canvas id = "preview" > < / canvas > < / div >
< button class = "regen" type = "button" style = "display:none" > 重新生成 PDF< / button >
< / div >
< div class = "footbar" id = "footbar" >
@@ -161,7 +199,10 @@ body{display:flex;flex-direction:column;height:100%;height:100dvh}
< div id = "setSheet" class = "sheet" >
< div class = "card" >
< h3 > 全局设置 < / h3 >
< div class = "shd" >
< h3 > 全局设置< / h3 >
< button id = "setCloseX" class = "x" type = "button" aria-label = "关闭" > ✕< / button >
< / div >
< p > 这四项对整批生效,不影响单页角点。< / p >
< div class = "grp" > < div class = "gl" > 纸张< / div >
< div class = "seg" id = "seg-paper" >
@@ -192,24 +233,13 @@ body{display:flex;flex-direction:column;height:100%;height:100dvh}
< button data-v = "landscape" > 全部横< / button >
< / div >
< / div >
< div class = "grp" > < div class = "gl" > 本页< / div >
< div class = "seg" id = "seg-page" >
< button id = "moveUp" > 上移< / button >
< button id = "moveDown" > 下移< / button >
< button id = "delPage" > 删除/恢复< / button >
< / div >
< / div >
< p id = "summary" class = "hint" > < / p >
< div id = "warnings" class = "hint" > < / div >
< div class = "row" > < button id = "pdf" class = "pri" > 下载当前 PDF< / button > < / div >
< div class = "row" > < button id = "setClose" class = "pri" > 完成< / button > < / div >
< / div >
< / div >
< div id = "toast" > < / div >
< button id = "apply" class = "fab" title = "应用修改并重新生成" > < span class = "lbl" > 生成 PDF< / span > < / button >
< script >
"use strict";
var TASK = (location.pathname.split("/").filter(Boolean)[1] || "");
@@ -229,7 +259,7 @@ var ICON_EYE = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strok
var ICON_CROP = '< svg viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke-width = "2" stroke-linecap = "round" stroke-linejoin = "round" > < path d = "M6 2v14a2 2 0 0 0 2 2h14" / > < path d = "M18 22V8a2 2 0 0 0-2-2H2" / > < / svg > ';
/* ---------------------------------------------------------------- 数据 */
var S = {cur: 0, pages: [], batch: null, busy: false};
var S = {cur: 0, pages: [], batch: null, busy: false, savedEdits: null };
function parseJSON(s, d) {
if (!s) return d;
@@ -251,8 +281,8 @@ function apiDb(sql, params) {
function paintSummary() {
var b = S.batch || {};
var el = document.getElementById("summary ");
if (el) el .textContent = b.summary || " ";
var t = document.getElementById("btitle ");
if (t) t .textContent = b.output ? String(b.output).split("/").pop() : "文档审核 ";
var w = parseJSON(b.warnings, []);
var we = document.getElementById("warnings");
if (we) {
@@ -269,17 +299,7 @@ function paintSummary() {
}
}
var pdf = document.getElementById("pdf");
if (pdf) {
if (b.output) {
pdf.disabled = false;
pdf.dataset.url = "/api/sessions/" + encodeURIComponent(TASK) +
"/files/download?path=" + encodeURIComponent(b.output) +
"& v=" + encodeURIComponent(b.updated_at || Date.now());
} else {
pdf.disabled = true;
pdf.dataset.url = "";
}
}
if (pdf) pdf.disabled = !b.output;
}
function loadBatch() {
@@ -323,6 +343,7 @@ function loadBatch() {
S.cur = 0;
while (S.cur < S.pages.length & & S . pages [ S . cur ] . deleted ) S . cur + + ;
if (S.cur >= S.pages.length) S.cur = 0;
S.savedEdits = collect();
paintSummary();
return S.pages;
});
@@ -377,6 +398,7 @@ function save() {
g: G
}));
} catch (e) {}
updateActions();
}
/* ---------------------------------------------------------------- 几何 */
@@ -622,7 +644,7 @@ function bindDrag() {
/* 角点优先于翻页按钮:两者可能撞在同一块屏幕上,角点是主操作 */
function hitHandle(ev) {
var p = S.pages[S.cur];
if (!p || p.deleted || !p.w || !p.h) return -1;
if (S.busy || !p || p.deleted || !p.w || !p.h) return -1;
var r = cvEl.getBoundingClientRect();
var px = ev.clientX - r.left, py = ev.clientY - r.top;
var best = -1, bestD = HIT_R;
@@ -636,7 +658,7 @@ function bindDrag() {
function begin(i, ev) {
var p = S.pages[S.cur];
if (!p || p.deleted || !p.w || !p.h) return;
if (S.busy || !p || p.deleted || !p.w || !p.h) return;
drag = {i: i, id: ev.pointerId};
HANDLES[i].classList.add("on");
showLoupe(i, ev);
@@ -645,7 +667,7 @@ function bindDrag() {
function move(ev) {
if (!drag) return;
var p = S.pages[S.cur];
if (!p || p.deleted || !p.w || !p.h) return;
if (S.busy || !p || p.deleted || !p.w || !p.h) return;
var n = toNorm(ev);
/* 允许拖出画面:纸被切掉一块时角点必须在画面外,服务端会外推填白 */
p.c[drag.i] = [clamp(n[0],-0.35,1.35), clamp(n[1],-0.35,1.35)];
@@ -693,6 +715,35 @@ function bindDrag() {
});
}
function bindSwipe() {
var sw = null;
function onDown(ev) {
if (!ev.isPrimary) return;
sw = null;
if (S.busy || drag || ev.pointerType === 'mouse') return;
if (ev.target & & ev.target.closest & & ev.target.closest('button')) return;
sw = {x: ev.clientX, y: ev.clientY, t: Date.now(), id: ev.pointerId};
}
function onUp(ev) {
if (!sw || sw.id !== ev.pointerId) return;
var dx = ev.clientX - sw.x, dy = ev.clientY - sw.y, dt = Date.now() - sw.t;
sw = null;
if (S.busy || drag) return;
if (dt > 800 || Math.abs(dx) < 45 | | Math . abs ( dx ) < Math . abs ( dy ) * 1 . 2 ) return ;
if (dx < 0 ) step ( 1 ) ; else step ( -1 ) ;
}
function onCancel() { sw = null; }
['stage', 'prevwrap'].forEach(function(id){
var el = document.getElementById(id);
if (!el) return;
el.addEventListener('pointerdown', onDown, {passive: true});
el.addEventListener('pointerup', onUp, {passive: true});
el.addEventListener('pointercancel', onCancel, {passive: true});
});
document.addEventListener('pointerup', onUp, {passive: true});
document.addEventListener('pointercancel', onCancel, {passive: true});
}
function paintChrome() {
if (!S.pages.length) return;
var p = S.pages[S.cur];
@@ -705,8 +756,9 @@ function paintChrome() {
else if (p.status === "render_failed") badge = "出页失败";
else if (p.status === "failed") badge = "图片不可读";
if (!badge & & !p.img) badge = "图片不可读";
document.getElementById("cur").textContent = S.cur + 1;
document.getElementById("total ").textContent = S.pages.length ;
var pos = ( S.cur + 1) + "/" + S.pages.length ;
document.getElementById("stagePage ").textContent = pos ;
document.getElementById("pvPage").textContent = pos;
document.getElementById("name").textContent = p.name +
(badge ? "( " + badge + ") " : "");
document.getElementById("prev").disabled = (S.cur === 0);
@@ -722,7 +774,9 @@ function goto(idx) {
}
function step(delta) {
goto(S.cur + delta) ;
var i = S.cur ;
do { i += delta; } while (i >= 0 & & i < S.pages.length & & S . pages [ i ] . deleted ) ;
if (i >= 0 & & i < S.pages.length ) goto ( i ) ;
}
/* ---------------------------------------------------------------- 导出 */
@@ -758,11 +812,27 @@ function collect() {
function setBusy(on) {
S.busy = on;
var b = document.getElementById("apply ");
if (!b) return ;
b.disabled = on ;
var l = b.querySelector(".lbl") ;
if (l) l.textContent = on ? "生成中…" : "生成" ;
var st = document.getElementById("stage ");
if (st) st.style.pointerEvents = on ? "none" : "" ;
var gear = document.getElementById("gear") ;
if (gear) gear.disabled = on ;
var bs = document.querySelectorAll(".regen") ;
for (var i = 0; i < bs.length ; i + + ) {
bs[i].disabled = on;
bs[i].textContent = on ? "生成中…" : "重新生成 PDF";
}
}
function updateActions() {
var dirty = false;
if (S.savedEdits) {
try { dirty = JSON.stringify(collect()) !== JSON.stringify(S.savedEdits); } catch (e) {}
}
var bs = document.querySelectorAll(".regen");
for (var i = 0; i < bs.length ; i + + ) {
bs[i].style.display = dirty ? "inline-flex" : "none";
if (!S.busy) bs[i].textContent = "重新生成 PDF";
}
}
function loadImages() {
@@ -798,9 +868,35 @@ function reloadAfterApply() {
paintChrome();
paintSeg();
layout();
updateActions();
});
}
// 下载走与文件面板同一条链路:先换签名的 download-name 直链再导航。
// 不要直接导航 /files/download: APK/系统下载器不携带登录 cookie,会拿 401;
// 且 URL 末段是固定的 download,解析不了 Content-Disposition 的下载器只能存成 download.pdf。
function downloadPdf() {
var b = S.batch || {};
if (!b.output) return;
var btn = document.getElementById("pdf");
if (btn.disabled) return;
btn.disabled = true;
fetch("/api/sessions/" + encodeURIComponent(TASK) +
"/files/download-token?path=" + encodeURIComponent(b.output))
.then(function(r){
return r.json().then(function(j){ return {ok: r.ok, body: j}; });
})
.then(function(x){
var j = x.body || {};
if (!x.ok || !j.url) throw new Error(j.error || ("HTTP " + x.status));
window.location.href = j.url;
})
.catch(function(e){
toast("下载失败:" + (e & & e.message || e));
})
.then(function(){ btn.disabled = false; });
}
function applyChanges() {
if (S.busy) return;
var edits = collect();
@@ -841,32 +937,6 @@ function applyChanges() {
});
}
function movePage(delta) {
if (S.busy) return;
var p = S.pages[S.cur];
if (!p) return;
var j = S.cur + delta;
while (j >= 0 & & j < S.pages.length & & S . pages [ j ] . deleted ) j + = delta ;
if (j < 0 | | j > = S.pages.length) return;
S.pages[S.cur] = S.pages[j];
S.pages[j] = p;
S.cur = j;
save();
paintChrome();
toast(delta < 0 ? " 已上移 " : " 已下移 " ) ;
}
function deletePage() {
if (S.busy) return;
var p = S.pages[S.cur];
if (!p) return;
p.deleted = !p.deleted;
save();
paintChrome();
layout();
toast(p.deleted ? "已标记删除(生成时跳过);再点一次可恢复" : "已恢复本页");
}
function toast(msg) {
var t = document.getElementById("toast");
t.textContent = msg;
@@ -875,16 +945,21 @@ function toast(msg) {
}
function closeSheet() {
document.getElementById("setSheet").classList.remove("on");
drawPreview();
}
/* ---------------------------------------------------------------- 启动 */
function boot() {
/* 手机上先看校正预览:打开链接第一眼就是成品效果;点左上角再切到裁切。 */
var mobile = window.matchMedia("(max-width:899.98px)").matches;
if (mobile) document.body.classList.add("view-prev");
document.getElementById("total").textContent = S.pages.length;
loadImages();
cv = document.getElementById("photo");
bindDrag();
bindSwipe();
paintChrome();
paintSeg();
layout();
@@ -894,10 +969,8 @@ function boot() {
paintSeg();
document.getElementById("setSheet").classList.add("on");
};
document.getElementById("setClose").onclick = function(){
document.getElementById("setSheet").classList.remove("on") ;
drawPreview();
};
document.getElementById("setClose").onclick = closeSheet;
document.getElementById("setCloseX").onclick = closeSheet ;
document.getElementById("setSheet").onclick = function(e){
if (e.target === this) this.classList.remove("on");
};
@@ -915,11 +988,14 @@ function boot() {
});
/* --- 移动端:原图 / 预览 二选一,按钮在左上角。桌面端两个都显示,按钮隐藏 --- */
/* 当前模式不做成按钮状态:两个面板各自的左上角常驻标签(手动定位 / 校正预览),
移动端一次只显示一个,看到哪个就是当前模式。 */
var viewBtn = document.getElementById("view");
if (mobile) viewBtn.innerHTML = ICON_CROP ;
var viewIcon = document.getElementById("viewIcon") ;
viewIcon.innerHTML = mobile ? ICON_CROP : ICON_EYE;
viewBtn.onclick = function(){
var on = document.body.classList.toggle("view-prev");
viewBt n.innerHTML = on ? ICON_CROP : ICON_EYE;
var prev = document.body.classList.toggle("view-prev");
viewIco n.innerHTML = prev ? ICON_CROP : ICON_EYE;
setTimeout(function(){ layout(); drawPreview(); }, 40);
};
@@ -928,16 +1004,15 @@ function boot() {
document.getElementById("navPrev").onclick = function(){ step(-1); };
document.getElementById("navNext").onclick = function(){ step(1); };
document.getElementById("apply").onclick = applyChanges ;
document.getElementById("moveUp").onclick = function(){ movePage(-1); };
document.getElementById("moveDown ").onclick = function(){ movePage(1); };
document.getElementById("delPage").onclick = deletePage ;
document.getElementById("pdf").onclick = function(){
var u = this.dataset.url;
if (u) window.location.href = u;
var regens = document.querySelectorAll(".regen") ;
for (var i = 0; i < regens.length ; i + + ) regens [ i ] . onclick = applyChanges;
document.getElementById("back ").onclick = function(){
location.href = TASK ? ("/?s=" + encodeURIComponent(TASK)) : "/" ;
};
document.getElementById("pdf").onclick = downloadPdf;
document.getElementById("rot").onclick = function(){
if (S.busy) return;
var p = S.pages[S.cur];
if (!p || p.deleted) return;
p.r = (p.r + 90) % 360;
@@ -947,6 +1022,7 @@ function boot() {
};
document.getElementById("reset").onclick = function(){
if (S.busy) return;
var p = S.pages[S.cur];
if (!p || p.deleted) return;
p.c = p.base.map(function(v){ return [v[0], v[1]]; });
@@ -962,6 +1038,7 @@ function boot() {
/* 兜底:首帧 stage 量到 0 时 layout 会直接返回,稍后再来一次 */
setTimeout(layout, 80);
if (document.fonts & & document.fonts.ready) document.fonts.ready.then(layout);
updateActions();
}
function start() {