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