dknowc-dsh 1.2.1 → 1.4.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 +4 -2
- package/package.json +3 -3
- package/skills/dknowc-official-doc-writer/README.md +15 -38
- package/skills/dknowc-official-doc-writer/SKILL.md +134 -221
- package/skills/dknowc-official-doc-writer/reference/local_memory_guide.md +53 -0
- package/skills/dknowc-official-doc-writer/reference/material_usage_guidance.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/onboarding_scripts.md +132 -0
- package/skills/dknowc-official-doc-writer/reference/output_guide.md +4 -4
- package/skills/dknowc-official-doc-writer/reference/review_checklist.md +16 -16
- package/skills/dknowc-official-doc-writer/reference/revision_workflow.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/sample_search_result.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/sample_trace_report.html +1006 -224
- package/skills/dknowc-official-doc-writer/reference/search_guide.md +64 -33
- package/skills/dknowc-official-doc-writer/reference/search_intro.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/search_policy.md +26 -13
- package/skills/dknowc-official-doc-writer/reference/standards/01_report.md +3 -2
- package/skills/dknowc-official-doc-writer/reference/standards/02_qingshi.md +3 -2
- package/skills/dknowc-official-doc-writer/reference/standards/03_pifu.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/04_tongzhi.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/standards/05_yijian.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/06_han.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/standards/08_tongbao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/09_tonggao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/10_gonggao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/11_fuhan_approve.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/12_fuhan_objection.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/13_reminder.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/standards/14_generic.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/16_decision.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/18_order.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/standards/19_gazette.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/standards/20_motion.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/22_application.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/23_publicity.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/task_router.md +10 -10
- package/skills/dknowc-official-doc-writer/scripts/adapt_mcp_result.py +52 -2
- package/skills/dknowc-official-doc-writer/scripts/api_key.py +41 -0
- package/skills/dknowc-official-doc-writer/scripts/dkag_search.py +40 -7
- package/skills/dknowc-official-doc-writer/scripts/format_document.py +30 -26
- package/skills/dknowc-official-doc-writer/scripts/initialize.py +45 -23
- package/skills/dknowc-official-doc-writer/scripts/local_memory.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/mcp_direct.py +9 -1
- package/skills/dknowc-official-doc-writer/scripts/merge_search_results.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/outline_reference.py +7 -11
- package/skills/dknowc-official-doc-writer/scripts/register.mjs +51 -10
- package/skills/dknowc-official-doc-writer/scripts/render_trace_html.py +1400 -595
- package/skills/dknowc-official-doc-writer/scripts/review_document.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/source_note_html.py +174 -48
- package/skills/dknowc-official-doc-writer/scripts/template_generator.py +3 -3
- package/skills/dknowc-ppt-assistant/README.md +4 -4
- package/skills/dknowc-ppt-assistant/SKILL.md +16 -20
- package/skills/dknowc-ppt-assistant/references/content-pack.md +3 -3
- package/skills/dknowc-ppt-assistant/references/material_usage.md +9 -6
- package/skills/dknowc-ppt-assistant/references/onboarding_scripts.md +120 -0
- package/skills/dknowc-ppt-assistant/references/sample_search_result.md +1 -1
- package/skills/dknowc-ppt-assistant/references/sample_trace_report.html +1543 -0
- package/skills/dknowc-ppt-assistant/references/search_intro.md +1 -1
- package/skills/dknowc-ppt-assistant/references/svg-authoring.md +1 -1
- package/skills/dknowc-ppt-assistant/scripts/api_key.py +41 -0
- package/skills/dknowc-ppt-assistant/scripts/initialize.py +54 -23
- package/skills/dknowc-ppt-assistant/scripts/mcp_direct.py +8 -0
- package/skills/dknowc-ppt-assistant/scripts/register_key.mjs +112 -26
- package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +1556 -609
- package/skills/dknowc-ppt-assistant/scripts/trusted_search.py +65 -15
- package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +10 -10
- package/skills/dknowc-ppt-assistant/workflows/routing.md +1 -1
- package/skills/dknowc-trusted-consulting/README.md +8 -9
- package/skills/dknowc-trusted-consulting/SKILL.md +54 -34
- package/skills/dknowc-trusted-consulting/reference/consult_intro.md +3 -35
- package/skills/dknowc-trusted-consulting/reference/onboarding_scripts.md +132 -0
- package/skills/dknowc-trusted-consulting/reference/sample_trace_report.html +682 -272
- package/skills/dknowc-trusted-consulting/scripts/api_key.py +41 -0
- package/skills/dknowc-trusted-consulting/scripts/gov_chat.py +39 -19
- package/skills/dknowc-trusted-consulting/scripts/initialize.py +52 -18
- package/skills/dknowc-trusted-consulting/scripts/mcp_direct.py +8 -0
- package/skills/dknowc-trusted-consulting/scripts/register_key.mjs +122 -21
- package/skills/dknowc-trusted-consulting/scripts/render_trace_html.py +1665 -743
- package/skills/dknowc-trusted-search/README.md +2 -1
- package/skills/dknowc-trusted-search/SKILL.md +33 -33
- package/skills/dknowc-trusted-search/reference/onboarding_scripts.md +132 -0
- package/skills/dknowc-trusted-search/reference/sample_trace_report.html +1148 -233
- package/skills/dknowc-trusted-search/scripts/api_key.py +41 -0
- package/skills/dknowc-trusted-search/scripts/deep_query.py +81 -9
- package/skills/dknowc-trusted-search/scripts/initialize.py +64 -17
- package/skills/dknowc-trusted-search/scripts/mcp_direct.py +8 -0
- package/skills/dknowc-trusted-search/scripts/register_key.mjs +111 -24
- package/skills/dknowc-trusted-search/scripts/render_policy_visualization.py +2 -3
- package/skills/dknowc-trusted-search/scripts/render_trace_html.py +1688 -718
- package/skills/dknowc-trusted-search/scripts/trusted_search.py +86 -14
- package/src/index.js +3 -3
- package/skills/dknowc-official-doc-writer/official-docs/input/mcp_intro_content.md +0 -61
- package/skills/dknowc-official-doc-writer/scripts/check_release.py +0 -93
- package/skills/dknowc-ppt-assistant/scripts/check_release.py +0 -106
- package/skills/dknowc-trusted-consulting/scripts/check_release.py +0 -66
- package/skills/dknowc-trusted-search/reference/search_intro.md +0 -79
- package/skills/dknowc-trusted-search/scripts/check_release.py +0 -79
|
@@ -1,45 +1,52 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""深知可信PPT
|
|
2
|
+
"""深知可信PPT 溯源核验报告渲染器:把检索素材 JSON + 答案文件渲染为单文件可核验 HTML。
|
|
3
3
|
|
|
4
4
|
双版支持(--stage):
|
|
5
5
|
- outline 提纲版:结构方案确认门前的提纲答案文件(页面规划表 + 口径事项清单)→ 事前核验
|
|
6
6
|
- final 成稿版:交付时的页面级结论文本 → 事后溯源
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
3.7.0 同源架构(对齐公文写作 3.7.0,参考深知晓交互原型,数据口径保持自有与真实):
|
|
9
|
+
- 顶栏:身份章 + 标题 + 工具组(只看正文 / 复制全文 / 打印归档)+ 阅读进度条
|
|
10
|
+
- Hero:大标题 + 真实统计(N 次检索 · M 条材料 · K 处引用)+ 双视图切换
|
|
11
|
+
- 过程回顾条:检索 → 入库 → 逐条比对 → 核验完成(静态回放,数字全部真实计算)
|
|
12
|
+
- 核验报告视图(默认):核验报告单 + 正文文档流(章节标题 + 句后引文胶囊,点击原地展开溯源卡)
|
|
13
|
+
- 材料专库视图(全屏):大搜索 + 热词(真实计算)+ 检索分组 tabs + 材料卡
|
|
14
|
+
- 链接质量保障:生成时检测全部材料链接(HTTP 404/410 + 政府站软 404 标题嗅探),
|
|
15
|
+
失效链接改用存档快照回看(接口 screenShotPath,路径容错补 /A/,纯本地校验不误杀)
|
|
16
|
+
|
|
17
|
+
PPT 特有口径(与公文写作的差异,均为产品决策):
|
|
18
|
+
- 提醒制:数据缺口(缺原文链接/缺摘录)不判不通过、指标恒绿附温和提醒;只有无素材/
|
|
19
|
+
正文无角标/角标未绑定三种真实错误才判不通过
|
|
20
|
+
- 双版 stage:提纲版(事前核验)与成稿版(事后溯源)同脚本同形式,标题与身份章带版本后缀
|
|
21
|
+
- 双形态 JSON:素材数组认顶层 {"检索文章": [...]} 或原始接口 content.data.检索文章
|
|
22
|
+
- 未引用判定双通道:JSON 标记(recalled_materials)∪ 正文角标未引用
|
|
23
|
+
- 去重键含角标:同一文章被赋不同角标时各留一卡;双向硬校验(exit 2)
|
|
24
|
+
|
|
25
|
+
诚实原则:脚本真实计算的结果才打勾;政策现行效力等无法自动判定项归入"建议人工复核"。
|
|
26
|
+
布局为单文件静态 HTML;打印归档模式单栏全展开并附材料附录。
|
|
25
27
|
"""
|
|
26
28
|
|
|
27
29
|
from __future__ import annotations
|
|
28
30
|
|
|
29
31
|
import argparse
|
|
32
|
+
import concurrent.futures
|
|
30
33
|
import html
|
|
31
34
|
import json
|
|
32
35
|
import re
|
|
33
36
|
import sys
|
|
37
|
+
import urllib.error
|
|
38
|
+
import urllib.request
|
|
34
39
|
from datetime import datetime
|
|
35
40
|
from pathlib import Path
|
|
36
41
|
from typing import Any, Dict, List, Optional, Tuple
|
|
37
42
|
|
|
38
43
|
SKILL_ROOT = Path(__file__).resolve().parent.parent
|
|
39
|
-
#
|
|
44
|
+
# 工作区根:dsh 场景通过环境变量 DKNWOC_WS_ROOT 指向会话工作区,未设置时回退到 cwd
|
|
40
45
|
import os as _os
|
|
41
46
|
_ws = _os.environ.get("DKNWOC_WS_ROOT")
|
|
42
47
|
if not _ws:
|
|
48
|
+
# dsh 会话隔离:每会话独立产物目录 <工作区>/dknowc-output/<DSH_SESSION_ID前8位>/,
|
|
49
|
+
# 多会话共用同一工作区时互不混杂;非 dsh 环境回退为工作区本身。
|
|
43
50
|
_sid = _os.environ.get("DSH_SESSION_ID", "")
|
|
44
51
|
_ws = str(Path(_os.getcwd()) / "dknowc-output" / (_sid[:8] if _sid else "_default"))
|
|
45
52
|
WS_ROOT = Path(_ws).resolve()
|
|
@@ -47,6 +54,11 @@ SEARCH_RESULTS_DIR = WS_ROOT / "official-docs" / "search-results"
|
|
|
47
54
|
OUTPUT_DIR = WS_ROOT / "official-docs" / "output"
|
|
48
55
|
|
|
49
56
|
STAGE_LABELS = {"outline": "提纲版", "final": "成稿版"}
|
|
57
|
+
REPORT_NAME = "溯源核验报告"
|
|
58
|
+
|
|
59
|
+
# 快照兜底开关:默认启用。接口 screenShotPath 曾存在路径缺 /A/ 层级的拼接 bug;
|
|
60
|
+
# verify_snapshots 在展示前完成"补 /A/ 修订 + 纯本地格式校验 + 非法弃用"。
|
|
61
|
+
SNAPSHOT_ENABLED = True
|
|
50
62
|
|
|
51
63
|
|
|
52
64
|
def _is_within(path: Path, parent: Path) -> bool:
|
|
@@ -151,8 +163,8 @@ KIND_CATALOG = {
|
|
|
151
163
|
}
|
|
152
164
|
|
|
153
165
|
|
|
154
|
-
def normalize_kind(raw: str) -> Tuple[str, str
|
|
155
|
-
"""把来源类型文本归一化为(类型键,
|
|
166
|
+
def normalize_kind(raw: str) -> Tuple[str, str]:
|
|
167
|
+
"""把来源类型文本归一化为(类型键, 中文标签);css 类名查 KIND_CATALOG。"""
|
|
156
168
|
text = str(raw or "")
|
|
157
169
|
if "政策" in text or "法规" in text or "依据" in text or "policy" in text.lower():
|
|
158
170
|
key = "policy"
|
|
@@ -164,8 +176,8 @@ def normalize_kind(raw: str) -> Tuple[str, str, str]:
|
|
|
164
176
|
key = "reference"
|
|
165
177
|
else:
|
|
166
178
|
key = "material"
|
|
167
|
-
label,
|
|
168
|
-
return key, label
|
|
179
|
+
label, _css = KIND_CATALOG[key]
|
|
180
|
+
return key, label
|
|
169
181
|
|
|
170
182
|
|
|
171
183
|
def parse_year_month(raw: str) -> Optional[Tuple[int, int]]:
|
|
@@ -183,22 +195,40 @@ def parse_year_month(raw: str) -> Optional[Tuple[int, int]]:
|
|
|
183
195
|
|
|
184
196
|
|
|
185
197
|
# ============================================================
|
|
186
|
-
# 素材提取(数据层:材料级编号优先 +
|
|
198
|
+
# 素材提取(数据层:材料级编号优先 + 位置兜底 + 双形态 JSON)
|
|
187
199
|
# ============================================================
|
|
188
200
|
|
|
201
|
+
def clean_paragraph_noise(text: str) -> str:
|
|
202
|
+
"""清洗接口段落文本中的附件链接噪音。
|
|
203
|
+
|
|
204
|
+
接口段落内容格式为「段落标题 https://attach.dknowc.cn/file/<正文>」——
|
|
205
|
+
URL 前是段落标题(已由标题链单独展示),URL 本身是附件地址(卡片有"查看全文"入口)。
|
|
206
|
+
摘录只保留 URL 之后的正文;无该前缀时兜底剔除文本中的裸 URL。
|
|
207
|
+
"""
|
|
208
|
+
value = str(text or "")
|
|
209
|
+
m = re.search(r"https?://\S*attach\.dknowc\.cn/file/", value)
|
|
210
|
+
if m:
|
|
211
|
+
return value[m.end():].strip()
|
|
212
|
+
value = re.sub(r"https?://\S+", " ", value)
|
|
213
|
+
return re.sub(r"[ \t]{2,}", " ", value).strip()
|
|
214
|
+
|
|
215
|
+
|
|
189
216
|
def paragraph_text(item: Dict[str, Any]) -> str:
|
|
190
217
|
paragraphs = item.get("content") or item.get("段落") or item.get("paragraphs") or item.get("paragraphList")
|
|
191
218
|
if isinstance(paragraphs, list):
|
|
192
219
|
chunks = []
|
|
193
220
|
for para in paragraphs:
|
|
194
221
|
if isinstance(para, dict):
|
|
195
|
-
|
|
222
|
+
chunk = first_str(para.get("text"), para.get("内容"), para.get("content"), para.get("summary"), para.get("标题"), para.get("title"))
|
|
196
223
|
else:
|
|
197
|
-
|
|
198
|
-
|
|
224
|
+
chunk = str(para)
|
|
225
|
+
chunk = clean_paragraph_noise(chunk)
|
|
226
|
+
if chunk:
|
|
227
|
+
chunks.append(chunk)
|
|
228
|
+
text = "\n".join(chunks)
|
|
199
229
|
if text:
|
|
200
230
|
return text
|
|
201
|
-
return first_str(
|
|
231
|
+
return clean_paragraph_noise(first_str(
|
|
202
232
|
item.get("摘录"),
|
|
203
233
|
item.get("摘要"),
|
|
204
234
|
item.get("相关段落"),
|
|
@@ -208,7 +238,7 @@ def paragraph_text(item: Dict[str, Any]) -> str:
|
|
|
208
238
|
item.get("content"),
|
|
209
239
|
item.get("text"),
|
|
210
240
|
item.get("snippet"),
|
|
211
|
-
)
|
|
241
|
+
))
|
|
212
242
|
|
|
213
243
|
|
|
214
244
|
def content_segments(item: Dict[str, Any]) -> List[Dict[str, str]]:
|
|
@@ -233,8 +263,8 @@ def content_segments(item: Dict[str, Any]) -> List[Dict[str, str]]:
|
|
|
233
263
|
def source_from_article(item: Dict[str, Any], index: int, segment: Optional[Dict[str, str]] = None) -> Dict[str, str]:
|
|
234
264
|
vo = item.get("vo") if isinstance(item.get("vo"), dict) else {}
|
|
235
265
|
segment = segment or {}
|
|
236
|
-
# 材料级编号(角标/编号/materialIndex 等)优先;段落 id
|
|
237
|
-
#
|
|
266
|
+
# 材料级编号(角标/编号/materialIndex 等)优先;段落 id 是文章内段落序号(各篇独立
|
|
267
|
+
# 从 1 起,多篇同为 "1" 会互相冲突导致角标错乱),彻底不用作材料编号。
|
|
238
268
|
explicit_id = first_str(
|
|
239
269
|
item.get("角标"),
|
|
240
270
|
item.get("编号"),
|
|
@@ -247,7 +277,6 @@ def source_from_article(item: Dict[str, Any], index: int, segment: Optional[Dict
|
|
|
247
277
|
item.get("seq"),
|
|
248
278
|
vo.get("index"),
|
|
249
279
|
vo.get("idx"),
|
|
250
|
-
segment.get("id"),
|
|
251
280
|
)
|
|
252
281
|
if explicit_id:
|
|
253
282
|
match = re.search(r"\d+", explicit_id)
|
|
@@ -279,17 +308,48 @@ def source_from_article(item: Dict[str, Any], index: int, segment: Optional[Dict
|
|
|
279
308
|
"url": first_str(item.get("sourceUrl"), item.get("source_url"), item.get("源网址"), item.get("原文链接"), item.get("url"), item.get("原文"), vo.get("sourceUrl"), vo.get("url")),
|
|
280
309
|
"policy_url": first_str(item.get("policyUrl"), item.get("policy_url"), item.get("知识专库原文"), vo.get("policyUrl")),
|
|
281
310
|
"excerpt": segment.get("text") or paragraph_text(item),
|
|
282
|
-
"section": first_str(
|
|
311
|
+
"section": first_str(item.get("正文对应"), item.get("section"), item.get("支撑")),
|
|
283
312
|
"kind": first_str(item.get("类型"), item.get("type"), item.get("素材类型"), vo.get("typeName"), "材料"),
|
|
284
313
|
"verify_note": first_str(item.get("核验"), item.get("verification"), item.get("核验说明")),
|
|
285
314
|
"area": first_str(item.get("intentionArea"), item.get("area"), item.get("地域")),
|
|
286
315
|
}
|
|
287
|
-
|
|
316
|
+
# 段落级数据(多段分块展示用):每段 {chain:[文章,章节,子节...], text}
|
|
317
|
+
# 段落标题自带 > 层级,拆级成面包屑;段落标题与文章标题相同或缺失时链只含文章一级。
|
|
318
|
+
segments = []
|
|
319
|
+
for seg in content_segments(item):
|
|
320
|
+
seg_title = first_str(seg.get("title"))
|
|
321
|
+
levels = [lvl.strip() for lvl in re.split(r"\s*>\s*", seg_title) if lvl.strip()] if seg_title else []
|
|
322
|
+
if levels and levels[0] == source["title"]:
|
|
323
|
+
levels = levels[1:]
|
|
324
|
+
seg_text = clean_paragraph_noise(seg.get("text"))
|
|
325
|
+
chain_lvls = [source["title"]] + levels
|
|
326
|
+
segments.append({"chain": chain_lvls, "text": strip_leading_chain(seg_text, chain_lvls)})
|
|
327
|
+
source["segments"] = segments
|
|
328
|
+
# 首段章节位置(兼容旧单行引用处)
|
|
329
|
+
first_chain = segments[0]["chain"][1:] if segments else []
|
|
330
|
+
source["doc_section"] = " › ".join(first_chain)
|
|
331
|
+
source["chain_full"] = " › ".join(segments[0]["chain"]) if segments else ""
|
|
332
|
+
# 发文字号(接口字段或合并 JSON 的 文号/doc_number;无文号按数据源名显示)
|
|
333
|
+
source["doc_number"] = first_str(item.get("文号"), item.get("发文字号"), item.get("doc_number"))
|
|
334
|
+
# 所属搜索条件(多路检索分组)与引用状态(未引用=接口召回但正文未采用)
|
|
335
|
+
source["search_key"] = first_str(item.get("搜索条件"), item.get("search_key"))
|
|
336
|
+
source["used"] = item.get("已引用", item.get("used", True))
|
|
337
|
+
if not isinstance(source["used"], bool):
|
|
338
|
+
source["used"] = True
|
|
339
|
+
# 快照兜底:原文链接 404/410(生成时真实检测)或接口未返回源网址时,
|
|
340
|
+
# 改用接口提供的存档快照链接回看——快照是原文的存档副本,按钮文案如实区分。
|
|
341
|
+
source["snapshot"] = first_str(item.get("快照链接"), item.get("snapshot"), item.get("screenShotPath"))
|
|
342
|
+
source["link_dead"] = item.get("链接失效") is True or item.get("link_dead") is True
|
|
343
|
+
# 发布日期可信度(实测:「高」=模型治理入库、标题模型精抽;「较高」=门户抓取、标题规则提取)
|
|
344
|
+
source["conf"] = first_str(item.get("发布日期可信度"), item.get("可信度"), item.get("confidence"))
|
|
345
|
+
key, label = normalize_kind(source["kind"])
|
|
288
346
|
source["type_key"] = key
|
|
289
347
|
source["type_label"] = label
|
|
290
|
-
source["type_css"] =
|
|
291
|
-
|
|
292
|
-
|
|
348
|
+
source["type_css"] = KIND_CATALOG[key][1]
|
|
349
|
+
live_url = bool(source["url"] and source["url"] != "接口未返回") and not source["link_dead"]
|
|
350
|
+
source["has_link"] = live_url or bool(source["policy_url"]) or bool(source["snapshot"])
|
|
351
|
+
# 核验状态只看摘录可比对;原文链接死活与快照有无是回看通道问题,不影响核验结论
|
|
352
|
+
# (PPT 提醒制:数据缺口不判不通过,卡片与指标行温和提醒)
|
|
293
353
|
source["verified"] = bool(source["excerpt"])
|
|
294
354
|
return source
|
|
295
355
|
|
|
@@ -336,15 +396,16 @@ def extract_reference_materials(payload: Dict[str, Any]) -> List[Dict[str, Any]]
|
|
|
336
396
|
return []
|
|
337
397
|
|
|
338
398
|
|
|
339
|
-
def
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
399
|
+
def collect_raw_articles(payload: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
400
|
+
"""链接检测/快照校验的作用对象:全部原始材料 dict(含未引用召回),就地修改生效。"""
|
|
401
|
+
raws: List[Dict[str, Any]] = []
|
|
402
|
+
raws.extend(extract_reference_materials(payload))
|
|
403
|
+
raws.extend(extract_articles_from_search(payload))
|
|
404
|
+
raws.extend(extract_articles_from_deep(payload))
|
|
405
|
+
recalled = payload.get("recalled_materials") or payload.get("召回材料")
|
|
406
|
+
if isinstance(recalled, list):
|
|
407
|
+
raws.extend(x for x in recalled if isinstance(x, dict))
|
|
408
|
+
return raws
|
|
348
409
|
|
|
349
410
|
|
|
350
411
|
def extract_sources(payload: Dict[str, Any]) -> List[Dict[str, str]]:
|
|
@@ -352,28 +413,33 @@ def extract_sources(payload: Dict[str, Any]) -> List[Dict[str, str]]:
|
|
|
352
413
|
raw_sources.extend(extract_reference_materials(payload))
|
|
353
414
|
raw_sources.extend(extract_articles_from_search(payload))
|
|
354
415
|
raw_sources.extend(extract_articles_from_deep(payload))
|
|
416
|
+
# 未引用召回材料(接口召回但正文未采用,agent 筛选后全量放入 recalled_materials):
|
|
417
|
+
# 进面板「未引用」分组,不占正文角标编号,不参与核验统计。
|
|
418
|
+
recalled = payload.get("recalled_materials") or payload.get("召回材料")
|
|
419
|
+
if isinstance(recalled, list):
|
|
420
|
+
raw_sources.extend({**{"已引用": False}, **x} for x in recalled if isinstance(x, dict))
|
|
355
421
|
|
|
356
422
|
sources: List[Dict[str, str]] = []
|
|
357
423
|
seen = set()
|
|
358
|
-
# 任一材料带材料级编号(角标等)即视为「已按素材清单编号」;
|
|
359
|
-
# 全库都没有时按合并数组位置 1..N 自动编号(一条材料一张卡),
|
|
360
|
-
# 与答案文件按合并顺序书写 [N] 角标的约定对齐。
|
|
361
|
-
has_material_ids = any(material_level_id(item) for item in raw_sources)
|
|
362
424
|
for item in raw_sources:
|
|
363
|
-
|
|
364
|
-
#
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
source = source_from_article(item, len(sources) + 1, segment=segment)
|
|
370
|
-
key = (source["id"], source["title"], source["url"], source["excerpt"][:80])
|
|
371
|
-
if key in seen:
|
|
425
|
+
# 一篇材料一张卡:段落合并为摘录(paragraph_text 拼接全部段落),不按段落拆卡——
|
|
426
|
+
# 素材清单与正文角标按「材料」粒度一一对应,拆段会使编号错位。
|
|
427
|
+
source = source_from_article(item, len(sources) + 1)
|
|
428
|
+
if not source.get("used", True):
|
|
429
|
+
# 召回材料与已引用材料同题同链时跳过(避免同一材料既在引用区又在未引用区)
|
|
430
|
+
if any(s["title"] == source["title"] and s["url"] == source["url"] for s in sources):
|
|
372
431
|
continue
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
432
|
+
key = ("__unused__", source["title"], source["url"], source["excerpt"][:80])
|
|
433
|
+
else:
|
|
434
|
+
# 完整键含角标编号:合并时同一文章被赋不同角标(历史实测出现过 8/13、10/12/28),
|
|
435
|
+
# 提纲按各自编号引用,须各留一卡,不能按内容合并。
|
|
436
|
+
key = (source["id"], source["title"], source["url"], source["excerpt"][:80])
|
|
437
|
+
if key in seen:
|
|
438
|
+
continue
|
|
439
|
+
seen.add(key)
|
|
440
|
+
if not source["id"]:
|
|
441
|
+
source["id"] = str(len(sources) + 1)
|
|
442
|
+
sources.append(source)
|
|
377
443
|
return sources
|
|
378
444
|
|
|
379
445
|
|
|
@@ -399,7 +465,7 @@ def extract_answer(payload: Dict[str, Any]) -> str:
|
|
|
399
465
|
vo = item.get("vo") if isinstance(item.get("vo"), dict) else {}
|
|
400
466
|
rows.append(f"[{idx}] {first_str(vo.get('showTitle'), vo.get('title'), item.get('title'), '未命名材料')}")
|
|
401
467
|
return "\n".join(rows)
|
|
402
|
-
return "
|
|
468
|
+
return "接口返回中未识别到正文内容;请查看材料专库或原始 JSON。"
|
|
403
469
|
|
|
404
470
|
|
|
405
471
|
def extract_question(payload: Dict[str, Any]) -> str:
|
|
@@ -490,10 +556,15 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
490
556
|
"""核验报告单数据。只计算脚本真实可得的结果,不虚构通过。"""
|
|
491
557
|
generated_at = generated_at or datetime.now()
|
|
492
558
|
|
|
493
|
-
# ① 依据溯源:摘录可比对 +
|
|
494
|
-
#
|
|
495
|
-
|
|
496
|
-
|
|
559
|
+
# ① 依据溯源:摘录可比对 + 原文链接可回看。
|
|
560
|
+
# 只统计被正文引用的材料——未引用召回材料未进入正文核验流程,其缺链在自身卡片上如实标注,
|
|
561
|
+
# 不应拖累"正文依据可交付"的报告级结论。
|
|
562
|
+
# PPT 提醒制:缺原文链接(接口对部分治理库文章不返回源网址,属数据源覆盖问题)与
|
|
563
|
+
# 缺摘录均降级为提醒,不参与核验判定——报告级只拦真实错误。
|
|
564
|
+
cited_sources = [s for s in sources if s.get("used", True)]
|
|
565
|
+
missing_links = [s["title"] for s in cited_sources if not s.get("has_link")]
|
|
566
|
+
missing_excerpts = [s["title"] for s in cited_sources if not (s.get("excerpt") or "").strip()]
|
|
567
|
+
trace_passed = len(cited_sources) - len(missing_excerpts)
|
|
497
568
|
|
|
498
569
|
# ② 引用绑定:正文角标与来源卡一一对应(按角标出现次数计,与用户在正文中数到的一致)
|
|
499
570
|
cited = citation_ids(answer)
|
|
@@ -520,7 +591,7 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
520
591
|
for s in sources:
|
|
521
592
|
coverage[s.get("type_key", "material")] = coverage.get(s.get("type_key", "material"), 0) + 1
|
|
522
593
|
|
|
523
|
-
# ⑤
|
|
594
|
+
# ⑤ 交付前检查:由检索/溯源 JSON 的 self_check 传入,未传入如实显示未记录
|
|
524
595
|
self_check_raw = None
|
|
525
596
|
for holder in (payload, payload.get("content") if isinstance(payload.get("content"), dict) else {}):
|
|
526
597
|
self_check_raw = self_check_raw or holder.get("selfCheck") or holder.get("self_check")
|
|
@@ -536,29 +607,29 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
536
607
|
# 政策效力:无法自动判定现行效力,列出建议人工复核
|
|
537
608
|
policy_count = coverage.get("policy", 0)
|
|
538
609
|
|
|
539
|
-
#
|
|
540
|
-
#
|
|
541
|
-
trace_ok = bool(
|
|
610
|
+
# 核验判定(PPT 提醒制):只有真实错误才判不通过(无素材 / 正文无角标 / 角标未绑定);
|
|
611
|
+
# 数据缺口(缺链/缺摘录)只提醒不影响判定。
|
|
612
|
+
trace_ok = bool(cited_sources)
|
|
542
613
|
binding_ok = (not unbound) and not no_citation
|
|
543
614
|
overall_passed = trace_ok and binding_ok
|
|
544
615
|
|
|
545
616
|
reasons = []
|
|
546
617
|
if not sources:
|
|
547
|
-
reasons.append("
|
|
618
|
+
reasons.append("没有找到来源材料")
|
|
548
619
|
if no_citation:
|
|
549
|
-
reasons.append("
|
|
620
|
+
reasons.append("正文里没有来源角标,对不上材料")
|
|
550
621
|
if unbound:
|
|
551
|
-
reasons.append(f"{len(unbound)}
|
|
622
|
+
reasons.append(f"有 {len(unbound)} 处角标找不到对应材料")
|
|
552
623
|
if self_check["status"] == "fail":
|
|
553
|
-
reasons.append("
|
|
624
|
+
reasons.append("交付前检查有没过的项")
|
|
554
625
|
|
|
555
626
|
return {
|
|
556
627
|
"overall": {
|
|
557
628
|
"passed": overall_passed,
|
|
558
|
-
"label": "
|
|
629
|
+
"label": "核验完成,正文依据逐条对过原文" if overall_passed else "核验未完全通过",
|
|
559
630
|
"reasons": reasons,
|
|
560
631
|
},
|
|
561
|
-
"traceability": {"total": len(
|
|
632
|
+
"traceability": {"total": len(cited_sources), "passed": trace_passed,
|
|
562
633
|
"missing_links": missing_links, "missing_excerpts": missing_excerpts},
|
|
563
634
|
"binding": {"total": len(all_marks), "bound": len(all_marks) - len(unbound), "unbound": unbound_ids, "no_citation": no_citation},
|
|
564
635
|
"freshness": freshness,
|
|
@@ -569,6 +640,100 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
569
640
|
}
|
|
570
641
|
|
|
571
642
|
|
|
643
|
+
# ============================================================
|
|
644
|
+
# 过程回顾 / 热词(真实计算,不虚构流程)
|
|
645
|
+
# ============================================================
|
|
646
|
+
|
|
647
|
+
def compute_process_stats(sources: List[Dict[str, str]], answer: str) -> Dict[str, Any]:
|
|
648
|
+
"""过程回顾条数据:检索次数、每组检索的召回/采用数、入库与引用计数。
|
|
649
|
+
|
|
650
|
+
全部来自素材自带的真实字段(search_key 分组、used 引用状态、正文角标计数),
|
|
651
|
+
不虚构任何流程步骤。
|
|
652
|
+
"""
|
|
653
|
+
order: List[str] = []
|
|
654
|
+
for s in sources:
|
|
655
|
+
key = (s.get("search_key") or "").strip()
|
|
656
|
+
if key and key not in order:
|
|
657
|
+
order.append(key)
|
|
658
|
+
cond_rows = []
|
|
659
|
+
for key in order:
|
|
660
|
+
group = [s for s in sources if (s.get("search_key") or "").strip() == key]
|
|
661
|
+
cond_rows.append({
|
|
662
|
+
"key": key,
|
|
663
|
+
"total": len(group),
|
|
664
|
+
"used": sum(1 for s in group if s.get("used", True)),
|
|
665
|
+
})
|
|
666
|
+
n_searches = len(cond_rows) or (1 if sources else 0)
|
|
667
|
+
used_count = sum(1 for s in sources if s.get("used", True))
|
|
668
|
+
unused_count = len(sources) - used_count
|
|
669
|
+
n_cite_marks = len(re.findall(r"\[(\d+)\]", answer))
|
|
670
|
+
return {
|
|
671
|
+
"conds": cond_rows,
|
|
672
|
+
"n_searches": n_searches,
|
|
673
|
+
"has_cond_detail": bool(cond_rows),
|
|
674
|
+
"n_materials": len(sources),
|
|
675
|
+
"used_count": used_count,
|
|
676
|
+
"unused_count": unused_count,
|
|
677
|
+
"n_cite_marks": n_cite_marks,
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
HOT_STOP = {
|
|
682
|
+
"关于", "通知", "工作", "意见", "方案", "实施", "有关", "问题", "情况", "报告", "总结",
|
|
683
|
+
"制度", "体系", "机制", "指导", "贯彻", "落实", "进一步", "以及", "其他", "相关", "以下",
|
|
684
|
+
"以上", "共和国", "人民", "中华", "国务院", "人民政府", "办公厅", "印发", "试行",
|
|
685
|
+
"办法", "条例", "若干", "的重点", "有所", "一个", "方面", "方式", "内容", "基本",
|
|
686
|
+
"发展", "建设", "政策", "产业", "企业", "应用", "改革", "目标", "任务", "规划",
|
|
687
|
+
"领域", "措施", "支持", "行动", "服务", "管理", "政府",
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
def extract_hot_terms(answer: str, sources: List[Dict[str, str]], top: int = 8) -> List[str]:
|
|
692
|
+
"""材料专库热词:材料标题(加权)+ 检索条件 + 正文的高频 2-4 字词,真实统计。
|
|
693
|
+
|
|
694
|
+
泛词过滤:出现在超过 60% 材料标题中的词(如库内全部材料共有的主题词)
|
|
695
|
+
无法筛出子集,没有筛选价值,剔除。
|
|
696
|
+
"""
|
|
697
|
+
corpus_parts: List[str] = []
|
|
698
|
+
for s in sources:
|
|
699
|
+
if s.get("title"):
|
|
700
|
+
corpus_parts.extend([s["title"]] * 3)
|
|
701
|
+
if s.get("search_key"):
|
|
702
|
+
corpus_parts.extend([s["search_key"]] * 2)
|
|
703
|
+
clean_answer = re.sub(r"\[\d+\]", "", answer or "")
|
|
704
|
+
corpus_parts.append(clean_answer)
|
|
705
|
+
corpus = "\n".join(corpus_parts)
|
|
706
|
+
|
|
707
|
+
counts: Dict[str, int] = {}
|
|
708
|
+
for run in re.findall(r"[一-鿿]{2,}", corpus):
|
|
709
|
+
for n in (2, 3, 4):
|
|
710
|
+
for i in range(len(run) - n + 1):
|
|
711
|
+
gram = run[i:i + n]
|
|
712
|
+
counts[gram] = counts.get(gram, 0) + 1
|
|
713
|
+
|
|
714
|
+
titles = [s.get("title") or "" for s in sources]
|
|
715
|
+
n_titles = max(1, len(titles))
|
|
716
|
+
df_limit = max(1, int(n_titles * 0.6))
|
|
717
|
+
|
|
718
|
+
cands = [(g, c) for g, c in counts.items()
|
|
719
|
+
if c >= 2 and g not in HOT_STOP and "的" not in g and not any(ch.isdigit() for ch in g)
|
|
720
|
+
and sum(1 for t in titles if g in t) <= df_limit]
|
|
721
|
+
cands.sort(key=lambda x: (-x[1], -len(x[0])))
|
|
722
|
+
kept: List[Tuple[str, int]] = []
|
|
723
|
+
for gram, count in cands:
|
|
724
|
+
redundant = False
|
|
725
|
+
for kgram, kcount in kept:
|
|
726
|
+
# 短词是已入选高频长词的子串且计数接近 → 被长词覆盖,剔除
|
|
727
|
+
if gram in kgram and kcount >= count * 0.6:
|
|
728
|
+
redundant = True
|
|
729
|
+
break
|
|
730
|
+
if not redundant:
|
|
731
|
+
kept.append((gram, count))
|
|
732
|
+
if len(kept) >= top:
|
|
733
|
+
break
|
|
734
|
+
return [g for g, _ in kept]
|
|
735
|
+
|
|
736
|
+
|
|
572
737
|
# ============================================================
|
|
573
738
|
# 正文解析与分节
|
|
574
739
|
# ============================================================
|
|
@@ -579,6 +744,7 @@ def render_inline_markdown(text: str, citation_repl) -> str:
|
|
|
579
744
|
body = re.sub(r"\*\*(.+?)\*\*", r"<strong>\1</strong>", body)
|
|
580
745
|
body = re.sub(r"__(.+?)__", r"<strong>\1</strong>", body)
|
|
581
746
|
body = re.sub(r"(?<!\*)\*([^*\n]+)\*(?!\*)", r"<em>\1</em>", body)
|
|
747
|
+
body = re.sub(r"(?<!_)_([^_\n]+_)(?!_)", r"<em>\1</em>", body)
|
|
582
748
|
body = re.sub(r"\[(\d+)\]", citation_repl, body)
|
|
583
749
|
return body
|
|
584
750
|
|
|
@@ -611,12 +777,10 @@ def render_markdown_table(lines: List[str], citation_repl) -> str:
|
|
|
611
777
|
return f'<div class="tbl-wrap"><table class="data-tbl{wide_cls}"><thead><tr>{head_html}</tr></thead><tbody>{"".join(rows)}</tbody></table></div>'
|
|
612
778
|
|
|
613
779
|
|
|
614
|
-
def
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
cleaned = re.sub(r"(?is)<script.*?</script>", "", value)
|
|
619
|
-
cleaned = re.sub(r"(?is)<style.*?</style>", "", value)
|
|
780
|
+
def sanitize_table_html(text: str) -> str:
|
|
781
|
+
"""清洗接口表格 HTML:仅保留 table/thead/tbody/tr/td/th/br,去脚本样式与属性。"""
|
|
782
|
+
cleaned = re.sub(r"(?is)<script.*?</script>", "", text)
|
|
783
|
+
cleaned = re.sub(r"(?is)<style.*?</style>", "", cleaned)
|
|
620
784
|
cleaned = re.sub(r"\s+on\w+\s*=\s*(['\"]).*?\1", "", cleaned)
|
|
621
785
|
cleaned = re.sub(r"\s+(href|src)\s*=\s*(['\"]).*?\2", "", cleaned)
|
|
622
786
|
allowed = {"table", "thead", "tbody", "tr", "td", "th", "br"}
|
|
@@ -627,17 +791,89 @@ def render_excerpt_html(text: str) -> str:
|
|
|
627
791
|
return ""
|
|
628
792
|
return f"<{closing}{name}>"
|
|
629
793
|
|
|
630
|
-
|
|
631
|
-
return f'<div class="sc-excerpt rich">{cleaned}</div>'
|
|
794
|
+
return re.sub(r"<\s*(/?)\s*([a-zA-Z0-9]+)(?:\s+[^>]*)?>", tag_repl, cleaned)
|
|
632
795
|
|
|
633
796
|
|
|
634
|
-
def
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
797
|
+
def render_excerpt_html(text: str) -> str:
|
|
798
|
+
value = str(text or "")
|
|
799
|
+
if "<table" not in value.lower():
|
|
800
|
+
return f'<div class="sc-excerpt plain">{esc(value)}</div>'
|
|
801
|
+
return f'<div class="sc-excerpt rich">{sanitize_table_html(value)}</div>'
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
def parse_answer_blocks(answer: str, valid_ids: set, chip_map: Optional[Dict[str, Any]] = None) -> Tuple[List[Dict[str, Any]], set]:
|
|
805
|
+
"""把正文 Markdown 解析为结构化块;同时收集全部角标。
|
|
806
|
+
|
|
807
|
+
角标渲染为原型式 jb 胶囊(编号圆徽章 + 材料标题),点击原地展开溯源卡;
|
|
808
|
+
表格单元格内的角标同样就地变胶囊(证据在含角标的单元格内,不挂表外)。
|
|
809
|
+
"""
|
|
810
|
+
|
|
811
|
+
def jb_html(cid: str) -> str:
|
|
812
|
+
jb = chip_map.get(cid)
|
|
813
|
+
if not jb:
|
|
814
|
+
return ""
|
|
815
|
+
if jb.get("url"):
|
|
816
|
+
btn_txt = "查看存档全文" if jb.get("dead") else "查看全文"
|
|
817
|
+
link = (f'<a class="jb-src" href="{esc(jb["url"])}" target="_blank" rel="noopener noreferrer">'
|
|
818
|
+
f'{ARROW_SVG}<span>{btn_txt}</span></a>')
|
|
819
|
+
else:
|
|
820
|
+
link = ""
|
|
821
|
+
# 原文直达区展示标题链(多段分块,各段带链——快速人工核验的核心抓手)
|
|
822
|
+
segs = jb.get("segments") or []
|
|
823
|
+
if segs:
|
|
824
|
+
quote = ""
|
|
825
|
+
seg_idx = -1
|
|
826
|
+
for seg in segs:
|
|
827
|
+
text = (seg.get("text") or "").strip()
|
|
828
|
+
if not text:
|
|
829
|
+
continue
|
|
830
|
+
seg_idx += 1
|
|
831
|
+
if "<table" in text.lower():
|
|
832
|
+
# 表格不能静态写进 span(解析器会拆散):此处留占位,
|
|
833
|
+
# 表格数据由 render_html 汇总注入页尾 JSON,展开时 JS 填充
|
|
834
|
+
tbl_key = f"{cid}-{seg_idx}"
|
|
835
|
+
jb.setdefault("_tables", {})[tbl_key] = sanitize_table_html(text)
|
|
836
|
+
body_txt = f'<span class="sc-excerpt rich tbl-holder" data-tbl="{esc(tbl_key)}"></span>'
|
|
837
|
+
else:
|
|
838
|
+
body_txt = f'<span class="sc-excerpt">{esc(text)}</span>'
|
|
839
|
+
inner = f'<i class="jb-no">{esc(cid)}</i>{body_txt}'
|
|
840
|
+
item = f'<span class="jb-quote" role="button" tabindex="0">{inner}</span>'
|
|
841
|
+
quote += render_crumb(seg.get("chain") or []) + item
|
|
842
|
+
elif jb["excerpt"]:
|
|
843
|
+
inner = f'<i class="jb-no">{esc(cid)}</i><span>{esc(jb["excerpt"])}</span>'
|
|
844
|
+
quote = f'<span class="jb-quote" role="button" tabindex="0">{inner}</span>'
|
|
845
|
+
else:
|
|
846
|
+
quote = ""
|
|
847
|
+
site_html = (f'<span class="jb-site"><span class="dot"></span>{esc(jb.get("site") or "")}</span>'
|
|
848
|
+
if (jb.get("site") or "").strip() else "")
|
|
849
|
+
return (
|
|
850
|
+
f'<span class="jb" data-cite="{esc(cid)}">'
|
|
851
|
+
f'<button class="jb-name" type="button" aria-expanded="false">{CARET_SVG}'
|
|
852
|
+
f'<i class="jb-id">{esc(cid)}</i>'
|
|
853
|
+
f'<span class="jb-txt">{esc(jb["title"])}</span></button>'
|
|
854
|
+
f'<span class="jb-body"><span class="jb-head"><span class="jb-label">{SRC_ICO_SVG}溯源原文:</span>{link}</span>'
|
|
855
|
+
f'{site_html}'
|
|
856
|
+
f'{quote}</span></span>'
|
|
857
|
+
)
|
|
858
|
+
|
|
859
|
+
def make_block_repl(block_text: str):
|
|
860
|
+
"""按块构造角标替换器:同块同材料只保留最后一次出现的角标(前处整体删除),
|
|
861
|
+
最后一处挂 jb 胶囊——一块中同一材料只出现一次,杜绝重复引用刷屏。"""
|
|
862
|
+
remaining: Dict[str, int] = {}
|
|
863
|
+
for cid in re.findall(r"\[(\d+)\]", block_text):
|
|
864
|
+
remaining[cid] = remaining.get(cid, 0) + 1
|
|
865
|
+
|
|
866
|
+
def repl(match: re.Match[str]) -> str:
|
|
867
|
+
cid = match.group(1)
|
|
868
|
+
remaining[cid] = max(0, remaining.get(cid, 1) - 1)
|
|
869
|
+
if remaining[cid] > 0:
|
|
870
|
+
return ""
|
|
871
|
+
if cid in chip_map:
|
|
872
|
+
return jb_html(cid)
|
|
873
|
+
# 未绑定角标(无对应材料):红色数字警示,绝不按位置猜测
|
|
874
|
+
return f'<sup class="cite unresolved" data-cite="{esc(cid)}" title="核验依据 [{esc(cid)}?]">{esc(cid)}?</sup>'
|
|
875
|
+
|
|
876
|
+
return repl
|
|
641
877
|
|
|
642
878
|
blocks: List[Dict[str, Any]] = []
|
|
643
879
|
lines = answer.split("\n")
|
|
@@ -647,11 +883,15 @@ def parse_answer_blocks(answer: str, valid_ids: set) -> Tuple[List[Dict[str, Any
|
|
|
647
883
|
if not block:
|
|
648
884
|
idx += 1
|
|
649
885
|
continue
|
|
886
|
+
# 引文胶囊位置规范:角标与后随标点换位——标点紧跟文字,胶囊放标点之后
|
|
887
|
+
# (避免胶囊把句号挤到下一行孤悬,对齐深知晓原型"…内容。~出处"形态)
|
|
888
|
+
block = re.sub(r"\[(\d+)\]([。;,、!?:;,.])", r"\2[\1]", block)
|
|
650
889
|
ids = citation_ids(block)
|
|
890
|
+
repl = make_block_repl(block)
|
|
651
891
|
heading_match = re.match(r"^(#{1,4})\s+(.+)$", block)
|
|
652
892
|
if heading_match:
|
|
653
893
|
blocks.append({"kind": "heading", "level": len(heading_match.group(1)),
|
|
654
|
-
"text": heading_match.group(2).strip(), "cites": ids})
|
|
894
|
+
"text": heading_match.group(2).strip(), "cites": ids, "repl": repl})
|
|
655
895
|
idx += 1
|
|
656
896
|
elif "|" in block and idx + 1 < len(lines) and is_markdown_table_separator(lines[idx + 1]):
|
|
657
897
|
table_lines = [block, lines[idx + 1].strip()]
|
|
@@ -659,6 +899,7 @@ def parse_answer_blocks(answer: str, valid_ids: set) -> Tuple[List[Dict[str, Any
|
|
|
659
899
|
while idx < len(lines) and "|" in lines[idx].strip() and lines[idx].strip():
|
|
660
900
|
table_lines.append(lines[idx].strip())
|
|
661
901
|
idx += 1
|
|
902
|
+
repl = make_block_repl("\n".join(table_lines))
|
|
662
903
|
blocks.append({"kind": "table", "html": render_markdown_table(table_lines, repl), "cites": citation_ids("\n".join(table_lines))})
|
|
663
904
|
elif block in {"---", "***"}:
|
|
664
905
|
blocks.append({"kind": "hr", "html": '<hr class="doc-divider">', "cites": []})
|
|
@@ -686,10 +927,10 @@ def split_heading_number(text: str) -> Tuple[Optional[str], str]:
|
|
|
686
927
|
|
|
687
928
|
|
|
688
929
|
def group_sections(blocks: List[Dict[str, Any]]) -> Tuple[Optional[str], List[Dict[str, Any]]]:
|
|
689
|
-
"""
|
|
930
|
+
"""按标题层级切分章节。返回(报告标题, 章节列表)。
|
|
690
931
|
|
|
691
|
-
|
|
692
|
-
|
|
932
|
+
规则:最浅层级标题若唯一且居文首,视为报告标题提出;其下一级为章节边界。
|
|
933
|
+
无标题的短正文整篇一节。
|
|
693
934
|
"""
|
|
694
935
|
if not blocks:
|
|
695
936
|
return None, [{"title": None, "blocks": []}]
|
|
@@ -727,38 +968,43 @@ def group_sections(blocks: List[Dict[str, Any]]) -> Tuple[Optional[str], List[Di
|
|
|
727
968
|
# 各部分渲染
|
|
728
969
|
# ============================================================
|
|
729
970
|
|
|
730
|
-
def
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
971
|
+
def build_chip_data(sources: List[Dict[str, str]]) -> Dict[str, Dict[str, Any]]:
|
|
972
|
+
"""行内引文胶囊数据:id → {title, site, url, excerpt, segments}。
|
|
973
|
+
|
|
974
|
+
角标后渲染原型式 jb(行内小胶囊,点击展开块级卡)。摘录展示完整
|
|
975
|
+
原文原段、不截断——块内去重后重复量可控,核对场景下就地读全文。
|
|
976
|
+
"""
|
|
977
|
+
chip_map: Dict[str, Dict[str, Any]] = {}
|
|
978
|
+
for source in sources:
|
|
979
|
+
cid = source["id"]
|
|
980
|
+
if cid in chip_map:
|
|
736
981
|
continue
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
)
|
|
753
|
-
if not chips:
|
|
754
|
-
return ""
|
|
755
|
-
return f'<div class="ev-row">{"".join(chips)}</div>'
|
|
982
|
+
meta_bits = [v for v in [source.get("agency"), source.get("date")] if v and v != "未知来源"]
|
|
983
|
+
url = source.get("url") if (source.get("url") and source["url"] != "接口未返回") else (source.get("policy_url") or "")
|
|
984
|
+
if source.get("link_dead"):
|
|
985
|
+
url = source.get("snapshot") or ""
|
|
986
|
+
site_bits = ([source["doc_number"]] if source.get("doc_number") else []) + meta_bits
|
|
987
|
+
chip_map[cid] = {
|
|
988
|
+
"title": short(source.get("title") or "未命名材料", 30),
|
|
989
|
+
"site": " · ".join(site_bits) or "来源站点",
|
|
990
|
+
"url": url,
|
|
991
|
+
"snapshot": source.get("snapshot") or "",
|
|
992
|
+
"dead": bool(source.get("link_dead")),
|
|
993
|
+
"excerpt": (source.get("excerpt") or "").strip(),
|
|
994
|
+
"segments": source.get("segments") or [],
|
|
995
|
+
}
|
|
996
|
+
return chip_map
|
|
756
997
|
|
|
757
998
|
|
|
758
|
-
def render_source_links(url: str, policy_url: str = "") -> str:
|
|
999
|
+
def render_source_links(url: str, policy_url: str = "", snapshot: str = "", link_dead: bool = False) -> str:
|
|
1000
|
+
"""链接区四态:原文可回看 / 原文失效改快照 / 原文失效无快照 / 无源网址有快照。
|
|
1001
|
+
快照是接口对原文的存档副本,文案如实标注,不冒充原文链接。"""
|
|
759
1002
|
links = []
|
|
760
|
-
if url and url != "接口未返回":
|
|
761
|
-
links.append(f'<a href="{esc(url)}" target="_blank" rel="noopener"
|
|
1003
|
+
if url and url != "接口未返回" and not link_dead:
|
|
1004
|
+
links.append(f'<a href="{esc(url)}" target="_blank" rel="noopener">查看全文 ↗</a>')
|
|
1005
|
+
if snapshot:
|
|
1006
|
+
# 有哪个显示哪个:快照统一展示"查看存档全文",不做原文失效的状态解释
|
|
1007
|
+
links.append(f'<a class="snap" href="{esc(snapshot)}" target="_blank" rel="noopener">查看存档全文 ↗</a>')
|
|
762
1008
|
if policy_url:
|
|
763
1009
|
links.append(f'<a href="{esc(policy_url)}" target="_blank" rel="noopener">知识专库原文 ↗</a>')
|
|
764
1010
|
if not links:
|
|
@@ -767,10 +1013,8 @@ def render_source_links(url: str, policy_url: str = "") -> str:
|
|
|
767
1013
|
|
|
768
1014
|
|
|
769
1015
|
def render_verify_panel(v: Dict[str, Any], stage: str = "final") -> str:
|
|
770
|
-
"""核验报告单:报告级核验结论 +
|
|
1016
|
+
"""核验报告单:报告级核验结论 + 五项指标(PPT 双版 + 提醒制口径)。"""
|
|
771
1017
|
stage_label = STAGE_LABELS.get(stage, "成稿版")
|
|
772
|
-
check_name = "提纲自检" if stage == "outline" else "成稿自检"
|
|
773
|
-
check_hint = "事实/口径/占位/素材清单/类型标注" if stage == "outline" else "事实/质检/占位/来源注/口径"
|
|
774
1018
|
manual_checks_html = "".join("<br>· " + esc(x) for x in v.get("manual_checks", []))
|
|
775
1019
|
ov = v["overall"]
|
|
776
1020
|
state = "ok" if ov["passed"] else "fail"
|
|
@@ -780,68 +1024,72 @@ def render_verify_panel(v: Dict[str, Any], stage: str = "final") -> str:
|
|
|
780
1024
|
reasons_html = '<div class="v-reasons">' + ";".join(esc(r) for r in ov["reasons"]) + "</div>"
|
|
781
1025
|
|
|
782
1026
|
tr = v["traceability"]
|
|
1027
|
+
n_missing = len(set(tr["missing_links"]) | set(tr["missing_excerpts"]))
|
|
783
1028
|
if not tr["total"]:
|
|
784
1029
|
tr_html = ('<div class="vi"><span class="s fail">✗ 依据溯源 0/0</span>'
|
|
785
1030
|
'<span class="d">未识别到来源材料</span></div>')
|
|
786
|
-
elif
|
|
787
|
-
|
|
1031
|
+
elif n_missing:
|
|
1032
|
+
# PPT 提醒制:数据缺口恒绿,附温和提醒(缺口明细在材料卡上如实标注)
|
|
788
1033
|
tr_html = (f'<div class="vi"><span class="s ok">✓ 依据溯源 {tr["total"]}/{tr["total"]}</span>'
|
|
789
|
-
f'<span class="d">素材摘录可比对;{
|
|
1034
|
+
f'<span class="d">素材摘录可比对;{n_missing} 条原文链接或摘录待补,卡片已标注,汇报前请注意核对</span></div>')
|
|
790
1035
|
else:
|
|
791
1036
|
tr_html = (f'<div class="vi"><span class="s ok">✓ 依据溯源 {tr["passed"]}/{tr["total"]}</span>'
|
|
792
|
-
f'<span class="d"
|
|
1037
|
+
f'<span class="d">每条素材摘录可比对,原文或存档快照可回看</span></div>')
|
|
793
1038
|
|
|
794
1039
|
bd = v["binding"]
|
|
795
1040
|
if bd.get("no_citation"):
|
|
796
|
-
bd_html = (f'<div class="vi"><span class="s fail">✗
|
|
797
|
-
f'<span class="d"
|
|
1041
|
+
bd_html = (f'<div class="vi"><span class="s fail">✗ 引用对应 0/0</span>'
|
|
1042
|
+
f'<span class="d">正文里没有来源角标,{v["traceability"]["total"]} 条材料对不上正文</span></div>')
|
|
798
1043
|
elif not bd["total"]:
|
|
799
|
-
bd_html = '<div class="vi"><span class="s none">—
|
|
1044
|
+
bd_html = '<div class="vi"><span class="s none">— 引用对应 0/0</span><span class="d">正文里没有来源角标</span></div>'
|
|
800
1045
|
elif not bd["unbound"]:
|
|
801
|
-
bd_html = (f'<div class="vi"><span class="s ok">✓
|
|
802
|
-
f'<span class="d"
|
|
1046
|
+
bd_html = (f'<div class="vi"><span class="s ok">✓ 引用对应 {bd["bound"]}/{bd["total"]}</span>'
|
|
1047
|
+
f'<span class="d">正文每处 [n] 都能找到对应材料</span></div>')
|
|
803
1048
|
else:
|
|
804
1049
|
unbound_text = "、".join(f"[{esc(x)}]" for x in bd["unbound"][:8])
|
|
805
|
-
bd_html = (f'<div class="vi"><span class="s fail">✗
|
|
806
|
-
f'<span class="d"
|
|
1050
|
+
bd_html = (f'<div class="vi"><span class="s fail">✗ 引用对应 {bd["bound"]}/{bd["total"]}</span>'
|
|
1051
|
+
f'<span class="d">对不上的角标 {unbound_text}</span></div>')
|
|
807
1052
|
|
|
808
1053
|
fr = v["freshness"]
|
|
809
1054
|
if fr:
|
|
810
1055
|
rng = f"{fr['min'][0]}-{fr['min'][1]:02d}~{fr['max'][0]}-{fr['max'][1]:02d}"
|
|
811
|
-
old = f"({fr['old_count']}
|
|
812
|
-
fr_html = f'<div class="vi"><span class="s ok">✓
|
|
1056
|
+
old = f"({fr['old_count']} 条年头较久,按参考口径使用)" if fr["old_count"] else ""
|
|
1057
|
+
fr_html = f'<div class="vi"><span class="s ok">✓ 材料新旧 已核</span><span class="d">材料日期 {esc(rng)}{esc(old)}</span></div>'
|
|
813
1058
|
else:
|
|
814
|
-
fr_html = '<div class="vi"><span class="s none">—
|
|
1059
|
+
fr_html = '<div class="vi"><span class="s none">— 材料新旧 未记录</span><span class="d">材料没标发布日期</span></div>'
|
|
815
1060
|
|
|
816
1061
|
cov = v["coverage"]
|
|
817
1062
|
parts = [f"{KIND_CATALOG[k][0]} {cov[k]}" for k in ("policy", "data", "case", "reference") if cov.get(k)]
|
|
818
1063
|
cov_state = "ok" if cov.get("policy") or cov.get("data") or cov.get("case") else "none"
|
|
819
|
-
cov_html = (f'<div class="vi"><span class="s {cov_state}">{"✓" if cov_state == "ok" else "—"}
|
|
820
|
-
f'<span class="d">{esc(" · ".join(parts)) if parts else "
|
|
1064
|
+
cov_html = (f'<div class="vi"><span class="s {cov_state}">{"✓" if cov_state == "ok" else "—"} 材料构成</span>'
|
|
1065
|
+
f'<span class="d">{esc(" · ".join(parts)) if parts else "材料没标类型(合并 JSON 可加「类型」字段)"}</span></div>')
|
|
821
1066
|
|
|
822
1067
|
sc = v["self_check"]
|
|
823
1068
|
if sc["status"] == "pass":
|
|
824
1069
|
notes = ";".join(note for _, note in sc["items"].values() if note)
|
|
825
1070
|
title_attr = f' title="{esc(notes)}"' if notes else ""
|
|
826
|
-
|
|
827
|
-
|
|
1071
|
+
item_names = "、".join(sc["items"].keys()) if sc["items"] else "、".join(label for _, label in SELF_CHECK_ITEMS)
|
|
1072
|
+
sc_html = (f'<div class="vi"><span class="s ok"{title_attr}>✓ 交付前检查 {sc["passed"]}/{sc["total"]}</span>'
|
|
1073
|
+
f'<span class="d">{esc(item_names)}{esc(" · 悬停查看说明" if notes else "")}</span></div>')
|
|
828
1074
|
elif sc["status"] == "fail":
|
|
829
1075
|
failed_parts = []
|
|
830
1076
|
for label, (status, note) in sc["items"].items():
|
|
831
1077
|
if status != "pass":
|
|
832
1078
|
suffix = f"({note[:40]}…)" if len(note) > 40 else (f"({note})" if note else "")
|
|
833
1079
|
failed_parts.append(label + suffix)
|
|
834
|
-
sc_html = (f'<div class="vi"><span class="s fail">✗
|
|
835
|
-
f'<span class="d"
|
|
1080
|
+
sc_html = (f'<div class="vi"><span class="s fail">✗ 交付前检查 {sc["passed"]}/{sc["total"]}</span>'
|
|
1081
|
+
f'<span class="d">没过的项:{esc("、".join(failed_parts))}</span></div>')
|
|
836
1082
|
else:
|
|
837
|
-
|
|
838
|
-
|
|
1083
|
+
default_names = "、".join(label for _, label in SELF_CHECK_ITEMS)
|
|
1084
|
+
sc_html = (f'<div class="vi"><span class="s none">— 交付前检查 未记录</span>'
|
|
1085
|
+
f'<span class="d">检索 JSON 没写入 self_check(默认查:{esc(default_names)})</span></div>')
|
|
839
1086
|
|
|
840
1087
|
manual = ""
|
|
841
1088
|
if v["policy_count"]:
|
|
842
|
-
manual = (f'<div class="vi"><span class="s man">◐
|
|
843
|
-
f'<span class="d">{v["policy_count"]}
|
|
1089
|
+
manual = (f'<div class="vi"><span class="s man">◐ 现行效力</span>'
|
|
1090
|
+
f'<span class="d">{v["policy_count"]} 份政策文件建议按官方发布确认是否现行有效</span></div>')
|
|
844
1091
|
|
|
1092
|
+
what = "提纲页面规划" if stage == "outline" else "页面级结论"
|
|
845
1093
|
return f"""
|
|
846
1094
|
<div class="verify {state}">
|
|
847
1095
|
<div class="v-head"><span class="v-shield">{'✓' if ov['passed'] else '!'}</span>{esc(ov['label'])}({esc(stage_label)}){stamp}</div>
|
|
@@ -849,117 +1097,292 @@ def render_verify_panel(v: Dict[str, Any], stage: str = "final") -> str:
|
|
|
849
1097
|
<div class="v-grid">
|
|
850
1098
|
{tr_html}{bd_html}{fr_html}{cov_html}{sc_html}{manual}
|
|
851
1099
|
</div>
|
|
852
|
-
<div class="v-note"
|
|
1100
|
+
<div class="v-note">核验方式:先用深知可信搜索找权威来源,再把{esc(what)}的每处依据和原文逐条比对(都能点开原文回看),最后做了交付前五项检查。政策是否现行有效,以官方发布为准。{manual_checks_html}</div>
|
|
853
1101
|
</div>"""
|
|
854
1102
|
|
|
855
1103
|
|
|
1104
|
+
SRC_ICO_SVG = ('<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.8" '
|
|
1105
|
+
'stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">'
|
|
1106
|
+
'<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/>'
|
|
1107
|
+
'<path d="M9 13h6M9 17h4"/></svg>')
|
|
1108
|
+
ARROW_SVG = ('<svg viewBox="0 0 24 24" width="11" height="11" fill="none" stroke="currentColor" stroke-width="2.2" '
|
|
1109
|
+
'stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 17 17 7M9 7h8v8"/></svg>')
|
|
1110
|
+
CARET_SVG = ('<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2.4" '
|
|
1111
|
+
'stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg>')
|
|
1112
|
+
|
|
1113
|
+
|
|
856
1114
|
def render_section_cards(sections: List[Dict[str, Any]], sources: List[Dict[str, str]]) -> str:
|
|
1115
|
+
"""正文渲染(原型复刻):chapter(h2)+ lead/para 段落文档流 + 句后 jb 引文胶囊。
|
|
1116
|
+
|
|
1117
|
+
同一块内同一材料只保留最后一处角标与胶囊(make_block_repl 去重);
|
|
1118
|
+
提纲页面规划表等 markdown 表格内角标同样就地变胶囊(证据在含角标的单元格内)。
|
|
1119
|
+
"""
|
|
1120
|
+
parts: List[str] = []
|
|
1121
|
+
first_para = True
|
|
857
1122
|
source_ids = {s["id"] for s in sources}
|
|
858
|
-
|
|
859
|
-
|
|
1123
|
+
for sec_idx, sec in enumerate(sections, 1):
|
|
1124
|
+
number, title_text = split_heading_number(sec["title"] or "")
|
|
1125
|
+
chapter_title = f"{number}、{title_text}" if (number and title_text) else (title_text or "")
|
|
860
1126
|
sec_cites: List[str] = []
|
|
861
1127
|
for b in sec["blocks"]:
|
|
862
1128
|
for cid in b.get("cites", []):
|
|
863
1129
|
if cid not in sec_cites:
|
|
864
1130
|
sec_cites.append(cid)
|
|
865
|
-
|
|
866
|
-
number, title_text = split_heading_number(sec["title"] or "")
|
|
867
|
-
no_html = f'<span class="sec-no">{esc(number)}</span>' if number else ""
|
|
868
|
-
title_html = f"<h3>{esc(title_text)}</h3>" if title_text else ""
|
|
869
|
-
if sec_cites:
|
|
870
|
-
badge_state = "bad" if unbound_count else ""
|
|
871
|
-
badge_text = f"本节引用 {len(sec_cites)} 处" + (f" · {unbound_count} 处未绑定" if unbound_count else " · 已核验")
|
|
872
|
-
badge_html = f'<span class="sec-badge {badge_state}">{esc(badge_text)}</span>'
|
|
873
|
-
else:
|
|
1131
|
+
if chapter_title:
|
|
874
1132
|
badge_html = ""
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
1133
|
+
if sec_cites:
|
|
1134
|
+
unbound = sum(1 for cid in sec_cites if cid not in source_ids)
|
|
1135
|
+
state = "bad" if unbound else ""
|
|
1136
|
+
text = f"本章引用 {len(sec_cites)} 处" + (f" · {unbound} 处未绑定" if unbound else " · 已核验")
|
|
1137
|
+
badge_html = f'<span class="sec-badge {state}">{esc(text)}</span>'
|
|
1138
|
+
parts.append(f'<section class="chapter" id="sec-{sec_idx}">'
|
|
1139
|
+
f'<header class="ch-head"><h2>{esc(chapter_title)}</h2>{badge_html}</header>')
|
|
878
1140
|
for b in sec["blocks"]:
|
|
879
1141
|
if b["kind"] == "heading":
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
1142
|
+
parts.append(f'<p class="para"><b class="kw">{esc(b["text"])}</b></p>')
|
|
1143
|
+
first_para = False
|
|
1144
|
+
continue
|
|
1145
|
+
cls = "lead" if first_para else "para"
|
|
1146
|
+
first_para = False
|
|
1147
|
+
if b["kind"] == "list_item":
|
|
883
1148
|
marker = f'{esc(b.get("number", "•"))}.' if b.get("numbered") else "•"
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
)
|
|
1149
|
+
parts.append(f'<p class="{cls}"><b class="kw">{marker}</b> {b["html"]}</p>')
|
|
1150
|
+
elif b["kind"] == "hr":
|
|
1151
|
+
parts.append('<hr class="doc-divider">')
|
|
888
1152
|
else:
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
1153
|
+
parts.append(f'<p class="{cls}">{b["html"]}</p>')
|
|
1154
|
+
if chapter_title:
|
|
1155
|
+
parts.append("</section>")
|
|
1156
|
+
return "\n".join(parts)
|
|
1157
|
+
|
|
1158
|
+
|
|
1159
|
+
def strip_leading_chain(text: str, chain: List[str]) -> str:
|
|
1160
|
+
"""剥掉段落文本开头与标题链各级重复的前缀。
|
|
1161
|
+
|
|
1162
|
+
接口部分材料的"内容"字段自带段落标题前缀(个别还重复两遍),标题链已承载
|
|
1163
|
+
位置信息,摘录开头再出现同级文本即冗余;逐级最长匹配剥离,无重复则原样返回。
|
|
1164
|
+
"""
|
|
1165
|
+
t = (text or "").strip()
|
|
1166
|
+
cands = set()
|
|
1167
|
+
for lvl in chain:
|
|
1168
|
+
lvl = (lvl or "").strip()
|
|
1169
|
+
if lvl:
|
|
1170
|
+
cands.add(lvl)
|
|
1171
|
+
# 粘连标题(接口未给分隔符,如"建设交通强省5.民航和低空")拆出编号尾部子串
|
|
1172
|
+
parts = re.split(r"(?<=[一-鿿])(?=\d+[.、])", lvl)
|
|
1173
|
+
if len(parts) > 1 and parts[-1].strip():
|
|
1174
|
+
cands.add(parts[-1].strip())
|
|
1175
|
+
levels = sorted(cands, key=len, reverse=True)
|
|
1176
|
+
changed = True
|
|
1177
|
+
while changed and t:
|
|
1178
|
+
changed = False
|
|
1179
|
+
for lvl in levels:
|
|
1180
|
+
if t.startswith(lvl):
|
|
1181
|
+
t = t[len(lvl):].lstrip(" \n\r\t、。;;,,").strip()
|
|
1182
|
+
changed = True
|
|
1183
|
+
break
|
|
1184
|
+
return t
|
|
1185
|
+
|
|
1186
|
+
|
|
1187
|
+
def render_crumb(chain: List[str]) -> str:
|
|
1188
|
+
"""面包屑标题链:文章 › 章 › 节(标题链是模型生成的结构化位置,核验核心抓手)。"""
|
|
1189
|
+
parts = [esc(level) for level in chain if level]
|
|
1190
|
+
if not parts:
|
|
1191
|
+
return ""
|
|
1192
|
+
return '<span class="crumb">' + ' <i>›</i> '.join(parts) + "</span>"
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
def render_segments(source: Dict[str, Any]) -> str:
|
|
1196
|
+
"""多段分块摘录:每段独立区块,各带自己的标题链——段落结构与位置直接可见。"""
|
|
1197
|
+
segments = source.get("segments") or []
|
|
1198
|
+
if not segments:
|
|
1199
|
+
return render_excerpt_html(source.get("excerpt") or "接口返回中未识别到可展示的摘录。")
|
|
1200
|
+
blocks = []
|
|
1201
|
+
for seg in segments:
|
|
1202
|
+
text = (seg.get("text") or "").strip()
|
|
1203
|
+
if not text:
|
|
1204
|
+
continue
|
|
1205
|
+
blocks.append(f'<div class="seg-block">{render_crumb(seg.get("chain") or [])}'
|
|
1206
|
+
f'{render_excerpt_html(text)}</div>')
|
|
1207
|
+
return "".join(blocks) if blocks else render_excerpt_html(source.get("excerpt") or "接口返回中未识别到可展示的摘录。")
|
|
892
1208
|
|
|
893
1209
|
|
|
894
|
-
def render_source_card(source: Dict[str, str]) -> str:
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
1210
|
+
def render_source_card(source: Dict[str, str], for_print: bool = False) -> str:
|
|
1211
|
+
if not source.get("used", True):
|
|
1212
|
+
# 未引用召回材料:不标"已核验"(未进入正文核验流程),只标可否查看
|
|
1213
|
+
vk = ('<span class="sc-vk" style="color:var(--muted)">可查看全文</span>' if source.get("has_link")
|
|
1214
|
+
else '<span class="sc-vk warn">待补链接</span>')
|
|
1215
|
+
note_html = ""
|
|
1216
|
+
elif source.get("verified"):
|
|
1217
|
+
note = source.get("verify_note") or "摘录可比对,原文链接与知识专库可回看"
|
|
1218
|
+
if not source.get("has_link"):
|
|
1219
|
+
# PPT 提醒制:无原文链接不改变核验状态,卡片附温和提醒
|
|
1220
|
+
note = "摘录可比对;本条无原文链接,请留意核对"
|
|
1221
|
+
vk = f'<span class="sc-vk ok" title="{esc(note)}">✓ 已核验</span>'
|
|
1222
|
+
if not source.get("has_link"):
|
|
1223
|
+
vk += '<span class="sc-vk warn">◐ 无原文链接</span>'
|
|
900
1224
|
note_html = f'<div class="sc-vnote">{esc(short(note, 90))}</div>' if source.get("verify_note") else ""
|
|
901
1225
|
else:
|
|
1226
|
+
reason = "待补原文链接" if not source.get("has_link") else "待补摘录"
|
|
1227
|
+
vk = f'<span class="sc-vk warn">◐ {reason}</span>'
|
|
902
1228
|
note_html = ""
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
1229
|
+
links = render_source_links(source.get("url"), source.get("policy_url", ""), source.get("snapshot", ""), source.get("link_dead", False))
|
|
1230
|
+
# 关键性行:有文号(接口字段或合并 JSON)时"文号 · 数据源 · 日期",否则"数据源 · 日期"
|
|
1231
|
+
meta_parts = [v for v in [source.get("doc_number"), source.get("agency"), source.get("date"), source.get("area")]
|
|
1232
|
+
if v and v != "未知来源"]
|
|
1233
|
+
meta = " | ".join(meta_parts)
|
|
1234
|
+
# 高可信徽标:仅"发布日期可信度=高"(模型治理入库、标题模型精抽)的材料;"较高"(门户抓取)不标。
|
|
1235
|
+
conf_badge = ""
|
|
1236
|
+
if source.get("conf") == "高":
|
|
1237
|
+
conf_badge = ('<span class="sc-conf" title="发布日期可信度:高。内容经模型治理入库,'
|
|
1238
|
+
'标题为模型从原文动态抽取,非规则提取">高可信</span>')
|
|
1239
|
+
# 已引用材料显示角标编号;未引用召回材料显示"未引用"灰标(不占正文角标号)
|
|
1240
|
+
id_html = f'<span class="sc-id">[{esc(source["id"])}]</span>' if source.get("used", True) else '<span class="sc-unused">未引用</span>'
|
|
1241
|
+
body_html = (f'<div class="sc-head">{id_html}'
|
|
1242
|
+
f'<span class="sc-type">{esc(source["type_label"])}</span>{conf_badge}{vk}</div>'
|
|
1243
|
+
f'<h4>{esc(source.get("title"))}</h4>'
|
|
1244
|
+
f'<div class="sc-meta">{esc(meta)}</div>'
|
|
1245
|
+
f'{note_html}'
|
|
1246
|
+
f'{render_segments(source)}'
|
|
1247
|
+
f'{links}')
|
|
1248
|
+
if for_print:
|
|
1249
|
+
# 打印附录版:无交互属性,避免与专库卡片 id 冲突
|
|
1250
|
+
return f'<article class="scard print-only {source["type_css"]}">{body_html}</article>'
|
|
1251
|
+
unused_attr = "" if source.get("used", True) else ' data-unused="1"'
|
|
912
1252
|
return (
|
|
913
|
-
f'<article class="scard {source["type_css"]}" id="src-{esc(source["id"])}" data-type="{esc(source["type_key"])}"
|
|
914
|
-
f'
|
|
915
|
-
f'<span class="sc-type">{esc(source["type_label"])}</span>{vk}</div>'
|
|
916
|
-
f'<h4>{esc(source.get("title"))}</h4>'
|
|
917
|
-
f'<div class="sc-meta">{esc(meta)}</div>'
|
|
918
|
-
f'{section_html}{note_html}'
|
|
919
|
-
f'{render_excerpt_html(source.get("excerpt") or "接口返回中未识别到可展示的摘录。")}'
|
|
920
|
-
f'{links}</article>'
|
|
1253
|
+
f'<article class="scard {source["type_css"]}" id="src-{esc(source["id"])}" data-type="{esc(source["type_key"])}" '
|
|
1254
|
+
f'data-cite-id="{esc(source["id"])}" data-search="{esc(source.get("search_key", ""))}"{unused_attr}>{body_html}</article>'
|
|
921
1255
|
)
|
|
922
1256
|
|
|
923
1257
|
|
|
924
|
-
def
|
|
1258
|
+
def render_process_bar(stats: Dict[str, Any], verification: Dict[str, Any]) -> str:
|
|
1259
|
+
"""过程回顾条:静态回放真实流程。无思考流数据,不做"深度思考"步骤。"""
|
|
1260
|
+
ov = verification["overall"]
|
|
1261
|
+
tr = verification["traceability"]
|
|
1262
|
+
first_query = stats["conds"][0]["key"] if stats["conds"] else ""
|
|
1263
|
+
detail_rows = "".join(
|
|
1264
|
+
f'<div class="pd-row"><b>{esc(row["key"])}</b>'
|
|
1265
|
+
f'<span>召回 {row["total"]} 条 · 正文采用 {row["used"]} 条</span></div>'
|
|
1266
|
+
for row in stats["conds"]
|
|
1267
|
+
) or '<div class="pd-row"><span>本次溯源 JSON 未记录各次检索条件</span></div>'
|
|
1268
|
+
detail_hint = f'{esc(short(first_query, 26))}…' if (stats["n_searches"] > 1 and first_query) else "查看检索明细"
|
|
1269
|
+
if stats["n_searches"] > 1:
|
|
1270
|
+
step1_sub = f"共 {stats['n_searches']} 路检索 · {detail_hint}"
|
|
1271
|
+
elif first_query:
|
|
1272
|
+
step1_sub = esc(short(first_query, 26))
|
|
1273
|
+
else:
|
|
1274
|
+
step1_sub = "深知可信搜索"
|
|
1275
|
+
step4_state = "done" if ov["passed"] else "bad"
|
|
1276
|
+
step4_icon = "✓" if ov["passed"] else "!"
|
|
1277
|
+
step4_label = "核验完成" if ov["passed"] else "核验未完全通过"
|
|
1278
|
+
step4_sub = "结论:正文依据逐条对过原文" if ov["passed"] else esc(short(";".join(ov["reasons"]) or "见核验报告单", 30))
|
|
1279
|
+
return f"""
|
|
1280
|
+
<section class="process" aria-label="生成过程回顾">
|
|
1281
|
+
<div class="p-head"><b>过程回顾</b><span>数字来自本次任务的真实记录</span></div>
|
|
1282
|
+
<ol class="p-steps">
|
|
1283
|
+
<li class="p-step expandable" id="p-step-search" role="button" tabindex="0" title="展开各路检索明细">
|
|
1284
|
+
<span class="p-no">1</span>
|
|
1285
|
+
<div class="p-txt"><b>深知检索 {stats['n_searches']} 次</b><i>{step1_sub}</i></div>
|
|
1286
|
+
</li>
|
|
1287
|
+
<li class="p-arrow" aria-hidden="true">›</li>
|
|
1288
|
+
<li class="p-step">
|
|
1289
|
+
<span class="p-no">2</span>
|
|
1290
|
+
<div class="p-txt"><b>材料入库 {stats['n_materials']} 条</b><i>正文采用 {stats['used_count']} · 召回未采用 {stats['unused_count']}</i></div>
|
|
1291
|
+
</li>
|
|
1292
|
+
<li class="p-arrow" aria-hidden="true">›</li>
|
|
1293
|
+
<li class="p-step">
|
|
1294
|
+
<span class="p-no">3</span>
|
|
1295
|
+
<div class="p-txt"><b>逐条比对原文</b><i>依据溯源 {tr['passed']}/{tr['total']} · 摘录可比对</i></div>
|
|
1296
|
+
</li>
|
|
1297
|
+
<li class="p-arrow" aria-hidden="true">›</li>
|
|
1298
|
+
<li class="p-step {step4_state}">
|
|
1299
|
+
<span class="p-no">{step4_icon}</span>
|
|
1300
|
+
<div class="p-txt"><b>{esc(step4_label)}</b><i>{step4_sub}</i></div>
|
|
1301
|
+
</li>
|
|
1302
|
+
</ol>
|
|
1303
|
+
<div class="p-detail" id="p-detail">{detail_rows}</div>
|
|
1304
|
+
</section>"""
|
|
1305
|
+
|
|
1306
|
+
|
|
1307
|
+
def render_library_view(sources: List[Dict[str, str]], hot_terms: List[str], kb_zone: str = "") -> str:
|
|
1308
|
+
"""材料专库全屏视图:大搜索 + 热词 + 检索分组 tabs + 材料卡列表(+ 原始召回存档)。"""
|
|
925
1309
|
if not sources:
|
|
926
|
-
return '<
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
'<
|
|
952
|
-
f'<
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
1310
|
+
return ('<section class="view" id="view-library" aria-label="材料专库">'
|
|
1311
|
+
'<div class="lib-empty">接口返回中未识别到可展示的材料。</div></section>')
|
|
1312
|
+
used_sources = [s for s in sources if s.get("used", True)]
|
|
1313
|
+
unused_sources = [s for s in sources if not s.get("used", True)]
|
|
1314
|
+
|
|
1315
|
+
# tabs = 检索分组(全部 / 各路检索 / 未引用),数字真实统计
|
|
1316
|
+
conds: List[Tuple[str, int]] = []
|
|
1317
|
+
for s in sources:
|
|
1318
|
+
key = (s.get("search_key") or "").strip()
|
|
1319
|
+
if not key:
|
|
1320
|
+
continue
|
|
1321
|
+
for i, (name, count) in enumerate(conds):
|
|
1322
|
+
if name == key:
|
|
1323
|
+
conds[i] = (name, count + 1)
|
|
1324
|
+
break
|
|
1325
|
+
else:
|
|
1326
|
+
conds.append((key, 1))
|
|
1327
|
+
tabs = [f'<button class="on" data-cond="" type="button">全部({len(sources)})</button>']
|
|
1328
|
+
for name, count in conds:
|
|
1329
|
+
tabs.append(f'<button data-cond="{esc(name)}" type="button">{esc(name)}({count})</button>')
|
|
1330
|
+
if unused_sources:
|
|
1331
|
+
tabs.append(f'<button data-cond="__unused__" type="button">未引用({len(unused_sources)})</button>')
|
|
1332
|
+
|
|
1333
|
+
hot_html = ""
|
|
1334
|
+
if hot_terms:
|
|
1335
|
+
hot_items = "".join(f'<button class="hot-term" type="button">{esc(term)}</button>' for term in hot_terms)
|
|
1336
|
+
hot_html = f'<div class="hot-terms" aria-label="热门搜索词"><span class="hot-label">大家都在搜</span>{hot_items}</div>'
|
|
1337
|
+
|
|
1338
|
+
cards_html = "".join(render_source_card(s) for s in used_sources)
|
|
1339
|
+
cards_html += "".join(render_source_card(s) for s in unused_sources)
|
|
1340
|
+
|
|
1341
|
+
cited_verified = sum(1 for s in used_sources if s.get("verified"))
|
|
1342
|
+
badge = "全部已核验" if used_sources and cited_verified == len(used_sources) else f"{cited_verified}/{len(used_sources)} 已核验"
|
|
1343
|
+
return f"""
|
|
1344
|
+
<section class="view" id="view-library" aria-label="材料专库">
|
|
1345
|
+
<div class="lib-head">
|
|
1346
|
+
<div class="lib-title"><b>材料专库</b>
|
|
1347
|
+
<span>共 {len(sources)} 条 · 已引用 {len(used_sources)} · {esc(badge)}</span>
|
|
1348
|
+
</div>
|
|
1349
|
+
<div class="lib-searchWrap">
|
|
1350
|
+
<span class="lib-searchIcon" aria-hidden="true">⌕</span>
|
|
1351
|
+
<input class="lib-search" type="search" placeholder="搜索标题 / 来源 / 摘录…" aria-label="搜索材料">
|
|
1352
|
+
</div>
|
|
1353
|
+
{hot_html}
|
|
1354
|
+
<div class="lib-tabs" role="tablist" aria-label="按检索分组筛选">{"".join(tabs)}</div>
|
|
1355
|
+
</div>
|
|
1356
|
+
<div class="lib-list" id="lib-list">{cards_html}</div>
|
|
1357
|
+
<div class="lib-empty hide" id="lib-empty">没有符合当前筛选的材料。</div>
|
|
1358
|
+
{kb_zone}
|
|
1359
|
+
<div class="lib-foot">材料来源:深知可信搜索 · 每条摘录均取自原文原段</div>
|
|
1360
|
+
</section>"""
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
def render_toc(sections: List[Dict[str, Any]]) -> str:
|
|
1364
|
+
"""章节目录(滚动 spy):长报告(≥6 节)显示,桌面端左侧浮动。"""
|
|
1365
|
+
if len(sections) < 6:
|
|
1366
|
+
return ""
|
|
1367
|
+
items = []
|
|
1368
|
+
for i, sec in enumerate(sections, 1):
|
|
1369
|
+
number, title_text = split_heading_number(sec["title"] or "")
|
|
1370
|
+
label = f"{number} {title_text}" if (number and title_text) else (title_text or f"第 {i} 节")
|
|
1371
|
+
items.append(f'<a href="#sec-{i}">{esc(short(label, 16))}</a>')
|
|
1372
|
+
return f'<nav class="toc" aria-label="章节目录">{"".join(items)}</nav>'
|
|
1373
|
+
|
|
1374
|
+
|
|
1375
|
+
def render_print_appendix(sources: List[Dict[str, str]]) -> str:
|
|
1376
|
+
"""打印归档附录:全部材料卡全展开(屏幕不显示,仅打印)。"""
|
|
1377
|
+
if not sources:
|
|
1378
|
+
return ""
|
|
1379
|
+
cards = "".join(render_source_card(s, for_print=True) for s in sources)
|
|
1380
|
+
return (f'<section class="print-appendix" aria-label="核验材料附录(打印归档)">'
|
|
1381
|
+
f'<h3>核验材料(全 {len(sources)} 条)</h3>{cards}</section>')
|
|
960
1382
|
|
|
961
1383
|
|
|
962
1384
|
def render_kb_zone(kb_urls: List[str], kb_labels: List[str], source_count: int) -> str:
|
|
1385
|
+
"""原始召回存档(深知知识专库):回看每次搜索的完整召回结果(PPT 特有)。"""
|
|
963
1386
|
if not kb_urls:
|
|
964
1387
|
return ""
|
|
965
1388
|
chips = []
|
|
@@ -974,7 +1397,7 @@ def render_kb_zone(kb_urls: List[str], kb_labels: List[str], source_count: int)
|
|
|
974
1397
|
return (
|
|
975
1398
|
'<div class="kb-zone"><div class="kb-title">原始召回存档(深知知识专库)</div>'
|
|
976
1399
|
'<div class="kb-desc">以下链接可回看每次搜索的完整召回结果(含未写入正文的材料);'
|
|
977
|
-
'
|
|
1400
|
+
'原文页面改版或下线时可回看当时召回的快照。逐条材料的核验请点击材料卡上的"查看全文"直达官方页面。</div>'
|
|
978
1401
|
f'<div class="kb-list">{"".join(chips)}</div></div>'
|
|
979
1402
|
)
|
|
980
1403
|
|
|
@@ -991,6 +1414,802 @@ def safe_output_filename(question: str, timestamp: datetime, fallback: str = "dk
|
|
|
991
1414
|
return f"{stem}_{suffix}{suffix_ext}"
|
|
992
1415
|
|
|
993
1416
|
|
|
1417
|
+
# ============================================================
|
|
1418
|
+
# 链接活性检测与快照兜底(生成时真实检测,就地改写材料 dict)
|
|
1419
|
+
# ============================================================
|
|
1420
|
+
|
|
1421
|
+
# 软 404 关键词:政府站常以 HTTP 200 返回"页面不存在"错误页,状态码识别不了,
|
|
1422
|
+
# 需读页面标题嗅探。关键词取自实测样例,且仅匹配 <title>(政策正文不会出现在标题里),
|
|
1423
|
+
# 误杀风险极低。
|
|
1424
|
+
SOFT_404_KEYWORDS = ("页面不存在", "页面未找到", "您访问的页面", "已删除", "已下线", "无法找到", "not found", "404")
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
def check_link_alive(url: str, timeout: int = 8) -> bool:
|
|
1428
|
+
"""检测原文链接是否仍然可达。失效判据(客观信号,与请求方无关):
|
|
1429
|
+
① HTTP 404/410;② 软 404——HTTP 200 但页面标题为典型失效页。
|
|
1430
|
+
连接失败、超时、403、5xx 等一律视为"无法确认"按有效处理——政府站
|
|
1431
|
+
常对脚本请求反爬,凭这些判死会误杀可用链接。
|
|
1432
|
+
"""
|
|
1433
|
+
for method in ("HEAD", "GET"):
|
|
1434
|
+
try:
|
|
1435
|
+
req = urllib.request.Request(
|
|
1436
|
+
url, method=method,
|
|
1437
|
+
headers={"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36"},
|
|
1438
|
+
)
|
|
1439
|
+
with urllib.request.urlopen(req, timeout=timeout) as resp:
|
|
1440
|
+
if resp.status in (404, 410):
|
|
1441
|
+
return False
|
|
1442
|
+
if method == "GET":
|
|
1443
|
+
chunk = resp.read(4096).decode("utf-8", errors="replace")
|
|
1444
|
+
title = re.search(r"<title>(.*?)</title>", chunk, re.I | re.S)
|
|
1445
|
+
text = title.group(1) if title else chunk[:200]
|
|
1446
|
+
lowered = text.lower()
|
|
1447
|
+
return not any(k in text or k in lowered for k in SOFT_404_KEYWORDS)
|
|
1448
|
+
except urllib.error.HTTPError as e:
|
|
1449
|
+
if method == "GET":
|
|
1450
|
+
return e.code not in (404, 410)
|
|
1451
|
+
except Exception:
|
|
1452
|
+
if method == "GET":
|
|
1453
|
+
return True
|
|
1454
|
+
return True
|
|
1455
|
+
|
|
1456
|
+
|
|
1457
|
+
def normalize_snapshot_url(url: str) -> str:
|
|
1458
|
+
"""快照路径容错:接口部分返回值缺 /A/ 层级(实测拼接 bug),统一规范化为
|
|
1459
|
+
https://attach.dknowc.cn/snapshot/A/<2位>/<2位>/<哈希>.jpg。"""
|
|
1460
|
+
u = (url or "").strip()
|
|
1461
|
+
if u.startswith("https://attach.dknowc.cn/snapshot/") and "/snapshot/A/" not in u:
|
|
1462
|
+
return u.replace("/snapshot/", "/snapshot/A/", 1)
|
|
1463
|
+
return u
|
|
1464
|
+
|
|
1465
|
+
|
|
1466
|
+
def mark_dead_links(articles: List[Dict[str, Any]]) -> int:
|
|
1467
|
+
"""并发检测全部材料的原文链接,404/410(含软 404)的标记 链接失效=True。返回失效数。"""
|
|
1468
|
+
targets = [(i, a) for i, a in enumerate(articles) if (first_str(a.get("源网址"), a.get("sourceUrl"), a.get("source_url"), a.get("原文链接"), a.get("url")) or "").strip()]
|
|
1469
|
+
if not targets:
|
|
1470
|
+
return 0
|
|
1471
|
+
urls = [first_str(a.get("源网址"), a.get("sourceUrl"), a.get("source_url"), a.get("原文链接"), a.get("url")) for _, a in targets]
|
|
1472
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=8) as pool:
|
|
1473
|
+
alive = dict(zip((i for i, _ in targets), pool.map(check_link_alive, urls)))
|
|
1474
|
+
dead = 0
|
|
1475
|
+
for i, _ in targets:
|
|
1476
|
+
if not alive.get(i, True):
|
|
1477
|
+
articles[i]["链接失效"] = True
|
|
1478
|
+
dead += 1
|
|
1479
|
+
return dead
|
|
1480
|
+
|
|
1481
|
+
|
|
1482
|
+
def apply_snapshots(articles: List[Dict[str, Any]]) -> Tuple[int, int]:
|
|
1483
|
+
"""快照兜底预处理:路径补全(/A/ 层级)+ 纯本地格式校验,非法路径弃用。
|
|
1484
|
+
|
|
1485
|
+
不做网络可达检测:attach 前置雷池 WAF 的拦截与请求方 IP 风控相关
|
|
1486
|
+
(检测机高频请求会被拦而普通用户正常),可达性实测会误杀好快照;
|
|
1487
|
+
快照文件本身的存在性由可信搜索侧的数据质量保障。
|
|
1488
|
+
"""
|
|
1489
|
+
fixed = dropped = 0
|
|
1490
|
+
for a in articles:
|
|
1491
|
+
raw = first_str(a.get("快照链接"), a.get("snapshot"), a.get("screenShotPath"), a.get("screenshot_path"))
|
|
1492
|
+
if not raw:
|
|
1493
|
+
continue
|
|
1494
|
+
normalized = normalize_snapshot_url(raw)
|
|
1495
|
+
if normalized != raw:
|
|
1496
|
+
fixed += 1
|
|
1497
|
+
if normalized.startswith("https://attach.dknowc.cn/snapshot/A/"):
|
|
1498
|
+
a["快照链接"] = normalized
|
|
1499
|
+
else:
|
|
1500
|
+
a["快照链接"] = ""
|
|
1501
|
+
dropped += 1
|
|
1502
|
+
return fixed, dropped
|
|
1503
|
+
# ============================================================
|
|
1504
|
+
# 样式与脚本(独立常量,避免模板转义)
|
|
1505
|
+
# ============================================================
|
|
1506
|
+
|
|
1507
|
+
PAGE_CSS = """
|
|
1508
|
+
:root{
|
|
1509
|
+
--navy:#20242c; --navy-2:#3a4152;
|
|
1510
|
+
--ink:#1f2328; --muted:#6b7280; --line:#e5e7eb; --line-strong:#cbd2dd;
|
|
1511
|
+
--brand:#6512ad; --brand-2:#8b5cf6; --brand-soft:#ede9fe;
|
|
1512
|
+
--grad:linear-gradient(135deg,#6512ad,#8b5cf6);
|
|
1513
|
+
--policy:#0f9d6e; --policy-soft:#e3f5ee;
|
|
1514
|
+
--case:#9a6700; --case-soft:#fdf3dc;
|
|
1515
|
+
--ref:#4b5563; --ref-soft:#f0f1f4;
|
|
1516
|
+
--warn:#9a6700; --danger:#e5484d; --ok:#0f9d6e;
|
|
1517
|
+
--shadow-1:0 1px 3px rgba(24,20,40,.04),0 8px 30px rgba(24,20,40,.08);
|
|
1518
|
+
--shadow-2:0 3px 9px rgba(101,18,173,.22),0 14px 36px rgba(24,20,40,.14);
|
|
1519
|
+
--primary-bright:#8b5cf6; --tint:#f3edfc; --tint-2:#faf7ff; --tint-bd:#e9dff9;
|
|
1520
|
+
--tint-strong:#e6d9f9; --tint-bd-strong:#d3bef0; --body-c:#3b4152; --card-bd:#e8e6f0;
|
|
1521
|
+
}
|
|
1522
|
+
*{box-sizing:border-box}
|
|
1523
|
+
html{scroll-behavior:smooth}
|
|
1524
|
+
body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",Roboto,"PingFang SC","HarmonyOS Sans SC","Microsoft YaHei",sans-serif;
|
|
1525
|
+
color:var(--ink);background:#f4f5f7;line-height:1.75;font-size:14.5px}
|
|
1526
|
+
a{color:var(--brand)}
|
|
1527
|
+
|
|
1528
|
+
/* ===== 顶栏 ===== */
|
|
1529
|
+
.topbar{position:sticky;top:0;z-index:50;display:flex;justify-content:space-between;align-items:center;gap:10px;
|
|
1530
|
+
padding:9px 22px;background:rgba(255,255,255,.92);backdrop-filter:blur(10px);
|
|
1531
|
+
border-bottom:1px solid var(--line)}
|
|
1532
|
+
.tb-left{display:flex;align-items:center;gap:10px;min-width:0}
|
|
1533
|
+
.tb-stamp{flex:none;font-size:12.5px;font-weight:800;color:var(--navy);letter-spacing:4px;text-indent:4px}
|
|
1534
|
+
.tb-stamp::before,.tb-stamp::after{content:"";display:inline-block;width:22px;border-top:1px solid var(--line-strong);
|
|
1535
|
+
vertical-align:middle;margin:0 6px}
|
|
1536
|
+
.tb-title{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:13px}
|
|
1537
|
+
.tb-right{display:flex;align-items:center;gap:8px;flex:none}
|
|
1538
|
+
.view-switch{display:inline-flex;border:1px solid var(--line);border-radius:999px;overflow:hidden;background:#fff}
|
|
1539
|
+
.view-switch button{border:0;background:transparent;color:var(--muted);font-size:12.5px;font-weight:700;
|
|
1540
|
+
padding:5px 14px;cursor:pointer}
|
|
1541
|
+
.view-switch button.on{background:var(--grad);color:#fff}
|
|
1542
|
+
.tb-tools{display:flex;gap:6px}
|
|
1543
|
+
.tb-tools button{border:1px solid var(--line);border-radius:8px;background:#fff;color:#3b3550;
|
|
1544
|
+
font-size:12.5px;font-weight:700;padding:5px 11px;cursor:pointer}
|
|
1545
|
+
.tb-tools button:hover{border-color:var(--brand-2);color:var(--brand)}
|
|
1546
|
+
.tb-tools button[aria-pressed="true"]{background:var(--grad);border-color:var(--brand);color:#fff}
|
|
1547
|
+
.print-menu{position:relative;display:inline-flex}
|
|
1548
|
+
.print-drop{position:absolute;top:calc(100% + 6px);right:0;z-index:70;display:flex;flex-direction:column;gap:4px;
|
|
1549
|
+
min-width:190px;padding:6px;background:#fff;border:1px solid var(--tint-bd);border-radius:10px;
|
|
1550
|
+
box-shadow:var(--shadow-2);text-align:left}
|
|
1551
|
+
.print-drop[hidden]{display:none}
|
|
1552
|
+
.print-drop button{border:0;background:none;border-radius:7px;color:var(--ink);font-size:12.5px;font-weight:600;
|
|
1553
|
+
padding:8px 12px;cursor:pointer;text-align:left;font-family:inherit;white-space:nowrap}
|
|
1554
|
+
.print-drop button:hover{background:var(--tint);color:var(--brand)}
|
|
1555
|
+
.progress{position:absolute;left:0;right:0;bottom:-1px;height:2px;background:transparent}
|
|
1556
|
+
.progress i{display:block;height:100%;width:0;background:linear-gradient(90deg,#6512ad,#8b5cf6)}
|
|
1557
|
+
|
|
1558
|
+
/* ===== Hero ===== */
|
|
1559
|
+
.hero{position:relative;background:linear-gradient(180deg,#fbfaff 0%,#f7f4fd 100%);
|
|
1560
|
+
color:var(--ink);padding:32px 22px 58px;text-align:center;border-bottom:1px solid var(--line)}
|
|
1561
|
+
.r-badge{display:inline-flex;align-items:center;gap:14px;margin:0 0 8px;
|
|
1562
|
+
background:var(--grad);color:#fff;border-radius:999px;padding:4px 22px;
|
|
1563
|
+
font-size:15px;font-weight:800;letter-spacing:7px;text-indent:7px;line-height:1.6;
|
|
1564
|
+
box-shadow:0 2px 8px rgba(101,18,173,.22)}
|
|
1565
|
+
.hero h1{margin:0 0 10px;font-size:24px;line-height:1.5;max-width:860px;margin-left:auto;margin-right:auto;color:var(--ink)}
|
|
1566
|
+
.hero .meta{color:var(--muted);font-size:13px;letter-spacing:.5px}
|
|
1567
|
+
.hero-switch{margin-top:16px;display:flex;justify-content:center}
|
|
1568
|
+
.hero-switch .view-switch{border-color:#d9c9f4;background:#fff;box-shadow:0 1px 3px rgba(24,20,40,.04)}
|
|
1569
|
+
.hero-switch .view-switch button{color:#70678a;padding:6px 22px;font-size:13px}
|
|
1570
|
+
.hero-switch .view-switch button.on{background:var(--grad);color:#fff}
|
|
1571
|
+
|
|
1572
|
+
/* ===== 容器与视图 ===== */
|
|
1573
|
+
.container{max-width:1080px;margin:0 auto;padding:0 18px}
|
|
1574
|
+
.app[data-view="library"] #view-report{display:none}
|
|
1575
|
+
#view-library{display:none}
|
|
1576
|
+
.app[data-view="library"] #view-library{display:block}
|
|
1577
|
+
|
|
1578
|
+
/* ===== 过程回顾条 ===== */
|
|
1579
|
+
.process{background:#fff;border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow-1);
|
|
1580
|
+
padding:15px 20px 13px;margin:-36px auto 16px;position:relative}
|
|
1581
|
+
.p-head{display:flex;align-items:baseline;gap:10px;margin-bottom:10px}
|
|
1582
|
+
.p-head b{font-size:14.5px;color:var(--navy);letter-spacing:1px}
|
|
1583
|
+
.p-head span{font-size:11.5px;color:var(--muted)}
|
|
1584
|
+
.p-steps{list-style:none;display:flex;align-items:stretch;gap:8px;margin:0;padding:0;flex-wrap:wrap}
|
|
1585
|
+
.p-step{display:flex;gap:9px;align-items:center;min-width:0;flex:1 1 150px;
|
|
1586
|
+
border:1px solid var(--line);border-radius:10px;padding:8px 11px;background:#fafbfc}
|
|
1587
|
+
.p-no{flex:none;width:24px;height:24px;border-radius:50%;background:var(--grad);color:#fff;
|
|
1588
|
+
display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:800}
|
|
1589
|
+
.p-txt{min-width:0}
|
|
1590
|
+
.p-txt b{display:block;font-size:12.8px;color:var(--navy);line-height:1.5}
|
|
1591
|
+
.p-txt i{display:block;font-style:normal;font-size:11px;color:var(--muted);line-height:1.5;
|
|
1592
|
+
overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1593
|
+
.p-step.done{border-color:#bfe8da;background:#f2faf7}
|
|
1594
|
+
.p-step.done .p-no{background:var(--ok)}
|
|
1595
|
+
.p-step.bad{border-color:#f6c9cb;background:#fffafa}
|
|
1596
|
+
.p-step.bad .p-no{background:var(--danger)}
|
|
1597
|
+
.p-step.expandable{cursor:pointer}
|
|
1598
|
+
.p-step.expandable:hover{border-color:var(--brand)}
|
|
1599
|
+
.p-arrow{align-self:center;color:#b9c6d9;font-size:16px;font-weight:700;flex:none}
|
|
1600
|
+
.p-detail{display:none;margin-top:10px;border-top:1px dashed var(--line-strong);padding-top:9px}
|
|
1601
|
+
.p-detail.show{display:block}
|
|
1602
|
+
.pd-row{display:flex;justify-content:space-between;gap:14px;padding:3px 2px;font-size:12.3px;flex-wrap:wrap}
|
|
1603
|
+
.pd-row b{color:var(--navy);font-weight:700;min-width:0}
|
|
1604
|
+
.pd-row span{color:var(--muted)}
|
|
1605
|
+
|
|
1606
|
+
/* ===== 核验报告视图 ===== */
|
|
1607
|
+
#view-report{padding-bottom:26px}
|
|
1608
|
+
.warn-box{margin:0 0 16px;padding:13px 16px;border:1.5px solid var(--danger);border-radius:10px;
|
|
1609
|
+
background:#fdf3f3;color:#8f2626;font-size:13.5px;line-height:1.7}
|
|
1610
|
+
.verify{margin:0 0 16px;background:#fff;border:1px solid #bfe8da;border-left:4px solid var(--ok);
|
|
1611
|
+
border-radius:14px;padding:16px 20px;box-shadow:var(--shadow-1)}
|
|
1612
|
+
.verify.fail{border-color:#f6c9cb;border-left-color:var(--danger);background:#fffafa}
|
|
1613
|
+
.v-head{display:flex;align-items:center;gap:9px;font-size:15px;font-weight:800;color:var(--ok)}
|
|
1614
|
+
.verify.fail .v-head{color:var(--danger)}
|
|
1615
|
+
.v-shield{display:inline-flex;width:22px;height:22px;border-radius:50%;background:var(--ok);color:#fff;
|
|
1616
|
+
align-items:center;justify-content:center;font-size:12px;flex:none}
|
|
1617
|
+
.verify.fail .v-shield{background:var(--danger)}
|
|
1618
|
+
.v-stamp{margin-left:auto;font-size:11px;border:1.5px solid var(--ok);color:var(--ok);border-radius:5px;
|
|
1619
|
+
padding:1px 8px;letter-spacing:2px;flex:none}
|
|
1620
|
+
.v-stamp.bad{border-color:var(--danger);color:var(--danger)}
|
|
1621
|
+
.v-reasons{margin-top:6px;font-size:12.5px;color:var(--danger)}
|
|
1622
|
+
.v-grid{display:grid;grid-template-columns:1fr 1fr;gap:4px 20px;margin-top:10px}
|
|
1623
|
+
.vi{display:flex;gap:7px;align-items:baseline;font-size:12.5px;color:#3b3550;line-height:1.7;min-width:0}
|
|
1624
|
+
.vi .s{font-weight:800;flex:none}
|
|
1625
|
+
.vi .s.ok{color:var(--ok)}
|
|
1626
|
+
.vi .s.warn{color:var(--warn)}
|
|
1627
|
+
.vi .s.fail{color:var(--danger)}
|
|
1628
|
+
.vi .s.man{color:var(--case)}
|
|
1629
|
+
.vi .s.none{color:var(--muted)}
|
|
1630
|
+
.vi .d{color:var(--muted);min-width:0}
|
|
1631
|
+
.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}
|
|
1632
|
+
|
|
1633
|
+
/* 正文(原型复刻):章节 / 段落 / 角标 / 句后引文胶囊 */
|
|
1634
|
+
.doc-paper{background:#fff;border-radius:14px;box-shadow:var(--shadow-1);padding:26px 34px 22px;margin:0 0 16px}
|
|
1635
|
+
.chapter{margin:40px 0 0}
|
|
1636
|
+
.chapter:first-child{margin-top:6px}
|
|
1637
|
+
.ch-head{display:flex;align-items:center;gap:14px;margin-bottom:18px;scroll-margin-top:86px}
|
|
1638
|
+
.ch-head h2{font-size:19.5px;font-weight:700;color:var(--ink);letter-spacing:.2px;line-height:1.4;flex:1;min-width:0}
|
|
1639
|
+
.ch-head::after{content:"";flex-basis:110px;height:1px;background:linear-gradient(90deg,#e9dff9,transparent);order:3;flex-grow:0;flex-shrink:0}
|
|
1640
|
+
.ch-head .sec-badge{order:4;flex:none;font-size:11.5px;color:var(--ok);background:var(--policy-soft);border-radius:6px;padding:2px 9px;font-weight:700}
|
|
1641
|
+
.ch-head .sec-badge.bad{color:var(--danger);background:#fdecec}
|
|
1642
|
+
@media(min-width:1000px){.ch-head::after{flex-basis:200px}}
|
|
1643
|
+
.lead{font-size:15.5px;line-height:1.95;color:var(--body-c);margin:14px 0;padding:0 2px;word-break:break-word}
|
|
1644
|
+
.para{font-size:15.5px;line-height:1.95;color:var(--body-c);margin:14px 0;padding:0 2px;word-break:break-word}
|
|
1645
|
+
.para b.kw,.lead b.kw{font-weight:600;color:var(--ink)}
|
|
1646
|
+
.doc-divider{border:0;border-top:1px solid var(--line);margin:18px 0}
|
|
1647
|
+
code{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#3f3d52;
|
|
1648
|
+
font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px}
|
|
1649
|
+
.tbl-wrap{max-width:100%;overflow-x:auto;margin:8px 0}
|
|
1650
|
+
.data-tbl{width:100%;border-collapse:collapse;border:1px solid var(--line);font-size:13px}
|
|
1651
|
+
.data-tbl th,.data-tbl td{border:1px solid var(--line);padding:8px 10px;text-align:left;vertical-align:top;line-height:1.65}
|
|
1652
|
+
.data-tbl th{background:#f5f6f8;font-weight:700;color:#3f3d52}
|
|
1653
|
+
.data-tbl.wide{min-width:560px}
|
|
1654
|
+
|
|
1655
|
+
/* 角标 */
|
|
1656
|
+
.cite{display:inline-flex;align-items:center;justify-content:center;min-width:19px;height:18px;padding:0 5px;margin:0 2px 2px 3px;font-size:10.5px;font-weight:700;font-variant-numeric:tabular-nums;color:var(--brand);background:var(--tint);border:1px solid var(--tint-bd);border-radius:5px;cursor:pointer;vertical-align:super;line-height:1;transition:.14s;position:relative;top:-1px;user-select:none;font-family:inherit}
|
|
1657
|
+
.cite:hover{background:var(--brand);border-color:var(--brand);color:#fff}
|
|
1658
|
+
.cite.flash{background:var(--primary-bright);border-color:var(--primary-bright);color:#fff}
|
|
1659
|
+
.cite.unresolved{color:var(--danger);border-color:#f6c9cb;background:#fdf7f7}
|
|
1660
|
+
|
|
1661
|
+
/* 行内引文 jb(原型复刻):角标后小胶囊,点击展开块级卡(溯源原文+引文摘录) */
|
|
1662
|
+
.jb{display:inline-block;vertical-align:top;max-width:100%;margin:2px 4px 2px 0;position:relative}
|
|
1663
|
+
.jb.active{display:block;margin:12px 0 2px;max-width:none}
|
|
1664
|
+
.jb-name{display:inline-flex;align-items:center;gap:6px;max-width:380px;min-height:26px;padding:4px 13px;border-radius:13px;border:1px solid var(--tint-bd);background:var(--tint);color:#540e8f;font-family:inherit;font-size:12px;font-weight:600;line-height:18px;cursor:pointer;transition:.16s;white-space:nowrap}
|
|
1665
|
+
.jb-name:hover{background:#fff;border-color:var(--brand)}
|
|
1666
|
+
.jb-name .jb-id{flex:none;width:18px;height:18px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-style:normal;font-size:10.5px;font-weight:800;font-variant-numeric:tabular-nums;color:#fff;background:linear-gradient(135deg,#6512ad,#8b5cf6);box-shadow:0 1px 3px rgba(101,18,173,.28)}
|
|
1667
|
+
.jb-name .jb-txt{overflow:hidden;text-overflow:ellipsis}
|
|
1668
|
+
.jb-name svg{flex:none;transition:transform .2s}
|
|
1669
|
+
.jb.active .jb-name{max-width:100%;white-space:normal;line-height:20px;color:var(--ink);background:#fff;font-size:13.5px;font-weight:700;text-align:left}
|
|
1670
|
+
.jb.active .jb-name svg{transform:rotate(180deg)}
|
|
1671
|
+
.jb-src{display:inline-flex;align-items:center;gap:5px;min-height:26px;padding:4px 13px;border-radius:13px;background:linear-gradient(135deg,#6512ad,#8b5cf6);color:#fff;font-size:11px;font-weight:600;text-decoration:none;box-shadow:0 2px 8px rgba(101,18,173,.22);transition:.15s;flex-shrink:0}
|
|
1672
|
+
.jb-src:hover{filter:brightness(1.1)}
|
|
1673
|
+
.jb-src span{max-width:210px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1674
|
+
.jb-body{display:none}
|
|
1675
|
+
.jb.active .jb-body{position:relative;display:block;margin-top:13px;background:#fff;border:1px solid var(--card-bd);border-radius:12px;padding:13px 15px;box-shadow:var(--shadow-1)}
|
|
1676
|
+
.jb-head{display:flex;align-items:center;gap:9px;flex-wrap:wrap}
|
|
1677
|
+
.jb-label{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;font-weight:700;color:var(--brand);letter-spacing:.5px}
|
|
1678
|
+
.jb-label svg{flex:none}
|
|
1679
|
+
.jb-site{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;color:#70678a;background:#f6f4fa;
|
|
1680
|
+
border:1px solid var(--line);border-radius:999px;padding:3.5px 10px;max-width:100%;overflow:hidden;
|
|
1681
|
+
text-overflow:ellipsis;white-space:nowrap;margin:0 0 2px}
|
|
1682
|
+
.jb-site .dot{width:6px;height:6px;border-radius:50%;background:linear-gradient(135deg,#6512ad,#8b5cf6);flex-shrink:0}
|
|
1683
|
+
.jb-quote{display:flex;gap:9px;align-items:flex-start;margin-top:9px;padding:10px 12px;background:#faf9fd;border:1px solid var(--line);border-radius:9px;text-decoration:none;transition:.15s;cursor:pointer}
|
|
1684
|
+
.jb-quote:hover{border-color:var(--brand);background:#f7f4fc}
|
|
1685
|
+
.jb-no{flex:none;width:17px;height:17px;margin-top:4px;border-radius:4px;background:var(--tint);border:1px solid var(--tint-bd);color:var(--brand);font-size:10px;font-weight:700;font-style:normal;display:flex;align-items:center;justify-content:center}
|
|
1686
|
+
.jb-quote span{font-size:12.5px;line-height:1.95;color:#4b4658;word-break:break-word;text-align:justify}
|
|
1687
|
+
.jb-quote .sc-excerpt{flex:1;min-width:0;display:block}
|
|
1688
|
+
a.jb-quote{text-decoration:none}
|
|
1689
|
+
.jb.flash{animation:cardFlash 1.6s ease}
|
|
1690
|
+
@keyframes cardFlash{0%,100%{box-shadow:none}30%{box-shadow:0 0 0 3px rgba(139,92,246,.45)}}
|
|
1691
|
+
.sc-links{display:flex;flex-wrap:wrap;gap:8px;margin-top:6px}
|
|
1692
|
+
.sc-links span{display:inline-flex}
|
|
1693
|
+
.sc-links a{display:inline-flex;align-items:center;min-height:24px;padding:3px 9px;border-radius:6px;
|
|
1694
|
+
background:var(--brand-soft);color:var(--brand);font-weight:700;text-decoration:none;font-size:12px}
|
|
1695
|
+
|
|
1696
|
+
/* ===== 材料专库视图 ===== */
|
|
1697
|
+
#view-library{padding:26px 0 30px}
|
|
1698
|
+
.lib-head{max-width:860px;margin:0 auto 16px;text-align:center}
|
|
1699
|
+
.lib-title{margin-bottom:14px}
|
|
1700
|
+
.lib-title b{font-size:17px;color:var(--navy);letter-spacing:2px}
|
|
1701
|
+
.lib-title span{display:block;font-size:12px;color:var(--muted);margin-top:2px}
|
|
1702
|
+
.lib-searchWrap{position:relative;max-width:620px;margin:0 auto}
|
|
1703
|
+
.lib-searchIcon{position:absolute;left:14px;top:50%;transform:translateY(-50%);color:#a6adbd;font-size:16px;font-weight:700}
|
|
1704
|
+
.lib-search{width:100%;padding:11px 16px 11px 38px;border:1.5px solid var(--line-strong);border-radius:999px;
|
|
1705
|
+
font-size:14px;background:#fff;box-shadow:var(--shadow-1);outline:none}
|
|
1706
|
+
.lib-search:focus{border-color:var(--brand-2);box-shadow:0 0 0 3px rgba(139,92,246,.18)}
|
|
1707
|
+
.hot-terms{display:flex;flex-wrap:wrap;justify-content:center;gap:7px;margin-top:12px;align-items:center}
|
|
1708
|
+
.hot-label{font-size:12px;color:var(--muted)}
|
|
1709
|
+
.hot-term{border:0;border-radius:999px;background:var(--brand-soft);color:var(--brand);
|
|
1710
|
+
font-size:12.3px;font-weight:700;padding:3px 13px;cursor:pointer}
|
|
1711
|
+
.hot-term:hover{background:var(--grad);color:#fff}
|
|
1712
|
+
.lib-tabs{display:flex;flex-wrap:wrap;justify-content:center;gap:6px;margin-top:14px}
|
|
1713
|
+
.lib-tabs button{border:1px solid var(--line);border-radius:999px;background:#fff;color:var(--muted);
|
|
1714
|
+
padding:4px 13px;font-size:12.3px;cursor:pointer}
|
|
1715
|
+
.lib-tabs button.on{background:var(--grad);border-color:var(--brand);color:#fff;font-weight:700}
|
|
1716
|
+
.lib-list{max-width:860px;margin:0 auto;display:grid;grid-template-columns:1fr;gap:14px}
|
|
1717
|
+
.lib-empty{max-width:860px;margin:30px auto;text-align:center;color:var(--muted);font-size:13.5px}
|
|
1718
|
+
.lib-empty.hide{display:none}
|
|
1719
|
+
.lib-foot{text-align:center;color:var(--muted);font-size:11.5px;padding:18px 0 0;line-height:1.8}
|
|
1720
|
+
|
|
1721
|
+
/* ===== 材料卡 ===== */
|
|
1722
|
+
.scard{border:1px solid var(--line);border-left-width:3px;border-radius:12px;padding:14px 18px;
|
|
1723
|
+
background:#fff;box-shadow:var(--shadow-1);transition:box-shadow .25s}
|
|
1724
|
+
.scard:hover{box-shadow:var(--shadow-2)}
|
|
1725
|
+
.scard.pol{border-left-color:var(--policy)}
|
|
1726
|
+
.scard.dat{border-left-color:var(--brand-2)}
|
|
1727
|
+
.scard.cas{border-left-color:var(--case)}
|
|
1728
|
+
.scard.ref,.scard.mat{border-left-color:var(--ref)}
|
|
1729
|
+
.scard.hl{box-shadow:0 0 0 3px rgba(139,92,246,.35),var(--shadow-2)}
|
|
1730
|
+
.scard.hide{display:none}
|
|
1731
|
+
.sc-head{display:flex;align-items:center;gap:7px;margin-bottom:6px}
|
|
1732
|
+
.sc-id{font-family:monospace;font-weight:800;font-size:11px;color:#fff;background:var(--grad);
|
|
1733
|
+
border-radius:5px;padding:1px 8px}
|
|
1734
|
+
.sc-type{font-size:11px;font-weight:700;border-radius:4px;padding:1px 8px;background:var(--ref-soft);color:var(--ref)}
|
|
1735
|
+
.scard.pol .sc-type{background:var(--policy-soft);color:var(--policy)}
|
|
1736
|
+
.scard.dat .sc-type{background:var(--brand-soft);color:var(--brand)}
|
|
1737
|
+
.scard.cas .sc-type{background:var(--case-soft);color:var(--case)}
|
|
1738
|
+
.sc-vk{margin-left:auto;font-size:11px;font-weight:800;color:var(--ok)}
|
|
1739
|
+
.sc-vk + .sc-vk{margin-left:0}
|
|
1740
|
+
.sc-vk.warn{color:var(--warn)}
|
|
1741
|
+
.sc-unused{font-size:10.5px;font-weight:800;color:var(--muted);background:#efedf4;border-radius:4px;
|
|
1742
|
+
padding:1px 7px;flex:none}
|
|
1743
|
+
.sc-conf{font-size:10.5px;font-weight:800;color:#8a5a00;background:var(--case-soft);border:1px solid #e6cf8f;
|
|
1744
|
+
border-radius:4px;padding:0 7px;flex:none}
|
|
1745
|
+
.scard h4{margin:0 0 5px;font-size:14.5px;color:var(--ink);line-height:1.55}
|
|
1746
|
+
.sc-meta{font-size:11.5px;color:var(--muted)}
|
|
1747
|
+
/* 标题链面包屑(模型生成的结构化位置,核验核心抓手)与多段分块 */
|
|
1748
|
+
.crumb{font-size:11.5px;color:var(--brand);margin:10px 0 4px;font-weight:600;line-height:1.6;
|
|
1749
|
+
padding:3px 9px;background:var(--tint);border-radius:7px;display:inline-block;max-width:100%;
|
|
1750
|
+
overflow-wrap:break-word}
|
|
1751
|
+
.crumb i{font-style:normal;color:#c9b3ec;margin:0 2px;font-weight:400}
|
|
1752
|
+
.seg-block{margin-top:8px}
|
|
1753
|
+
.seg-block:first-child{margin-top:2px}
|
|
1754
|
+
.seg-block .sc-excerpt{margin-top:5px}
|
|
1755
|
+
.sc-vnote{margin-top:5px;font-size:11.3px;color:var(--ok);line-height:1.6}
|
|
1756
|
+
.sc-excerpt{margin:8px 0 0;padding:10px 12px;border:1px solid #eceaf2;border-radius:9px;
|
|
1757
|
+
background:#faf9fd;color:#4a4260;font-size:12.3px;line-height:1.75}
|
|
1758
|
+
.sc-excerpt.rich{overflow-x:auto}
|
|
1759
|
+
.sc-excerpt.rich table{width:max-content;min-width:100%;border-collapse:collapse;background:#fff;font-size:12px}
|
|
1760
|
+
.sc-excerpt.rich td,.sc-excerpt.rich th{min-width:92px;max-width:220px;padding:7px 8px;border:1px solid var(--line);
|
|
1761
|
+
vertical-align:top;word-break:break-word}
|
|
1762
|
+
.sc-excerpt.rich thead td,.sc-excerpt.rich th{background:#f3f4f6;color:#3f3d52;font-weight:700}
|
|
1763
|
+
.scard .sc-links a{font-size:12px}
|
|
1764
|
+
.scard .sc-links{margin-top:4px}
|
|
1765
|
+
.no-link{font-size:11.5px;color:var(--muted)}
|
|
1766
|
+
.sc-links a.snap{background:#faf5ff;border-color:#d9c9f4;color:#5b21b6}
|
|
1767
|
+
.dead-link{font-size:11.5px;color:var(--warn)}
|
|
1768
|
+
|
|
1769
|
+
/* ===== PPT:原始召回存档(深知知识专库) ===== */
|
|
1770
|
+
.kb-zone{max-width:860px;margin:18px auto 0;text-align:left;border:1px dashed var(--line-strong);
|
|
1771
|
+
border-radius:12px;padding:14px 16px;background:#fff}
|
|
1772
|
+
.kb-title{font-size:13px;font-weight:800;color:var(--navy);margin-bottom:4px}
|
|
1773
|
+
.kb-desc{font-size:11.5px;color:var(--muted);line-height:1.7;margin-bottom:10px}
|
|
1774
|
+
.kb-list{display:flex;flex-wrap:wrap;gap:8px}
|
|
1775
|
+
.kb-chip{display:inline-flex;flex-direction:column;gap:2px;border:1px solid var(--line);border-radius:9px;
|
|
1776
|
+
padding:8px 12px;text-decoration:none;background:#faf9fd;max-width:100%}
|
|
1777
|
+
.kb-chip:hover{border-color:var(--brand)}
|
|
1778
|
+
.kb-label{font-size:12.5px;font-weight:700;color:var(--brand)}
|
|
1779
|
+
.kb-count{font-size:10.5px;color:var(--muted)}
|
|
1780
|
+
.kb-arrow{font-size:11px;color:var(--brand)}
|
|
1781
|
+
|
|
1782
|
+
/* ===== 章节目录(spy,长报告) ===== */
|
|
1783
|
+
.toc{position:fixed;left:calc((100vw - 1080px)/2 - 168px);top:120px;width:140px;max-height:60vh;overflow:auto;
|
|
1784
|
+
display:flex;flex-direction:column;gap:2px;font-size:12px}
|
|
1785
|
+
.toc a{color:var(--muted);text-decoration:none;padding:4px 10px;border-left:2px solid var(--line);
|
|
1786
|
+
line-height:1.5;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1787
|
+
.toc a.on{color:var(--brand);border-left-color:var(--brand);font-weight:700}
|
|
1788
|
+
@media (max-width:1460px){.toc{display:none}}
|
|
1789
|
+
|
|
1790
|
+
.foot{text-align:center;color:var(--muted);font-size:11.5px;padding:16px 0 4px;line-height:1.8}
|
|
1791
|
+
|
|
1792
|
+
/* ===== 只看正文(纯净阅读态) ===== */
|
|
1793
|
+
body.reading .process,body.reading .verify,body.reading .jb,body.reading .sec-badge,
|
|
1794
|
+
body.reading .cite,body.reading .toc,body.reading .p-detail{display:none!important}
|
|
1795
|
+
|
|
1796
|
+
/* ===== 打印附录 ===== */
|
|
1797
|
+
.print-appendix{display:none}
|
|
1798
|
+
|
|
1799
|
+
/* ===== 移动端 ===== */
|
|
1800
|
+
.sheet-mask{display:none}
|
|
1801
|
+
.sheet{display:none}
|
|
1802
|
+
@media (max-width:680px){
|
|
1803
|
+
body{font-size:14px;line-height:1.8}
|
|
1804
|
+
.topbar{padding:7px 10px;gap:6px}
|
|
1805
|
+
.tb-stamp{font-size:11px;letter-spacing:2px;text-indent:2px}
|
|
1806
|
+
.tb-stamp::before,.tb-stamp::after{width:12px;margin:0 4px}
|
|
1807
|
+
.tb-title{display:none}
|
|
1808
|
+
.topbar .view-switch{display:none}
|
|
1809
|
+
.tb-tools button{font-size:11.5px;padding:4px 8px}
|
|
1810
|
+
.hero{padding:24px 14px 50px}
|
|
1811
|
+
.ch-head{gap:8px;margin-bottom:14px;flex-wrap:nowrap}
|
|
1812
|
+
.ch-head h2{font-size:17px;line-height:1.45}
|
|
1813
|
+
.ch-head::after{display:none}
|
|
1814
|
+
.ch-head .sec-badge{font-size:10.5px;padding:2px 7px;white-space:nowrap}
|
|
1815
|
+
.jb-name{max-width:calc(100vw - 72px)}
|
|
1816
|
+
.r-badge{font-size:13.5px;letter-spacing:6px;text-indent:6px;gap:10px}
|
|
1817
|
+
.hero h1{font-size:18.5px}
|
|
1818
|
+
.hero .meta{font-size:11.5px;line-height:1.7}
|
|
1819
|
+
.hero-switch .view-switch button{padding:6px 16px;font-size:12.5px}
|
|
1820
|
+
.process{margin-top:-30px;padding:12px 12px 11px}
|
|
1821
|
+
.p-step{flex:1 1 100%}
|
|
1822
|
+
.p-arrow{display:none}
|
|
1823
|
+
.verify{padding:13px 14px}
|
|
1824
|
+
.v-head{font-size:14px}
|
|
1825
|
+
.v-grid{grid-template-columns:1fr;gap:2px 0}
|
|
1826
|
+
.vi{flex-wrap:wrap;gap:4px 8px}
|
|
1827
|
+
.vi .d{min-width:0}
|
|
1828
|
+
.warn-box{font-size:12.5px;padding:11px 12px}
|
|
1829
|
+
.doc-paper{padding:16px 14px 10px;border-radius:10px}
|
|
1830
|
+
.data-tbl{font-size:12px}
|
|
1831
|
+
.data-tbl th,.data-tbl td{padding:6px 7px;line-height:1.55}
|
|
1832
|
+
.cite{font-size:11px;padding:0 4px}
|
|
1833
|
+
#view-library{padding:18px 0 24px}
|
|
1834
|
+
.lib-search{padding:10px 14px 10px 34px;font-size:13.5px}
|
|
1835
|
+
.lib-tabs{justify-content:flex-start;flex-wrap:nowrap;overflow-x:auto;padding-bottom:4px;
|
|
1836
|
+
-webkit-overflow-scrolling:touch;scrollbar-width:none}
|
|
1837
|
+
.lib-tabs::-webkit-scrollbar{display:none}
|
|
1838
|
+
.lib-tabs button{flex:none}
|
|
1839
|
+
.lib-list{grid-template-columns:1fr;gap:10px}
|
|
1840
|
+
.scard{padding:10px 11px}
|
|
1841
|
+
.crumb{font-size:11px}
|
|
1842
|
+
.sc-excerpt{font-size:11.5px}
|
|
1843
|
+
.kb-zone{margin:14px 12px 0}
|
|
1844
|
+
/* 移动端材料底部弹层:点角标就地弹出材料卡,不跳转打断阅读 */
|
|
1845
|
+
.sheet-mask{display:block;position:fixed;inset:0;background:rgba(11,31,58,.45);z-index:99;opacity:0;
|
|
1846
|
+
pointer-events:none;transition:opacity .2s}
|
|
1847
|
+
.sheet-mask.show{opacity:1;pointer-events:auto}
|
|
1848
|
+
.sheet{display:block;position:fixed;left:0;right:0;bottom:0;z-index:100;background:#fff;
|
|
1849
|
+
border-radius:14px 14px 0 0;box-shadow:0 -8px 30px rgba(11,31,58,.25);
|
|
1850
|
+
max-height:68vh;overflow-y:auto;-webkit-overflow-scrolling:touch;
|
|
1851
|
+
padding:10px 16px 22px;transform:translateY(105%);transition:transform .25s ease}
|
|
1852
|
+
.sheet.show{transform:translateY(0)}
|
|
1853
|
+
.sheet-grab{width:38px;height:4px;border-radius:2px;background:#c9d4e2;margin:2px auto 8px}
|
|
1854
|
+
.sheet-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}
|
|
1855
|
+
.sheet-head b{font-size:13.5px;color:var(--navy)}
|
|
1856
|
+
.sheet-close{border:1px solid var(--line);background:#f5f3fa;border-radius:8px;color:#3b4a61;
|
|
1857
|
+
font-size:12.5px;font-weight:700;padding:5px 14px;cursor:pointer}
|
|
1858
|
+
.sheet .scard{box-shadow:none;margin-bottom:0}
|
|
1859
|
+
.sheet .sc-excerpt{display:block;-webkit-line-clamp:unset;cursor:auto}
|
|
1860
|
+
/* 正文表述 ↔ 原文原段 对照区(弹层顶部) */
|
|
1861
|
+
.cmp{margin:0 0 10px;border:1px solid var(--line);border-radius:10px;overflow:hidden}
|
|
1862
|
+
.cmp-tag{font-size:11px;font-weight:800;padding:3px 10px}
|
|
1863
|
+
.cmp-side{padding:9px 12px;font-size:12.8px;line-height:1.7}
|
|
1864
|
+
.cmp-side p{margin:0}
|
|
1865
|
+
.cmp-ai{background:#fbfaff;color:#3f3d52}
|
|
1866
|
+
.cmp-ai .cmp-tag{background:#eef1f6;color:var(--ref)}
|
|
1867
|
+
.cmp-src{background:#f4faf7;color:#2f4a3e;border-top:1px dashed var(--line-strong)}
|
|
1868
|
+
.cmp-src .cmp-tag{background:var(--policy-soft);color:#0b6e4f}
|
|
1869
|
+
.cmp-src .sc-excerpt{display:block;-webkit-line-clamp:unset;background:#fff;cursor:auto;font-size:12px;padding:8px 10px;margin:0}
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
/* ===== 打印归档 ===== */
|
|
1873
|
+
@media print{
|
|
1874
|
+
.topbar,.process .p-detail,.hero-switch,.tb-tools,.view-switch,.lib-head,.toc,.sheet,.sheet-mask,
|
|
1875
|
+
.progress{display:none!important}
|
|
1876
|
+
#view-library{display:none!important}
|
|
1877
|
+
#view-report{display:block!important}
|
|
1878
|
+
.app[data-view="library"] #view-report{display:block!important}
|
|
1879
|
+
.hero{background:none;border:0;color:var(--ink);padding:10px 0 4px}
|
|
1880
|
+
.hero .meta{color:var(--muted)}
|
|
1881
|
+
*{-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
1882
|
+
.process{box-shadow:none;margin:6px 0 12px}
|
|
1883
|
+
.verify{border-color:#bbb;box-shadow:none;break-inside:avoid}
|
|
1884
|
+
.doc-paper{box-shadow:none;border-radius:0;padding:0}
|
|
1885
|
+
body{background:#fff;font-size:12.5px}
|
|
1886
|
+
.sc-excerpt{display:block;-webkit-line-clamp:unset;cursor:auto}
|
|
1887
|
+
.scard{break-inside:avoid}
|
|
1888
|
+
.cite{background:none!important;color:#333!important;text-decoration:none!important}
|
|
1889
|
+
.cite::before{content:"["}.cite::after{content:"]"}
|
|
1890
|
+
.jb{display:inline!important}
|
|
1891
|
+
.jb .jb-name{border:0;background:none;padding:0;color:#333;font-weight:600}
|
|
1892
|
+
.jb .jb-name .jb-id{color:#333;background:none;border:1px solid #999;border-radius:3px}
|
|
1893
|
+
.jb .jb-body{display:none!important}
|
|
1894
|
+
.jb.active{break-inside:avoid}
|
|
1895
|
+
.jb.active .jb-body{display:block!important}
|
|
1896
|
+
.jb.active .jb-body .jb-quote{break-inside:avoid}
|
|
1897
|
+
body.reading .verify,body.reading .process,body.reading .ev-row,body.reading .sec-badge,
|
|
1898
|
+
body.reading .cite{display:none!important}
|
|
1899
|
+
.print-appendix{display:block;break-before:page}
|
|
1900
|
+
body.print-body-only .verify,body.print-body-only .process,body.print-body-only .print-appendix,
|
|
1901
|
+
body.print-body-only .jb,body.print-body-only .foot{display:none!important}
|
|
1902
|
+
.print-appendix h3{font-size:15px;color:var(--navy);border-bottom:1px solid #999;padding-bottom:6px;margin:0 0 12px}
|
|
1903
|
+
.print-appendix .scard{margin-bottom:10px}
|
|
1904
|
+
}
|
|
1905
|
+
"""
|
|
1906
|
+
|
|
1907
|
+
PAGE_JS = """
|
|
1908
|
+
(function () {
|
|
1909
|
+
"use strict";
|
|
1910
|
+
function $(sel, root) { return (root || document).querySelector(sel); }
|
|
1911
|
+
function $$(sel, root) { return Array.prototype.slice.call((root || document).querySelectorAll(sel)); }
|
|
1912
|
+
|
|
1913
|
+
var app = $(".app");
|
|
1914
|
+
var isMobile = function () { return window.matchMedia("(max-width:680px)").matches; };
|
|
1915
|
+
|
|
1916
|
+
/* ===== 1. 双视图切换(保存/恢复各自滚动位置) ===== */
|
|
1917
|
+
var savedScroll = { report: 0, library: 0 };
|
|
1918
|
+
function setView(view) {
|
|
1919
|
+
if (!app || app.getAttribute("data-view") === view) return;
|
|
1920
|
+
savedScroll[app.getAttribute("data-view") || "report"] = window.scrollY;
|
|
1921
|
+
app.setAttribute("data-view", view);
|
|
1922
|
+
$$(".view-switch button").forEach(function (b) {
|
|
1923
|
+
b.classList.toggle("on", b.getAttribute("data-view") === view);
|
|
1924
|
+
});
|
|
1925
|
+
window.scrollTo(0, Math.max(0, savedScroll[view] || 0));
|
|
1926
|
+
}
|
|
1927
|
+
$$(".view-switch button").forEach(function (b) {
|
|
1928
|
+
b.addEventListener("click", function () { setView(b.getAttribute("data-view")); });
|
|
1929
|
+
});
|
|
1930
|
+
|
|
1931
|
+
/* ===== 2. 阅读进度条 ===== */
|
|
1932
|
+
var progress = $(".progress i");
|
|
1933
|
+
function updateProgress() {
|
|
1934
|
+
if (!progress) return;
|
|
1935
|
+
var h = document.documentElement;
|
|
1936
|
+
var max = h.scrollHeight - h.clientHeight;
|
|
1937
|
+
progress.style.width = (max > 0 ? Math.min(100, (h.scrollTop / max) * 100) : 0) + "%";
|
|
1938
|
+
}
|
|
1939
|
+
window.addEventListener("scroll", updateProgress, { passive: true });
|
|
1940
|
+
updateProgress();
|
|
1941
|
+
|
|
1942
|
+
/* ===== 3. 只看正文(纯净阅读态切换) ===== */
|
|
1943
|
+
var readBtn = $("#btn-reading");
|
|
1944
|
+
if (readBtn) {
|
|
1945
|
+
readBtn.addEventListener("click", function () {
|
|
1946
|
+
var on = document.body.classList.toggle("reading");
|
|
1947
|
+
readBtn.setAttribute("aria-pressed", on ? "true" : "false");
|
|
1948
|
+
readBtn.textContent = on ? "显示核验" : "只看正文";
|
|
1949
|
+
/* 只看正文只作用于核验报告视图:正在材料专库时切回报告,专库不受影响 */
|
|
1950
|
+
if (on && app && app.getAttribute("data-view") !== "report") setView("report");
|
|
1951
|
+
});
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
/* ===== 4. 复制全文(章节标题 + 段落 + 表格,去角标) ===== */
|
|
1955
|
+
var copyBtn = $("#btn-copy");
|
|
1956
|
+
if (copyBtn) {
|
|
1957
|
+
copyBtn.addEventListener("click", function () {
|
|
1958
|
+
var parts = [];
|
|
1959
|
+
/* 按文档流顺序收集章节标题/段落/表格;克隆后剔除引文胶囊与角标,
|
|
1960
|
+
只复制正文本身(胶囊标题/展开摘录/编号数字均不带出) */
|
|
1961
|
+
var nodes = $$("#view-report .ch-head h2, #view-report .lead, #view-report .para, #view-report .tbl-wrap");
|
|
1962
|
+
nodes.sort(function (a, b) { return (a.compareDocumentPosition(b) & 4) ? -1 : 1; });
|
|
1963
|
+
nodes.forEach(function (el) {
|
|
1964
|
+
var clone = el.cloneNode(true);
|
|
1965
|
+
clone.querySelectorAll(".jb, sup.cite").forEach(function (x) { x.remove(); });
|
|
1966
|
+
var t = clone.textContent.replace(/[ \\t]+/g, " ").trim();
|
|
1967
|
+
if (t) parts.push(t);
|
|
1968
|
+
});
|
|
1969
|
+
var text = parts.filter(Boolean).join("\\n\\n");
|
|
1970
|
+
function done(ok) {
|
|
1971
|
+
var old = copyBtn.textContent;
|
|
1972
|
+
copyBtn.textContent = ok ? "已复制 ✓" : "复制失败";
|
|
1973
|
+
setTimeout(function () { copyBtn.textContent = old; }, 1600);
|
|
1974
|
+
}
|
|
1975
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
1976
|
+
navigator.clipboard.writeText(text).then(function () { done(true); }, function () { done(fallback(text)); });
|
|
1977
|
+
} else {
|
|
1978
|
+
done(fallback(text));
|
|
1979
|
+
}
|
|
1980
|
+
function fallback(value) {
|
|
1981
|
+
try {
|
|
1982
|
+
var ta = document.createElement("textarea");
|
|
1983
|
+
ta.value = value;
|
|
1984
|
+
ta.style.position = "fixed";
|
|
1985
|
+
ta.style.opacity = "0";
|
|
1986
|
+
document.body.appendChild(ta);
|
|
1987
|
+
ta.select();
|
|
1988
|
+
var ok = document.execCommand("copy");
|
|
1989
|
+
document.body.removeChild(ta);
|
|
1990
|
+
return ok;
|
|
1991
|
+
} catch (e) { return false; }
|
|
1992
|
+
}
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
/* ===== 5. 打印归档(PDF):下拉双选项——只打印正文 / 完整归档 ===== */
|
|
1997
|
+
var printBtn = $("#btn-print");
|
|
1998
|
+
var printDrop = $("#print-drop");
|
|
1999
|
+
function printBy(mode) {
|
|
2000
|
+
if (mode === "body") document.body.classList.add("print-body-only");
|
|
2001
|
+
if (printDrop) printDrop.hidden = true;
|
|
2002
|
+
window.print();
|
|
2003
|
+
}
|
|
2004
|
+
if (printBtn && printDrop) {
|
|
2005
|
+
printBtn.addEventListener("click", function (e) {
|
|
2006
|
+
e.stopPropagation();
|
|
2007
|
+
printDrop.hidden = !printDrop.hidden;
|
|
2008
|
+
});
|
|
2009
|
+
printDrop.addEventListener("click", function (e) {
|
|
2010
|
+
e.stopPropagation();
|
|
2011
|
+
var t = e.target.closest("button");
|
|
2012
|
+
if (!t) return;
|
|
2013
|
+
printBy(t.id === "print-body" ? "body" : "full");
|
|
2014
|
+
});
|
|
2015
|
+
document.addEventListener("click", function () { printDrop.hidden = true; });
|
|
2016
|
+
/* 打印结束移除临时模式(浏览器打印窗口关闭后触发) */
|
|
2017
|
+
window.addEventListener("afterprint", function () { document.body.classList.remove("print-body-only"); });
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
/* ===== 6. 材料卡索引(专库列表内,不含打印附录) ===== */
|
|
2021
|
+
var cards = $$("#lib-list .scard");
|
|
2022
|
+
var byId = {};
|
|
2023
|
+
cards.forEach(function (c) {
|
|
2024
|
+
var id = c.getAttribute("data-cite-id");
|
|
2025
|
+
if (id) byId[id] = c;
|
|
2026
|
+
});
|
|
2027
|
+
|
|
2028
|
+
/* 移动端底部弹层:正文表述 ↔ 原文原段 对照 + 材料卡 */
|
|
2029
|
+
var sheet = $(".sheet");
|
|
2030
|
+
var mask = $(".sheet-mask");
|
|
2031
|
+
function escHtml(s) {
|
|
2032
|
+
var d = document.createElement("div");
|
|
2033
|
+
d.textContent = s;
|
|
2034
|
+
return d.innerHTML;
|
|
2035
|
+
}
|
|
2036
|
+
function sentenceOf(el) {
|
|
2037
|
+
var para = el && el.closest ? el.closest(".para,.lead") : null;
|
|
2038
|
+
return para ? para.innerText.trim() : "";
|
|
2039
|
+
}
|
|
2040
|
+
function openSheet(card, sentence) {
|
|
2041
|
+
if (!sheet) return;
|
|
2042
|
+
var body = sheet.querySelector(".sheet-body");
|
|
2043
|
+
body.innerHTML = "";
|
|
2044
|
+
if (sentence) {
|
|
2045
|
+
var excerpt = card.querySelector(".sc-excerpt");
|
|
2046
|
+
var cmp = document.createElement("div");
|
|
2047
|
+
cmp.className = "cmp";
|
|
2048
|
+
cmp.innerHTML =
|
|
2049
|
+
'<div class="cmp-side cmp-ai"><div class="cmp-tag">正文表述</div><p>' + escHtml(sentence) + '</p></div>' +
|
|
2050
|
+
'<div class="cmp-side cmp-src"><div class="cmp-tag">原文原段</div>' +
|
|
2051
|
+
'<div class="sc-excerpt">' + (excerpt ? excerpt.innerHTML : "") + '</div></div>';
|
|
2052
|
+
body.appendChild(cmp);
|
|
2053
|
+
}
|
|
2054
|
+
var clone = card.cloneNode(true);
|
|
2055
|
+
clone.removeAttribute("id");
|
|
2056
|
+
clone.classList.remove("hide");
|
|
2057
|
+
clone.classList.add("open");
|
|
2058
|
+
body.appendChild(clone);
|
|
2059
|
+
sheet.classList.add("show");
|
|
2060
|
+
mask.classList.add("show");
|
|
2061
|
+
document.body.style.overflow = "hidden";
|
|
2062
|
+
sheet.scrollTop = 0;
|
|
2063
|
+
}
|
|
2064
|
+
function closeSheet() {
|
|
2065
|
+
if (!sheet) return;
|
|
2066
|
+
sheet.classList.remove("show");
|
|
2067
|
+
mask.classList.remove("show");
|
|
2068
|
+
document.body.style.overflow = "";
|
|
2069
|
+
}
|
|
2070
|
+
if (sheet && mask) {
|
|
2071
|
+
mask.addEventListener("click", closeSheet);
|
|
2072
|
+
var closeBtn = sheet.querySelector(".sheet-close");
|
|
2073
|
+
if (closeBtn) closeBtn.addEventListener("click", closeSheet);
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
/* 行内引文 jb(原型行为):点小胶囊 toggle 展开卡;展开卡内引文条目点击进专库。
|
|
2077
|
+
未绑定角标红色警示,绝不按位置猜测。 */
|
|
2078
|
+
var JB_TABLES = {};
|
|
2079
|
+
try {
|
|
2080
|
+
var jbTablesEl = document.getElementById("jb-tables");
|
|
2081
|
+
if (jbTablesEl) JB_TABLES = JSON.parse(jbTablesEl.textContent || "{}");
|
|
2082
|
+
} catch (e) { JB_TABLES = {}; }
|
|
2083
|
+
function fillTableHolders(jb) {
|
|
2084
|
+
jb.querySelectorAll(".tbl-holder[data-tbl]").forEach(function (h) {
|
|
2085
|
+
if (h.getAttribute("data-filled")) return;
|
|
2086
|
+
var html = JB_TABLES[h.getAttribute("data-tbl")];
|
|
2087
|
+
if (html) h.innerHTML = html;
|
|
2088
|
+
h.setAttribute("data-filled", "1");
|
|
2089
|
+
});
|
|
2090
|
+
}
|
|
2091
|
+
function toggleJb(jb, forceOpen) {
|
|
2092
|
+
var open = forceOpen === true ? true : !jb.classList.contains("active");
|
|
2093
|
+
document.querySelectorAll(".jb.active").forEach(function (x) { if (x !== jb) x.classList.remove("active"); });
|
|
2094
|
+
jb.classList.toggle("active", open);
|
|
2095
|
+
if (open) fillTableHolders(jb);
|
|
2096
|
+
var name = jb.querySelector(".jb-name");
|
|
2097
|
+
if (name) name.setAttribute("aria-expanded", open ? "true" : "false");
|
|
2098
|
+
return open;
|
|
2099
|
+
}
|
|
2100
|
+
document.querySelectorAll(".jb-name").forEach(function (name) {
|
|
2101
|
+
name.addEventListener("click", function () { toggleJb(name.closest(".jb")); });
|
|
2102
|
+
});
|
|
2103
|
+
|
|
2104
|
+
/* 引文条目点击 → 材料专库定位对应卡:库内导航看完整材料;
|
|
2105
|
+
外部原文跳转只保留 jb-head 的"查看全文"按钮,动线分离 */
|
|
2106
|
+
function jumpToLibrary(id) {
|
|
2107
|
+
var card = byId[id];
|
|
2108
|
+
if (!card) return;
|
|
2109
|
+
setView("library");
|
|
2110
|
+
card.classList.remove("hide", "open");
|
|
2111
|
+
card.classList.add("hl", "open");
|
|
2112
|
+
requestAnimationFrame(function () {
|
|
2113
|
+
requestAnimationFrame(function () { card.scrollIntoView({ block: "center", behavior: "smooth" }); });
|
|
2114
|
+
});
|
|
2115
|
+
setTimeout(function () { card.classList.remove("hl"); }, 2200);
|
|
2116
|
+
}
|
|
2117
|
+
document.querySelectorAll(".jb-quote").forEach(function (q) {
|
|
2118
|
+
function go() {
|
|
2119
|
+
var jbEl = q.closest(".jb");
|
|
2120
|
+
var id = jbEl && jbEl.getAttribute("data-cite");
|
|
2121
|
+
if (isMobile()) {
|
|
2122
|
+
/* 移动端不跳视图(跳转会打断阅读),就地展开/收起当前 jb */
|
|
2123
|
+
var card = id && byId[id];
|
|
2124
|
+
if (card) { openSheet(card, sentenceOf(q)); return; }
|
|
2125
|
+
}
|
|
2126
|
+
if (id) jumpToLibrary(id);
|
|
2127
|
+
}
|
|
2128
|
+
q.addEventListener("click", go);
|
|
2129
|
+
q.addEventListener("keydown", function (e) {
|
|
2130
|
+
if (e.key === "Enter" || e.key === " ") { e.preventDefault(); go(); }
|
|
2131
|
+
});
|
|
2132
|
+
});
|
|
2133
|
+
document.querySelectorAll("sup.cite").forEach(function (btn) {
|
|
2134
|
+
/* 仅剩未绑定角标(红色数字)走到这里:点击控制台留痕 */
|
|
2135
|
+
btn.addEventListener("click", function () {
|
|
2136
|
+
if (console.error) console.error("[核验] 未绑定角标:", btn.getAttribute("data-cite"));
|
|
2137
|
+
});
|
|
2138
|
+
});
|
|
2139
|
+
|
|
2140
|
+
/* ===== 7. 材料专库:tabs + 搜索 + 热词 ===== */
|
|
2141
|
+
var cond = "";
|
|
2142
|
+
var kw = "";
|
|
2143
|
+
function applyFilter() {
|
|
2144
|
+
var visible = 0;
|
|
2145
|
+
cards.forEach(function (c) {
|
|
2146
|
+
var okCond = !cond;
|
|
2147
|
+
if (cond === "__unused__") okCond = c.getAttribute("data-unused") === "1";
|
|
2148
|
+
else if (cond) okCond = c.getAttribute("data-search") === cond;
|
|
2149
|
+
var okKw = !kw || (c.textContent || "").toLowerCase().indexOf(kw) !== -1;
|
|
2150
|
+
var show = okCond && okKw;
|
|
2151
|
+
c.classList.toggle("hide", !show);
|
|
2152
|
+
if (show) visible++;
|
|
2153
|
+
});
|
|
2154
|
+
var empty = $("#lib-empty");
|
|
2155
|
+
if (empty) empty.classList.toggle("hide", visible !== 0);
|
|
2156
|
+
}
|
|
2157
|
+
$$(".lib-tabs button").forEach(function (b) {
|
|
2158
|
+
b.addEventListener("click", function () {
|
|
2159
|
+
$$(".lib-tabs button").forEach(function (x) { x.classList.remove("on"); });
|
|
2160
|
+
b.classList.add("on");
|
|
2161
|
+
cond = b.getAttribute("data-cond") || "";
|
|
2162
|
+
applyFilter();
|
|
2163
|
+
});
|
|
2164
|
+
});
|
|
2165
|
+
var search = $(".lib-search");
|
|
2166
|
+
if (search) search.addEventListener("input", function () { kw = search.value.trim().toLowerCase(); applyFilter(); });
|
|
2167
|
+
$$(".hot-term").forEach(function (t) {
|
|
2168
|
+
t.addEventListener("click", function () {
|
|
2169
|
+
if (!search) return;
|
|
2170
|
+
search.value = t.textContent.trim();
|
|
2171
|
+
kw = search.value.toLowerCase();
|
|
2172
|
+
applyFilter();
|
|
2173
|
+
if (search.focus) search.focus();
|
|
2174
|
+
});
|
|
2175
|
+
});
|
|
2176
|
+
|
|
2177
|
+
/* ===== 8. 过程回顾条:检索步骤展开 ===== */
|
|
2178
|
+
var pStep = $("#p-step-search");
|
|
2179
|
+
var pDetail = $("#p-detail");
|
|
2180
|
+
if (pStep && pDetail) {
|
|
2181
|
+
function toggleDetail() { pDetail.classList.toggle("show"); }
|
|
2182
|
+
pStep.addEventListener("click", toggleDetail);
|
|
2183
|
+
pStep.addEventListener("keydown", function (e) {
|
|
2184
|
+
if (e.key === "Enter" || e.key === " ") { e.preventDefault(); toggleDetail(); }
|
|
2185
|
+
});
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
/* ===== 9. 章节目录(spy) ===== */
|
|
2189
|
+
var toc = $(".toc");
|
|
2190
|
+
if (toc) {
|
|
2191
|
+
var links = $$("a", toc);
|
|
2192
|
+
var secs = links.map(function (a) { return document.querySelector(a.getAttribute("href")); });
|
|
2193
|
+
links.forEach(function (a) {
|
|
2194
|
+
a.addEventListener("click", function (e) {
|
|
2195
|
+
e.preventDefault();
|
|
2196
|
+
var target = document.querySelector(a.getAttribute("href"));
|
|
2197
|
+
if (target) target.scrollIntoView({ block: "start", behavior: "smooth" });
|
|
2198
|
+
});
|
|
2199
|
+
});
|
|
2200
|
+
function spy() {
|
|
2201
|
+
var pos = window.scrollY + 130;
|
|
2202
|
+
var current = -1;
|
|
2203
|
+
secs.forEach(function (s, i) { if (s && s.offsetTop <= pos) current = i; });
|
|
2204
|
+
links.forEach(function (a, i) { a.classList.toggle("on", i === current); });
|
|
2205
|
+
}
|
|
2206
|
+
window.addEventListener("scroll", spy, { passive: true });
|
|
2207
|
+
spy();
|
|
2208
|
+
}
|
|
2209
|
+
})();
|
|
2210
|
+
"""
|
|
2211
|
+
|
|
2212
|
+
|
|
994
2213
|
def render_html(payload: Dict[str, Any], title: str, answer_override: str = "", question_override: str = "",
|
|
995
2214
|
generated_at: Optional[datetime] = None, stage: str = "final") -> str:
|
|
996
2215
|
# unwrap 会取出 content 包装;self_check / verification_checks / knowledgeBase 等
|
|
@@ -998,12 +2217,18 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
|
|
|
998
2217
|
raw_payload = payload
|
|
999
2218
|
payload = unwrap(payload)
|
|
1000
2219
|
for key in ("selfCheck", "self_check", "verificationChecks", "verification_checks",
|
|
1001
|
-
"knowledgeBases", "knowledgeBase", "knowledgeBaseLabels"
|
|
2220
|
+
"knowledgeBases", "knowledgeBase", "knowledgeBaseLabels",
|
|
2221
|
+
"recalled_materials", "召回材料", "检索文章"):
|
|
1002
2222
|
if key in raw_payload and key not in payload:
|
|
1003
2223
|
payload[key] = raw_payload[key]
|
|
1004
2224
|
answer = normalize_citations(answer_override) if answer_override.strip() else extract_answer(payload)
|
|
1005
2225
|
sources = align_sources_to_answer(answer, extract_sources(payload))
|
|
1006
2226
|
used = citation_ids(answer)
|
|
2227
|
+
# 未引用判定双通道 = JSON 标记(recalled_materials)∪ 正文角标未引用:
|
|
2228
|
+
# 进「未引用」分组,不占角标语义,不参与核验统计。
|
|
2229
|
+
for s in sources:
|
|
2230
|
+
if s["id"] not in used:
|
|
2231
|
+
s["used"] = False
|
|
1007
2232
|
kb_urls = extract_knowledge_bases(payload)
|
|
1008
2233
|
kb_labels = payload.get("knowledgeBaseLabels") if isinstance(payload.get("knowledgeBaseLabels"), list) else []
|
|
1009
2234
|
generated_at = generated_at or datetime.now()
|
|
@@ -1011,6 +2236,8 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
|
|
|
1011
2236
|
stage_label = STAGE_LABELS.get(stage, "成稿版")
|
|
1012
2237
|
|
|
1013
2238
|
verification = compute_verification(answer, sources, payload, generated_at)
|
|
2239
|
+
process_stats = compute_process_stats(sources, answer)
|
|
2240
|
+
hot_terms = extract_hot_terms(answer, sources)
|
|
1014
2241
|
citation_warning = ""
|
|
1015
2242
|
if sources and not used:
|
|
1016
2243
|
citation_warning = (
|
|
@@ -1019,21 +2246,31 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
|
|
|
1019
2246
|
'请修正答案文件(提纲版 _outline.md / 成稿版 _answer.txt):在关键事实后标注 [1]、[2] 等角标'
|
|
1020
2247
|
'并逐条对应素材清单,然后重新运行 render_trace_html.py 生成核验报告。</div>'
|
|
1021
2248
|
)
|
|
1022
|
-
|
|
2249
|
+
chip_map = build_chip_data(sources)
|
|
2250
|
+
blocks, _ = parse_answer_blocks(answer, {s["id"] for s in sources}, chip_map)
|
|
2251
|
+
# 胶囊内表格数据汇总(span 内静态表格会被解析器拆散,改为页尾 JSON + 展开时 JS 注入)
|
|
2252
|
+
jb_tables: Dict[str, str] = {}
|
|
2253
|
+
for cid, jb in chip_map.items():
|
|
2254
|
+
for key, tbl_html in (jb.pop("_tables", {}) or {}).items():
|
|
2255
|
+
jb_tables[key] = tbl_html
|
|
1023
2256
|
doc_title, sections = group_sections(blocks)
|
|
1024
2257
|
display_title = doc_title or title
|
|
1025
|
-
report_label = f"
|
|
2258
|
+
report_label = f"{REPORT_NAME}({stage_label})"
|
|
1026
2259
|
kb_zone = render_kb_zone(kb_urls, kb_labels, len(sources))
|
|
1027
2260
|
|
|
1028
|
-
|
|
2261
|
+
jb_tables_json = json.dumps(jb_tables, ensure_ascii=False).replace("</", "<\\/")
|
|
2262
|
+
jb_tables_script = (f'<script type="application/json" id="jb-tables">{jb_tables_json}</script>\n'
|
|
2263
|
+
if jb_tables else "")
|
|
2264
|
+
|
|
1029
2265
|
meta_bits = []
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
meta_bits.append("素材:" + " · ".join(cov_bits))
|
|
2266
|
+
if process_stats["n_searches"]:
|
|
2267
|
+
meta_bits.append(f"深知检索 {process_stats['n_searches']} 次")
|
|
1033
2268
|
if sources:
|
|
1034
|
-
meta_bits.append(f"
|
|
1035
|
-
|
|
1036
|
-
|
|
2269
|
+
meta_bits.append(f"召回材料 {len(sources)} 条")
|
|
2270
|
+
if process_stats["n_cite_marks"]:
|
|
2271
|
+
meta_bits.append(f"正文引用 {process_stats['n_cite_marks']} 处")
|
|
2272
|
+
meta_bits.append(f"生成于 {generated}")
|
|
2273
|
+
meta_line = " · ".join(meta_bits)
|
|
1037
2274
|
|
|
1038
2275
|
return f"""<!doctype html>
|
|
1039
2276
|
<html lang="zh-CN">
|
|
@@ -1041,384 +2278,74 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
|
|
|
1041
2278
|
<meta charset="utf-8">
|
|
1042
2279
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
1043
2280
|
<title>{esc(display_title)} · {esc(report_label)}</title>
|
|
1044
|
-
<style>
|
|
1045
|
-
:root{{
|
|
1046
|
-
--navy:#0b1f3a; --ink:#172236; --muted:#667085; --line:#dce4ef; --line-strong:#b9c6d9;
|
|
1047
|
-
--brand:#1559c7; --brand-soft:#e8f0ff;
|
|
1048
|
-
--policy:#0c9b78; --policy-soft:#e2f6ef;
|
|
1049
|
-
--case:#b26a00; --case-soft:#fff4e0;
|
|
1050
|
-
--ref:#4b5563; --ref-soft:#eef1f6;
|
|
1051
|
-
--warn:#b26a00; --danger:#b93939; --ok:#0c9b78;
|
|
1052
|
-
}}
|
|
1053
|
-
*{{box-sizing:border-box}}
|
|
1054
|
-
body{{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;
|
|
1055
|
-
color:var(--ink);background:#f4f7fb;line-height:1.75;font-size:14.5px}}
|
|
1056
|
-
a{{color:var(--brand)}}
|
|
1057
|
-
.topbar{{position:sticky;top:0;z-index:10;display:flex;justify-content:space-between;align-items:center;gap:10px;
|
|
1058
|
-
padding:10px 22px;background:var(--navy);color:#fff;font-size:13px}}
|
|
1059
|
-
.topbar .tb-title{{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}}
|
|
1060
|
-
.topbar .tags{{display:flex;align-items:center;gap:6px;flex:none}}
|
|
1061
|
-
.topbar .tags span{{padding:2px 10px;border:1px solid rgba(255,255,255,.3);border-radius:999px;font-size:11.5px}}
|
|
1062
|
-
.layout{{display:grid;grid-template-columns:minmax(0,760px) minmax(340px,420px);gap:26px;
|
|
1063
|
-
max-width:1240px;margin:0 auto;padding:26px 18px 60px}}
|
|
1064
|
-
/* 左栏 */
|
|
1065
|
-
.report{{min-width:0}}
|
|
1066
|
-
.r-head{{padding:22px 26px;background:#fff;border:1px solid var(--line);border-radius:12px;margin-bottom:16px;text-align:center}}
|
|
1067
|
-
.r-head h1{{margin:0 0 8px;font-size:22px;color:var(--navy);line-height:1.5}}
|
|
1068
|
-
.r-head .sub{{color:var(--muted);font-size:12.5px}}
|
|
1069
|
-
.warn-box{{margin:0 0 16px;padding:13px 16px;border:1.5px solid var(--danger);border-radius:10px;
|
|
1070
|
-
background:#fdf3f3;color:#8f2626;font-size:13.5px;line-height:1.7}}
|
|
1071
|
-
.verify{{margin:0 0 16px;background:#fff;border:1px solid #bfe5d6;border-radius:12px;padding:16px 20px}}
|
|
1072
|
-
.verify.fail{{border-color:#f2c4c4;background:#fffafa}}
|
|
1073
|
-
.v-head{{display:flex;align-items:center;gap:9px;font-size:15px;font-weight:800;color:var(--ok)}}
|
|
1074
|
-
.verify.fail .v-head{{color:var(--danger)}}
|
|
1075
|
-
.v-shield{{display:inline-flex;width:22px;height:22px;border-radius:50%;background:var(--ok);color:#fff;
|
|
1076
|
-
align-items:center;justify-content:center;font-size:12px;flex:none}}
|
|
1077
|
-
.verify.fail .v-shield{{background:var(--danger)}}
|
|
1078
|
-
.v-stamp{{margin-left:auto;font-size:11px;border:1.5px solid var(--ok);color:var(--ok);border-radius:5px;
|
|
1079
|
-
padding:1px 8px;letter-spacing:2px;flex:none}}
|
|
1080
|
-
.v-stamp.bad{{border-color:var(--danger);color:var(--danger)}}
|
|
1081
|
-
.v-reasons{{margin-top:6px;font-size:12.5px;color:var(--danger)}}
|
|
1082
|
-
.v-grid{{display:grid;grid-template-columns:1fr 1fr;gap:4px 20px;margin-top:10px}}
|
|
1083
|
-
.vi{{display:flex;gap:7px;align-items:baseline;font-size:12.5px;color:#35445c;line-height:1.7;min-width:0}}
|
|
1084
|
-
.vi .s{{font-weight:800;flex:none}}
|
|
1085
|
-
.vi .s.ok{{color:var(--ok)}}
|
|
1086
|
-
.vi .s.warn{{color:var(--warn)}}
|
|
1087
|
-
.vi .s.fail{{color:var(--danger)}}
|
|
1088
|
-
.vi .s.man{{color:var(--case)}}
|
|
1089
|
-
.vi .s.none{{color:var(--muted)}}
|
|
1090
|
-
.vi .d{{color:var(--muted);min-width:0}}
|
|
1091
|
-
.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}}
|
|
1092
|
-
/* 正文章节卡 */
|
|
1093
|
-
.doc-sec{{background:#fff;border:1px solid var(--line);border-radius:12px;padding:20px 24px;margin-bottom:16px}}
|
|
1094
|
-
.sec-head{{display:flex;align-items:center;gap:9px;flex-wrap:wrap;margin-bottom:10px;
|
|
1095
|
-
padding-bottom:10px;border-bottom:1px solid var(--line)}}
|
|
1096
|
-
.sec-no{{display:inline-flex;width:26px;height:26px;border-radius:7px;background:var(--brand);color:#fff;
|
|
1097
|
-
align-items:center;justify-content:center;font-size:13.5px;font-weight:700;flex:none}}
|
|
1098
|
-
.sec-head h3{{margin:0;font-size:16.5px;color:var(--navy);line-height:1.5}}
|
|
1099
|
-
.sec-badge{{margin-left:auto;font-size:11.5px;color:var(--ok);background:var(--policy-soft);
|
|
1100
|
-
border-radius:6px;padding:2px 9px;font-weight:700;flex:none}}
|
|
1101
|
-
.sec-badge.bad{{color:var(--danger);background:#fdecea}}
|
|
1102
|
-
.doc-sub{{margin:16px 0 8px;color:var(--navy);font-size:14.5px;font-weight:700}}
|
|
1103
|
-
h5.doc-sub{{font-size:13.5px}}
|
|
1104
|
-
.doc-block,.doc-item{{margin:0 0 12px}}
|
|
1105
|
-
.doc-block p,.doc-item p{{margin:0;font-size:14px;line-height:1.9}}
|
|
1106
|
-
.doc-item{{display:grid;grid-template-columns:22px minmax(0,1fr);gap:8px}}
|
|
1107
|
-
.doc-item.numbered{{grid-template-columns:28px minmax(0,1fr)}}
|
|
1108
|
-
.doc-bullet{{padding-top:1px;color:#111827;font-size:15px;line-height:1.85}}
|
|
1109
|
-
.doc-divider{{border:0;border-top:1px solid var(--line);margin:18px 0}}
|
|
1110
|
-
code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
1111
|
-
font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px}}
|
|
1112
|
-
.tbl-wrap{{max-width:100%;overflow-x:auto;margin:8px 0}}
|
|
1113
|
-
.data-tbl{{width:100%;border-collapse:collapse;border:1px solid var(--line);font-size:13px}}
|
|
1114
|
-
.data-tbl th,.data-tbl td{{border:1px solid var(--line);padding:8px 10px;text-align:left;vertical-align:top;line-height:1.65}}
|
|
1115
|
-
.data-tbl th{{background:#f2f5fb;font-weight:700;color:#374151;white-space:nowrap}}
|
|
1116
|
-
.data-tbl tbody tr:nth-child(even) td{{background:#fafbfd}}
|
|
1117
|
-
.data-tbl.wide{{min-width:560px}}
|
|
1118
|
-
/* 角标 */
|
|
1119
|
-
.cite{{margin:0 1px;padding:0 5px;border:0;border-radius:4px;background:var(--brand-soft);color:var(--brand);
|
|
1120
|
-
font-weight:800;font-size:10.5px;cursor:pointer;vertical-align:super;font-family:monospace}}
|
|
1121
|
-
.cite:hover,.cite:focus-visible{{background:var(--brand);color:#fff;outline:none}}
|
|
1122
|
-
.cite.unresolved{{background:#fdecea;color:var(--danger)}}
|
|
1123
|
-
/* 段落级证据 chips */
|
|
1124
|
-
.ev-row{{display:flex;flex-wrap:wrap;gap:6px;margin:6px 0 2px}}
|
|
1125
|
-
.ev-chip{{max-width:100%}}
|
|
1126
|
-
.ev-chip summary{{display:inline-flex;align-items:center;max-width:100%;border-radius:999px;padding:3px 10px;
|
|
1127
|
-
color:#4b5563;background:#f3f4f6;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
|
|
1128
|
-
list-style:none;font-size:11.5px}}
|
|
1129
|
-
.ev-chip summary::-webkit-details-marker{{display:none}}
|
|
1130
|
-
.ev-chip summary::after{{content:"核验";margin-left:7px;color:#9ca3af;font-size:10.5px}}
|
|
1131
|
-
.ev-chip[open] summary::after{{content:"收起"}}
|
|
1132
|
-
.ev-chip summary b{{color:var(--brand);margin-right:5px}}
|
|
1133
|
-
.ev-panel{{margin:7px 0 6px;padding:12px 14px;border:1px solid var(--line);border-radius:9px;background:#fbfcfe;
|
|
1134
|
-
box-shadow:0 8px 24px rgba(15,23,42,.06)}}
|
|
1135
|
-
.ev-title{{font-weight:700;font-size:13.5px;margin-bottom:4px;color:var(--navy)}}
|
|
1136
|
-
.ev-meta{{color:var(--muted);font-size:12px;margin-bottom:6px}}
|
|
1137
|
-
.ev-panel p{{margin:0 0 8px;color:#374151;font-size:12.8px;line-height:1.7}}
|
|
1138
|
-
.sc-links{{display:flex;flex-wrap:wrap;gap:8px;margin-top:6px}}
|
|
1139
|
-
.sc-links span{{display:inline-flex}}
|
|
1140
|
-
.sc-links a{{display:inline-flex;align-items:center;min-height:24px;padding:3px 9px;border-radius:6px;
|
|
1141
|
-
background:var(--brand-soft);color:var(--brand);font-weight:700;text-decoration:none;font-size:12px}}
|
|
1142
|
-
/* 右栏 核验材料 */
|
|
1143
|
-
.sources{{position:sticky;top:56px;align-self:start;max-height:calc(100vh - 76px);overflow:auto;
|
|
1144
|
-
background:#fff;border:1px solid var(--line);border-radius:12px;padding:16px 18px}}
|
|
1145
|
-
.sources h3{{margin:0 0 3px;font-size:15px;color:var(--navy)}}
|
|
1146
|
-
.src-tip{{font-size:11.5px;color:var(--muted);margin-bottom:10px}}
|
|
1147
|
-
.filters{{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px}}
|
|
1148
|
-
.filters button{{border:1px solid var(--line);border-radius:999px;background:#fff;color:var(--muted);
|
|
1149
|
-
padding:3px 11px;font-size:12px;cursor:pointer}}
|
|
1150
|
-
.filters button.on{{background:var(--brand);border-color:var(--brand);color:#fff;font-weight:700}}
|
|
1151
|
-
.src-search{{width:100%;padding:7px 10px;border:1px solid var(--line);border-radius:7px;font-size:12.5px;margin-bottom:12px}}
|
|
1152
|
-
.scard{{border:1px solid var(--line);border-left-width:3px;border-radius:10px;padding:11px 13px;margin-bottom:10px;
|
|
1153
|
-
background:#fff;transition:box-shadow .25s}}
|
|
1154
|
-
.scard.pol{{border-left-color:var(--policy)}}
|
|
1155
|
-
.scard.dat{{border-left-color:var(--brand)}}
|
|
1156
|
-
.scard.cas{{border-left-color:var(--case)}}
|
|
1157
|
-
.scard.ref,.scard.mat{{border-left-color:var(--ref)}}
|
|
1158
|
-
.scard.hl{{box-shadow:0 0 0 3px var(--brand)}}
|
|
1159
|
-
.scard.hide{{display:none}}
|
|
1160
|
-
.sc-head{{display:flex;align-items:center;gap:7px;margin-bottom:4px}}
|
|
1161
|
-
.sc-id{{font-family:monospace;font-weight:800;font-size:11px;color:var(--brand);background:var(--brand-soft);
|
|
1162
|
-
border-radius:4px;padding:1px 7px}}
|
|
1163
|
-
.sc-type{{font-size:11px;font-weight:700;border-radius:4px;padding:1px 8px;background:var(--ref-soft);color:var(--ref)}}
|
|
1164
|
-
.scard.pol .sc-type{{background:var(--policy-soft);color:var(--policy)}}
|
|
1165
|
-
.scard.dat .sc-type{{background:var(--brand-soft);color:var(--brand)}}
|
|
1166
|
-
.scard.cas .sc-type{{background:var(--case-soft);color:var(--case)}}
|
|
1167
|
-
.sc-vk{{margin-left:auto;font-size:11px;font-weight:800;color:var(--ok)}}
|
|
1168
|
-
.sc-vk.warn{{color:var(--warn)}}
|
|
1169
|
-
.scard h4{{margin:0 0 4px;font-size:13px;color:var(--navy);line-height:1.55}}
|
|
1170
|
-
.sc-meta{{font-size:11.5px;color:var(--muted)}}
|
|
1171
|
-
.sc-section{{font-size:11.5px;color:var(--brand);margin-top:3px;font-weight:600}}
|
|
1172
|
-
.sc-vnote{{margin-top:5px;font-size:11.3px;color:var(--ok);line-height:1.6}}
|
|
1173
|
-
.sc-excerpt{{margin:7px 0;padding:9px 10px;border-radius:7px;background:#f8fafc;color:#42566f;font-size:12px;line-height:1.7;
|
|
1174
|
-
display:-webkit-box;-webkit-line-clamp:4;-webkit-box-orient:vertical;overflow:hidden;cursor:pointer}}
|
|
1175
|
-
.scard.open .sc-excerpt{{display:block;-webkit-line-clamp:unset}}
|
|
1176
|
-
.sc-excerpt.rich{{overflow-x:auto}}
|
|
1177
|
-
.sc-excerpt.rich table{{width:max-content;min-width:100%;border-collapse:collapse;background:#fff;font-size:12px}}
|
|
1178
|
-
.sc-excerpt.rich td,.sc-excerpt.rich th{{min-width:92px;max-width:220px;padding:7px 8px;border:1px solid var(--line);
|
|
1179
|
-
vertical-align:top;word-break:break-word}}
|
|
1180
|
-
.sc-excerpt.rich thead td,.sc-excerpt.rich th{{background:#f3f4f6;color:#374151;font-weight:700}}
|
|
1181
|
-
.scard .sc-links a{{font-size:12px}}
|
|
1182
|
-
.scard .sc-links{{margin-top:4px}}
|
|
1183
|
-
.no-link{{font-size:11.5px;color:var(--muted)}}
|
|
1184
|
-
.uncited-group{{margin-top:12px;border-top:1px dashed var(--line-strong);padding-top:10px}}
|
|
1185
|
-
.ug-title{{font-size:12.5px;color:var(--muted);font-weight:700;line-height:1.6}}
|
|
1186
|
-
.uncited-group .uncited-list{{margin-top:10px}}
|
|
1187
|
-
/* 知识专库 */
|
|
1188
|
-
.kb-zone{{margin-top:14px;border-top:1px dashed var(--line-strong);padding-top:12px}}
|
|
1189
|
-
.kb-title{{font-size:12.5px;font-weight:800;color:var(--navy)}}
|
|
1190
|
-
.kb-desc{{font-size:11.3px;color:var(--muted);line-height:1.65;margin:3px 0 8px}}
|
|
1191
|
-
.kb-list{{display:flex;flex-direction:column;gap:7px}}
|
|
1192
|
-
.kb-chip{{display:flex;align-items:center;gap:8px;padding:7px 10px;border:1px solid var(--line);border-radius:8px;
|
|
1193
|
-
background:#fbfcfe;text-decoration:none;font-size:11.5px}}
|
|
1194
|
-
.kb-chip:hover{{border-color:var(--brand);background:var(--brand-soft)}}
|
|
1195
|
-
.kb-label{{font-weight:700;color:#374151;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}}
|
|
1196
|
-
.kb-count{{padding-left:8px;border-left:1px solid var(--line);color:var(--muted);white-space:nowrap}}
|
|
1197
|
-
.kb-arrow{{margin-left:auto;color:var(--brand);font-weight:700;white-space:nowrap}}
|
|
1198
|
-
.empty{{color:var(--muted)}}
|
|
1199
|
-
.foot{{text-align:center;color:var(--muted);font-size:11.5px;padding:16px 0 4px;line-height:1.8}}
|
|
1200
|
-
.mobile-nav{{display:none}}
|
|
1201
|
-
.back-doc{{display:none}}
|
|
1202
|
-
/* 移动端材料底部弹层:点角标就地弹出材料卡,不跳转打断阅读 */
|
|
1203
|
-
.sheet-mask{{display:none}}
|
|
1204
|
-
.sheet{{display:none}}
|
|
1205
|
-
@media (max-width:680px){{
|
|
1206
|
-
body{{font-size:14px;line-height:1.8}}
|
|
1207
|
-
.layout{{grid-template-columns:1fr;padding:12px 10px 40px;gap:14px}}
|
|
1208
|
-
.topbar{{padding:8px 12px;font-size:12px;gap:4px;flex-wrap:wrap}}
|
|
1209
|
-
.topbar .tags span{{font-size:10.5px;padding:1px 8px;margin-left:4px}}
|
|
1210
|
-
.r-head{{padding:16px 14px;border-radius:10px}}
|
|
1211
|
-
.r-head h1{{font-size:18px}}
|
|
1212
|
-
.r-head .sub{{font-size:11.5px;line-height:1.6}}
|
|
1213
|
-
.verify{{padding:13px 14px;border-radius:10px}}
|
|
1214
|
-
.v-head{{font-size:14px}}
|
|
1215
|
-
.v-grid{{grid-template-columns:1fr;gap:2px 0}}
|
|
1216
|
-
.vi{{flex-wrap:wrap;gap:4px 8px}}
|
|
1217
|
-
.vi .d{{min-width:0}}
|
|
1218
|
-
.warn-box{{font-size:12.5px;padding:11px 12px}}
|
|
1219
|
-
.doc-sec{{padding:14px;border-radius:10px}}
|
|
1220
|
-
.sec-no{{width:22px;height:22px;font-size:12px;border-radius:6px}}
|
|
1221
|
-
.sec-head{{gap:7px;padding-bottom:8px;margin-bottom:8px}}
|
|
1222
|
-
.sec-head h3{{font-size:15px}}
|
|
1223
|
-
.sec-badge{{margin-left:0;font-size:11px}}
|
|
1224
|
-
.doc-block p,.doc-item p{{font-size:13.5px;line-height:1.95}}
|
|
1225
|
-
.doc-sub{{font-size:14px;margin:12px 0 6px}}
|
|
1226
|
-
.data-tbl{{font-size:12px}}
|
|
1227
|
-
.data-tbl th,.data-tbl td{{padding:6px 7px;line-height:1.55}}
|
|
1228
|
-
.cite{{font-size:11px;padding:0 4px}}
|
|
1229
|
-
.ev-chip summary{{font-size:11px}}
|
|
1230
|
-
.sources{{padding:12px;border-radius:10px}}
|
|
1231
|
-
.scard{{padding:10px 11px}}
|
|
1232
|
-
.sc-excerpt{{font-size:11.5px}}
|
|
1233
|
-
.kb-chip{{flex-wrap:wrap}}
|
|
1234
|
-
.kb-label{{white-space:normal}}
|
|
1235
|
-
.mobile-nav{{display:block;margin:0 0 14px;padding:11px 14px;border:1.5px solid var(--brand);
|
|
1236
|
-
border-radius:10px;background:var(--brand-soft);color:var(--brand);font-weight:800;
|
|
1237
|
-
font-size:13.5px;text-decoration:none;text-align:center}}
|
|
1238
|
-
.back-doc{{display:inline-block;margin:0 0 8px;font-size:12px;color:var(--brand);
|
|
1239
|
-
font-weight:700;text-decoration:none}}
|
|
1240
|
-
.sheet-mask{{display:block;position:fixed;inset:0;background:rgba(11,31,58,.45);z-index:99;opacity:0;
|
|
1241
|
-
pointer-events:none;transition:opacity .2s}}
|
|
1242
|
-
.sheet-mask.show{{opacity:1;pointer-events:auto}}
|
|
1243
|
-
.sheet{{display:block;position:fixed;left:0;right:0;bottom:0;z-index:100;background:#fff;
|
|
1244
|
-
border-radius:14px 14px 0 0;box-shadow:0 -8px 30px rgba(11,31,58,.25);
|
|
1245
|
-
max-height:68vh;overflow-y:auto;-webkit-overflow-scrolling:touch;
|
|
1246
|
-
padding:10px 16px 22px;transform:translateY(105%);transition:transform .25s ease}}
|
|
1247
|
-
.sheet.show{{transform:translateY(0)}}
|
|
1248
|
-
.sheet-grab{{width:38px;height:4px;border-radius:2px;background:#c9d4e2;margin:2px auto 8px}}
|
|
1249
|
-
.sheet-head{{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}}
|
|
1250
|
-
.sheet-head b{{font-size:13.5px;color:var(--navy)}}
|
|
1251
|
-
.sheet-close{{border:1px solid var(--line);background:#f5f8fc;border-radius:8px;color:#3b4a61;
|
|
1252
|
-
font-size:12.5px;font-weight:700;padding:5px 14px;cursor:pointer}}
|
|
1253
|
-
.sheet .scard{{box-shadow:none;margin-bottom:0}}
|
|
1254
|
-
.sheet .sc-excerpt{{display:block;-webkit-line-clamp:unset;cursor:auto}}
|
|
1255
|
-
}}
|
|
1256
|
-
@media (max-width:1020px){{
|
|
1257
|
-
.layout{{grid-template-columns:1fr}}
|
|
1258
|
-
.sources{{position:static;max-height:none}}
|
|
1259
|
-
}}
|
|
1260
|
-
@media print{{
|
|
1261
|
-
.topbar,.filters,.src-search{{display:none!important}}
|
|
1262
|
-
.layout{{grid-template-columns:1fr;max-width:none;padding:0;gap:14px}}
|
|
1263
|
-
body{{background:#fff;font-size:12.5px}}
|
|
1264
|
-
.sources{{position:static;max-height:none;border:0;padding:0;overflow:visible}}
|
|
1265
|
-
.r-head,.verify,.doc-sec{{border-color:#bbb;box-shadow:none;break-inside:avoid}}
|
|
1266
|
-
.sc-excerpt{{display:block;-webkit-line-clamp:unset;cursor:auto}}
|
|
1267
|
-
.uncited-group[open] .uncited-list,.uncited-group{{break-inside:avoid}}
|
|
1268
|
-
.scard{{break-inside:avoid}}
|
|
1269
|
-
.cite{{background:#eee;color:#333}}
|
|
1270
|
-
}}
|
|
1271
|
-
</style>
|
|
2281
|
+
<style>{PAGE_CSS}</style>
|
|
1272
2282
|
</head>
|
|
1273
2283
|
<body>
|
|
1274
2284
|
|
|
1275
2285
|
<header class="topbar">
|
|
1276
|
-
<div class="tb-
|
|
1277
|
-
|
|
1278
|
-
<span
|
|
1279
|
-
<span>素材来源:深知可信搜索</span>
|
|
2286
|
+
<div class="tb-left">
|
|
2287
|
+
<span class="tb-stamp">{esc(REPORT_NAME)}</span>
|
|
2288
|
+
<span class="tb-title">{esc(display_title)}</span>
|
|
1280
2289
|
</div>
|
|
2290
|
+
<div class="tb-right">
|
|
2291
|
+
<div class="view-switch" role="tablist" aria-label="视图切换">
|
|
2292
|
+
<button class="on" data-view="report" type="button">核验报告</button>
|
|
2293
|
+
<button data-view="library" type="button">材料专库</button>
|
|
2294
|
+
</div>
|
|
2295
|
+
<div class="tb-tools">
|
|
2296
|
+
<button id="btn-reading" type="button" aria-pressed="false" title="隐藏核验元素,纯阅读正文">只看正文</button>
|
|
2297
|
+
<button id="btn-copy" type="button" title="复制正文纯文本">复制全文</button>
|
|
2298
|
+
<span class="print-menu">
|
|
2299
|
+
<button id="btn-print" type="button" aria-haspopup="true" title="浏览器打印/另存为 PDF">打印归档 ▾</button>
|
|
2300
|
+
<span class="print-drop" id="print-drop" hidden>
|
|
2301
|
+
<button id="print-body" type="button">只打印正文</button>
|
|
2302
|
+
<button id="print-full" type="button">完整归档(含核验材料)</button>
|
|
2303
|
+
</span>
|
|
2304
|
+
</span>
|
|
2305
|
+
</div>
|
|
2306
|
+
</div>
|
|
2307
|
+
<div class="progress" aria-hidden="true"><i></i></div>
|
|
1281
2308
|
</header>
|
|
1282
2309
|
|
|
1283
|
-
<div class="
|
|
1284
|
-
<
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
2310
|
+
<div class="hero">
|
|
2311
|
+
<div class="r-badge">{esc(report_label)}</div>
|
|
2312
|
+
<h1>{esc(display_title)}</h1>
|
|
2313
|
+
<div class="meta">{esc(meta_line)} | 素材来源:深知可信搜索</div>
|
|
2314
|
+
<div class="hero-switch">
|
|
2315
|
+
<div class="view-switch" role="tablist" aria-label="视图切换">
|
|
2316
|
+
<button class="on" data-view="report" type="button">核验报告</button>
|
|
2317
|
+
<button data-view="library" type="button">材料专库({len(sources)})</button>
|
|
1288
2318
|
</div>
|
|
2319
|
+
</div>
|
|
2320
|
+
</div>
|
|
2321
|
+
|
|
2322
|
+
<div class="app container" data-view="report">
|
|
2323
|
+
{render_process_bar(process_stats, verification)}
|
|
2324
|
+
|
|
2325
|
+
<main class="view" id="view-report" aria-label="核验报告正文">
|
|
1289
2326
|
{citation_warning}
|
|
1290
2327
|
{render_verify_panel(verification, stage)}
|
|
1291
|
-
<
|
|
2328
|
+
<div class="doc-paper">
|
|
1292
2329
|
{render_section_cards(sections, sources)}
|
|
1293
|
-
|
|
2330
|
+
</div>
|
|
2331
|
+
<div class="foot">深知可信PPT · 溯源核验报告 | 内容由 AI 生成,仅供参考,政策现行效力以官方发布为准</div>
|
|
1294
2332
|
</main>
|
|
1295
|
-
|
|
2333
|
+
|
|
2334
|
+
{render_library_view(sources, hot_terms, kb_zone)}
|
|
2335
|
+
{render_print_appendix(sources)}
|
|
1296
2336
|
</div>
|
|
1297
2337
|
|
|
1298
|
-
|
|
2338
|
+
{render_toc(sections)}
|
|
2339
|
+
|
|
2340
|
+
<div class="ev-panel" id="ev-pop" hidden></div>
|
|
2341
|
+
{jb_tables_script}<div class="sheet-mask" aria-hidden="true"></div>
|
|
1299
2342
|
<div class="sheet" role="dialog" aria-label="核验材料">
|
|
1300
2343
|
<div class="sheet-grab"></div>
|
|
1301
|
-
<div class="sheet-head"><b
|
|
2344
|
+
<div class="sheet-head"><b>依据对照</b><button class="sheet-close" type="button">收起</button></div>
|
|
1302
2345
|
<div class="sheet-body"></div>
|
|
1303
2346
|
</div>
|
|
1304
2347
|
|
|
1305
|
-
<script>
|
|
1306
|
-
(function () {{
|
|
1307
|
-
"use strict";
|
|
1308
|
-
var cards = Array.prototype.slice.call(document.querySelectorAll(".scard"));
|
|
1309
|
-
var byId = {{}};
|
|
1310
|
-
cards.forEach(function (c) {{
|
|
1311
|
-
var id = c.getAttribute("data-cite-id");
|
|
1312
|
-
if (id) byId[id] = c;
|
|
1313
|
-
}});
|
|
1314
|
-
|
|
1315
|
-
/* 移动端底部弹层:点角标就地展示材料卡,不打断正文阅读 */
|
|
1316
|
-
var sheet = document.querySelector(".sheet");
|
|
1317
|
-
var mask = document.querySelector(".sheet-mask");
|
|
1318
|
-
function isMobile() {{
|
|
1319
|
-
return window.matchMedia("(max-width:680px)").matches;
|
|
1320
|
-
}}
|
|
1321
|
-
function openSheet(card) {{
|
|
1322
|
-
if (!sheet) return;
|
|
1323
|
-
var body = sheet.querySelector(".sheet-body");
|
|
1324
|
-
var clone = card.cloneNode(true);
|
|
1325
|
-
clone.removeAttribute("id");
|
|
1326
|
-
clone.classList.remove("hide");
|
|
1327
|
-
clone.classList.add("open");
|
|
1328
|
-
body.innerHTML = "";
|
|
1329
|
-
body.appendChild(clone);
|
|
1330
|
-
sheet.classList.add("show");
|
|
1331
|
-
mask.classList.add("show");
|
|
1332
|
-
document.body.style.overflow = "hidden";
|
|
1333
|
-
sheet.scrollTop = 0;
|
|
1334
|
-
}}
|
|
1335
|
-
function closeSheet() {{
|
|
1336
|
-
if (!sheet) return;
|
|
1337
|
-
sheet.classList.remove("show");
|
|
1338
|
-
mask.classList.remove("show");
|
|
1339
|
-
document.body.style.overflow = "";
|
|
1340
|
-
}}
|
|
1341
|
-
if (sheet && mask) {{
|
|
1342
|
-
mask.addEventListener("click", closeSheet);
|
|
1343
|
-
var closeBtn = sheet.querySelector(".sheet-close");
|
|
1344
|
-
if (closeBtn) closeBtn.addEventListener("click", closeSheet);
|
|
1345
|
-
}}
|
|
1346
|
-
|
|
1347
|
-
/* 角标 → 来源卡:精确 ID 匹配,缺失即红色警示,绝不按位置猜测。
|
|
1348
|
-
手机单栏下不滚动定位(会跳到页面底部打断阅读),改为底部弹层就地查看。 */
|
|
1349
|
-
document.querySelectorAll(".data-cite,[data-cite]").forEach(function (btn) {{
|
|
1350
|
-
if (btn.classList.contains("sheet-close")) return;
|
|
1351
|
-
btn.addEventListener("click", function () {{
|
|
1352
|
-
var card = byId[btn.getAttribute("data-cite")];
|
|
1353
|
-
if (!card) {{
|
|
1354
|
-
btn.classList.add("unresolved");
|
|
1355
|
-
if (console.error) console.error("[核验] 未绑定角标:", btn.getAttribute("data-cite"));
|
|
1356
|
-
return;
|
|
1357
|
-
}}
|
|
1358
|
-
if (isMobile()) {{
|
|
1359
|
-
openSheet(card);
|
|
1360
|
-
return;
|
|
1361
|
-
}}
|
|
1362
|
-
card.classList.remove("hide", "open");
|
|
1363
|
-
card.classList.add("hl", "open");
|
|
1364
|
-
card.scrollIntoView({{ block: "center", behavior: "smooth" }});
|
|
1365
|
-
setTimeout(function () {{ card.classList.remove("hl"); }}, 2200);
|
|
1366
|
-
}});
|
|
1367
|
-
}});
|
|
1368
|
-
|
|
1369
|
-
/* 摘录点击展开/收起 */
|
|
1370
|
-
cards.forEach(function (c) {{
|
|
1371
|
-
var ex = c.querySelector(".sc-excerpt");
|
|
1372
|
-
if (!ex) return;
|
|
1373
|
-
ex.addEventListener("click", function (e) {{
|
|
1374
|
-
if (e.target.closest("a")) return;
|
|
1375
|
-
c.classList.toggle("open");
|
|
1376
|
-
}});
|
|
1377
|
-
}});
|
|
1378
|
-
|
|
1379
|
-
/* 证据 chips(灰框):桌面端点击就地展开并高亮右栏来源卡;手机端不就地展开,点击直接弹出底部材料弹层 */
|
|
1380
|
-
document.querySelectorAll(".ev-chip").forEach(function (chip) {{
|
|
1381
|
-
var summary = chip.querySelector("summary");
|
|
1382
|
-
if (summary) {{
|
|
1383
|
-
summary.addEventListener("click", function (e) {{
|
|
1384
|
-
if (!isMobile()) return;
|
|
1385
|
-
e.preventDefault();
|
|
1386
|
-
var card = byId[chip.getAttribute("data-cite")];
|
|
1387
|
-
if (card) openSheet(card);
|
|
1388
|
-
}});
|
|
1389
|
-
}}
|
|
1390
|
-
chip.addEventListener("toggle", function () {{
|
|
1391
|
-
if (!chip.open || isMobile()) return;
|
|
1392
|
-
var card = byId[chip.getAttribute("data-cite")];
|
|
1393
|
-
if (!card) return;
|
|
1394
|
-
cards.forEach(function (c) {{ c.classList.remove("hl"); }});
|
|
1395
|
-
card.classList.add("hl");
|
|
1396
|
-
setTimeout(function () {{ card.classList.remove("hl"); }}, 2200);
|
|
1397
|
-
}});
|
|
1398
|
-
}});
|
|
1399
|
-
|
|
1400
|
-
/* 类型筛选 + 搜索 */
|
|
1401
|
-
var filter = "all";
|
|
1402
|
-
var kw = "";
|
|
1403
|
-
function apply() {{
|
|
1404
|
-
cards.forEach(function (c) {{
|
|
1405
|
-
var okType = filter === "all" || c.getAttribute("data-type") === filter;
|
|
1406
|
-
var okKw = !kw || (c.textContent || "").toLowerCase().indexOf(kw) !== -1;
|
|
1407
|
-
c.classList.toggle("hide", !(okType && okKw));
|
|
1408
|
-
}});
|
|
1409
|
-
}}
|
|
1410
|
-
document.querySelectorAll(".filters button").forEach(function (b) {{
|
|
1411
|
-
b.addEventListener("click", function () {{
|
|
1412
|
-
document.querySelectorAll(".filters button").forEach(function (x) {{ x.classList.remove("on"); }});
|
|
1413
|
-
b.classList.add("on");
|
|
1414
|
-
filter = b.getAttribute("data-f");
|
|
1415
|
-
apply();
|
|
1416
|
-
}});
|
|
1417
|
-
}});
|
|
1418
|
-
var search = document.querySelector(".src-search");
|
|
1419
|
-
if (search) search.addEventListener("input", function () {{ kw = search.value.trim().toLowerCase(); apply(); }});
|
|
1420
|
-
}})();
|
|
1421
|
-
</script>
|
|
2348
|
+
<script>{PAGE_JS}</script>
|
|
1422
2349
|
</body>
|
|
1423
2350
|
</html>"""
|
|
1424
2351
|
|
|
@@ -1442,26 +2369,46 @@ def align_sources_to_answer(answer: str, sources: List[Dict[str, str]]) -> List[
|
|
|
1442
2369
|
|
|
1443
2370
|
|
|
1444
2371
|
def main() -> None:
|
|
1445
|
-
parser = argparse.ArgumentParser(description="生成深知可信PPT
|
|
2372
|
+
parser = argparse.ArgumentParser(description="生成深知可信PPT 溯源核验报告 HTML(提纲版/成稿版)")
|
|
1446
2373
|
parser.add_argument("input_json", help="trusted_search.py 或合并后的检索 JSON")
|
|
1447
2374
|
parser.add_argument("--output", help="输出 HTML 路径;不传时根据问题自动生成短文件名到 official-docs/output/")
|
|
1448
|
-
parser.add_argument("--title", default="
|
|
2375
|
+
parser.add_argument("--title", default="溯源核验报告", help="演示标题;正文首行有标题时以正文为准")
|
|
1449
2376
|
parser.add_argument("--answer-file", help="答案文件(提纲版 <项目短名>_outline.md / 成稿版 <项目短名>_answer.txt),关键事实后标 [N] 角标。")
|
|
1450
2377
|
parser.add_argument("--clean-md-output", help="输出干净 Markdown 路径;内容来自同一份答案,并移除 [1]、【1】等溯源角标。")
|
|
1451
2378
|
parser.add_argument("--question", default="", help="用户需求,用于自动生成文件名。")
|
|
1452
2379
|
parser.add_argument("--stage", choices=["outline", "final"], default="final",
|
|
1453
2380
|
help="报告版本:outline 提纲版(确认门前事前核验)/ final 成稿版(交付时事后溯源),默认 final。")
|
|
2381
|
+
parser.add_argument("--skip-link-check", action="store_true",
|
|
2382
|
+
help="跳过原文链接活性检测(默认检测:404/410 含软 404 标记失效)")
|
|
2383
|
+
parser.add_argument("--disable-snapshot", action="store_true",
|
|
2384
|
+
help="关闭快照兜底展示(默认启用:原文失效时以存档快照回看)")
|
|
1454
2385
|
args = parser.parse_args()
|
|
2386
|
+
if args.disable_snapshot:
|
|
2387
|
+
global SNAPSHOT_ENABLED
|
|
2388
|
+
SNAPSHOT_ENABLED = False
|
|
1455
2389
|
|
|
1456
2390
|
payload = load_json(_safe_input_path(args.input_json, {".json"}))
|
|
1457
2391
|
answer_override = ""
|
|
1458
2392
|
if args.answer_file:
|
|
1459
2393
|
answer_override = _safe_input_path(args.answer_file, {".txt", ".md"}).read_text(encoding="utf-8")
|
|
1460
2394
|
question = args.question.strip() or extract_question(unwrap(payload))
|
|
2395
|
+
unwrapped = unwrap(payload)
|
|
2396
|
+
|
|
2397
|
+
# 原文链接活性检测 + 快照兜底(就地改写原始材料 dict:链接失效=True / 快照链接 规范化)
|
|
2398
|
+
raw_articles = collect_raw_articles(unwrapped)
|
|
2399
|
+
if not args.skip_link_check and raw_articles:
|
|
2400
|
+
dead = mark_dead_links(raw_articles)
|
|
2401
|
+
if dead:
|
|
2402
|
+
print(f"链接检测:{dead} 条原文链接已失效(404/410),将改用存档快照或如实标注")
|
|
2403
|
+
if SNAPSHOT_ENABLED and raw_articles:
|
|
2404
|
+
fixed, dropped = apply_snapshots(raw_articles)
|
|
2405
|
+
total_snap = sum(1 for a in raw_articles if (a.get("快照链接") or "").strip())
|
|
2406
|
+
if total_snap or fixed or dropped:
|
|
2407
|
+
print(f"快照校验:{total_snap} 条路径合法放行(补全 /A/ {fixed} 条)/ 弃用 {dropped} 条非法路径(不做网络检测)")
|
|
1461
2408
|
|
|
1462
2409
|
# 生成前硬校验:有素材而正文无角标时拒绝生成,杜绝产出无核验对应的报告
|
|
1463
|
-
pre_answer = normalize_citations(answer_override) if answer_override.strip() else extract_answer(
|
|
1464
|
-
pre_sources = extract_sources(
|
|
2410
|
+
pre_answer = normalize_citations(answer_override) if answer_override.strip() else extract_answer(unwrapped)
|
|
2411
|
+
pre_sources = extract_sources(unwrapped)
|
|
1465
2412
|
if pre_sources and not citation_ids(pre_answer):
|
|
1466
2413
|
print("生成检查未通过:答案正文没有任何 [N] 来源角标,无法建立\"结论-素材\"核验对应。", file=sys.stderr)
|
|
1467
2414
|
print(f"请修正答案文件({'提纲版 _outline.md:页面规划表事实要点' if args.stage == 'outline' else '成稿版 _answer.txt:页面级结论文本'}"
|