diff --git a/skills/document-photo-to-pdf/REVIEW.md b/skills/document-photo-to-pdf/REVIEW.md index 156deea..0dc3217 100644 --- a/skills/document-photo-to-pdf/REVIEW.md +++ b/skills/document-photo-to-pdf/REVIEW.md @@ -95,17 +95,36 @@ requested_at TEXT, started_at TEXT, finished_at TEXT 1. 页面从 `/app//doc-review/` 加载;无 `?b=` 时查 `doc_review_batch` 最新一行。 2. 通过 `POST /api/db//query` 读 `doc_review_batch` / `doc_review_page`。 3. 用户拖角/旋转/删页/排序/改四项参数,只改浏览器内状态并写 localStorage 草稿。 -4. 点「生成 PDF」: +4. 点「重新生成 PDF」: - `INSERT ... ON CONFLICT` 写 `doc_review_job`(`status=queued`,`edits` 是完整快照); - 调通用执行接口 `POST /api/sessions//skills/document-photo-to-pdf/run`,body `{args:{batch_id}}`; - 技能读 job → 应用 edits → 覆盖同名 PDF → 更新 batch/page/job; - - 页面重新读 data.db,刷新摘要、状态、PDF 链接。 + - 页面重新读 data.db,刷新警告、状态、PDF 链接。 5. 全程不经过模型,也不需要用户复制 JSON。 通用接口实现在 `app/server/routes/skill-run.js`:core 只做会话/并发/错误映射,执行仍走 `tools/skills.runSkill`,不感知技能名或参数语义。 +## 页面交互约定 + +- 顶部标题条(白底,参考 H5 全屏预览):左侧 PDF 名,右侧下载 PDF,最右 X 返回会话。 +- 重新生成 PDF 不在顶栏:放在照片区底部(stage 与预览各一个,按当前视图显示;桌面只用 + stage),仅在存在未保存修改时出现。 +- 底部只保留翻页和当前页名,不再放操作按钮。 +- 页码不占顶栏:`1/n` 浮在图片右上角(裁切区、预览区各一个,按当前视图显示); + 左上角常驻当前模式标签(裁切区「手动定位」、预览区「校正预览」)。 + 移动端一次只显示一个面板,看到哪个标签就是当前模式;视图按钮固定叫「切换」。 + 移动端顶栏按钮带文字而非只靠图标:视图按钮写“点下去会去哪”(当前在预览→手动定位, + 在当前裁切→校正预览),另三个是旋转 / 重置 / 设置。 +- 裁切区/预览区支持左右滑动翻页:左滑下一页、右滑上一页;仅触摸/笔生效,拖角优先, + 按钮点击不触发。 +- 是否 dirty 用 `collect()` 与加载时的基线 `S.savedEdits` 比较;拖角、旋转、删页/排序、 + 改四项参数都会触发。 +- 重新生成成功后重读 DB、清本地草稿、把新状态设为基线,按钮自动消失;失败则保留以便重试。 +- X 返回 `/?s=`;独立页面里也适用。 +- 手机默认进校正预览,点左上角切到裁切。 + ## edits / 旋转语义 ```json diff --git a/skills/document-photo-to-pdf/SKILL.md b/skills/document-photo-to-pdf/SKILL.md index d40f11a..90e2fb0 100644 --- a/skills/document-photo-to-pdf/SKILL.md +++ b/skills/document-photo-to-pdf/SKILL.md @@ -34,7 +34,7 @@ input_schema: 访问地址:https://agent.ai.foresh.com/app/task-20261023-001/doc-review/ ``` -审核页可拖角、旋转、删页/排序、改纸张与清晰度;点「生成 PDF」覆盖同名文件。 +审核页可拖角、旋转、删页/排序、改纸张与清晰度;改动后点「重新生成 PDF」覆盖同名文件。 ## 失败与拍摄 diff --git a/skills/document-photo-to-pdf/doc_deskew/check.py b/skills/document-photo-to-pdf/doc_deskew/check.py index 775e8c0..833e1dc 100644 --- a/skills/document-photo-to-pdf/doc_deskew/check.py +++ b/skills/document-photo-to-pdf/doc_deskew/check.py @@ -203,40 +203,45 @@ def inspect_pdf(pdf, expect_pages=None, dpi=None, params=None): # 折算,否则选 300dpi 会白白放宽、选 72dpi 会误报“分辨率不足”。 render_dpi = float(p["render"]["dpi"]) min_short = c["min_short"] * dpi / render_dpi - for i, path in enumerate(files, 1): - with Image.open(path) as im: - r = analyse(im, p) - pw, ph = r["paper_px"] - short = min(pw, ph) - short_ok = short >= min_short - border_ok = ((not r["border_bad"]) and - all(v <= c["edge_dark_frac"] - for v in r["edge_dark"].values())) - cut_ok = not r["cut"] - dev = (abs(r["paper_ratio"] - r["ratio"]) / r["ratio"] - if r["ratio"] else 0.0) + try: + for i, path in enumerate(files, 1): + with Image.open(path) as im: + r = analyse(im, p) + pw, ph = r["paper_px"] + short = min(pw, ph) + short_ok = short >= min_short + border_ok = ((not r["border_bad"]) and + all(v <= c["edge_dark_frac"] + for v in r["edge_dark"].values())) + cut_ok = not r["cut"] + dev = (abs(r["paper_ratio"] - r["ratio"]) / r["ratio"] + if r["ratio"] else 0.0) - item = { - "index": i, - "paper_px": [int(pw), int(ph)], - "short_side_px": int(short), - "short_side_ok": bool(short_ok), - "paper_ratio": round(float(r["paper_ratio"]), 4), - "page_ratio": round(float(r["ratio"]), 4), - "ratio_dev_pct": round(float(dev * 100), 1), - "border_ok": bool(border_ok), - "cut_ok": bool(cut_ok), - "border": {k: round(float(v), 1) for k, v in r["border"].items()}, - "edge_dark": {k: round(float(v), 3) - for k, v in r["edge_dark"].items()}, - "cut": [[k, round(float(v), 3)] for k, v in r["cut"]], - "box_fallback": bool(r["box_fallback"]), - "paper_luma": round(float(r["paper"]), 1), - "back_luma": round(float(r["back"]), 1), - } - out["pages"].append(item) - if not (short_ok and border_ok and cut_ok): - out["ok"] = False + item = { + "index": i, + "paper_px": [int(pw), int(ph)], + "short_side_px": int(short), + "short_side_ok": bool(short_ok), + "paper_ratio": round(float(r["paper_ratio"]), 4), + "page_ratio": round(float(r["ratio"]), 4), + "ratio_dev_pct": round(float(dev * 100), 1), + "border_ok": bool(border_ok), + "cut_ok": bool(cut_ok), + "border": {k: round(float(v), 1) for k, v in r["border"].items()}, + "edge_dark": {k: round(float(v), 3) + for k, v in r["edge_dark"].items()}, + "cut": [[k, round(float(v), 3)] for k, v in r["cut"]], + "box_fallback": bool(r["box_fallback"]), + "paper_luma": round(float(r["paper"]), 1), + "back_luma": round(float(r["back"]), 1), + } + out["pages"].append(item) + if not (short_ok and border_ok and cut_ok): + out["ok"] = False + finally: + # 渲染图只是自检的中间产物:PPM 未压缩,100dpi 的 A4 一页约 3MB, + # 检验完立刻删(量已经记录在返回值里),不要留在会话目录占空间。 + shutil.rmtree(outdir, ignore_errors=True) return out diff --git a/skills/document-photo-to-pdf/doc_deskew/params.py b/skills/document-photo-to-pdf/doc_deskew/params.py index 2087570..7621b77 100644 --- a/skills/document-photo-to-pdf/doc_deskew/params.py +++ b/skills/document-photo-to-pdf/doc_deskew/params.py @@ -108,7 +108,7 @@ P = { "flat_pct": 99.5, # 页面纯白分位 "nonwhite_delta": 8.0, # 低于纯白该值视为非白(用于找纸面框) "paper_row_frac": 0.05, # 行列非白占比阈值 - "tmp_dir": ".tmp/pdfcheck", # 检验渲染临时目录(相对输出目录) + "tmp_dir": ".tmp/pdfcheck", # 检验渲染临时目录(相对输出目录,检验完即删) }, # ---------------------------------------------------------------- 输出 diff --git a/skills/document-photo-to-pdf/web/index.html b/skills/document-photo-to-pdf/web/index.html index 5b6a12c..22f2c59 100644 --- a/skills/document-photo-to-pdf/web/index.html +++ b/skills/document-photo-to-pdf/web/index.html @@ -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:15px} +/* 页码浮在图片右上角(裁切区 / 预览区共用),不占顶栏 */ +.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:11px;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}} +
+
文档审核
+ + +
+
- + -
1 / 1
- - - + + +
+
手动定位
+
1/1
+
-
校正预览
+
校正预览
+
1/1
+
@@ -161,7 +199,10 @@ body{display:flex;flex-direction:column;height:100%;height:100dvh}
-

全局设置

+
+

全局设置

+ +

这四项对整批生效,不影响单页角点。

纸张
@@ -192,24 +233,13 @@ body{display:flex;flex-direction:column;height:100%;height:100dvh}
-
本页
-
- - - -
-
-

-
- -