dknowc-dsh 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -8
- package/package.json +3 -3
- package/skills/dknowc-official-doc-writer/README.md +24 -11
- package/skills/dknowc-official-doc-writer/SKILL.md +43 -36
- package/skills/dknowc-official-doc-writer/reference/fact_discipline.md +2 -0
- package/skills/dknowc-official-doc-writer/reference/material_usage_guidance.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/onboarding_scripts.md +42 -5
- package/skills/dknowc-official-doc-writer/reference/output_guide.md +4 -4
- package/skills/dknowc-official-doc-writer/reference/research_notes.md +6 -2
- package/skills/dknowc-official-doc-writer/reference/review_checklist.md +11 -11
- package/skills/dknowc-official-doc-writer/reference/revision_workflow.md +4 -4
- package/skills/dknowc-official-doc-writer/reference/sample_search_result.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/sample_trace_report.html +387 -430
- package/skills/dknowc-official-doc-writer/reference/search_guide.md +13 -13
- package/skills/dknowc-official-doc-writer/reference/search_intro.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/search_policy.md +5 -5
- package/skills/dknowc-official-doc-writer/reference/task_router.md +77 -34
- package/skills/dknowc-official-doc-writer/scripts/api_key.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/attribution.py +5 -4
- package/skills/dknowc-official-doc-writer/scripts/build_trace_json.py +16 -3
- package/skills/dknowc-official-doc-writer/scripts/check_materials.py +63 -31
- package/skills/dknowc-official-doc-writer/scripts/deep_convert.py +27 -4
- package/skills/dknowc-official-doc-writer/scripts/deep_query.py +2 -2
- package/skills/dknowc-official-doc-writer/scripts/dkag_search.py +6 -3
- package/skills/dknowc-official-doc-writer/scripts/extract_reference.py +6 -6
- package/skills/dknowc-official-doc-writer/scripts/format_document.py +8 -8
- package/skills/dknowc-official-doc-writer/scripts/initialize.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/mcp_convert.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/merge_search_results.py +103 -3
- package/skills/dknowc-official-doc-writer/scripts/outline_reference.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/prose_lint.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/register.mjs +173 -21
- package/skills/dknowc-official-doc-writer/scripts/render_trace_html.py +293 -263
- package/skills/dknowc-official-doc-writer/scripts/review_document.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/source_note_html.py +26 -64
- package/skills/dknowc-official-doc-writer/scripts/template_generator.py +2 -2
- package/skills/dknowc-ppt-assistant/README.md +11 -13
- package/skills/dknowc-ppt-assistant/SKILL.md +12 -12
- package/skills/dknowc-ppt-assistant/references/material_usage.md +2 -2
- package/skills/dknowc-ppt-assistant/references/onboarding_scripts.md +44 -15
- package/skills/dknowc-ppt-assistant/scripts/attribution.py +4 -3
- package/skills/dknowc-ppt-assistant/scripts/initialize.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/preview_slide_html.py +2 -2
- package/skills/dknowc-ppt-assistant/scripts/register_key.mjs +202 -30
- package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +126 -116
- package/skills/dknowc-ppt-assistant/scripts/trusted_search.py +2 -2
- package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +24 -21
- package/skills/dknowc-trusted-search/README.md +11 -12
- package/skills/dknowc-trusted-search/SKILL.md +52 -44
- package/skills/dknowc-trusted-search/reference/onboarding_scripts.md +35 -6
- package/skills/dknowc-trusted-search/resources/echarts.custom.min.js +48 -0
- package/skills/dknowc-trusted-search/scripts/attribution.py +5 -5
- package/skills/dknowc-trusted-search/scripts/chart_embed.py +1 -1
- package/skills/dknowc-trusted-search/scripts/deep_convert.py +124 -0
- package/skills/dknowc-trusted-search/scripts/deep_query.py +12 -2
- package/skills/dknowc-trusted-search/scripts/initialize.py +4 -4
- package/skills/dknowc-trusted-search/scripts/mcp_convert.py +11 -2
- package/skills/dknowc-trusted-search/scripts/merge_search_results.py +176 -16
- package/skills/dknowc-trusted-search/scripts/register_key.mjs +206 -38
- package/skills/dknowc-trusted-search/scripts/render_trace_html.py +389 -344
- package/skills/dknowc-trusted-search/scripts/trusted_search.py +10 -3
- package/src/index.js +3 -3
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
2
|
+
"""产出物 HTML 渲染器:把结构化正文/素材 JSON 渲染为单文件三页 HTML(正文 / 溯源核验报告 / 知识专库)。
|
|
3
3
|
|
|
4
4
|
报告定位:不止展示"材料从哪来"(溯源),更要传达"我们查过了,可以交付"(核验)。
|
|
5
|
-
3.
|
|
6
|
-
- 顶栏:身份章 + 标题 +
|
|
7
|
-
- Hero:大标题 + 真实统计(N 次检索 · M 条材料 · K 处引用)+
|
|
5
|
+
3.8.0 架构(交互形态参考自研原型,数据口径保持自有与真实):
|
|
6
|
+
- 顶栏:身份章 + 标题 + 工具组(复制全文 / 打印归档)+ 阅读进度条
|
|
7
|
+
- Hero:大标题 + 真实统计(N 次检索 · M 条材料 · K 处引用)+ 三页切换
|
|
8
8
|
- 过程回顾条:检索 → 入库 → 逐条比对 → 核验完成(静态回放,数字全部真实计算;
|
|
9
9
|
无思考流数据就不展示"思考"步骤——硬造即违背核验诚实性)
|
|
10
|
-
-
|
|
11
|
-
-
|
|
10
|
+
- 正文页(默认):干净正式内容,不带任何角标/胶囊(与 Word 正文一致)
|
|
11
|
+
- 溯源核验报告页:过程回顾 + 核验报告单 + 带角标正文(角标可点击跳来源)
|
|
12
|
+
- 知识专库页(全屏):大搜索 + 热词(标题/正文高频词真实计算)+ 检索分组 tabs + 材料卡
|
|
12
13
|
三个核验层次:报告级(核验报告单)/材料级(来源卡核验链标记)/引用级(角标一一绑定)。
|
|
13
|
-
诚实原则:脚本真实计算的结果才打勾;无法自动判定的项不虚构展示("现行效力"
|
|
14
|
+
诚实原则:脚本真实计算的结果才打勾;无法自动判定的项不虚构展示("现行效力"人工复核提示行已按产品要求移除)。
|
|
14
15
|
布局为单文件静态 HTML;打印归档模式单栏全展开并附材料附录。
|
|
15
16
|
"""
|
|
16
17
|
|
|
@@ -265,8 +266,9 @@ def source_from_article(item: Dict[str, Any], index: int, segment: Optional[Dict
|
|
|
265
266
|
source["chain_full"] = " › ".join(segments[0]["chain"]) if segments else ""
|
|
266
267
|
# 发文字号(接口 policyFiles.writtenText,本地标题匹配)
|
|
267
268
|
source["doc_number"] = first_str(item.get("文号"), item.get("doc_number"))
|
|
268
|
-
#
|
|
269
|
+
# 所属搜索条件(多路检索分组)、检索通道(深知深度搜索/深知可信搜索)与引用状态
|
|
269
270
|
source["search_key"] = first_str(item.get("搜索条件"), item.get("search_key"))
|
|
271
|
+
source["channel"] = first_str(item.get("检索通道"), item.get("channel"))
|
|
270
272
|
source["used"] = item.get("已引用", item.get("used", True))
|
|
271
273
|
if not isinstance(source["used"], bool):
|
|
272
274
|
source["used"] = True
|
|
@@ -336,7 +338,18 @@ def extract_sources(payload: Dict[str, Any]) -> List[Dict[str, str]]:
|
|
|
336
338
|
# 一篇材料一张卡:段落合并为摘录(paragraph_text 拼接全部段落),不按段落拆卡——
|
|
337
339
|
# 溯源 JSON 的 materials 与正文角标按"材料"粒度一一对应,拆段会使编号错位。
|
|
338
340
|
source = source_from_article(item, len(sources) + 1)
|
|
339
|
-
|
|
341
|
+
# 去重键(2026-10-08 修复):按归一化「标题 + URL」判同一篇,不含 source["id"]——
|
|
342
|
+
# id 是递增序号、每条都不同,旧键含 id 等于从不去重;可信搜索对同一篇文章按段落
|
|
343
|
+
# 返回多条片段时会全部出卡(曾出现同一篇文章同名卡片重复十余张的情况)。
|
|
344
|
+
# 标题或 URL 单独可用时退用其一,均缺失退用摘录前缀。
|
|
345
|
+
_t = re.sub(r"\s+", "", source["title"] or "")
|
|
346
|
+
_u = (source["url"] or "").strip().rstrip("/")
|
|
347
|
+
if _t and _u:
|
|
348
|
+
key = ("tu", _t, _u)
|
|
349
|
+
elif _t:
|
|
350
|
+
key = ("t", _t)
|
|
351
|
+
else:
|
|
352
|
+
key = ("x", (source["excerpt"] or "")[:120])
|
|
340
353
|
if key in seen:
|
|
341
354
|
continue
|
|
342
355
|
seen.add(key)
|
|
@@ -418,8 +431,7 @@ def classify_check_value(raw: Any) -> Tuple[str, str]:
|
|
|
418
431
|
兼容多种写法:`pass` / `true` / `通过` / `通过:说明文字` / `✓` 等;
|
|
419
432
|
值后面的说明文字保留下来供核验单展示。红项(fail)只给显式声明的
|
|
420
433
|
"未通过";无法识别的描述性文本按"未记录"(none)处理不判红——
|
|
421
|
-
|
|
422
|
-
实测模型写入"备注"等额外键导致交付前检查误判 5/7)。
|
|
434
|
+
自检书写格式走样不应被放大成核验红项(模型写入"备注"等额外键曾导致交付前检查误判)。
|
|
423
435
|
"""
|
|
424
436
|
text = str(raw or "").strip()
|
|
425
437
|
lowered = text.lower()
|
|
@@ -475,7 +487,7 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
475
487
|
# ③ 时效检查:**正文依据**的日期范围与历史材料计数。
|
|
476
488
|
# 核验单五项都应只针对正文依据;① 依据溯源、② 引用对应 本就按正文角标计算,而 ③④ 此前
|
|
477
489
|
# 误用全部召回(sources 同时含未引用的 recalled_materials),口径不一致。
|
|
478
|
-
#
|
|
490
|
+
# 修复:43 篇正文依据的日期范围是 2020-01~2026-09,却因未引用
|
|
479
491
|
# 材料里有两篇接口标注 2027-09 的条目,核验单显示成 2016-03~2027-09 —— 把"未来日期"
|
|
480
492
|
# 和 11 年跨度算进了交付物的时效说明里。
|
|
481
493
|
dated = [parse_year_month(s.get("date")) for s in cited_sources]
|
|
@@ -506,7 +518,7 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
506
518
|
# 状态由显式 fail 决定;none(描述性值/未记录)不判红也不拖垮通过
|
|
507
519
|
status = "fail" if fails else ("pass" if passed else "missing")
|
|
508
520
|
# 分母固定为五项标准检查项,不取"实际写入的键数"——否则只写 1 个键会显示
|
|
509
|
-
# "✓ 1/1",把"只做了一项"
|
|
521
|
+
# "✓ 1/1",把"只做了一项"显示成满通过
|
|
510
522
|
missing_items = [label for key, label in SELF_CHECK_ITEMS if label not in self_items]
|
|
511
523
|
self_check = {"items": self_items, "passed": passed, "total": len(SELF_CHECK_ITEMS),
|
|
512
524
|
"missing_items": missing_items, "status": status}
|
|
@@ -520,7 +532,7 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
520
532
|
trace_ok = cited_sources and not missing_excerpts
|
|
521
533
|
binding_ok = (not unbound) and not no_citation
|
|
522
534
|
# 成稿自检显式写"未通过"时必须否决报告级结论:自检发现未闭环(规则要求先补搜闭环,
|
|
523
|
-
#
|
|
535
|
+
# 补不到停下与用户确认),不得照样打「已核验」章
|
|
524
536
|
self_check_ok = self_check["status"] != "fail"
|
|
525
537
|
overall_passed = bool(trace_ok and binding_ok and self_check_ok)
|
|
526
538
|
|
|
@@ -577,18 +589,31 @@ def compute_process_stats(sources: List[Dict[str, str]], answer: str) -> Dict[st
|
|
|
577
589
|
cond_rows = []
|
|
578
590
|
for key in order:
|
|
579
591
|
group = [s for s in sources if (s.get("search_key") or "").strip() == key]
|
|
592
|
+
# 该路检索的接口通道(深知深度搜索/深知可信搜索):取组内多数通道
|
|
593
|
+
# (同一材料被两接口召回时通道为顿号拼接的多值,按拆分后的单值计数)
|
|
594
|
+
chan_counts: Dict[str, int] = {}
|
|
595
|
+
for s in group:
|
|
596
|
+
ch = (s.get("channel") or "").strip()
|
|
597
|
+
for token in [t.strip() for t in ch.split("、") if t.strip()]:
|
|
598
|
+
chan_counts[token] = chan_counts.get(token, 0) + 1
|
|
599
|
+
channel = max(chan_counts, key=chan_counts.get) if chan_counts else ""
|
|
580
600
|
cond_rows.append({
|
|
581
601
|
"key": key,
|
|
582
602
|
"total": len(group),
|
|
583
603
|
"used": sum(1 for s in group if s.get("used", True)),
|
|
604
|
+
"channel": channel,
|
|
584
605
|
})
|
|
585
606
|
n_searches = len(cond_rows) or (1 if sources else 0)
|
|
607
|
+
deep_routes = sum(1 for r in cond_rows if "深度" in r.get("channel", ""))
|
|
608
|
+
trusted_routes = sum(1 for r in cond_rows if "可信" in r.get("channel", ""))
|
|
586
609
|
used_count = sum(1 for s in sources if s.get("used", True))
|
|
587
610
|
unused_count = len(sources) - used_count
|
|
588
611
|
n_cite_marks = len(re.findall(r"\[(\d+)\]", answer))
|
|
589
612
|
return {
|
|
590
613
|
"conds": cond_rows,
|
|
591
614
|
"n_searches": n_searches,
|
|
615
|
+
"deep_routes": deep_routes,
|
|
616
|
+
"trusted_routes": trusted_routes,
|
|
592
617
|
"has_cond_detail": bool(cond_rows),
|
|
593
618
|
"n_materials": len(sources),
|
|
594
619
|
"used_count": used_count,
|
|
@@ -597,60 +622,6 @@ def compute_process_stats(sources: List[Dict[str, str]], answer: str) -> Dict[st
|
|
|
597
622
|
}
|
|
598
623
|
|
|
599
624
|
|
|
600
|
-
HOT_STOP = {
|
|
601
|
-
"关于", "通知", "工作", "意见", "方案", "实施", "有关", "问题", "情况", "报告", "总结",
|
|
602
|
-
"制度", "体系", "机制", "指导", "贯彻", "落实", "进一步", "以及", "其他", "相关", "以下",
|
|
603
|
-
"以上", "共和国", "人民", "中华", "国务院", "人民政府", "办公厅", "印发", "试行",
|
|
604
|
-
"办法", "条例", "若干", "的重点", "有所", "一个", "方面", "方式", "内容", "基本",
|
|
605
|
-
"发展", "建设", "政策", "产业", "企业", "应用", "改革", "目标", "任务", "规划",
|
|
606
|
-
"领域", "措施", "支持", "行动", "服务", "管理", "政府",
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
def extract_hot_terms(answer: str, sources: List[Dict[str, str]], top: int = 8) -> List[str]:
|
|
611
|
-
"""知识专库热词:材料标题(加权)+ 检索条件 + 正文的高频 2-4 字词,真实统计。
|
|
612
|
-
|
|
613
|
-
泛词过滤:出现在超过 60% 材料标题中的词(如库内全部材料共有的主题词)
|
|
614
|
-
无法筛出子集,没有筛选价值,剔除。
|
|
615
|
-
"""
|
|
616
|
-
corpus_parts: List[str] = []
|
|
617
|
-
for s in sources:
|
|
618
|
-
if s.get("title"):
|
|
619
|
-
corpus_parts.extend([s["title"]] * 3)
|
|
620
|
-
if s.get("search_key"):
|
|
621
|
-
corpus_parts.extend([s["search_key"]] * 2)
|
|
622
|
-
clean_answer = re.sub(r"\[\d+\]", "", answer or "")
|
|
623
|
-
corpus_parts.append(clean_answer)
|
|
624
|
-
corpus = "\n".join(corpus_parts)
|
|
625
|
-
|
|
626
|
-
counts: Dict[str, int] = {}
|
|
627
|
-
for run in re.findall(r"[一-鿿]{2,}", corpus):
|
|
628
|
-
for n in (2, 3, 4):
|
|
629
|
-
for i in range(len(run) - n + 1):
|
|
630
|
-
gram = run[i:i + n]
|
|
631
|
-
counts[gram] = counts.get(gram, 0) + 1
|
|
632
|
-
|
|
633
|
-
titles = [s.get("title") or "" for s in sources]
|
|
634
|
-
n_titles = max(1, len(titles))
|
|
635
|
-
df_limit = max(1, int(n_titles * 0.6))
|
|
636
|
-
|
|
637
|
-
cands = [(g, c) for g, c in counts.items()
|
|
638
|
-
if c >= 2 and g not in HOT_STOP and "的" not in g and not any(ch.isdigit() for ch in g)
|
|
639
|
-
and sum(1 for t in titles if g in t) <= df_limit]
|
|
640
|
-
cands.sort(key=lambda x: (-x[1], -len(x[0])))
|
|
641
|
-
kept: List[Tuple[str, int]] = []
|
|
642
|
-
for gram, count in cands:
|
|
643
|
-
redundant = False
|
|
644
|
-
for kgram, kcount in kept:
|
|
645
|
-
# 短词是已入选高频长词的子串且计数接近 → 被长词覆盖,剔除
|
|
646
|
-
if gram in kgram and kcount >= count * 0.6:
|
|
647
|
-
redundant = True
|
|
648
|
-
break
|
|
649
|
-
if not redundant:
|
|
650
|
-
kept.append((gram, count))
|
|
651
|
-
if len(kept) >= top:
|
|
652
|
-
break
|
|
653
|
-
return [g for g, _ in kept]
|
|
654
625
|
|
|
655
626
|
|
|
656
627
|
# ============================================================
|
|
@@ -715,7 +686,8 @@ def render_excerpt_html(text: str) -> str:
|
|
|
715
686
|
return f'<div class="sc-excerpt rich">{sanitize_table_html(value)}</div>'
|
|
716
687
|
|
|
717
688
|
|
|
718
|
-
def parse_answer_blocks(answer: str, valid_ids: set, chip_map: Optional[Dict[str, str]] = None
|
|
689
|
+
def parse_answer_blocks(answer: str, valid_ids: set, chip_map: Optional[Dict[str, str]] = None,
|
|
690
|
+
strip_cites: bool = False) -> Tuple[List[Dict[str, Any]], set]:
|
|
719
691
|
"""把正文 Markdown 解析为结构化块;同时收集全部角标。
|
|
720
692
|
|
|
721
693
|
角标渲染为原型式 sup.cite 上标胶囊;段落对应的溯源卡(src-card)由
|
|
@@ -772,7 +744,10 @@ def parse_answer_blocks(answer: str, valid_ids: set, chip_map: Optional[Dict[str
|
|
|
772
744
|
|
|
773
745
|
def make_block_repl(block_text: str):
|
|
774
746
|
"""按块构造角标替换器:同段同材料只保留最后一次出现的角标(前处整体删除),
|
|
775
|
-
最后一处挂数字角标 + 引文胶囊——一段中同一材料只出现一次。
|
|
747
|
+
最后一处挂数字角标 + 引文胶囊——一段中同一材料只出现一次。
|
|
748
|
+
正文页(strip_cites=True)直接删掉全部角标,输出干净正文。"""
|
|
749
|
+
if strip_cites:
|
|
750
|
+
return lambda match: ""
|
|
776
751
|
remaining: Dict[str, int] = {}
|
|
777
752
|
for cid in re.findall(r"\[(\d+)\]", block_text):
|
|
778
753
|
remaining[cid] = remaining.get(cid, 0) + 1
|
|
@@ -798,11 +773,11 @@ def parse_answer_blocks(answer: str, valid_ids: set, chip_map: Optional[Dict[str
|
|
|
798
773
|
idx += 1
|
|
799
774
|
continue
|
|
800
775
|
# 引文胶囊位置规范:角标与后随标点换位——标点紧跟文字,胶囊放标点之后
|
|
801
|
-
#
|
|
776
|
+
# (避免胶囊把句号挤到下一行孤悬,保持"…内容。~出处"形态)
|
|
802
777
|
# 注意:须把连续角标序列整体换位(如 [13][14];),否则标点被夹在两个胶囊
|
|
803
|
-
# 中间——[13];[14] 会让分号"跑到胶囊后边"
|
|
778
|
+
# 中间——[13];[14] 会让分号"跑到胶囊后边"。
|
|
804
779
|
block = re.sub(r"((?:\[\d+\])+)([。;,、!?:;,.])", r"\2\1", block)
|
|
805
|
-
ids = citation_ids(block)
|
|
780
|
+
ids = [] if strip_cites else citation_ids(block)
|
|
806
781
|
repl = make_block_repl(block)
|
|
807
782
|
heading_match = re.match(r"^(#{1,4})\s+(.+)$", block)
|
|
808
783
|
if heading_match:
|
|
@@ -816,7 +791,8 @@ def parse_answer_blocks(answer: str, valid_ids: set, chip_map: Optional[Dict[str
|
|
|
816
791
|
table_lines.append(lines[idx].strip())
|
|
817
792
|
idx += 1
|
|
818
793
|
repl = make_block_repl("\n".join(table_lines))
|
|
819
|
-
blocks.append({"kind": "table", "html": render_markdown_table(table_lines, repl),
|
|
794
|
+
blocks.append({"kind": "table", "html": render_markdown_table(table_lines, repl),
|
|
795
|
+
"cites": [] if strip_cites else citation_ids("\n".join(table_lines))})
|
|
820
796
|
elif block in {"---", "***"}:
|
|
821
797
|
blocks.append({"kind": "hr", "html": '<hr class="doc-divider">', "cites": []})
|
|
822
798
|
idx += 1
|
|
@@ -930,7 +906,14 @@ def render_source_links(url: str, policy_url: str = "", snapshot: str = "", link
|
|
|
930
906
|
|
|
931
907
|
def render_verify_panel(v: Dict[str, Any]) -> str:
|
|
932
908
|
"""核验报告单:报告级核验结论 + 五项指标。"""
|
|
933
|
-
|
|
909
|
+
# 核验明细(溯源 JSON 的 verification_checks)默认折叠——明细可能很长(逐条"已完成…"),
|
|
910
|
+
# 平铺会把核验单撑得过高;折叠后默认只见一句方式说明,点开才展开逐条明细。
|
|
911
|
+
_checks = [str(x) for x in (v.get("manual_checks") or []) if str(x).strip()]
|
|
912
|
+
manual_checks_html = ""
|
|
913
|
+
if _checks:
|
|
914
|
+
_items = "".join(f"<li>{esc(x)}</li>" for x in _checks)
|
|
915
|
+
manual_checks_html = (f'<details class="v-checks"><summary>查看核验明细({len(_checks)} 项)</summary>'
|
|
916
|
+
f'<ul>{_items}</ul></details>')
|
|
934
917
|
ov = v["overall"]
|
|
935
918
|
state = "ok" if ov["passed"] else "fail"
|
|
936
919
|
stamp = '<span class="v-stamp">已核验</span>' if ov["passed"] else '<span class="v-stamp bad">核验未通过</span>'
|
|
@@ -948,7 +931,7 @@ def render_verify_panel(v: Dict[str, Any]) -> str:
|
|
|
948
931
|
f'<span class="d">每篇来源文章的摘录可比对,原文或存档快照可回看</span></div>')
|
|
949
932
|
elif tr["passed"] == tr["total"]:
|
|
950
933
|
# 摘录齐全但有材料没有回看通道:不得照写"原文或存档快照可回看"
|
|
951
|
-
#
|
|
934
|
+
# (此前 missing_links 算出却从未参与结论,属虚假背书)
|
|
952
935
|
tr_html = (f'<div class="vi"><span class="s warn">◐ 依据溯源 {tr["passed"]}/{tr["total"]}</span>'
|
|
953
936
|
f'<span class="d">摘录可比对,其中 {n_no_link} 条没有原文链接或存档快照、无法回看</span></div>')
|
|
954
937
|
else:
|
|
@@ -966,7 +949,7 @@ def render_verify_panel(v: Dict[str, Any]) -> str:
|
|
|
966
949
|
bd_html = '<div class="vi"><span class="s none">— 引用对应 0/0</span><span class="d">正文里没有来源角标</span></div>'
|
|
967
950
|
elif not bd["unbound"]:
|
|
968
951
|
bd_html = (f'<div class="vi"><span class="s ok">✓ 引用对应 {bd["bound"]}/{bd["total"]}</span>'
|
|
969
|
-
f'<span class="d"
|
|
952
|
+
f'<span class="d">正文每一处引用都已对回来源文章,点开即可核对原文</span></div>')
|
|
970
953
|
else:
|
|
971
954
|
unbound_text = "、".join(f"[{esc(x)}]" for x in bd["unbound"][:8])
|
|
972
955
|
bd_html = (f'<div class="vi"><span class="s fail">✗ 引用对应 {bd["bound"]}/{bd["total"]}</span>'
|
|
@@ -975,7 +958,7 @@ def render_verify_panel(v: Dict[str, Any]) -> str:
|
|
|
975
958
|
fr = v["freshness"]
|
|
976
959
|
if fr:
|
|
977
960
|
rng = f"{fr['min'][0]}-{fr['min'][1]:02d}~{fr['max'][0]}-{fr['max'][1]:02d}"
|
|
978
|
-
#
|
|
961
|
+
# 不再输出"N 条年头较久,按参考口径使用"——"年头较久"按
|
|
979
962
|
# "发布日期年份 ≤ 生成年份 − 3"划线,对长期有效的政策法规偏严(如 2020 年出台、
|
|
980
963
|
# 至今有效的条例会被判为"较久"),且"参考口径"一说读者无从理解。只保留日期范围。
|
|
981
964
|
# old_count 仍在 freshness 中照常计算,留待后续需要时使用。
|
|
@@ -990,9 +973,8 @@ def render_verify_panel(v: Dict[str, Any]) -> str:
|
|
|
990
973
|
f'<span class="d">{esc(" · ".join(parts)) if parts else "材料没标类型"}</span></div>')
|
|
991
974
|
|
|
992
975
|
sc = v["self_check"]
|
|
976
|
+
selfcheck_notes_html = ""
|
|
993
977
|
if sc["status"] == "pass":
|
|
994
|
-
notes = ";".join(note for _, note in sc["items"].values() if note)
|
|
995
|
-
title_attr = f' title="{esc(notes)}"' if notes else ""
|
|
996
978
|
missing = sc.get("missing_items") or []
|
|
997
979
|
none_count = sum(1 for status, _ in sc["items"].values() if status == "none")
|
|
998
980
|
unrecorded = len(missing) + none_count
|
|
@@ -1001,10 +983,15 @@ def render_verify_panel(v: Dict[str, Any]) -> str:
|
|
|
1001
983
|
if missing:
|
|
1002
984
|
detail = f"缺少:{'、'.join(missing)}"
|
|
1003
985
|
else:
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
sc_html = (f'<div class="vi"><span class="s ok"{title_attr}>✓ 交付前检查 {sc["passed"]}/{sc["total"]}{esc(none_note)}</span>'
|
|
986
|
+
detail = "、".join(sc["items"].keys())
|
|
987
|
+
sc_html = (f'<div class="vi"><span class="s ok">✓ 交付前检查 {sc["passed"]}/{sc["total"]}{esc(none_note)}</span>'
|
|
1007
988
|
f'<span class="d">{esc(detail)}</span></div>')
|
|
989
|
+
# 逐项说明默认折叠(与底部"核验明细"同款交互、触屏可用),不再用鼠标悬浮 tooltip
|
|
990
|
+
note_items = [(label, note) for label, (status, note) in sc["items"].items() if note]
|
|
991
|
+
if note_items:
|
|
992
|
+
_li = "".join(f"<li><b>{esc(label)}</b>:{esc(note)}</li>" for label, note in note_items)
|
|
993
|
+
selfcheck_notes_html = (f'<details class="v-checks"><summary>查看交付前检查说明({len(note_items)} 项)</summary>'
|
|
994
|
+
f'<ul>{_li}</ul></details>')
|
|
1008
995
|
elif sc["status"] == "fail":
|
|
1009
996
|
failed_parts = []
|
|
1010
997
|
for label, (status, note) in sc["items"].items():
|
|
@@ -1016,7 +1003,7 @@ def render_verify_panel(v: Dict[str, Any]) -> str:
|
|
|
1016
1003
|
else:
|
|
1017
1004
|
sc_html = '<div class="vi"><span class="s none">— 交付前检查 未记录</span><span class="d">本次溯源 JSON 没写入检查结果</span></div>'
|
|
1018
1005
|
|
|
1019
|
-
# "现行效力"
|
|
1006
|
+
# "现行效力"人工复核提示行已按产品要求移除:政策是否现行有效
|
|
1020
1007
|
# 无法自动判定,此提示对用户无操作价值;policy_count 仅保留在计算层不再展示。
|
|
1021
1008
|
|
|
1022
1009
|
return f"""
|
|
@@ -1026,7 +1013,7 @@ def render_verify_panel(v: Dict[str, Any]) -> str:
|
|
|
1026
1013
|
<div class="v-grid">
|
|
1027
1014
|
{tr_html}{bd_html}{fr_html}{cov_html}{sc_html}
|
|
1028
1015
|
</div>
|
|
1029
|
-
<div class="v-note"
|
|
1016
|
+
<div class="v-note">AI 已完成自验收,正文依据可逐条点开原文复核。{selfcheck_notes_html}{manual_checks_html}</div>
|
|
1030
1017
|
</div>"""
|
|
1031
1018
|
|
|
1032
1019
|
|
|
@@ -1060,10 +1047,12 @@ def render_src_card(jb: Dict[str, str], cid: str, dup: bool = False) -> str:
|
|
|
1060
1047
|
)
|
|
1061
1048
|
|
|
1062
1049
|
|
|
1063
|
-
def render_section_cards(sections: List[Dict[str, Any]], sources: List[Dict[str, str]]
|
|
1050
|
+
def render_section_cards(sections: List[Dict[str, Any]], sources: List[Dict[str, str]],
|
|
1051
|
+
with_ids: bool = True, id_prefix: str = "sec") -> str:
|
|
1064
1052
|
"""正文渲染(原型复刻):chapter(h2)+ lead/para 段落 + 段后 src-card 溯源卡。
|
|
1065
1053
|
|
|
1066
1054
|
溯源卡按段内角标顺序输出;同一材料在同段只出一张,跨段重复出现标记 dup-card(灰化)。
|
|
1055
|
+
with_ids=False 时不输出 `id="sec-N"`(正文页锚点唯一,溯源核验报告页复用同一份正文时避免重复 id)。
|
|
1067
1056
|
"""
|
|
1068
1057
|
parts: List[str] = []
|
|
1069
1058
|
first_para = True
|
|
@@ -1083,7 +1072,8 @@ def render_section_cards(sections: List[Dict[str, Any]], sources: List[Dict[str,
|
|
|
1083
1072
|
state = "bad" if unbound else ""
|
|
1084
1073
|
text = f"本章引用 {len(sec_cites)} 处" + (f" · {unbound} 处未绑定" if unbound else " · 已核验")
|
|
1085
1074
|
badge_html = f'<span class="sec-badge {state}">{esc(text)}</span>'
|
|
1086
|
-
|
|
1075
|
+
sec_id = f' id="{id_prefix}-{sec_idx}"' if with_ids else ""
|
|
1076
|
+
parts.append(f'<section class="chapter"{sec_id}>'
|
|
1087
1077
|
f'<header class="ch-head"><h2>{esc(chapter_title)}</h2>{badge_html}</header>')
|
|
1088
1078
|
for b in sec["blocks"]:
|
|
1089
1079
|
if b["kind"] == "heading":
|
|
@@ -1135,7 +1125,7 @@ def strip_leading_chain(text: str, chain: List[str]) -> str:
|
|
|
1135
1125
|
def render_crumb(chain: List[str]) -> str:
|
|
1136
1126
|
"""面包屑标题链:文章 › 章 › 节(标题链是模型生成的结构化位置,核验核心抓手)。
|
|
1137
1127
|
段落本身无章节层级(链上只有文章名)时不显示——材料卡标题已是文章名,
|
|
1138
|
-
|
|
1128
|
+
单独一行重复文章名对定位无增量。"""
|
|
1139
1129
|
parts = [esc(level) for level in chain if level]
|
|
1140
1130
|
if len(parts) < 2:
|
|
1141
1131
|
return ""
|
|
@@ -1177,7 +1167,7 @@ def render_source_card(source: Dict[str, str], for_print: bool = False) -> str:
|
|
|
1177
1167
|
_dn = source.get("doc_number") or ""
|
|
1178
1168
|
# 只显示标准文号形式,拦掉模型自造的描述性文字("中办、国办 2026 年印发"类)。
|
|
1179
1169
|
# 除"〔年份〕序号"外,主席令/国务院令/部令等法定令号同样合规,一并放行
|
|
1180
|
-
#
|
|
1170
|
+
# (真实任务里《社会保险法》《国务院令第765号》曾被整条丢弃)
|
|
1181
1171
|
_dn = _dn if re.search(r"〔\d{4}〕\s*\d+\s*号|第\s*(?:\d+|[〇零一二三四五六七八九十百千]+)\s*号", _dn) else ""
|
|
1182
1172
|
meta_parts = [v for v in [_dn, source.get("agency"), source.get("date"), source.get("area")]
|
|
1183
1173
|
if v and v != "未知来源"]
|
|
@@ -1211,9 +1201,22 @@ def render_process_bar(stats: Dict[str, Any], verification: Dict[str, Any]) -> s
|
|
|
1211
1201
|
ov = verification["overall"]
|
|
1212
1202
|
tr = verification["traceability"]
|
|
1213
1203
|
first_query = stats["conds"][0]["key"] if stats["conds"] else ""
|
|
1204
|
+
# 步骤一标题按接口通道拆分(深度搜索与可信搜索是两个接口,不混计成一个数);
|
|
1205
|
+
# 无通道信息(历史 JSON)时退回"深知检索 N 次"
|
|
1206
|
+
deep_n = stats.get("deep_routes", 0)
|
|
1207
|
+
trusted_n = stats.get("trusted_routes", 0)
|
|
1208
|
+
if deep_n and trusted_n:
|
|
1209
|
+
step1_title = f"深度搜索 {deep_n} 路 · 可信补搜 {trusted_n} 次"
|
|
1210
|
+
elif deep_n:
|
|
1211
|
+
step1_title = f"深知深度搜索 {deep_n} 路"
|
|
1212
|
+
elif trusted_n:
|
|
1213
|
+
step1_title = f"深知可信搜索 {trusted_n} 次"
|
|
1214
|
+
else:
|
|
1215
|
+
step1_title = f"深知检索 {stats['n_searches']} 次"
|
|
1214
1216
|
detail_rows = "".join(
|
|
1215
|
-
f'<div class="pd-row"><b>{esc(row["key"])}
|
|
1216
|
-
f'
|
|
1217
|
+
f'<div class="pd-row"><b>{esc(row["key"])}'
|
|
1218
|
+
+ (f'({"深度搜索+可信搜索" if ("深度" in row.get("channel", "") and "可信" in row.get("channel", "")) else ("深度搜索" if "深度" in row.get("channel", "") else "可信搜索")})' if row.get("channel") else "")
|
|
1219
|
+
+ f'</b><span>召回 {row["total"]} 条 · 正文采用 {row["used"]} 条</span></div>'
|
|
1217
1220
|
for row in stats["conds"]
|
|
1218
1221
|
) or '<div class="pd-row"><span>本次溯源 JSON 未记录各次检索条件</span></div>'
|
|
1219
1222
|
detail_hint = f'{esc(short(first_query, 26))}…' if (stats["n_searches"] > 1 and first_query) else "查看检索明细"
|
|
@@ -1228,12 +1231,12 @@ def render_process_bar(stats: Dict[str, Any], verification: Dict[str, Any]) -> s
|
|
|
1228
1231
|
step4_label = "核验完成" if ov["passed"] else "核验未完全通过"
|
|
1229
1232
|
step4_sub = "结论:正文依据逐条对过原文" if ov["passed"] else esc(short(";".join(ov["reasons"]) or "见核验报告单", 30))
|
|
1230
1233
|
return f"""
|
|
1231
|
-
<section class="process" aria-label="
|
|
1232
|
-
<div class="p-head"><b
|
|
1234
|
+
<section class="process" aria-label="AI 自验收">
|
|
1235
|
+
<div class="p-head"><b>AI 自验收</b><span>交付前由 AI 自动完成,数字来自本次任务的真实记录</span></div>
|
|
1233
1236
|
<ol class="p-steps">
|
|
1234
1237
|
<li class="p-step expandable" id="p-step-search" role="button" tabindex="0" title="展开各路检索明细">
|
|
1235
1238
|
<span class="p-no">1</span>
|
|
1236
|
-
<div class="p-txt"><b
|
|
1239
|
+
<div class="p-txt"><b>{esc(step1_title)}</b><i>{step1_sub}</i></div>
|
|
1237
1240
|
</li>
|
|
1238
1241
|
<li class="p-arrow" aria-hidden="true">›</li>
|
|
1239
1242
|
<li class="p-step">
|
|
@@ -1255,7 +1258,7 @@ def render_process_bar(stats: Dict[str, Any], verification: Dict[str, Any]) -> s
|
|
|
1255
1258
|
</section>"""
|
|
1256
1259
|
|
|
1257
1260
|
|
|
1258
|
-
def render_library_view(sources: List[Dict[str, str]],
|
|
1261
|
+
def render_library_view(sources: List[Dict[str, str]], doc_title: str = "") -> str:
|
|
1259
1262
|
"""知识专库全屏视图:大搜索 + 热词 + 检索分组 tabs + 材料卡列表。"""
|
|
1260
1263
|
if not sources:
|
|
1261
1264
|
return ('<section class="view" id="view-library" aria-label="知识专库">'
|
|
@@ -1278,30 +1281,18 @@ def render_library_view(sources: List[Dict[str, str]], hot_terms: List[str]) ->
|
|
|
1278
1281
|
tabs = [f'<button class="on" data-cond="" type="button">全部({len(sources)})</button>']
|
|
1279
1282
|
for name, count in conds:
|
|
1280
1283
|
tabs.append(f'<button data-cond="{esc(name)}" type="button">{esc(name)}({count})</button>')
|
|
1281
|
-
if unused_sources:
|
|
1282
|
-
tabs.append(f'<button data-cond="__unused__" type="button">未引用({len(unused_sources)})</button>')
|
|
1283
|
-
|
|
1284
|
-
hot_html = ""
|
|
1285
|
-
if hot_terms:
|
|
1286
|
-
hot_items = "".join(f'<button class="hot-term" type="button">{esc(term)}</button>' for term in hot_terms)
|
|
1287
|
-
hot_html = f'<div class="hot-terms" aria-label="热门搜索词"><span class="hot-label">大家都在搜</span>{hot_items}</div>'
|
|
1288
|
-
|
|
1289
1284
|
cards_html = "".join(render_source_card(s) for s in used_sources)
|
|
1290
1285
|
cards_html += "".join(render_source_card(s) for s in unused_sources)
|
|
1291
1286
|
|
|
1292
|
-
|
|
1293
|
-
badge = "全部已核验" if used_sources and cited_verified == len(used_sources) else f"{cited_verified}/{len(used_sources)} 已核验"
|
|
1287
|
+
lib_title = f"知识专库:{doc_title}" if (doc_title or "").strip() else "知识专库"
|
|
1294
1288
|
return f"""
|
|
1295
1289
|
<section class="view" id="view-library" aria-label="知识专库">
|
|
1296
1290
|
<div class="lib-head">
|
|
1297
|
-
<div class="lib-title"><b
|
|
1298
|
-
<span>共 {len(sources)} 条 · 已引用 {len(used_sources)} · {esc(badge)}</span>
|
|
1299
|
-
</div>
|
|
1291
|
+
<div class="lib-title"><b>{esc(lib_title)}</b></div>
|
|
1300
1292
|
<div class="lib-searchWrap">
|
|
1301
1293
|
<span class="lib-searchIcon" aria-hidden="true">⌕</span>
|
|
1302
1294
|
<input class="lib-search" type="search" placeholder="搜索标题 / 来源 / 摘录…" aria-label="搜索来源文章">
|
|
1303
1295
|
</div>
|
|
1304
|
-
{hot_html}
|
|
1305
1296
|
<div class="lib-tabs" role="tablist" aria-label="按检索分组筛选">{"".join(tabs)}</div>
|
|
1306
1297
|
</div>
|
|
1307
1298
|
<div class="lib-list" id="lib-list">{cards_html}</div>
|
|
@@ -1317,13 +1308,13 @@ def render_toc(sections: List[Dict[str, Any]]) -> str:
|
|
|
1317
1308
|
title = (sec.get("title") or "").strip()
|
|
1318
1309
|
if not title:
|
|
1319
1310
|
# 无标题节=正文开头的导语/摘要段(第一个章节标题之前的内容),不是正式章节。
|
|
1320
|
-
#
|
|
1321
|
-
#
|
|
1311
|
+
# 修复:此前会被兜底成「第 N 节」列进目录,页面上表现为一条灰色
|
|
1312
|
+
# 占位项,读者不知道那是什么。内容仍照常
|
|
1322
1313
|
# 在正文里展示,只是不占目录条目、不参与滚动高亮。
|
|
1323
1314
|
continue
|
|
1324
1315
|
number, title_text = split_heading_number(title)
|
|
1325
1316
|
label = f"{number} {title_text}" if (number and title_text) else title_text
|
|
1326
|
-
items.append(f'<a href="#sec-{i}">{esc(short(label, 16))}</a>')
|
|
1317
|
+
items.append(f'<a href="#sec-{i}" data-sec="{i}">{esc(short(label, 16))}</a>')
|
|
1327
1318
|
if len(items) < 6:
|
|
1328
1319
|
return ""
|
|
1329
1320
|
return f'<nav class="toc" aria-label="章节目录">{"".join(items)}</nav>'
|
|
@@ -1375,16 +1366,20 @@ body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe
|
|
|
1375
1366
|
color:var(--ink);background:#f4f5f7;line-height:1.75;font-size:14.5px}
|
|
1376
1367
|
a{color:var(--brand)}
|
|
1377
1368
|
|
|
1378
|
-
/* =====
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
.
|
|
1369
|
+
/* ===== Banner 统一区 =====
|
|
1370
|
+
2026-10-14 反馈意见一:整体结构=上部 banner 区+下部正文区。
|
|
1371
|
+
banner 内统一收纳:文档名+三切换+工具(复制/导出)+原问题+统计;
|
|
1372
|
+
切换三页时 banner 高度与位置保持不变(同一容器,无页面各自的顶部块)。 */
|
|
1373
|
+
.banner{position:sticky;top:0;z-index:50;background:rgba(255,255,255,.94);backdrop-filter:blur(10px);
|
|
1374
|
+
border-bottom:1px solid var(--line);padding:8px 22px 9px}
|
|
1375
|
+
.banner-bar{display:flex;align-items:center;gap:14px;max-width:1080px;margin:0 auto}
|
|
1376
|
+
.banner-bar .tb-title{flex:0 1 auto;min-width:0;max-width:30%;overflow:hidden;text-overflow:ellipsis;
|
|
1377
|
+
white-space:nowrap;color:var(--muted);font-size:12.5px}
|
|
1378
|
+
.banner-bar .view-switch{margin:0 auto}
|
|
1379
|
+
.banner-bar .tb-tools{flex:0 0 auto}
|
|
1383
1380
|
.tb-stamp{flex:none;font-size:12.5px;font-weight:800;color:var(--navy);letter-spacing:4px;text-indent:4px}
|
|
1384
1381
|
.tb-stamp::before,.tb-stamp::after{content:"";display:inline-block;width:22px;border-top:1px solid var(--line-strong);
|
|
1385
1382
|
vertical-align:middle;margin:0 6px}
|
|
1386
|
-
.tb-title{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:13px}
|
|
1387
|
-
.tb-right{display:flex;align-items:center;gap:8px;flex:none}
|
|
1388
1383
|
.view-switch{display:inline-flex;border:1px solid var(--line);border-radius:999px;overflow:hidden;background:#fff}
|
|
1389
1384
|
.view-switch button{border:0;background:transparent;color:var(--muted);font-size:12.5px;font-weight:700;
|
|
1390
1385
|
padding:5px 14px;cursor:pointer}
|
|
@@ -1405,29 +1400,27 @@ a{color:var(--brand)}
|
|
|
1405
1400
|
.progress{position:absolute;left:0;right:0;bottom:-1px;height:2px;background:transparent}
|
|
1406
1401
|
.progress i{display:block;height:100%;width:0;background:linear-gradient(90deg,#6512ad,#8b5cf6)}
|
|
1407
1402
|
|
|
1408
|
-
/* =====
|
|
1409
|
-
.
|
|
1410
|
-
|
|
1411
|
-
.
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
.hero .meta{color:var(--muted);font-size:13px;letter-spacing:.5px}
|
|
1417
|
-
.hero-switch{margin-top:16px;display:flex;justify-content:center}
|
|
1418
|
-
.hero-switch .view-switch{border-color:#d9c9f4;background:#fff;box-shadow:0 1px 3px rgba(24,20,40,.04)}
|
|
1419
|
-
.hero-switch .view-switch button{color:#70678a;padding:6px 22px;font-size:13px}
|
|
1420
|
-
.hero-switch .view-switch button.on{background:var(--grad);color:#fff}
|
|
1403
|
+
/* ===== banner 内的原问题行与统计行 ===== */
|
|
1404
|
+
.banner .orig-q{max-width:1080px;margin:7px auto 0;color:var(--ink);font-size:13.5px;line-height:1.6;text-align:center}
|
|
1405
|
+
.banner .orig-q b{color:var(--brand);margin-right:2px}
|
|
1406
|
+
.banner .meta{max-width:1080px;margin:3px auto 0;color:var(--muted);font-size:11.5px;letter-spacing:.3px;text-align:center}
|
|
1407
|
+
.banner-bar .view-switch{border-color:#d9c9f4;background:#fff;box-shadow:0 1px 3px rgba(24,20,40,.04)}
|
|
1408
|
+
.banner-bar .view-switch button{color:#70678a;padding:6px 18px;font-size:13px}
|
|
1409
|
+
.banner-bar .view-switch button.on{background:var(--grad);color:#fff}
|
|
1410
|
+
/* 原问题行:报告须含完整原问题才能独立使用 */
|
|
1421
1411
|
|
|
1422
1412
|
/* ===== 容器与视图 ===== */
|
|
1423
1413
|
.container{max-width:1080px;margin:0 auto;padding:0 18px}
|
|
1424
|
-
.app
|
|
1425
|
-
|
|
1414
|
+
.app{padding-top:16px}
|
|
1415
|
+
/* 三页产出物:正文 / 溯源核验报告 / 知识专库,单文件顶部切换 */
|
|
1416
|
+
#view-body,#view-report,#view-library{display:none}
|
|
1417
|
+
.app[data-view="body"] #view-body{display:block}
|
|
1418
|
+
.app[data-view="report"] #view-report{display:block}
|
|
1426
1419
|
.app[data-view="library"] #view-library{display:block}
|
|
1427
1420
|
|
|
1428
1421
|
/* ===== 过程回顾条 ===== */
|
|
1429
1422
|
.process{background:#fff;border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow-1);
|
|
1430
|
-
padding:15px 20px 13px;margin
|
|
1423
|
+
padding:15px 20px 13px;margin:0 auto 16px;position:relative}
|
|
1431
1424
|
.p-head{display:flex;align-items:baseline;gap:10px;margin-bottom:10px}
|
|
1432
1425
|
.p-head b{font-size:14.5px;color:var(--navy);letter-spacing:1px}
|
|
1433
1426
|
.p-head span{font-size:11.5px;color:var(--muted)}
|
|
@@ -1454,7 +1447,7 @@ a{color:var(--brand)}
|
|
|
1454
1447
|
.pd-row span{color:var(--muted)}
|
|
1455
1448
|
|
|
1456
1449
|
/* ===== 核验报告视图 ===== */
|
|
1457
|
-
#view-report{padding-bottom:26px}
|
|
1450
|
+
#view-body,#view-report{padding-bottom:26px}
|
|
1458
1451
|
.warn-box{margin:0 0 16px;padding:13px 16px;border:1.5px solid var(--danger);border-radius:10px;
|
|
1459
1452
|
background:#fdf3f3;color:#8f2626;font-size:13.5px;line-height:1.7}
|
|
1460
1453
|
.verify{margin:0 0 16px;background:#fff;border:1px solid #bfe8da;border-left:4px solid var(--ok);
|
|
@@ -1478,6 +1471,15 @@ a{color:var(--brand)}
|
|
|
1478
1471
|
.vi .s.man{color:var(--case)}
|
|
1479
1472
|
.vi .s.none{color:var(--muted)}
|
|
1480
1473
|
.vi .d{color:var(--muted);min-width:0}
|
|
1474
|
+
/* 溯源核验报告页正文区的文头标题(反馈意见:标题放正文区,而非页面顶部) */
|
|
1475
|
+
.paper-title{margin:0 0 18px;font-size:20px;font-weight:800;color:var(--ink);text-align:center;line-height:1.55;letter-spacing:.3px}
|
|
1476
|
+
.v-checks{margin-top:9px}
|
|
1477
|
+
.v-checks summary{cursor:pointer;color:var(--brand);font-weight:700;font-size:12.5px;list-style:none;display:inline-flex;align-items:center;gap:5px}
|
|
1478
|
+
.v-checks summary::-webkit-details-marker{display:none}
|
|
1479
|
+
.v-checks summary::before{content:"+";font-weight:700;font-size:12px}
|
|
1480
|
+
.v-checks[open] summary::before{content:"-"}
|
|
1481
|
+
.v-checks ul{margin:7px 0 0 4px;padding-left:16px}
|
|
1482
|
+
.v-checks li{font-size:12.5px;color:var(--sub);line-height:1.72;margin:5px 0}
|
|
1481
1483
|
.v-note{margin-top:11px;padding-top:9px;border-top:1px dashed var(--line);font-size:11.5px;color:var(--muted);line-height:1.7}
|
|
1482
1484
|
|
|
1483
1485
|
/* 正文(原型复刻):章节 / 段落 / 角标 / 句后溯源卡 */
|
|
@@ -1559,29 +1561,23 @@ a.jb-quote{text-decoration:none}
|
|
|
1559
1561
|
#view-library{padding:26px 0 30px}
|
|
1560
1562
|
.lib-head{max-width:860px;margin:0 auto 16px;text-align:center}
|
|
1561
1563
|
.lib-title{margin-bottom:14px}
|
|
1562
|
-
.lib-title b{font-size:
|
|
1563
|
-
.lib-title span{display:block;font-size:12px;color:var(--muted);margin-top:2px}
|
|
1564
|
+
.lib-title b{font-size:16px;color:var(--navy);letter-spacing:.5px;line-height:1.5}
|
|
1564
1565
|
.lib-searchWrap{position:relative;max-width:620px;margin:0 auto}
|
|
1565
1566
|
.lib-searchIcon{position:absolute;left:14px;top:50%;transform:translateY(-50%);color:#a6adbd;font-size:16px;font-weight:700}
|
|
1566
1567
|
.lib-search{width:100%;padding:11px 16px 11px 38px;border:1.5px solid var(--line-strong);border-radius:999px;
|
|
1567
1568
|
font-size:14px;background:#fff;box-shadow:var(--shadow-1);outline:none}
|
|
1568
1569
|
.lib-search:focus{border-color:var(--brand-2);box-shadow:0 0 0 3px rgba(139,92,246,.18)}
|
|
1569
|
-
.hot-terms{display:flex;flex-wrap:wrap;justify-content:center;gap:7px;margin-top:12px;align-items:center}
|
|
1570
|
-
.hot-label{font-size:12px;color:var(--muted)}
|
|
1571
|
-
.hot-term{border:0;border-radius:999px;background:var(--brand-soft);color:var(--brand);
|
|
1572
|
-
font-size:12.3px;font-weight:700;padding:3px 13px;cursor:pointer}
|
|
1573
|
-
.hot-term:hover{background:var(--grad);color:#fff}
|
|
1574
1570
|
.lib-tabs{display:flex;flex-wrap:wrap;justify-content:center;gap:6px;margin-top:14px}
|
|
1575
1571
|
.lib-tabs button{border:1px solid var(--line);border-radius:999px;background:#fff;color:var(--muted);
|
|
1576
1572
|
padding:4px 13px;font-size:12.3px;cursor:pointer}
|
|
1577
1573
|
.lib-tabs button.on{background:var(--grad);border-color:var(--brand);color:#fff;font-weight:700}
|
|
1578
|
-
.lib-list{max-width:860px;margin:0 auto;display:grid;grid-template-columns:1fr;gap:14px}
|
|
1574
|
+
.lib-list{max-width:860px;margin:0 auto;display:grid;grid-template-columns:minmax(0,1fr);gap:14px}
|
|
1579
1575
|
.lib-empty{max-width:860px;margin:30px auto;text-align:center;color:var(--muted);font-size:13.5px}
|
|
1580
1576
|
.lib-empty.hide{display:none}
|
|
1581
1577
|
.lib-foot{text-align:center;color:var(--muted);font-size:11.5px;padding:18px 0 0;line-height:1.8}
|
|
1582
1578
|
|
|
1583
1579
|
/* ===== 材料卡 ===== */
|
|
1584
|
-
.scard{border:1px solid var(--line);border-left-width:3px;border-radius:12px;padding:14px 18px;
|
|
1580
|
+
.scard{min-width:0;border:1px solid var(--line);border-left-width:3px;border-radius:12px;padding:14px 18px;
|
|
1585
1581
|
background:#fff;box-shadow:var(--shadow-1);transition:box-shadow .25s}
|
|
1586
1582
|
.scard:hover{box-shadow:var(--shadow-2)}
|
|
1587
1583
|
.scard.pol{border-left-color:var(--policy)}
|
|
@@ -1633,17 +1629,15 @@ a.jb-quote{text-decoration:none}
|
|
|
1633
1629
|
.toc a{color:var(--muted);text-decoration:none;padding:4px 10px;border-left:2px solid var(--line);
|
|
1634
1630
|
line-height:1.5;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1635
1631
|
.toc a.on{color:var(--brand);border-left-color:var(--brand);font-weight:700}
|
|
1636
|
-
/*
|
|
1637
|
-
|
|
1632
|
+
/* 切到知识专库视图时隐藏章节目录(避免进入专库页后左侧仍残留目录栏)。
|
|
1633
|
+
正文页与溯源核验报告页都有分节正文,目录在这两页都显示;目录节点渲染在 .app 之后
|
|
1634
|
+
(.app 的兄弟节点),故主规则用兄弟选择器;同时兼容其被移入 .app 内的情况。 */
|
|
1638
1635
|
.app[data-view="library"] ~ .toc,.app[data-view="library"] .toc{display:none}
|
|
1639
1636
|
@media (max-width:1460px){.toc{display:none}}
|
|
1640
1637
|
|
|
1638
|
+
/* 顶部任务区(三切换+原问题+工具)样式已并入顶部 .banner 统一区 */
|
|
1641
1639
|
.foot{text-align:center;color:var(--muted);font-size:11.5px;padding:16px 0 4px;line-height:1.8}
|
|
1642
1640
|
|
|
1643
|
-
/* ===== 只看正文(纯净阅读态) ===== */
|
|
1644
|
-
body.reading .process,body.reading .verify,body.reading .jb,body.reading .sec-badge,
|
|
1645
|
-
body.reading .cite,body.reading .toc,body.reading .p-detail{display:none!important}
|
|
1646
|
-
|
|
1647
1641
|
/* ===== 打印附录 ===== */
|
|
1648
1642
|
.print-appendix{display:none}
|
|
1649
1643
|
|
|
@@ -1652,23 +1646,23 @@ body.reading .cite,body.reading .toc,body.reading .p-detail{display:none!importa
|
|
|
1652
1646
|
.sheet{display:none}
|
|
1653
1647
|
@media (max-width:680px){
|
|
1654
1648
|
body{font-size:14px;line-height:1.8}
|
|
1655
|
-
.
|
|
1649
|
+
.banner{padding:6px 10px 7px}
|
|
1656
1650
|
.tb-stamp{font-size:11px;letter-spacing:2px;text-indent:2px}
|
|
1657
1651
|
.tb-stamp::before,.tb-stamp::after{width:12px;margin:0 4px}
|
|
1658
|
-
.
|
|
1659
|
-
.
|
|
1652
|
+
.banner-bar{flex-wrap:wrap;justify-content:center;gap:7px}
|
|
1653
|
+
.banner-bar .tb-title{display:none}
|
|
1654
|
+
.banner-bar .view-switch{margin:0}
|
|
1655
|
+
.banner-bar .view-switch button{padding:5px 11px;font-size:12px}
|
|
1656
|
+
.banner .orig-q{font-size:12.5px}
|
|
1657
|
+
.banner .meta{font-size:11px}
|
|
1660
1658
|
.tb-tools button{font-size:11.5px;padding:4px 8px}
|
|
1661
|
-
.hero{padding:24px 14px 50px}
|
|
1662
1659
|
.ch-head{gap:8px;margin-bottom:14px;flex-wrap:nowrap}
|
|
1663
1660
|
.ch-head h2{font-size:17px;line-height:1.45}
|
|
1661
|
+
.paper-title{font-size:17.5px;margin-bottom:16px}
|
|
1664
1662
|
.ch-head::after{display:none}
|
|
1665
1663
|
.ch-head .sec-badge{font-size:10.5px;padding:2px 7px;white-space:nowrap}
|
|
1666
1664
|
.jb-name{max-width:calc(100vw - 72px)}
|
|
1667
|
-
.
|
|
1668
|
-
.hero h1{font-size:18.5px}
|
|
1669
|
-
.hero .meta{font-size:11.5px;line-height:1.7}
|
|
1670
|
-
.hero-switch .view-switch button{padding:6px 16px;font-size:12.5px}
|
|
1671
|
-
.process{margin-top:-30px;padding:12px 12px 11px}
|
|
1665
|
+
.process{padding:12px 12px 11px}
|
|
1672
1666
|
.p-step{flex:1 1 100%}
|
|
1673
1667
|
.p-arrow{display:none}
|
|
1674
1668
|
.verify{padding:13px 14px}
|
|
@@ -1693,7 +1687,7 @@ body.reading .cite,body.reading .toc,body.reading .p-detail{display:none!importa
|
|
|
1693
1687
|
-webkit-overflow-scrolling:touch;scrollbar-width:none}
|
|
1694
1688
|
.lib-tabs::-webkit-scrollbar{display:none}
|
|
1695
1689
|
.lib-tabs button{flex:none}
|
|
1696
|
-
.lib-list{grid-template-columns:1fr;gap:10px}
|
|
1690
|
+
.lib-list{grid-template-columns:minmax(0,1fr);gap:10px}
|
|
1697
1691
|
.scard{padding:10px 11px}
|
|
1698
1692
|
.crumb{font-size:11px}
|
|
1699
1693
|
.sc-excerpt{font-size:11.5px}
|
|
@@ -1727,13 +1721,14 @@ body.reading .cite,body.reading .toc,body.reading .p-detail{display:none!importa
|
|
|
1727
1721
|
|
|
1728
1722
|
/* ===== 打印归档 ===== */
|
|
1729
1723
|
@media print{
|
|
1730
|
-
.
|
|
1724
|
+
.banner-bar,.process .p-detail,.lib-head,.toc,.sheet,.sheet-mask,
|
|
1731
1725
|
.progress{display:none!important}
|
|
1732
|
-
|
|
1733
|
-
#view-report{display:block!important}
|
|
1734
|
-
.
|
|
1735
|
-
.
|
|
1736
|
-
.
|
|
1726
|
+
/* 溯源核验报告导出:三页顺序打印 */
|
|
1727
|
+
#view-body,#view-report,#view-library{display:block!important}
|
|
1728
|
+
.banner{position:static;background:none;border:0;padding:0 0 6px}
|
|
1729
|
+
.banner .orig-q{text-align:left;font-size:13px}
|
|
1730
|
+
.banner .meta{color:var(--muted);text-align:left}
|
|
1731
|
+
.app{padding-top:0}
|
|
1737
1732
|
*{-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
1738
1733
|
.process{box-shadow:none;margin:6px 0 12px}
|
|
1739
1734
|
.verify{border-color:#bbb;box-shadow:none;break-inside:avoid}
|
|
@@ -1750,13 +1745,14 @@ body.reading .cite,body.reading .toc,body.reading .p-detail{display:none!importa
|
|
|
1750
1745
|
.jb.active{break-inside:avoid}
|
|
1751
1746
|
.jb.active .jb-body{display:block!important}
|
|
1752
1747
|
.jb.active .jb-body .jb-quote{break-inside:avoid}
|
|
1753
|
-
body.reading .verify,body.reading .process,body.reading .ev-row,body.reading .sec-badge,
|
|
1754
|
-
body.reading .cite{display:none!important}
|
|
1755
1748
|
.print-appendix{display:block;break-before:page}
|
|
1756
|
-
body.print-body-only
|
|
1757
|
-
body.print-body-only .
|
|
1749
|
+
body.print-body-only #view-report,body.print-body-only #view-library,
|
|
1750
|
+
body.print-body-only .print-appendix,body.print-body-only .foot{display:none!important}
|
|
1758
1751
|
.print-appendix h3{font-size:15px;color:var(--navy);border-bottom:1px solid #999;padding-bottom:6px;margin:0 0 12px}
|
|
1759
1752
|
.print-appendix .scard{margin-bottom:10px}
|
|
1753
|
+
/* 打印时宽表格贴合页宽(屏幕端靠 .sc-excerpt.rich 横向滚动,纸张上不能滚) */
|
|
1754
|
+
.print-appendix .sc-excerpt.rich,.sc-excerpt.rich{overflow-x:visible}
|
|
1755
|
+
.print-appendix .sc-excerpt.rich table,.sc-excerpt.rich table{width:100%!important;min-width:0}
|
|
1760
1756
|
}
|
|
1761
1757
|
"""
|
|
1762
1758
|
|
|
@@ -1769,8 +1765,9 @@ PAGE_JS = """
|
|
|
1769
1765
|
var app = $(".app");
|
|
1770
1766
|
var isMobile = function () { return window.matchMedia("(max-width:680px)").matches; };
|
|
1771
1767
|
|
|
1772
|
-
/* ===== 1.
|
|
1773
|
-
var savedScroll = { report: 0, library: 0 };
|
|
1768
|
+
/* ===== 1. 三页切换(正文 / 溯源核验报告 / 知识专库;保存/恢复各自滚动位置) ===== */
|
|
1769
|
+
var savedScroll = { body: 0, report: 0, library: 0 };
|
|
1770
|
+
var viewChangeHook = null; /* 切页后重算目录锚点等 */
|
|
1774
1771
|
function setView(view) {
|
|
1775
1772
|
if (!app || app.getAttribute("data-view") === view) return;
|
|
1776
1773
|
savedScroll[app.getAttribute("data-view") || "report"] = window.scrollY;
|
|
@@ -1779,6 +1776,7 @@ PAGE_JS = """
|
|
|
1779
1776
|
b.classList.toggle("on", b.getAttribute("data-view") === view);
|
|
1780
1777
|
});
|
|
1781
1778
|
window.scrollTo(0, Math.max(0, savedScroll[view] || 0));
|
|
1779
|
+
if (viewChangeHook) viewChangeHook(view);
|
|
1782
1780
|
}
|
|
1783
1781
|
$$(".view-switch button").forEach(function (b) {
|
|
1784
1782
|
b.addEventListener("click", function () { setView(b.getAttribute("data-view")); });
|
|
@@ -1795,26 +1793,14 @@ PAGE_JS = """
|
|
|
1795
1793
|
window.addEventListener("scroll", updateProgress, { passive: true });
|
|
1796
1794
|
updateProgress();
|
|
1797
1795
|
|
|
1798
|
-
/* ===== 3.
|
|
1799
|
-
var readBtn = $("#btn-reading");
|
|
1800
|
-
if (readBtn) {
|
|
1801
|
-
readBtn.addEventListener("click", function () {
|
|
1802
|
-
var on = document.body.classList.toggle("reading");
|
|
1803
|
-
readBtn.setAttribute("aria-pressed", on ? "true" : "false");
|
|
1804
|
-
readBtn.textContent = on ? "显示核验" : "只看正文";
|
|
1805
|
-
/* 只看正文只作用于核验报告视图:正在知识专库时切回报告,专库不受影响 */
|
|
1806
|
-
if (on && app && app.getAttribute("data-view") !== "report") setView("report");
|
|
1807
|
-
});
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
|
-
/* ===== 4. 复制全文(章节标题 + 段落 + 表格,去角标) ===== */
|
|
1796
|
+
/* ===== 3. 复制全文(章节标题 + 段落 + 表格,去角标) ===== */
|
|
1811
1797
|
var copyBtn = $("#btn-copy");
|
|
1812
1798
|
if (copyBtn) {
|
|
1813
1799
|
copyBtn.addEventListener("click", function () {
|
|
1814
1800
|
var parts = [];
|
|
1815
1801
|
/* 按文档流顺序收集章节标题/段落/表格;克隆后剔除引文胶囊与角标,
|
|
1816
1802
|
只复制正文本身(胶囊标题/展开摘录/编号数字均不带出) */
|
|
1817
|
-
var nodes = $$("#view-
|
|
1803
|
+
var nodes = $$("#view-body .ch-head h2, #view-body .lead, #view-body .para, #view-body .tbl-wrap");
|
|
1818
1804
|
nodes.sort(function (a, b) { return (a.compareDocumentPosition(b) & 4) ? -1 : 1; });
|
|
1819
1805
|
nodes.forEach(function (el) {
|
|
1820
1806
|
var clone = el.cloneNode(true);
|
|
@@ -1849,26 +1835,45 @@ PAGE_JS = """
|
|
|
1849
1835
|
});
|
|
1850
1836
|
}
|
|
1851
1837
|
|
|
1852
|
-
/* ===== 5.
|
|
1853
|
-
var
|
|
1854
|
-
var
|
|
1838
|
+
/* ===== 5. 导出:正文 Markdown / PDF(浏览器打印另存为 PDF) ===== */
|
|
1839
|
+
var exportBtn = $("#btn-export");
|
|
1840
|
+
var exportDrop = $("#export-drop");
|
|
1841
|
+
function docTitleForFile() {
|
|
1842
|
+
var t = $(".tb-title");
|
|
1843
|
+
var name = (t ? t.textContent.trim() : "") || document.title || "文稿";
|
|
1844
|
+
return name.replace(/[\\/:*?"<>|]+/g, "_").trim() || "文稿";
|
|
1845
|
+
}
|
|
1846
|
+
function exportMarkdown() {
|
|
1847
|
+
var el = document.getElementById("doc-export");
|
|
1848
|
+
var data = { title: docTitleForFile(), markdown: "" };
|
|
1849
|
+
if (el) { try { data = JSON.parse(el.textContent) || data; } catch (err) {} }
|
|
1850
|
+
var blob = new Blob([data.markdown || ""], { type: "text/markdown;charset=utf-8" });
|
|
1851
|
+
var url = URL.createObjectURL(blob);
|
|
1852
|
+
var a = document.createElement("a");
|
|
1853
|
+
a.href = url;
|
|
1854
|
+
a.download = (data.title || docTitleForFile()) + ".md";
|
|
1855
|
+
document.body.appendChild(a);
|
|
1856
|
+
a.click();
|
|
1857
|
+
setTimeout(function () { URL.revokeObjectURL(url); if (a.parentNode) a.parentNode.removeChild(a); }, 800);
|
|
1858
|
+
}
|
|
1855
1859
|
function printBy(mode) {
|
|
1856
1860
|
if (mode === "body") document.body.classList.add("print-body-only");
|
|
1857
|
-
if (
|
|
1861
|
+
if (exportDrop) exportDrop.hidden = true;
|
|
1858
1862
|
window.print();
|
|
1859
1863
|
}
|
|
1860
|
-
if (
|
|
1861
|
-
|
|
1864
|
+
if (exportBtn && exportDrop) {
|
|
1865
|
+
exportBtn.addEventListener("click", function (e) {
|
|
1862
1866
|
e.stopPropagation();
|
|
1863
|
-
|
|
1867
|
+
exportDrop.hidden = !exportDrop.hidden;
|
|
1864
1868
|
});
|
|
1865
|
-
|
|
1869
|
+
exportDrop.addEventListener("click", function (e) {
|
|
1866
1870
|
e.stopPropagation();
|
|
1867
1871
|
var t = e.target.closest("button");
|
|
1868
1872
|
if (!t) return;
|
|
1869
|
-
|
|
1873
|
+
if (t.id === "export-md") { exportMarkdown(); exportDrop.hidden = true; return; }
|
|
1874
|
+
printBy(t.id === "export-pdf-body" ? "body" : "full");
|
|
1870
1875
|
});
|
|
1871
|
-
document.addEventListener("click", function () {
|
|
1876
|
+
document.addEventListener("click", function () { exportDrop.hidden = true; });
|
|
1872
1877
|
/* 打印结束移除临时模式(浏览器打印窗口关闭后触发) */
|
|
1873
1878
|
window.addEventListener("afterprint", function () { document.body.classList.remove("print-body-only"); });
|
|
1874
1879
|
}
|
|
@@ -2030,15 +2035,6 @@ PAGE_JS = """
|
|
|
2030
2035
|
});
|
|
2031
2036
|
var search = $(".lib-search");
|
|
2032
2037
|
if (search) search.addEventListener("input", function () { kw = search.value.trim().toLowerCase(); applyFilter(); });
|
|
2033
|
-
$$(".hot-term").forEach(function (t) {
|
|
2034
|
-
t.addEventListener("click", function () {
|
|
2035
|
-
if (!search) return;
|
|
2036
|
-
search.value = t.textContent.trim();
|
|
2037
|
-
kw = search.value.toLowerCase();
|
|
2038
|
-
applyFilter();
|
|
2039
|
-
if (search.focus) search.focus();
|
|
2040
|
-
});
|
|
2041
|
-
});
|
|
2042
2038
|
|
|
2043
2039
|
/* ===== 8. 过程回顾条:检索步骤展开 ===== */
|
|
2044
2040
|
var pStep = $("#p-step-search");
|
|
@@ -2051,20 +2047,30 @@ PAGE_JS = """
|
|
|
2051
2047
|
});
|
|
2052
2048
|
}
|
|
2053
2049
|
|
|
2054
|
-
/* ===== 9. 章节目录(spy
|
|
2050
|
+
/* ===== 9. 章节目录(spy;正文页与溯源核验报告页共用,按当前视图切换锚点) ===== */
|
|
2055
2051
|
var toc = $(".toc");
|
|
2056
2052
|
if (toc) {
|
|
2057
2053
|
var links = $$("a", toc);
|
|
2058
|
-
|
|
2054
|
+
function tocPrefix() {
|
|
2055
|
+
var v = app ? app.getAttribute("data-view") : "";
|
|
2056
|
+
return v === "report" ? "rsec" : (v === "body" ? "sec" : "");
|
|
2057
|
+
}
|
|
2058
|
+
function tocSecs() {
|
|
2059
|
+
var p = tocPrefix();
|
|
2060
|
+
if (!p) return [];
|
|
2061
|
+
return links.map(function (a) { return document.getElementById(p + "-" + a.getAttribute("data-sec")); });
|
|
2062
|
+
}
|
|
2063
|
+
var secs = tocSecs();
|
|
2059
2064
|
links.forEach(function (a) {
|
|
2060
2065
|
a.addEventListener("click", function (e) {
|
|
2061
2066
|
e.preventDefault();
|
|
2062
|
-
var
|
|
2067
|
+
var p = tocPrefix();
|
|
2068
|
+
var target = p ? document.getElementById(p + "-" + a.getAttribute("data-sec")) : null;
|
|
2063
2069
|
if (!target) return;
|
|
2064
2070
|
/* 手动定位而非 scrollIntoView({block:"start"}):后者把标题顶到视口 y=0,
|
|
2065
|
-
会被 sticky
|
|
2071
|
+
会被 sticky 顶栏盖住(点"四、…"后一级标题看不见)。
|
|
2066
2072
|
偏移量与目录吸顶位置同一基准(顶栏高 + 20px)。 */
|
|
2067
|
-
var bar = document.querySelector(".
|
|
2073
|
+
var bar = document.querySelector(".banner");
|
|
2068
2074
|
var offset = (bar ? bar.offsetHeight : 0) + 20;
|
|
2069
2075
|
var y = target.getBoundingClientRect().top + window.scrollY - offset;
|
|
2070
2076
|
window.scrollTo({ top: Math.max(0, y), behavior: "smooth" });
|
|
@@ -2077,24 +2083,20 @@ PAGE_JS = """
|
|
|
2077
2083
|
links.forEach(function (a, i) { a.classList.toggle("on", i === current); });
|
|
2078
2084
|
}
|
|
2079
2085
|
window.addEventListener("scroll", spy, { passive: true });
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
改为——初始与正文首节对齐,滚动时吸附在顶栏下方。 */
|
|
2083
|
-
var topbar = document.querySelector(".topbar");
|
|
2086
|
+
/* 目录纵向定位:初始与正文首节对齐,滚动时吸附在顶栏下方(目录过长由 CSS max-height 内部滚动兜底)。 */
|
|
2087
|
+
var bannerEl = document.querySelector(".banner");
|
|
2084
2088
|
function placeToc() {
|
|
2085
2089
|
var first = secs[0];
|
|
2086
2090
|
if (!first) return;
|
|
2087
|
-
var stick = (
|
|
2091
|
+
var stick = (bannerEl ? bannerEl.offsetHeight : 0) + 20;
|
|
2088
2092
|
var want = Math.round(first.getBoundingClientRect().top);
|
|
2089
|
-
/* 不再按"视口内放不放得下"压缩位置(2026-09-29 二次修复):正文首节上方还有页头、
|
|
2090
|
-
过程回顾和核验单,首屏内它常位于视口之外;若按 innerHeight 把目录上移,目录会被
|
|
2091
|
-
顶到页面中上部,反而显得"悬得过高",与正文脱节。直接跟随正文首节——首屏看不到
|
|
2092
|
-
目录属正常,向下滚动后它自然吸附在顶栏下方。目录过长时由 CSS 的
|
|
2093
|
-
max-height:60vh + overflow:auto 内部滚动兜底。 */
|
|
2094
2093
|
toc.style.top = Math.max(stick, want) + "px";
|
|
2095
2094
|
}
|
|
2096
2095
|
window.addEventListener("scroll", placeToc, { passive: true });
|
|
2097
2096
|
window.addEventListener("resize", placeToc);
|
|
2097
|
+
/* 切页时重算锚点与高亮(正文页 sec-N / 溯源核验报告页 rsec-N) */
|
|
2098
|
+
viewChangeHook = function () { secs = tocSecs(); spy(); placeToc(); };
|
|
2099
|
+
spy();
|
|
2098
2100
|
placeToc();
|
|
2099
2101
|
}
|
|
2100
2102
|
})();
|
|
@@ -2104,10 +2106,10 @@ PAGE_JS = """
|
|
|
2104
2106
|
def normalize_body_quotes(text: str) -> str:
|
|
2105
2107
|
"""报告正文引号归一:复用 `format_document.normalize_chinese_quotes`,与 Word 同源。
|
|
2106
2108
|
|
|
2107
|
-
|
|
2109
|
+
背景:`format_document.py` 生成 Word 时会统一把 ASCII 直引号转为
|
|
2108
2110
|
中文全角引号,但溯源报告直接读溯源 JSON 里的 document_content —— 模型落盘时若把
|
|
2109
2111
|
中文引号写成半角,报告就会与 Word 交付物不一致,而这条路径此前没有兜底
|
|
2110
|
-
|
|
2112
|
+
(此前靠任务侧手工跑引号脚本规避,机制上没有保障)。取不到该函数时原样返回,
|
|
2111
2113
|
不阻断渲染。
|
|
2112
2114
|
"""
|
|
2113
2115
|
if not text:
|
|
@@ -2134,7 +2136,6 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
|
|
|
2134
2136
|
|
|
2135
2137
|
verification = compute_verification(answer, sources, payload, generated_at)
|
|
2136
2138
|
process_stats = compute_process_stats(sources, answer)
|
|
2137
|
-
hot_terms = extract_hot_terms(answer, sources)
|
|
2138
2139
|
citation_warning = ""
|
|
2139
2140
|
if sources and not used:
|
|
2140
2141
|
citation_warning = (
|
|
@@ -2151,89 +2152,120 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
|
|
|
2151
2152
|
for key, html in (jb.pop("_tables", {}) or {}).items():
|
|
2152
2153
|
jb_tables[key] = html
|
|
2153
2154
|
doc_title, sections = group_sections(blocks)
|
|
2155
|
+
# 正文页:同一份正文去掉全部角标/引文胶囊,输出干净正式内容(核验内容归"溯源核验报告"页)
|
|
2156
|
+
clean_blocks, _ = parse_answer_blocks(answer, {s["id"] for s in sources}, chip_map, strip_cites=True)
|
|
2157
|
+
_, clean_sections = group_sections(clean_blocks)
|
|
2154
2158
|
display_title = doc_title or title
|
|
2159
|
+
# 原问题行:溯源报告须含完整原问题才能独立使用。
|
|
2160
|
+
# 只认调用方显式传入的 question_override(source_note_html 读溯源 JSON 顶层
|
|
2161
|
+
# question,即 build_trace_json --question 写入的用户原话)——不取 payload 内的
|
|
2162
|
+
# question 字段兜底(该字段历史上常被报告标题冒充,显示了反而误导);为空或与
|
|
2163
|
+
# 标题相同时不显示该行(历史 JSON 兼容)。
|
|
2164
|
+
question_text = (question_override or "").strip()
|
|
2165
|
+
orig_q_html = (f'<div class="orig-q" title="{esc(question_text)}"><b>原问题</b>:{esc(question_text)}</div>'
|
|
2166
|
+
if question_text and question_text != display_title else "")
|
|
2155
2167
|
|
|
2156
2168
|
jb_tables_json = json.dumps(jb_tables, ensure_ascii=False).replace("</", "<\\/")
|
|
2157
2169
|
jb_tables_script = (f'<script type="application/json" id="jb-tables">{jb_tables_json}</script>\n'
|
|
2158
2170
|
if jb_tables else "")
|
|
2171
|
+
# 导出用正文 Markdown(去角标,干净正文),供顶部"导出 ▾ → 导出正文 Markdown"下载
|
|
2172
|
+
export_payload = {"title": display_title, "markdown": strip_citation_markers(answer)}
|
|
2173
|
+
export_json = json.dumps(export_payload, ensure_ascii=False).replace("</", "<\\/")
|
|
2174
|
+
export_script = f'<script type="application/json" id="doc-export">{export_json}</script>\n'
|
|
2159
2175
|
|
|
2160
2176
|
meta_bits = []
|
|
2161
2177
|
if process_stats["n_searches"]:
|
|
2162
|
-
|
|
2178
|
+
# 检索计数按接口通道拆分显示(深度搜索与可信搜索是两个接口来源)
|
|
2179
|
+
_deep_n = process_stats.get("deep_routes", 0)
|
|
2180
|
+
_trusted_n = process_stats.get("trusted_routes", 0)
|
|
2181
|
+
if _deep_n and _trusted_n:
|
|
2182
|
+
meta_bits.append(f"深度搜索 {_deep_n} 路 · 可信补搜 {_trusted_n} 次")
|
|
2183
|
+
elif _deep_n:
|
|
2184
|
+
meta_bits.append(f"深知深度搜索 {_deep_n} 路")
|
|
2185
|
+
elif _trusted_n:
|
|
2186
|
+
meta_bits.append(f"深知可信搜索 {_trusted_n} 次")
|
|
2187
|
+
else:
|
|
2188
|
+
meta_bits.append(f"深知检索 {process_stats['n_searches']} 次")
|
|
2163
2189
|
if sources:
|
|
2164
|
-
meta_bits.append(f"
|
|
2190
|
+
meta_bits.append(f"知识专库文章 {len(sources)} 篇")
|
|
2165
2191
|
if process_stats["n_cite_marks"]:
|
|
2166
|
-
meta_bits.append(f"
|
|
2192
|
+
meta_bits.append(f"正文实际引用 {process_stats['n_cite_marks']} 处")
|
|
2167
2193
|
meta_bits.append(f"生成于 {generated}")
|
|
2168
2194
|
meta_line = " · ".join(meta_bits)
|
|
2195
|
+
# 来源=材料实际使用的检索通道(深知深度搜索 / 深知可信搜索,动态汇总);
|
|
2196
|
+
# 历史溯源 JSON 无通道信息时保留旧文案
|
|
2197
|
+
_channels: List[str] = []
|
|
2198
|
+
for s in sources:
|
|
2199
|
+
_ch = (s.get("channel") or "").strip()
|
|
2200
|
+
# 通道可能为顿号拼接的多值(同一材料被两接口召回),拆分后逐 token 汇总
|
|
2201
|
+
for token in [t.strip() for t in _ch.split("、") if t.strip()]:
|
|
2202
|
+
if token not in _channels:
|
|
2203
|
+
_channels.append(token)
|
|
2204
|
+
source_line = " · ".join(_channels) if _channels else "深知可信搜索"
|
|
2169
2205
|
|
|
2170
2206
|
return f"""<!doctype html>
|
|
2171
2207
|
<html lang="zh-CN">
|
|
2172
2208
|
<head>
|
|
2173
2209
|
<meta charset="utf-8">
|
|
2174
2210
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
2175
|
-
<title>{esc(display_title)}
|
|
2211
|
+
<title>{esc(display_title)}</title>
|
|
2176
2212
|
<style>{PAGE_CSS}</style>
|
|
2177
2213
|
</head>
|
|
2178
2214
|
<body>
|
|
2179
2215
|
|
|
2180
|
-
<header class="
|
|
2181
|
-
<div class="
|
|
2182
|
-
<span class="tb-stamp">溯源核验报告</span>
|
|
2216
|
+
<header class="banner">
|
|
2217
|
+
<div class="banner-bar">
|
|
2183
2218
|
<span class="tb-title">{esc(display_title)}</span>
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
<button
|
|
2188
|
-
<button data-view="library" type="button">知识专库</button>
|
|
2219
|
+
<div class="view-switch" role="tablist" aria-label="页面切换">
|
|
2220
|
+
<button data-view="body" type="button">正文(去索引)</button>
|
|
2221
|
+
<button class="on" data-view="report" type="button">溯源核验报告</button>
|
|
2222
|
+
<button data-view="library" type="button">知识专库({len(sources)})</button>
|
|
2189
2223
|
</div>
|
|
2190
2224
|
<div class="tb-tools">
|
|
2191
|
-
<button id="btn-reading" type="button" aria-pressed="false" title="隐藏核验元素,纯阅读正文">只看正文</button>
|
|
2192
2225
|
<button id="btn-copy" type="button" title="复制正文纯文本">复制全文</button>
|
|
2193
2226
|
<span class="print-menu">
|
|
2194
|
-
<button id="btn-
|
|
2195
|
-
<span class="print-drop" id="
|
|
2196
|
-
<button id="
|
|
2197
|
-
<button id="
|
|
2227
|
+
<button id="btn-export" type="button" aria-haspopup="true" title="导出正文 Markdown 或 PDF">导出 ▾</button>
|
|
2228
|
+
<span class="print-drop" id="export-drop" hidden>
|
|
2229
|
+
<button id="export-md" type="button">导出 Markdown(正文)</button>
|
|
2230
|
+
<button id="export-pdf-body" type="button">导出 PDF(正文)</button>
|
|
2231
|
+
<button id="export-pdf-full" type="button">导出 PDF(溯源核验报告)</button>
|
|
2198
2232
|
</span>
|
|
2199
2233
|
</span>
|
|
2200
2234
|
</div>
|
|
2201
2235
|
</div>
|
|
2236
|
+
{orig_q_html}
|
|
2237
|
+
<div class="meta">{esc(meta_line)} | 来源:{esc(source_line)}</div>
|
|
2202
2238
|
<div class="progress" aria-hidden="true"><i></i></div>
|
|
2203
2239
|
</header>
|
|
2204
2240
|
|
|
2205
|
-
<div class="hero">
|
|
2206
|
-
<div class="r-badge">溯源核验报告</div>
|
|
2207
|
-
<h1>{esc(display_title)}</h1>
|
|
2208
|
-
<div class="meta">{esc(meta_line)} | 来源:深知可信搜索</div>
|
|
2209
|
-
<div class="hero-switch">
|
|
2210
|
-
<div class="view-switch" role="tablist" aria-label="视图切换">
|
|
2211
|
-
<button class="on" data-view="report" type="button">核验报告</button>
|
|
2212
|
-
<button data-view="library" type="button">知识专库({len(sources)})</button>
|
|
2213
|
-
</div>
|
|
2214
|
-
</div>
|
|
2215
|
-
</div>
|
|
2216
|
-
|
|
2217
2241
|
<div class="app container" data-view="report">
|
|
2218
|
-
|
|
2242
|
+
<main class="view" id="view-body" aria-label="正文">
|
|
2243
|
+
<h2 class="paper-title">{esc(display_title)}</h2>
|
|
2244
|
+
<div class="doc-paper">
|
|
2245
|
+
{render_section_cards(clean_sections, sources, with_ids=True, id_prefix="sec")}
|
|
2246
|
+
</div>
|
|
2247
|
+
<div class="foot">深知公文写作 · 正文 | 内容由 AI 生成,仅供参考</div>
|
|
2248
|
+
</main>
|
|
2219
2249
|
|
|
2220
|
-
<main class="view" id="view-report" aria-label="
|
|
2250
|
+
<main class="view" id="view-report" aria-label="溯源核验报告">
|
|
2251
|
+
<h2 class="paper-title">溯源核验报告:{esc(display_title)}</h2>
|
|
2221
2252
|
{citation_warning}
|
|
2253
|
+
{render_process_bar(process_stats, verification)}
|
|
2222
2254
|
{render_verify_panel(verification)}
|
|
2223
2255
|
<div class="doc-paper">
|
|
2224
|
-
{render_section_cards(sections, sources)}
|
|
2256
|
+
{render_section_cards(sections, sources, with_ids=True, id_prefix="rsec")}
|
|
2225
2257
|
</div>
|
|
2226
2258
|
<div class="foot">深知公文写作 · 溯源核验报告 | 内容由 AI 生成,仅供参考</div>
|
|
2227
2259
|
</main>
|
|
2228
2260
|
|
|
2229
|
-
{render_library_view(sources,
|
|
2261
|
+
{render_library_view(sources, display_title)}
|
|
2230
2262
|
{render_print_appendix(sources)}
|
|
2231
2263
|
</div>
|
|
2232
2264
|
|
|
2233
2265
|
{render_toc(sections)}
|
|
2234
2266
|
|
|
2235
2267
|
<div class="ev-panel" id="ev-pop" hidden></div>
|
|
2236
|
-
{jb_tables_script}<div class="sheet-mask" aria-hidden="true"></div>
|
|
2268
|
+
{export_script}{jb_tables_script}<div class="sheet-mask" aria-hidden="true"></div>
|
|
2237
2269
|
<div class="sheet" role="dialog" aria-label="来源文章">
|
|
2238
2270
|
<div class="sheet-grab"></div>
|
|
2239
2271
|
<div class="sheet-head"><b>依据对照</b><button class="sheet-close" type="button">收起</button></div>
|
|
@@ -2248,7 +2280,7 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
|
|
|
2248
2280
|
def align_sources_to_answer(answer: str, sources: List[Dict[str, str]]) -> List[Dict[str, str]]:
|
|
2249
2281
|
"""不再按位置给材料重编号。
|
|
2250
2282
|
|
|
2251
|
-
|
|
2283
|
+
原实现会在"正文角标与素材 id 完全不相交"时按顺序把素材改号
|
|
2252
2284
|
迎合角标——正文写 `[7]` 而只有 1 条材料时,会被洗成"✓ 引用对应 1/1",与本文件
|
|
2253
2285
|
"未绑定角标绝不按位置猜测"的设计原则相反。现如实返回原素材,由核验单报未绑定。
|
|
2254
2286
|
"""
|
|
@@ -2258,7 +2290,7 @@ def align_sources_to_answer(answer: str, sources: List[Dict[str, str]]) -> List[
|
|
|
2258
2290
|
def _check_degraded_input(payload: Dict[str, Any], path: str) -> None:
|
|
2259
2291
|
"""渲染前硬校验:发现会产出"残缺核验报告"的输入直接报错,阻断静默降级。
|
|
2260
2292
|
|
|
2261
|
-
|
|
2293
|
+
手写溯源 JSON 曾出现缺 recalled_materials、self_check 结构
|
|
2262
2294
|
不完整,渲染器静默显示"依据溯源 0/24 / 材料新旧 未记录 / 交付前检查 未记录"。
|
|
2263
2295
|
这里只拦截两个必然导致报告失真的情况;完整校验用 scripts/check_materials.py。
|
|
2264
2296
|
"""
|
|
@@ -2288,10 +2320,8 @@ def _check_degraded_input(payload: Dict[str, Any], path: str) -> None:
|
|
|
2288
2320
|
)
|
|
2289
2321
|
|
|
2290
2322
|
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
2323
|
def _dsh_default_output_dir() -> str:
|
|
2294
|
-
"""dsh
|
|
2324
|
+
"""dsh:默认输出目录锚定会话工作区(与其他脚本的 WS_ROOT 同源解析)。"""
|
|
2295
2325
|
import os as _os
|
|
2296
2326
|
_ws = _os.environ.get("DKNWOC_WS_ROOT")
|
|
2297
2327
|
if not _ws:
|