@@ -13,20 +13,39 @@ html,body{margin:0;height:100%;background:#0b0f17;color:#e8edf5;
body { display : flex ; flex-direction : column ; height : 100 % ; height : 100 dvh }
body { display : flex ; flex-direction : column ; height : 100 % ; height : 100 dvh }
. top { display : flex ; align-items : center ; gap : 6 px ; flex : none ; z-index : 5 ;
. top { display : flex ; align-items : center ; gap : 6 px ; flex : none ; z-index : 5 ;
padding : 6 px 10 px ; padding-top : calc ( 6 px + env ( safe - area - inset - top ) ) ;
padding : 6 px 10 px ; border-bottom : 1 px solid #1b2434 ; background : #0b0f17 }
border-bottom : 1 px solid #1b2434 ; background : #0b0f17 }
/* 顶部标题条:白色,和深色编辑区区分(参考 H5 全屏预览的 fs-bar) */
. actbar { display : flex ; align-items : center ; gap : 6 px ; flex : none ; z-index : 7 ;
height : calc ( 40 px + env ( safe - area - inset - top ) ) ;
padding : env ( safe - area - inset - top ) 10 px 0 12 px ;
background : #fff ; border-bottom : 1 px solid #e5e7eb ; color : #111827 }
. abtn { height : 32 px ; min-width : 32 px ; padding : 0 8 px ; border : 0 ; border-radius : 8 px ;
background : transparent ; color : #111827 ; font-size : 13 px ; line-height : 1 ;
display : flex ; align-items : center ; justify-content : center ; gap : 6 px ; flex : none }
. abtn : active { background : #eef1f6 }
. abtn : disabled { opacity : .4 }
. abtn svg { width : 18 px ; height : 18 px ; display : block }
# back { font-size : 16 px }
. aname { flex : 1 ; min-width : 0 ; text-align : left ; font-size : 13 px ; font-weight : 600 ; color : #111827 ;
overflow : hidden ; text-overflow : ellipsis ; white-space : nowrap }
. top . nav { width : 36 px ; height : 40 px ; font-size : 20 px ; line-height : 1 ; border : 0 ; border-radius : 9 px ;
. top . nav { width : 36 px ; height : 40 px ; font-size : 20 px ; line-height : 1 ; border : 0 ; border-radius : 9 px ;
background : #161f2e ; color : #e8edf5 ; flex : none ; padding : 0 }
background : #161f2e ; color : #e8edf5 ; flex : none ; padding : 0 }
. top . nav : disabled { opacity : .25 }
. top . nav : disabled { opacity : .25 }
. pager { min-width : 48 px ; text-align : center ; color : #9fb0c8 ;
/* 页码浮在图片右上角(裁切区 / 预览区共用),不占顶栏 */
font-variant-numeric : tabular-nums ; flex : none }
. pbadge { position : absolute ; right : 10 px ; top : 10 px ; z-index : 7 ; padding : 2 px 8 px ; border-radius : 99 px ;
. pager b { color : #e8edf5 ; font-size : 15 px }
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 : 10 px ; right : auto ; color : #e8edf5 }
. acts { margin-left : auto ; display : flex ; gap : 4 px ; flex : none }
. acts { margin-left : auto ; display : flex ; gap : 4 px ; flex : none }
. ico { height : 40 px ; width : 40 px ; padding : 0 ; border : 0 ; border-radius : 9 px ; background : #161f2e ;
. ico { height : 40 px ; width : 40 px ; padding : 0 ; border : 0 ; border-radius : 9 px ; background : #161f2e ;
color : #c3d0e2 ; display : flex ; align-items : center ; justify-content : center ; flex : none ; gap : 7 px }
color : #c3d0e2 ; display : flex ; align-items : center ; justify-content : center ; flex : none ; gap : 7 px }
. ico : active { background : #22304a }
. ico : active { background : #22304a }
. ico : disabled { opacity : .4 }
. ico . pri { background : #1f6feb ; color : #fff }
. ico . pri { background : #1f6feb ; color : #fff }
. ico svg { width : 20 px ; height : 20 px ; display : block ; flex : none }
. ico svg { width : 20 px ; height : 20 px ; display : block ; flex : none }
. vi { display : flex ; align-items : center ; justify-content : center ; flex : none }
. lbl { display : none ; font-size : 13 px ; white-space : nowrap }
. lbl { display : none ; font-size : 13 px ; 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 ;
# prevwrap { display : none ; flex : 1 1 auto ; min-height : 0 ; flex-direction : column ;
background : #0a0e16 }
position : relative ; touch-action : none ; background : #0a0e16 }
. pv-hd { display : flex ; align-items : center ; gap : 8 px ; padding : 8 px 12 px 0 ; flex : none ;
font-size : 12 px ; color : #7d8ea6 }
# prevwrap . box { flex : 1 ; min-height : 0 ; display : flex ; align-items : center ; justify-content : center ;
# prevwrap . box { flex : 1 ; min-height : 0 ; display : flex ; align-items : center ; justify-content : center ;
padding : 8 px 12 px 10 px ; overflow : hidden }
padding : 8 px 12 px 10 px ; overflow : hidden }
# preview { display : block ; max-width : 100 % ; max-height : 100 % }
# preview { display : block ; max-width : 100 % ; max-height : 100 % }
/* 重新生成:放在照片区底部,避开顶部工具栏;sticky 预览模式下用 prevwrap 里的那个 */
. regen { position : absolute ; left : 50 % ; bottom : 14 px ; transform : translateX ( -50 % ) ; z-index : 8 ;
display : inline-flex ; align-items : center ; justify-content : center ; line-height : 1 ;
height : 38 px ; padding : 0 18 px ; border : 0 ; border-radius : 19 px ; background : #1f6feb ; color : #fff ;
font-size : 13 px ; font-weight : 600 ; white-space : nowrap ;
box-shadow : 0 4 px 14 px rgba ( 0 , 0 , 0 , .35 ) }
. regen : active { background : #1a5fd0 }
. regen : disabled { opacity : .55 }
@ media ( max-width : 899 . 98px ) {
@ media ( max-width : 899 . 98px ) {
. top . nav { display : none }
. top . nav { display : none }
body . view-prev . stage { display : none }
body . view-prev . stage { display : none }
body . view-prev # prevwrap { display : flex }
body . view-prev # prevwrap { display : flex }
/* 移动端只靠图标猜不出功能:图标在上、两字标签在下 */
. ico { flex-direction : column ; width : 54 px ; height : 48 px ; gap : 2 px ; padding : 0 }
. ico svg { width : 18 px ; height : 18 px }
. ico . lbl { display : block ; font-size : 10 px ; line-height : 1 }
}
}
. sheet { position : fixed ; inset : 0 ; background : rgba ( 4 , 7 , 12 , .74 ) ; display : none ;
. 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 : 520 px ; border-radius : 16 px 16 px 0 0 ;
. sheet . card { background : #111826 ; width : 100 % ; max-width : 520 px ; border-radius : 16 px 16 px 0 0 ;
padding : 16 px 16 px calc ( 14 px + env ( safe - area - inset - bottom ) ) ; max-height : 86 vh ; overflow : auto }
padding : 16 px 16 px calc ( 14 px + env ( safe - area - inset - bottom ) ) ; max-height : 86 vh ; overflow : auto }
. sheet . card h3 { margin : 0 0 6 px ; font-size : 15 px ; font-weight : 600 }
. sheet . card h3 { margin : 0 0 6 px ; font-size : 15 px ; font-weight : 600 }
. sheet . shd { display : flex ; align-items : center ; justify-content : space-between ; margin : 0 0 6 px }
. sheet . shd h3 { margin : 0 }
. sheet . shd . x { width : 28 px ; height : 28 px ; border : 0 ; border-radius : 50 % ; background : #1b2536 ; color : #c3d0e2 ;
font-size : 14 px ; line-height : 1 ; display : inline-flex ; align-items : center ; justify-content : center }
. sheet . card p { margin : 0 0 10 px ; color : #8ea1ba ; font-size : 12 px ; line-height : 1.5 }
. sheet . card p { margin : 0 0 10 px ; color : #8ea1ba ; font-size : 12 px ; line-height : 1.5 }
. grp { margin : 14 px 0 0 }
. grp { margin : 14 px 0 0 }
. gl { font-size : 12 px ; color : #8ea1ba ; margin-bottom : 6 px }
. gl { font-size : 12 px ; color : #8ea1ba ; margin-bottom : 6 px }
@@ -101,12 +135,14 @@ body{display:flex;flex-direction:column;height:100%;height:100dvh}
/* 桌面:左原图、右预览,顶栏按钮带文字 */
/* 桌面:左原图、右预览,顶栏按钮带文字 */
@ media ( min-width : 900px ) {
@ media ( min-width : 900px ) {
body { display : grid ; grid-template-columns : minmax ( 0 , 1 fr ) 432 px ;
body { display : grid ; grid-template-columns : minmax ( 0 , 1 fr ) 432 px ;
grid-template-rows : auto minmax ( 0 , 1 fr ) auto ; height : 100 dvh }
grid-template-rows : auto auto minmax ( 0 , 1 fr ) auto ; height : 100 dvh }
. top { grid-column : 1 /- 1 ; grid-row : 1 }
. actbar { grid-column : 1 /- 1 ; grid-row : 1 }
. stage { grid-row : 2 ; grid-column : 1 }
. top { grid-column : 1 /- 1 ; grid-row : 2 }
# prevwrap { grid-row : 2 / 4 ; grid-column : 2 ; border-left : 1 px solid #1b2434 }
. stage { grid-row : 3 ; grid-column : 1 }
# prevwrap { grid-row : 3 / 5 ; grid-column : 2 ; border-left : 1 px solid #1b2434 }
# view { display : none }
# view { display : none }
. footbar { grid-row : 3 ; grid-column : 1 ; border-top : 1 px solid #1b2434 ; padding-bottom : 6 px }
# prevwrap . regen { display : none !important }
. footbar { grid-row : 4 ; grid-column : 1 ; border-top : 1 px solid #1b2434 ; padding-bottom : 6 px }
. footbar . pnav { display : none }
. footbar . pnav { display : none }
/* 桌面端顶栏已有翻页,底栏两侧占位保持文件名真正居中 */
/* 桌面端顶栏已有翻页,底栏两侧占位保持文件名真正居中 */
. ico { width : auto ; padding : 0 14 px }
. ico { width : auto ; padding : 0 14 px }
@@ -114,43 +150,45 @@ body{display:flex;flex-direction:column;height:100%;height:100dvh}
/* 桌面端翻页在顶栏,底栏只留居中的文件名 */
/* 桌面端翻页在顶栏,底栏只留居中的文件名 */
. footname { font-size : 13 px ; color : #b9c8dd }
. footname { font-size : 13 px ; color : #b9c8dd }
}
}
/* 一键重生成:浮动主按钮。手机放在底栏上方,桌面放在预览区左侧,避免挤顶栏。 */
. fab { position : fixed ; right : 14 px ; bottom : calc ( 64 px + env ( safe - area - inset - bottom ) ) ; z-index : 15 ;
height : 48 px ; padding : 0 18 px ; border : 0 ; border-radius : 24 px ; background : #1f6feb ; color : #fff ;
font-size : 15 px ; font-weight : 600 ; box-shadow : 0 6 px 20 px 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 : 456 px ; bottom : 76 px } }
< / style >
< / style >
< / head >
< / head >
< body >
< 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" >
< 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 >
< 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 >
< button class = "nav" id = "navNext" aria-label = "下一页" > › < / button >
< div class = "acts" >
< 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 = "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 = "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 = "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 >
< / div >
< div class = "stage" id = "stage" >
< div class = "stage" id = "stage" >
< div class = "pbadge mtag" > 手动定位< / div >
< div class = "pbadge" id = "stagePage" > 1/1< / div >
< canvas id = "photo" > < / canvas >
< canvas id = "photo" > < / canvas >
< div class = "h" id = "h0" > < / div >
< div class = "h" id = "h0" > < / div >
< div class = "h" id = "h1" > < / div >
< div class = "h" id = "h1" > < / div >
< div class = "h" id = "h2" > < / div >
< div class = "h" id = "h2" > < / div >
< div class = "h" id = "h3" > < / div >
< div class = "h" id = "h3" > < / div >
< canvas id = "loupe" > < / canvas >
< canvas id = "loupe" > < / canvas >
< button class = "regen" type = "button" style = "display:none" > 重新生成 PDF< / button >
< / div >
< / div >
< div id = "prevwrap" >
< 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 >
< div class = "box" id = "pbox" > < canvas id = "preview" > < / canvas > < / div >
< button class = "regen" type = "button" style = "display:none" > 重新生成 PDF< / button >
< / div >
< / div >
< div class = "footbar" id = "footbar" >
< 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 id = "setSheet" class = "sheet" >
< div class = "card" >
< div class = "card" >
< div class = "shd" >
< h3 > 全局设置< / h3 >
< h3 > 全局设置< / h3 >
< button id = "setCloseX" class = "x" type = "button" aria-label = "关闭" > ✕< / button >
< / div >
< p > 这四项对整批生效,不影响单页角点。< / p >
< p > 这四项对整批生效,不影响单页角点。< / p >
< div class = "grp" > < div class = "gl" > 纸张< / div >
< div class = "grp" > < div class = "gl" > 纸张< / div >
< div class = "seg" id = "seg-paper" >
< 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 >
< button data-v = "landscape" > 全部横< / button >
< / div >
< / div >
< / 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 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 class = "row" > < button id = "setClose" class = "pri" > 完成< / button > < / div >
< / div >
< / div >
< / div >
< / div >
< div id = "toast" > < / div >
< div id = "toast" > < / div >
< button id = "apply" class = "fab" title = "应用修改并重新生成" > < span class = "lbl" > 生成 PDF< / span > < / button >
< script >
< script >
"use strict" ;
"use strict" ;
var TASK = ( location . pathname . split ( "/" ) . filter ( Boolean ) [ 1 ] || "" ) ;
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 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 ) {
function parseJSON ( s , d ) {
if ( ! s ) return d ;
if ( ! s ) return d ;
@@ -251,8 +281,8 @@ function apiDb(sql, params) {
function paintSummary ( ) {
function paintSummary ( ) {
var b = S . batch || { } ;
var b = S . batch || { } ;
var el = document . getElementById ( "summary " ) ;
var t = document . getElementById ( "btitle " ) ;
if ( el ) el . textContent = b . summary || " ";
if ( t ) t . textContent = b . output ? String ( b . output ) . split ( "/" ) . pop ( ) : "文档审核 ";
var w = parseJSON ( b . warnings , [ ] ) ;
var w = parseJSON ( b . warnings , [ ] ) ;
var we = document . getElementById ( "warnings" ) ;
var we = document . getElementById ( "warnings" ) ;
if ( we ) {
if ( we ) {
@@ -269,17 +299,7 @@ function paintSummary() {
}
}
}
}
var pdf = document . getElementById ( "pdf" ) ;
var pdf = document . getElementById ( "pdf" ) ;
if ( pdf ) {
if ( pdf ) pdf . disabled = ! b . output ;
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 = "" ;
}
}
}
}
function loadBatch ( ) {
function loadBatch ( ) {
@@ -323,6 +343,7 @@ function loadBatch() {
S . cur = 0 ;
S . cur = 0 ;
while ( S . cur < S . pages . length && S . pages [ S . cur ] . deleted ) S . cur ++ ;
while ( S . cur < S . pages . length && S . pages [ S . cur ] . deleted ) S . cur ++ ;
if ( S . cur >= S . pages . length ) S . cur = 0 ;
if ( S . cur >= S . pages . length ) S . cur = 0 ;
S . savedEdits = collect ( ) ;
paintSummary ( ) ;
paintSummary ( ) ;
return S . pages ;
return S . pages ;
} ) ;
} ) ;
@@ -377,6 +398,7 @@ function save() {
g : G
g : G
} ) ) ;
} ) ) ;
} catch ( e ) { }
} catch ( e ) { }
updateActions ( ) ;
}
}
/* ---------------------------------------------------------------- 几何 */
/* ---------------------------------------------------------------- 几何 */
@@ -622,7 +644,7 @@ function bindDrag() {
/* 角点优先于翻页按钮:两者可能撞在同一块屏幕上,角点是主操作 */
/* 角点优先于翻页按钮:两者可能撞在同一块屏幕上,角点是主操作 */
function hitHandle ( ev ) {
function hitHandle ( ev ) {
var p = S . pages [ S . cur ] ;
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 r = cvEl . getBoundingClientRect ( ) ;
var px = ev . clientX - r . left , py = ev . clientY - r . top ;
var px = ev . clientX - r . left , py = ev . clientY - r . top ;
var best = - 1 , bestD = HIT _R ;
var best = - 1 , bestD = HIT _R ;
@@ -636,7 +658,7 @@ function bindDrag() {
function begin ( i , ev ) {
function begin ( i , ev ) {
var p = S . pages [ S . cur ] ;
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 } ;
drag = { i : i , id : ev . pointerId } ;
HANDLES [ i ] . classList . add ( "on" ) ;
HANDLES [ i ] . classList . add ( "on" ) ;
showLoupe ( i , ev ) ;
showLoupe ( i , ev ) ;
@@ -645,7 +667,7 @@ function bindDrag() {
function move ( ev ) {
function move ( ev ) {
if ( ! drag ) return ;
if ( ! drag ) return ;
var p = S . pages [ S . cur ] ;
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 ) ;
var n = toNorm ( ev ) ;
/* 允许拖出画面:纸被切掉一块时角点必须在画面外,服务端会外推填白 */
/* 允许拖出画面:纸被切掉一块时角点必须在画面外,服务端会外推填白 */
p . c [ drag . i ] = [ clamp ( n [ 0 ] , - 0.35 , 1.35 ) , clamp ( n [ 1 ] , - 0.35 , 1.35 ) ] ;
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 ( ) {
function paintChrome ( ) {
if ( ! S . pages . length ) return ;
if ( ! S . pages . length ) return ;
var p = S . pages [ S . cur ] ;
var p = S . pages [ S . cur ] ;
@@ -705,8 +756,9 @@ function paintChrome() {
else if ( p . status === "render_failed" ) badge = "出页失败" ;
else if ( p . status === "render_failed" ) badge = "出页失败" ;
else if ( p . status === "failed" ) badge = "图片不可读" ;
else if ( p . status === "failed" ) badge = "图片不可读" ;
if ( ! badge && ! p . img ) badge = "图片不可读" ;
if ( ! badge && ! p . img ) badge = "图片不可读" ;
document . getElementById ( "cur" ) . textContent = S . cur + 1 ;
var pos = ( S . cur + 1 ) + "/" + S . pages . length ;
document . getElementById ( "total " ) . textContent = S . pages . length ;
document . getElementById ( "stagePage " ) . textContent = pos ;
document . getElementById ( "pvPage" ) . textContent = pos ;
document . getElementById ( "name" ) . textContent = p . name +
document . getElementById ( "name" ) . textContent = p . name +
( badge ? "( " + badge + ") " : "" ) ;
( badge ? "( " + badge + ") " : "" ) ;
document . getElementById ( "prev" ) . disabled = ( S . cur === 0 ) ;
document . getElementById ( "prev" ) . disabled = ( S . cur === 0 ) ;
@@ -722,7 +774,9 @@ function goto(idx) {
}
}
function step ( delta ) {
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 ) {
function setBusy ( on ) {
S . busy = on ;
S . busy = on ;
var b = document . getElementById ( "apply " ) ;
var st = document . getElementById ( "stage " ) ;
if ( ! b ) return ;
if ( st ) st . style . pointerEvents = on ? "none" : "" ;
b . disabled = on ;
var gear = document . getElementById ( "gear" ) ;
var l = b . querySelector ( ".lbl" ) ;
if ( gear ) gear . disabled = on ;
if ( l ) l . textContent = 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 ( ) {
function loadImages ( ) {
@@ -798,9 +868,35 @@ function reloadAfterApply() {
paintChrome ( ) ;
paintChrome ( ) ;
paintSeg ( ) ;
paintSeg ( ) ;
layout ( ) ;
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 ( ) {
function applyChanges ( ) {
if ( S . busy ) return ;
if ( S . busy ) return ;
var edits = collect ( ) ;
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 ) {
function toast ( msg ) {
var t = document . getElementById ( "toast" ) ;
var t = document . getElementById ( "toast" ) ;
t . textContent = msg ;
t . textContent = msg ;
@@ -875,16 +945,21 @@ function toast(msg) {
}
}
function closeSheet ( ) {
document . getElementById ( "setSheet" ) . classList . remove ( "on" ) ;
drawPreview ( ) ;
}
/* ---------------------------------------------------------------- 启动 */
/* ---------------------------------------------------------------- 启动 */
function boot ( ) {
function boot ( ) {
/* 手机上先看校正预览:打开链接第一眼就是成品效果;点左上角再切到裁切。 */
/* 手机上先看校正预览:打开链接第一眼就是成品效果;点左上角再切到裁切。 */
var mobile = window . matchMedia ( "(max-width:899.98px)" ) . matches ;
var mobile = window . matchMedia ( "(max-width:899.98px)" ) . matches ;
if ( mobile ) document . body . classList . add ( "view-prev" ) ;
if ( mobile ) document . body . classList . add ( "view-prev" ) ;
document . getElementById ( "total" ) . textContent = S . pages . length ;
loadImages ( ) ;
loadImages ( ) ;
cv = document . getElementById ( "photo" ) ;
cv = document . getElementById ( "photo" ) ;
bindDrag ( ) ;
bindDrag ( ) ;
bindSwipe ( ) ;
paintChrome ( ) ;
paintChrome ( ) ;
paintSeg ( ) ;
paintSeg ( ) ;
layout ( ) ;
layout ( ) ;
@@ -894,10 +969,8 @@ function boot() {
paintSeg ( ) ;
paintSeg ( ) ;
document . getElementById ( "setSheet" ) . classList . add ( "on" ) ;
document . getElementById ( "setSheet" ) . classList . add ( "on" ) ;
} ;
} ;
document . getElementById ( "setClose" ) . onclick = function ( ) {
document . getElementById ( "setClose" ) . onclick = closeSheet ;
document . getElementById ( "setSheet" ) . classList . remove ( "on" ) ;
document . getElementById ( "setCloseX" ) . onclick = closeSheet ;
drawPreview ( ) ;
} ;
document . getElementById ( "setSheet" ) . onclick = function ( e ) {
document . getElementById ( "setSheet" ) . onclick = function ( e ) {
if ( e . target === this ) this . classList . remove ( "on" ) ;
if ( e . target === this ) this . classList . remove ( "on" ) ;
} ;
} ;
@@ -915,11 +988,14 @@ function boot() {
} ) ;
} ) ;
/* --- 移动端:原图 / 预览 二选一,按钮在左上角。桌面端两个都显示,按钮隐藏 --- */
/* --- 移动端:原图 / 预览 二选一,按钮在左上角。桌面端两个都显示,按钮隐藏 --- */
/* 当前模式不做成按钮状态:两个面板各自的左上角常驻标签(手动定位 / 校正预览),
移动端一次只显示一个,看到哪个就是当前模式。 */
var viewBtn = document . getElementById ( "view" ) ;
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 ( ) {
viewBtn . onclick = function ( ) {
var on = document . body . classList . toggle ( "view-prev" ) ;
var prev = document . body . classList . toggle ( "view-prev" ) ;
viewBtn . innerHTML = on ? ICON _CROP : ICON _EYE ;
viewIcon . innerHTML = prev ? ICON _CROP : ICON _EYE ;
setTimeout ( function ( ) { layout ( ) ; drawPreview ( ) ; } , 40 ) ;
setTimeout ( function ( ) { layout ( ) ; drawPreview ( ) ; } , 40 ) ;
} ;
} ;
@@ -928,16 +1004,15 @@ function boot() {
document . getElementById ( "navPrev" ) . onclick = function ( ) { step ( - 1 ) ; } ;
document . getElementById ( "navPrev" ) . onclick = function ( ) { step ( - 1 ) ; } ;
document . getElementById ( "navNext" ) . onclick = function ( ) { step ( 1 ) ; } ;
document . getElementById ( "navNext" ) . onclick = function ( ) { step ( 1 ) ; } ;
document . getElementById ( "apply" ) . onclick = applyChanges ;
var regens = document . querySelectorAll ( ".regen" ) ;
document . getElementById ( "moveUp" ) . onclick = function ( ) { movePage ( - 1 ) ; } ;
for ( var i = 0 ; i < regens . length ; i ++ ) regens [ i ] . onclick = applyChanges ;
document . getElementById ( "moveDown " ) . onclick = function ( ) { movePage ( 1 ) ; } ;
document . getElementById ( "back " ) . onclick = function ( ) {
document . getElementById ( "delPage" ) . onclick = deletePage ;
location . href = TASK ? ( "/?s=" + encodeURIComponent ( TASK ) ) : "/" ;
document . getElementById ( "pdf" ) . onclick = function ( ) {
var u = this . dataset . url ;
if ( u ) window . location . href = u ;
} ;
} ;
document . getElementById ( "pdf" ) . onclick = downloadPdf ;
document . getElementById ( "rot" ) . onclick = function ( ) {
document . getElementById ( "rot" ) . onclick = function ( ) {
if ( S . busy ) return ;
var p = S . pages [ S . cur ] ;
var p = S . pages [ S . cur ] ;
if ( ! p || p . deleted ) return ;
if ( ! p || p . deleted ) return ;
p . r = ( p . r + 90 ) % 360 ;
p . r = ( p . r + 90 ) % 360 ;
@@ -947,6 +1022,7 @@ function boot() {
} ;
} ;
document . getElementById ( "reset" ) . onclick = function ( ) {
document . getElementById ( "reset" ) . onclick = function ( ) {
if ( S . busy ) return ;
var p = S . pages [ S . cur ] ;
var p = S . pages [ S . cur ] ;
if ( ! p || p . deleted ) return ;
if ( ! p || p . deleted ) return ;
p . c = p . base . map ( function ( v ) { return [ v [ 0 ] , v [ 1 ] ] ; } ) ;
p . c = p . base . map ( function ( v ) { return [ v [ 0 ] , v [ 1 ] ] ; } ) ;
@@ -962,6 +1038,7 @@ function boot() {
/* 兜底:首帧 stage 量到 0 时 layout 会直接返回,稍后再来一次 */
/* 兜底:首帧 stage 量到 0 时 layout 会直接返回,稍后再来一次 */
setTimeout ( layout , 80 ) ;
setTimeout ( layout , 80 ) ;
if ( document . fonts && document . fonts . ready ) document . fonts . ready . then ( layout ) ;
if ( document . fonts && document . fonts . ready ) document . fonts . ready . then ( layout ) ;
updateActions ( ) ;
}
}
function start ( ) {
function start ( ) {