sync update from LAN repo (source dhk-1 @ 3b1ec5b4)

This commit is contained in:
gozeros committed 2026-11-05 10:56:34 +08:00
1 parent da6521b6cb
commit 264e2200d6
995 files changed
+148105 -13399

No files matched your search

@@ -0,0 +1,84 @@
---
name: white-house-page-generator
description: 生成或绘制中文白宫官网及白宫风格行政机构门户的可交付单文件 HTML;仅在用户明确要求白宫官网、White House 风格政府首页或点名本技能时使用。先把材料或检索结果整理成读者文案全中文的十模块 JSON,再用内置模板确定性渲染,保留右上角模块化 JSON 编辑弹窗。
allowed-tools:
- read_file
- write_file
- bash
- present_files
- web_search
---
# 白宫官网页面生成器
本技能使用固定模板生成单文件白宫官网风格行政机构门户。模型只负责材料收集和 JSON,禁止重新手写页面结构、CSS 或运行时脚本。最终页面自带右上角设置按钮;用户可在弹窗中按模块编辑 JSON,并通过「应用并渲染」即时更新页面。
编辑弹窗还提供“上传图片/视频”:先把光标放进目标报道、帖子、视频或带 `visual`/`media` 的内容对象,上传文件会转换为 `data:` 地址并写入该对象的 `media` 字段。不设文件大小拦截;较大文件可能超过浏览器本地缓存容量,应同时下载 JSON 留存。
页面中已由 `media` 数据渲染的图片和视频还带悬浮上传图标:鼠标移入媒体后点击可任选图片或视频并直接替换,文件的实际类型会自动写入新的 `media.type`,结果同步写回页面 JSON 与浏览器缓存。头像、Logo 和无法映射回 JSON 的装饰图不会显示该入口;不按原媒体类型限制,也不设置文件大小拦截。
默认视觉直接复用模板原有的示例图:不要调用图像生成工具,不要让模型重新生成、拼装或内嵌新的内容型 SVG,也不要为了寻找“标准配图”延长检索。用户没有提供可直接使用的图片/视频且聚焦检索未得到可靠直链时,保留默认 JSON 的 `visual` 或内置视觉类型;这些是模板自带的静态示例,调用技能时不重新绘制。不要把大段 base64 示例图重复写进 JSON,图不合适时由用户在成品页面悬浮上传替换。
## 触发边界
- 用户明确说「生成/画/制作白宫官网」「White House 风格政府首页/行政机构门户」或点名 `white-house-page-generator` 时使用。
- 仅讨论白宫、总结白宫消息、分析美国行政机构或普通文本中出现 White House 时不要使用。
- 这是白宫官网风格单页门户,不改用 CNN、BBC、新华社或通用多页新闻模板。
## 极速工作流(默认)
页面结构已经固定。完成必要检索或材料整理后,模型只写一份小型规格 JSON;未写字段继续使用模板默认数据与示例视觉,脚本在一次进程内合并、校验并渲染。
1. 用 `write_file` 创建 `/mnt/user-data/outputs/white-house-page-spec.json`。直接写模块对象会递归合并;修改现有数组项优先用 `$set`:
```json
{"site":{"pageTitle":"白宫官网 · 中文专题"},"$set":{"hero.kicker":"最新议程","hero.title":"中文主标题","hero.summary":"中文摘要","notice.text":"中文公告"}}
```
2. 只执行一次 `python /mnt/skills/public/white-house-page-generator/scripts/fast_page.py --spec /mnt/user-data/outputs/white-house-page-spec.json --output-dir /mnt/user-data/outputs`。
3. stdout 为 `status: ok` 后立即用 `present_files` 交付完整 JSON 与 HTML,最终只回复一句完成说明。
规格只允许本技能十个模块和 `$set`;路径必须指向默认 JSON 的已存在字段。除技术键、品牌名、人物名和必要缩写外,所有读者可见内容必须是简体中文。未提供媒体直链时保留模板示例视觉。禁止读取默认数据、契约、模板、运行时或脚本源码,禁止 `--help`、独立 `init/validate/render`、生成后打补丁、临时脚本和冗长过程说明。规格报错时只修正一次并重跑。只有用户明确要求改变模块结构或批量重建完整数组时,才使用下面的完整工作流。
## 完整工作流(仅限结构改造)
1. 读取当前会话材料、上传附件和已有产物,确定机构标识、导航、主视觉、公告、官方动态、优先事项、行政团队、公共日历、公众参与和页脚。
2. 用户要求基于真实白宫、当前政府、现任官员、最新政策、实时直播或近期事件时,必须先检索可靠的一手资料再填 JSON;用户明确说不要检索时不得联网。检索到英文资料时先准确翻译成简体中文再写入 JSON,不得直接复制英文标题、摘要、按钮或日期。没有材料时使用中文中性概念内容,并在页脚明确说明不是官方政府网站。
3. 初始化新的完整 JSON:
```text
python /mnt/skills/public/white-house-page-generator/scripts/render_white_house_page.py init --output /mnt/user-data/outputs/white-house-page-data.json
```
4. 只修改 JSON。十个顶层模块必须全部保留:`site`、`navigation`、`hero`、`notice`、`updates`、`priorities`、`administration`、`calendar`、`participation`、`footer`。JSON 键名、`id`、`href`、`visual`、`theme` 等技术值继续使用契约规定的英文标识;除此之外,所有面向读者的机构名、标题、标签、摘要、按钮、日期、活动和页脚文案必须使用简体中文,`site.language` 固定为 `zh-CN`。字段不确定时读取 [references/data-schema.md](references/data-schema.md)。
5. 校验 JSON:
```text
python /mnt/skills/public/white-house-page-generator/scripts/render_white_house_page.py validate --input /mnt/user-data/outputs/white-house-page-data.json
```
6. 确定性渲染到 `outputs/`:
```text
python /mnt/skills/public/white-house-page-generator/scripts/render_white_house_page.py render --input /mnt/user-data/outputs/white-house-page-data.json --output /mnt/user-data/outputs/white-house-page.html
```
7. 检查 stdout 的 `status` 为 `ok`、HTML 存在且占位符已经消失,再用 `present_files` 同时交付 HTML 与源 JSON。不要在聊天中粘贴完整 HTML。
## 内容映射
- 机构名称、办公室名称、语言、主题和无障碍文案放入 `site`;主导航、全屏菜单和搜索文案放入 `navigation`。
- 建筑主视觉、双 CTA、直播简报和直播弹窗放入 `hero`;公告横条放入 `notice`。
- 官方动态放入 `updates.items`;政策重点放入 `priorities.items`。
- 行政团队介绍放入 `administration`;活动月份与事件放入 `calendar.months`。
- 参观、联系、实习等公众入口及订阅表单放入 `participation`;政府、媒体与参与链接放入 `footer`。
- `visual` 继续作为内置后备;`hero` 及具有视觉的对象可增加受校验的 `media`(`image`、`video`、`webpage`)替换当前视觉。所有外部文本由模板转义,不得包含 HTML、脚本或直接 iframe。
## 重要约束
- 只编辑 JSON,不修改 `assets/white-house-template.html` 或 `assets/white-house-runtime.js`,不复制模板后手改 DOM。
- 不得生成英文读者文案。即使来源为英文,也必须翻译为自然、准确的简体中文;只有 JSON 键名、稳定 `id`、锚点、视觉枚举和主题枚举保留英文技术值。
- 初始化与渲染默认拒绝覆盖已有文件;路径存在时换新文件名,不删除旧产物。
- 页面结构、样式和脚本完全自包含,不依赖 whitehouse.gov API、CDN 或 npm;仅当 JSON 明确提供受校验的媒体 URL 时加载图片、视频或网页。
- 保留三色顶线、透明转吸顶导航、建筑主视觉、官方动态、优先事项、行政团队、公共日历、全屏菜单搜索、直播字幕和订阅反馈。
- 浏览器缓存以初始 JSON 指纹隔离;沙箱禁止持久存储时必须继续使用内嵌 JSON 正常渲染。
@@ -0,0 +1,151 @@
{
"site": {
"brandName": "美国白宫",
"officeName": "公共服务办公室",
"pageTitle": "美国白宫——公共事务门户概念页",
"description": "面向公共信息发布与公众参与的白宫风格行政机构门户概念页面。",
"language": "zh-CN",
"theme": "light",
"skipLabel": "跳转到主要内容"
},
"navigation": {
"menuLabel": "菜单",
"searchLabel": "搜索",
"themeLightLabel": "已切换为浅色模式",
"themeDarkLabel": "已切换为深色模式",
"leftLinks": [
{"label": "新闻", "href": "#news"},
{"label": "施政重点", "href": "#priorities"}
],
"rightLinks": [
{"label": "行政团队", "href": "#administration"}
],
"menu": {
"eyebrow": "探索白宫",
"title": "人民之家",
"text": "了解公共信息、公共服务计划以及参与公共事务的方式。",
"ctaLabel": "联系白宫",
"ctaHref": "#involved",
"columns": [
{"id": "menu-news", "title": "新闻", "links": [{"label": "新闻发布", "href": "#news"}, {"label": "新闻简报", "href": "#news"}, {"label": "行政行动", "href": "#news"}, {"label": "讲话致辞", "href": "#news"}]},
{"id": "menu-government", "title": "政府事务", "links": [{"label": "行政团队", "href": "#administration"}, {"label": "施政重点", "href": "#priorities"}, {"label": "公共日历", "href": "#calendar"}, {"label": "政务公开", "href": "#news"}]},
{"id": "menu-involved", "title": "公众参与", "links": [{"label": "联系我们", "href": "#involved"}, {"label": "参观白宫", "href": "#involved"}, {"label": "实习项目", "href": "#involved"}, {"label": "订阅动态", "href": "#footer"}]}
]
},
"search": {
"title": "搜索白宫网站",
"placeholder": "请输入要查找的内容",
"emptyMessage": "请输入关键词后继续搜索。",
"resultPrefix": "条相关结果,关键词为"
}
},
"hero": {
"visual": "executive-house",
"kicker": "服务人民的政府",
"title": "为了人民",
"subtitle": "服务每一个社区",
"summary": "欢迎来到人民之家——公共服务、开放政府与公民参与在这里汇聚。",
"primaryAction": {"label": "了解施政重点", "href": "#priorities"},
"liveActionLabel": "观看直播",
"brief": {
"label": "直播简报",
"time": "下午2:00(美国东部时间)",
"title": "社区基础设施讲话",
"summary": "在大厅举行的公共服务现代化主题演示讲话。"
},
"scrollLabel": "向下滚动查看更多",
"liveModal": {
"title": "白宫直播",
"streamTitle": "社区基础设施讲话",
"streamSubtitle": "演示直播 · 提供实时字幕",
"location": "白宫大厅直播",
"captionsOn": "字幕:已开启",
"captionsOff": "字幕:已关闭"
}
},
"notice": {
"label": "公众公告",
"text": "十一月公众参观日历现已发布。",
"date": "2026年10月26日",
"href": "#calendar"
},
"updates": {
"eyebrow": "最新动态",
"title": "白宫消息",
"summary": "发布官方公告、公共简报以及来自全国各地社区的故事。",
"items": [
{"id": "update-1", "type": "重点简报", "title": "新框架推动基本公共服务走进每一个社区", "summary": "各部门将在交通、数字接入和韧性公共基础设施方面加强协同。", "date": "2026年10月26日", "visual": "hall"},
{"id": "update-2", "type": "公共投资", "title": "五个区域交通项目进入建设阶段", "summary": "新的交通连接将缩短通勤时间并扩大公共服务覆盖。", "date": "2026年10月26日", "visual": "mobility"},
{"id": "update-3", "type": "科技创新", "title": "开放科学计划扩大公共研究成果获取范围", "summary": "新工具将帮助教育工作者和小型企业更好地利用公共数据。", "date": "2026年10月25日", "visual": "science"},
{"id": "update-4", "type": "会议声明", "title": "州长工作会议情况通报", "summary": "与会代表讨论了应急准备和公共服务共享机制。", "date": "2026年10月25日", "visual": "statement"},
{"id": "update-5", "type": "行政行动", "title": "新行政令推动政府信息使用清晰易懂的语言", "summary": "各部门将简化表格并完善多语言支持。", "date": "2026年10月24日", "visual": "action"}
]
},
"priorities": {
"eyebrow": "我们的工作",
"title": "国家施政重点",
"summary": "聚焦切实成果:建设更有韧性的社区、促进经济增长、保障公共系统安全,让每个家庭都能共享发展机会。",
"agendaLabel": "查看议程 →",
"agendaHref": "#news",
"items": [
{"id": "priority-1", "title": "建设强大社区", "summary": "让基础设施和公共空间更好地服务日常生活。", "detail": "建设连接人民与发展机会的现代交通网络。"},
{"id": "priority-2", "title": "促进共同繁荣", "summary": "营造鼓励进取、尊重劳动的经济环境。", "detail": "支持小型企业、技能型就业和负责任的创新。"},
{"id": "priority-3", "title": "提升公共服务", "summary": "围绕人民实际需求建设政府服务体系。", "detail": "提供安全、便捷、可靠的现代数字政务服务。"},
{"id": "priority-4", "title": "增强国家韧性", "summary": "完善韧性系统与协同公共安全机制。", "detail": "以充分准备的公共机构和可信伙伴关系应对不断变化的世界。"}
]
},
"administration": {
"visual": "portrait",
"eyebrow": "行政团队",
"title": "以公共服务凝聚领导力",
"quote": "“政府通过认真倾听、清晰行动和诚信履职赢得公众信任。”",
"description": "本概念页面中的行政团队致力于建设开放政府、提升机构响应能力,并与地方社区共同推动务实进步。",
"signature": "总统办公室",
"links": [
{"label": "了解总统", "href": "#administration"},
{"label": "了解副总统", "href": "#administration"},
{"label": "了解内阁", "href": "#administration"}
]
},
"calendar": {
"eyebrow": "公民服务纪念计划",
"title": "公共服务季",
"countdownValue": "249",
"countdownLabel": "距离公民日还有249天 · 2027年7月4日",
"panelEyebrow": "公共日历",
"panelTitle": "白宫公共活动",
"panelText": "全年参与公共对话、志愿服务、文化活动和公众开放日。",
"months": [
{"id": "nov-2026", "label": "2026年11月", "events": [{"id": "nov-05", "day": "05", "month": "11月", "title": "公众开放日:公共建筑与历史", "summary": "全天开放公众参观,并举办历史建筑保护讲座。", "tag": "重点活动"}, {"id": "nov-12", "day": "12", "month": "11月", "title": "全国公共服务圆桌会", "summary": "与社区负责人共同开展公共对话。", "tag": "公众活动"}, {"id": "nov-19", "day": "19", "month": "11月", "title": "青年创新成果展示", "summary": "学生团队展示服务公共事务的科技项目。", "tag": "品牌活动"}]},
{"id": "dec-2026", "label": "2026年12月", "events": [{"id": "dec-03", "day": "03", "month": "12月", "title": "冬季志愿服务日", "summary": "参与各地区志愿项目和公益捐赠活动。", "tag": "公众活动"}, {"id": "dec-11", "day": "11", "month": "12月", "title": "冬季艺术交流会", "summary": "共同感受音乐与公共文化的魅力。", "tag": "重点活动"}, {"id": "dec-18", "day": "18", "month": "12月", "title": "年终新闻发布会", "summary": "回顾年度工作并回答公众关切。", "tag": "在线直播"}]},
{"id": "jan-2027", "label": "2027年1月", "events": [{"id": "jan-08", "day": "08", "month": "1月", "title": "新年公共事务简报", "summary": "介绍新一年的重点工作。", "tag": "在线直播"}, {"id": "jan-17", "day": "17", "month": "1月", "title": "社区领导力论坛", "summary": "地方负责人分享务实解决方案。", "tag": "公众活动"}, {"id": "jan-28", "day": "28", "month": "1月", "title": "科技服务公共事务日", "summary": "研究人员展示服务公共利益的实用工具。", "tag": "重点活动"}]}
]
},
"participation": {
"eyebrow": "公众参与",
"title": "人民之家,人民之声",
"summary": "通过学习、参观、写信和志愿服务参与国家公共生活。",
"cards": [
{"id": "visit", "kicker": "向公众开放", "title": "参观白宫", "summary": "规划公众参观行程,了解人民之家的历史、建筑与公共工作。", "actionLabel": "规划参观 →", "actionHref": "#calendar", "visual": "visit"},
{"id": "write", "kicker": "联系我们", "title": "致信总统", "summary": "分享意见、申请贺信或咨询公共服务问题。", "actionLabel": "发送留言 →", "actionHref": "#footer", "visual": "letter"},
{"id": "serve", "kicker": "投身公共服务", "title": "实习与培养计划", "summary": "将你的经验与技能投入公共服务事业。", "actionLabel": "查看机会 →", "actionHref": "#footer", "visual": "service"}
],
"newsletter": {
"title": "订阅白宫动态",
"text": "接收本概念门户发布的官方风格简报、公众公告和活动邀请。",
"placeholder": "请输入电子邮箱",
"button": "立即订阅",
"successPrefix": "感谢订阅,确认邮件已发送至"
}
},
"footer": {
"description": "用于展示公共信息发布和公众参与的行政机构门户概念页。本页面并非美国政府官方网站。",
"columns": [
{"id": "government", "title": "政府事务", "links": [{"label": "行政团队", "href": "#administration"}, {"label": "施政重点", "href": "#priorities"}, {"label": "行政行动", "href": "#news"}, {"label": "政务公开", "href": "#news"}]},
{"id": "media", "title": "新闻媒体", "links": [{"label": "最新新闻", "href": "#news"}, {"label": "新闻简报", "href": "#news"}, {"label": "图片资料", "href": "#involved"}, {"label": "在线直播", "href": "#top"}]},
{"id": "participate", "title": "公众参与", "links": [{"label": "联系我们", "href": "#involved"}, {"label": "参观白宫", "href": "#calendar"}, {"label": "实习项目", "href": "#involved"}, {"label": "公共日历", "href": "#calendar"}]}
],
"copyright": "© 2026 白宫公共事务门户概念页",
"legal": "概念模板 · 无障碍访问 · 隐私 · 版权 · 开放政府"
}
}
@@ -0,0 +1,695 @@
(() => {
"use strict";
const qs = (selector, root = document) => root.querySelector(selector);
const qsa = (selector, root = document) => Array.from(root.querySelectorAll(selector));
const clone = (value) => JSON.parse(JSON.stringify(value));
const escapeHTML = (value) => String(value ?? "").replace(/[&<>'"]/g, (char) => ({"&": "&amp;", "<": "&lt;", ">": "&gt;", "'": "&#39;", '"': "&quot;"})[char]);
const safeHref = (value) => String(value || "").startsWith("#") ? String(value) : "#top";
const safeRemoteUrl = (value, kind = "link") => {
const source = String(value || "").trim();
if (!source) return "";
const lowered = source.toLowerCase();
if (kind === "image" && lowered.startsWith("data:image/")) return source;
if (kind === "video" && lowered.startsWith("data:video/")) return source;
try { const url = new URL(source); return ["http:", "https:"].includes(url.protocol) ? url.href : ""; }
catch (_error) { return ""; }
};
const validateRemoteMediaTree = (value, path = "当前模块") => {
if (Array.isArray(value)) return value.forEach((item, index) => validateRemoteMediaTree(item, path + "[" + index + "]"));
if (!isObject(value)) return;
const media = value.media;
if (media && ["image", "video", "webpage"].includes(media.type)) {
if (["image", "video"].includes(media.type) && !safeRemoteUrl(media.mediaUrl, media.type)) throw new Error(path + ".media.mediaUrl 无效");
if (media.type === "webpage" && !safeRemoteUrl(media.pageUrl)) throw new Error(path + ".media.pageUrl 无效");
if (media.posterUrl && !safeRemoteUrl(media.posterUrl, "image")) throw new Error(path + ".media.posterUrl 无效");
}
Object.entries(value).forEach(([key, item]) => { if (key !== "media") validateRemoteMediaTree(item, path + "." + key); });
};
const MODULES = ["site", "navigation", "hero", "notice", "updates", "priorities", "administration", "calendar", "participation", "footer"];
const MODULE_META = {
site: ["站点信息", "品牌、办公室、语言和主题"],
navigation: ["页面导航", "页头、菜单和搜索"],
hero: ["首页主视觉", "核心信息、简报和直播弹窗"],
notice: ["公众公告", "公告标签、内容和日期"],
updates: ["最新动态", "官方新闻和简报"],
priorities: ["施政重点", "政策卡片和详细内容"],
administration: ["行政团队", "领导层说明和链接"],
calendar: ["公共日历", "月份、活动和倒计时"],
participation: ["公众参与", "参与入口和订阅信息"],
footer: ["页面页脚", "链接栏目和法律说明"]
};
const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
const isCompleteData = (value) => isObject(value) && MODULES.every((name) => isObject(value[name]));
const initialData = JSON.parse(qs("#whiteHousePageData").textContent);
const fingerprint = (() => {
const text = JSON.stringify(initialData);
let hash = 2166136261;
for (let index = 0; index < text.length; index += 1) {
hash ^= text.charCodeAt(index);
hash = Math.imul(hash, 16777619);
}
return (hash >>> 0).toString(16).padStart(8, "0");
})();
const storageKey = "white-house-page-data-v1:" + fingerprint;
const themeKey = "white-house-page-theme-v1:" + fingerprint;
const readStorage = (key) => { try { return window.localStorage.getItem(key); } catch (_error) { return null; } };
const writeStorage = (key, value) => { try { window.localStorage.setItem(key, value); return true; } catch (_error) { return false; } };
const removeStorage = (key) => { try { window.localStorage.removeItem(key); } catch (_error) { /* optional storage */ } };
let pageData = clone(initialData);
try {
const saved = readStorage(storageKey);
const parsed = saved ? JSON.parse(saved) : null;
if (isCompleteData(parsed)) pageData = parsed;
} catch (_error) {
pageData = clone(initialData);
}
const saveData = () => writeStorage(storageKey, JSON.stringify(pageData));
const toast = qs("#toast");
let toastTimer = 0;
const note = (message) => {
if (qs("#settingsOverlay").classList.contains("open")) {
const status = qs("#jsonStatus");
status.textContent = message;
status.className = "json-status valid";
return;
}
window.clearTimeout(toastTimer);
toast.textContent = message;
toast.classList.add("show");
toastTimer = window.setTimeout(() => toast.classList.remove("show"), 2300);
};
const sealWordmark = () => pageData.site.brandName || "美国白宫";
document.head.insertAdjacentHTML("beforeend", '<style data-external-media>.hero-art>img,.hero-art>video,.hero-art>iframe,.card-art>img,.card-art>video,.card-art>iframe,.involve-bg>img,.involve-bg>video,.involve-bg>iframe{width:100%;height:100%;display:block;border:0;object-fit:cover;background:#000}.hero-art>iframe,.card-art>iframe,.involve-bg>iframe{object-fit:initial}.external-open{position:absolute;right:10px;bottom:10px;z-index:4;padding:7px 11px;color:#fff;background:rgba(0,0,0,.72);text-decoration:none;font-size:12px;font-weight:700}.external-copy{position:absolute;left:10px;right:10px;bottom:10px;z-index:4;padding:9px;color:#fff;background:rgba(0,0,0,.72);text-decoration:none}.external-copy strong,.external-copy span{display:block}.external-copy span{margin-top:3px;font-size:12px}</style>');
const externalMediaMarkup = (media, label) => {
if (!isObject(media)) return "";
if (media.type === "image") {
const source = safeRemoteUrl(media.mediaUrl, "image");
if (!source) return "";
const pageUrl = safeRemoteUrl(media.pageUrl);
return '<img src="' + escapeHTML(source) + '" alt="' + escapeHTML(media.alt || label || "页面图片") + '" loading="lazy" referrerpolicy="no-referrer"/>' + (pageUrl ? '<a class="external-open" href="' + escapeHTML(pageUrl) + '" target="_blank" rel="noopener noreferrer">打开来源</a>' : "");
}
if (media.type === "video") {
const source = safeRemoteUrl(media.mediaUrl, "video");
const poster = safeRemoteUrl(media.posterUrl, "image");
return source ? '<video src="' + escapeHTML(source) + '"' + (poster ? ' poster="' + escapeHTML(poster) + '"' : "") + ' controls playsinline preload="metadata" aria-label="' + escapeHTML(media.alt || label || "页面视频") + '"></video>' : "";
}
if (media.type === "webpage") {
const pageUrl = safeRemoteUrl(media.pageUrl);
if (!pageUrl) return "";
const preview = safeRemoteUrl(media.mediaUrl, "image");
const body = media.embed === true ? '<iframe src="' + escapeHTML(pageUrl) + '" title="' + escapeHTML(media.title || "网页预览") + '" loading="lazy" referrerpolicy="no-referrer" sandbox="allow-forms allow-popups allow-scripts"></iframe>' : (preview ? '<img src="' + escapeHTML(preview) + '" alt="' + escapeHTML(media.alt || media.title || "网页预览图") + '" loading="lazy" referrerpolicy="no-referrer"/>' : "");
return body + '<a class="external-copy" href="' + escapeHTML(pageUrl) + '" target="_blank" rel="noopener noreferrer"><strong>' + escapeHTML(media.title || label || "打开网页") + '</strong><span>' + escapeHTML(media.description || "新窗口打开") + "</span></a>";
}
return "";
};
const heroArt = () => '<svg viewBox="0 0 1600 900" preserveAspectRatio="xMidYMid slice" aria-hidden="true"><defs><linearGradient id="heroSky" x2="0" y2="1"><stop stop-color="#809aac"/><stop offset=".48" stop-color="#d8c2a2"/><stop offset="1" stop-color="#263d50"/></linearGradient><linearGradient id="lawn" x2="0" y2="1"><stop stop-color="#345a4d"/><stop offset="1" stop-color="#172e29"/></linearGradient></defs><rect width="1600" height="900" fill="url(#heroSky)"/><circle cx="1283" cy="150" r="84" fill="#f1daa1" opacity=".8"/><path d="M0 661c269-110 498-131 792-75 267 51 483 47 808-55v369H0Z" fill="url(#lawn)"/><g transform="translate(647 215)"><path d="M-280 378h796" stroke="#dcd8ca" stroke-width="20"/><path d="M-181 362V174h594v188" fill="#e9e7df"/><path d="M-226 178h684L115-12Z" fill="#ddd9cc"/><path d="M-160 209h552v14h-552Z" fill="#c5c3ba"/><path d="M-139 226h55v119h-55Zm107 0h55v119h-55Zm107 0h55v119H75Zm107 0h55v119h-55Zm107 0h55v119h-55Z" fill="#f6f4eb" stroke="#a9aaa7" stroke-width="3"/><path d="M89 166h52v-56H89Z" fill="#e8e6dd"/><path d="M115 110V37" stroke="#d4d1c6" stroke-width="8"/><path d="m115 37 72 22-72 18Z" fill="#a7282f"/><g fill="#31465a"><path d="M-122 247h21v46h-21Zm107 0H6v46h-21Zm107 0h21v46H92Zm107 0h21v46h-21Zm107 0h21v46h-21Z"/></g></g><path d="M0 774c403-126 839-104 1600 9" stroke="#4f7667" stroke-width="86" fill="none"/></svg>';
const visualSvg = (type, title) => {
if (isObject(type)) {
const external = externalMediaMarkup(type, title);
if (external) return external;
type = "hall";
}
let background = "#d7c9b5";
let content = '<path d="M80 380h540M150 350V165h400v185" fill="#e5dfd3" stroke="#8e877b" stroke-width="8"/><path d="M115 170h470L350 55Z" fill="#f0eadf"/>';
if (type === "hall") {
background = "#d6c8b3";
content = '<path d="M95 450V95h510v355" fill="#d6c8b3"/><path d="M65 100h570L350 0Z" fill="#e6dccb"/><g fill="#f4eee2" stroke="#9d8b75" stroke-width="4"><rect x="125" y="135" width="72" height="250"/><rect x="252" y="135" width="72" height="250"/><rect x="378" y="135" width="72" height="250"/><rect x="505" y="135" width="72" height="250"/></g><path d="M0 390h700v60H0Z" fill="#263a4e"/>';
} else if (type === "mobility") {
background = "#cbd8dc";
content = '<path d="M0 330 125 198l90 83 144-165 341 245v89H0Z" fill="#667d72"/><path d="M0 388c214-78 428-78 700-2" stroke="#e9e3d5" stroke-width="20" fill="none"/><g fill="#394f58"><rect x="185" y="305" width="112" height="72"/><rect x="366" y="265" width="145" height="112"/></g>';
} else if (type === "science") {
background = "#132941";
content = '<circle cx="355" cy="215" r="136" fill="#2c5478"/><path d="M258 272c39-121 170-180 278-134-59 35-83 76-108 132-31 68-93 72-170 2Z" fill="#5d9ab6"/><path d="M80 385h540" stroke="#c9a45c" stroke-width="10"/>';
} else if (type === "statement") {
background = "#e3dacb";
content = '<rect x="125" y="75" width="450" height="310" rx="4" fill="#fffdf8"/><path d="M180 145h340M180 205h285M180 265h310M180 325h210" stroke="#9b9387" stroke-width="16"/><circle cx="520" cy="330" r="38" fill="#a7282f"/>';
} else if (type === "action") {
background = "#17314a";
content = '<path d="M145 375h410V125H145Z" fill="#ede8dd"/><path d="M205 195h290M205 250h240M205 305h275" stroke="#7f7568" stroke-width="14"/><path d="m495 325 77 75" stroke="#c9a45c" stroke-width="24"/>';
} else if (type === "portrait") {
background = "#d7c9b5";
content = '<path d="M0 400h700v50H0Z" fill="#17314a"/><circle cx="355" cy="165" r="90" fill="#d7b79a"/><path d="M265 150c20-95 170-120 205 5-39-27-71-37-111-37-43 0-70 10-94 32Z" fill="#6b594a"/><path d="M210 450c22-165 78-245 145-245s123 80 145 245Z" fill="#1b2b3a"/><path d="m295 230 60 90 60-90 37 220H258Z" fill="#eff0ec"/><path d="m356 318 24 132h-49Z" fill="#9f2930"/>';
} else if (type === "visit") {
background = "#9db2bd";
content = '<path d="M0 390c180-80 385-95 700-20v80H0Z" fill="#405f54"/><g transform="translate(145 105)"><path d="M-50 300h510" stroke="#e6e1d3" stroke-width="16"/><path d="M0 282V120h408v162" fill="#e6e3da"/><path d="M-30 124h468L204 0Z" fill="#d8d4c8"/><g fill="#faf8ef" stroke="#aaa" stroke-width="3"><rect x="27" y="154" width="48" height="113"/><rect x="111" y="154" width="48" height="113"/><rect x="195" y="154" width="48" height="113"/><rect x="279" y="154" width="48" height="113"/></g></g>';
} else if (type === "letter") {
background = "#15314c";
content = '<path d="M85 90h530v300H85Z" fill="#e8e1d4"/><path d="m85 90 265 185L615 90" stroke="#a7282f" stroke-width="16" fill="none"/><circle cx="350" cy="275" r="58" fill="#c9a45c"/>';
} else if (type === "service") {
background = "#d6cab7";
content = '<circle cx="350" cy="155" r="90" fill="#b29272"/><path d="M110 450c34-165 112-240 240-240s206 75 240 240Z" fill="#1e3c57"/><g fill="#f2eee5"><circle cx="95" cy="85" r="20"/><circle cx="590" cy="110" r="18"/><circle cx="100" cy="320" r="16"/></g>';
}
return '<svg viewBox="0 0 700 450" preserveAspectRatio="xMidYMid slice" role="img" aria-label="' + escapeHTML(title) + '"><rect width="700" height="450" fill="' + background + '"/>' + content + "</svg>";
};
let themeInitialized = false;
const syncTheme = () => qs("#themeToggle").setAttribute("aria-label", document.body.classList.contains("dark") ? "切换为浅色模式" : "切换为深色模式");
const applyInitialTheme = () => {
if (themeInitialized) return;
themeInitialized = true;
const stored = readStorage(themeKey);
const configured = pageData.site.theme;
const prefersDark = window.matchMedia && window.matchMedia("(prefers-color-scheme:dark)").matches;
const dark = stored === "dark" || (!stored && (configured === "dark" || (configured === "auto" && prefersDark)));
document.body.classList.toggle("dark", dark);
syncTheme();
};
const toggleTheme = () => {
const dark = document.body.classList.toggle("dark");
writeStorage(themeKey, dark ? "dark" : "light");
syncTheme();
note(dark ? pageData.navigation.themeDarkLabel : pageData.navigation.themeLightLabel);
};
const linksMarkup = (items, className = "") => (items || []).map((item) => '<a class="' + className + '" href="' + safeHref(item.href) + '">' + escapeHTML(item.label) + "</a>").join("");
const renderSite = () => {
const data = pageData.site;
document.documentElement.lang = data.language || "zh-CN";
document.title = data.pageTitle || data.brandName || "美国白宫";
qs('meta[name="description"]').content = data.description || "";
qs("#skipLink").textContent = data.skipLabel || "";
qs("#brandName").textContent = data.brandName || "";
qs("#officeName").textContent = data.officeName || "";
qs("#wordmark").setAttribute("aria-label", (data.brandName || "") + "首页");
qs("#footerBrand").textContent = data.brandName || "";
qs("#menuBrand").textContent = data.brandName || "";
qs("#searchBrand").textContent = data.brandName || "";
applyInitialTheme();
};
const renderNavigation = () => {
const data = pageData.navigation;
qs("#menuButtonLabel").textContent = data.menuLabel || "";
qs("#menuOpen").setAttribute("aria-label", data.menuLabel || "打开菜单");
qs("#searchOpen").setAttribute("aria-label", data.searchLabel || "搜索");
qs("#leftNav").innerHTML = linksMarkup(data.leftLinks, "nav-link");
qs("#rightNav").innerHTML = linksMarkup(data.rightLinks, "nav-link");
const menu = data.menu || {};
qs("#menuEyebrow").textContent = menu.eyebrow || "";
qs("#menuTitle").textContent = menu.title || "";
qs("#menuText").textContent = menu.text || "";
qs("#menuCta").textContent = menu.ctaLabel || "";
qs("#menuCta").href = safeHref(menu.ctaHref);
qs("#menuColumns").innerHTML = (menu.columns || []).map((column) => '<nav class="menu-col"><h3>' + escapeHTML(column.title) + "</h3>" + (column.links || []).map((link) => '<a href="' + safeHref(link.href) + '" data-close-menu>' + escapeHTML(link.label) + "</a>").join("") + "</nav>").join("");
const search = data.search || {};
qs("#searchTitle").textContent = search.title || "";
qs("#searchInput").placeholder = search.placeholder || "";
};
const renderHero = () => {
const data = pageData.hero;
qs("#heroArt").innerHTML = externalMediaMarkup(data.media, data.title) || heroArt();
qs("#heroKicker").textContent = data.kicker || "";
qs("#heroTitle").innerHTML = escapeHTML(data.title) + "<span>" + escapeHTML(data.subtitle) + "</span>";
qs("#heroSummary").textContent = data.summary || "";
qs("#heroPrimary").textContent = data.primaryAction?.label || "";
qs("#heroPrimary").href = safeHref(data.primaryAction?.href);
qs("#heroLive span").textContent = data.liveActionLabel || "";
const brief = data.brief || {};
qs("#briefLabel").textContent = brief.label || "";
qs("#briefTime").textContent = brief.time || "";
qs("#briefTitle").textContent = brief.title || "";
qs("#briefSummary").textContent = brief.summary || "";
qs("#scrollLabel").textContent = data.scrollLabel || "";
const modal = data.liveModal || {};
qs("#liveTitle").textContent = modal.title || "";
qs("#liveStreamTitle").textContent = modal.streamTitle || "";
qs("#liveStreamSubtitle").textContent = modal.streamSubtitle || "";
qs("#liveLocation").textContent = modal.location || "";
qs("#captionToggle").textContent = modal.captionsOn || "字幕:已开启";
};
const renderNotice = () => {
const data = pageData.notice;
qs("#noticeLabel").textContent = data.label || "";
qs("#noticeText").textContent = data.text || "";
qs("#noticeText").href = safeHref(data.href);
qs("#noticeDate").textContent = data.date || "";
};
const renderUpdates = () => {
const data = pageData.updates;
qs("#updatesEyebrow").textContent = data.eyebrow || "";
qs("#updatesTitle").textContent = data.title || "";
qs("#updatesSummary").textContent = data.summary || "";
qs("#newsGrid").innerHTML = (data.items || []).map((item, index) => '<article class="news-card' + (index === 0 ? " feature" : "") + '"><div class="card-art">' + visualSvg(item.media || item.visual, item.title) + '</div><div class="news-type">' + escapeHTML(item.type) + "</div><h3>" + escapeHTML(item.title) + "</h3><p>" + escapeHTML(item.summary) + "</p><time>" + escapeHTML(item.date) + "</time></article>").join("");
};
let activePriority = "";
const renderPriorities = () => {
const data = pageData.priorities;
const items = data.items || [];
if (!items.some((item) => item.id === activePriority)) activePriority = items[0]?.id || "";
qs("#prioritiesEyebrow").textContent = data.eyebrow || "";
qs("#prioritiesTitle").textContent = data.title || "";
qs("#prioritiesSummary").textContent = data.summary || "";
qs("#priorityGrid").innerHTML = items.map((item, index) => '<button class="priority' + (item.id === activePriority ? " active" : "") + '" data-priority="' + escapeHTML(item.id) + '"><span class="priority-arrow"><svg viewBox="0 0 24 24"><path d="m9 6 6 6-6 6"/></svg></span><span class="priority-no">' + String(index + 1).padStart(2, "0") + "</span><h3>" + escapeHTML(item.title) + "</h3><p>" + escapeHTML(item.summary) + "</p></button>").join("");
const selected = items.find((item) => item.id === activePriority) || items[0] || {};
qs("#priorityTitle").textContent = selected.title || "";
qs("#priorityText").textContent = selected.detail || "";
qs("#priorityAgenda").textContent = data.agendaLabel || "";
qs("#priorityAgenda").href = safeHref(data.agendaHref);
};
const renderAdministration = () => {
const data = pageData.administration;
qs("#adminArt").innerHTML = visualSvg(data.media || "portrait", data.title);
qs("#adminEyebrow").textContent = data.eyebrow || "";
qs("#adminTitle").textContent = data.title || "";
qs("#adminQuote").textContent = data.quote || "";
qs("#adminDescription").textContent = data.description || "";
qs("#adminSignature").textContent = data.signature || "";
qs("#adminLinks").innerHTML = linksMarkup(data.links);
};
let activeMonth = 0;
const renderCalendar = () => {
const data = pageData.calendar;
const months = data.months || [];
if (activeMonth >= months.length) activeMonth = 0;
qs("#calendarEyebrow").textContent = data.eyebrow || "";
qs("#calendarTitle").textContent = data.title || "";
qs("#countdownValue").textContent = data.countdownValue || "";
qs("#countdownLabel").textContent = data.countdownLabel || "";
qs("#calendarPanelEyebrow").textContent = data.panelEyebrow || "";
qs("#calendarPanelTitle").textContent = data.panelTitle || "";
qs("#calendarPanelText").textContent = data.panelText || "";
const month = months[activeMonth];
qs("#monthLabel").textContent = month?.label || "";
qs("#events").innerHTML = (month?.events || []).map((item) => '<article class="event"><div class="event-date"><b>' + escapeHTML(item.day) + "</b><span>" + escapeHTML(item.month) + "</span></div><div><h3>" + escapeHTML(item.title) + "</h3><p>" + escapeHTML(item.summary) + '</p></div><span class="event-tag">' + escapeHTML(item.tag) + "</span></article>").join("");
};
const renderParticipation = () => {
const data = pageData.participation;
qs("#participationEyebrow").textContent = data.eyebrow || "";
qs("#participationTitle").textContent = data.title || "";
qs("#participationSummary").textContent = data.summary || "";
qs("#participationGrid").innerHTML = (data.cards || []).map((item) => '<article class="involve-card"><div class="involve-bg">' + visualSvg(item.media || item.visual, item.title) + '</div><div class="involve-copy"><span>' + escapeHTML(item.kicker) + "</span><h3>" + escapeHTML(item.title) + "</h3><p>" + escapeHTML(item.summary) + '</p><a href="' + safeHref(item.actionHref) + '">' + escapeHTML(item.actionLabel) + "</a></div></article>").join("");
const newsletter = data.newsletter || {};
qs("#newsletterTitle").textContent = newsletter.title || "";
qs("#newsletterText").textContent = newsletter.text || "";
qs("#email").placeholder = newsletter.placeholder || "";
qs("#newsletterButton").textContent = newsletter.button || "";
};
const renderFooter = () => {
const data = pageData.footer;
qs("#footerDescription").textContent = data.description || "";
qs("#footerColumns").innerHTML = (data.columns || []).map((column) => '<nav class="foot-col"><h3>' + escapeHTML(column.title) + "</h3>" + (column.links || []).map((link) => '<a href="' + safeHref(link.href) + '"' + (/live/i.test(link.label) ? ' class="open-live"' : "") + ">" + escapeHTML(link.label) + "</a>").join("") + "</nav>").join("");
qs("#copyright").textContent = data.copyright || "";
qs("#legal").textContent = data.legal || "";
};
const renderAll = () => {
renderSite();
renderNavigation();
renderHero();
renderNotice();
renderUpdates();
renderPriorities();
renderAdministration();
renderCalendar();
renderParticipation();
renderFooter();
bindDynamicInteractions();
};
const siteHead = qs("#siteHead");
window.addEventListener("scroll", () => siteHead.classList.toggle("scrolled", window.scrollY > 80), {passive: true});
qs("#themeToggle").addEventListener("click", toggleTheme);
const menuOverlay = qs("#menuOverlay");
const searchOverlay = qs("#searchOverlay");
const liveOverlay = qs("#liveOverlay");
let lastFocus = null;
const openLayer = (layer, focusTarget) => {
lastFocus = document.activeElement;
layer.classList.add("open");
document.body.style.overflow = "hidden";
window.setTimeout(() => focusTarget?.focus(), 20);
};
const closeLayer = (layer) => {
layer.classList.remove("open");
document.body.style.overflow = "";
if (lastFocus) lastFocus.focus();
};
qs("#menuOpen").addEventListener("click", () => openLayer(menuOverlay, qs("#menuClose")));
qs("#menuClose").addEventListener("click", () => closeLayer(menuOverlay));
qs("#searchOpen").addEventListener("click", () => openLayer(searchOverlay, qs("#searchInput")));
qs("#searchClose").addEventListener("click", () => closeLayer(searchOverlay));
qs("#liveClose").addEventListener("click", () => closeLayer(liveOverlay));
[menuOverlay, searchOverlay, liveOverlay].forEach((layer) => layer.addEventListener("click", (event) => { if (event.target === layer) closeLayer(layer); }));
const bindDynamicInteractions = () => {
qsa("[data-close-menu]").forEach((link) => link.addEventListener("click", () => closeLayer(menuOverlay)));
qsa(".open-live").forEach((button) => button.addEventListener("click", (event) => { event.preventDefault(); openLayer(liveOverlay, qs("#liveClose")); }));
qsa("[data-priority]").forEach((button) => button.addEventListener("click", () => { activePriority = button.dataset.priority; renderPriorities(); bindDynamicInteractions(); }));
};
const collectStrings = (value, output = []) => {
if (typeof value === "string" && !value.startsWith("#")) output.push(value);
else if (Array.isArray(value)) value.forEach((item) => collectStrings(item, output));
else if (isObject(value)) Object.values(value).forEach((item) => collectStrings(item, output));
return output;
};
qs("#searchForm").addEventListener("submit", (event) => {
event.preventDefault();
const raw = qs("#searchInput").value.trim();
const query = raw.toLocaleLowerCase();
const search = pageData.navigation.search || {};
const count = query ? collectStrings(pageData).filter((value) => value.toLocaleLowerCase().includes(query)).length : 0;
qs("#searchResult").textContent = query ? count + " " + (search.resultPrefix || "条相关结果,关键词为") + "“" + raw + "”" : (search.emptyMessage || "");
});
qs("#captionToggle").addEventListener("click", (event) => {
const modal = pageData.hero.liveModal || {};
const isOn = event.currentTarget.textContent === modal.captionsOn;
event.currentTarget.textContent = isOn ? modal.captionsOff : modal.captionsOn;
note(isOn ? "字幕已关闭" : "字幕已开启");
});
qs("#nextMonth").addEventListener("click", () => {
const length = pageData.calendar.months?.length || 1;
activeMonth = (activeMonth + 1) % length;
renderCalendar();
});
qs("#prevMonth").addEventListener("click", () => {
const length = pageData.calendar.months?.length || 1;
activeMonth = (activeMonth - 1 + length) % length;
renderCalendar();
});
qs("#subForm").addEventListener("submit", (event) => {
event.preventDefault();
const email = qs("#email").value.trim();
qs("#subStatus").textContent = (pageData.participation.newsletter.successPrefix || "") + " " + email + ".";
event.currentTarget.reset();
});
const settingsOverlay = qs("#settingsOverlay");
const jsonEditor = qs("#jsonEditor");
const jsonStatus = qs("#jsonStatus");
let activeModule = MODULES[0];
let editorDraft = clone(pageData);
const validateEditor = () => {
try {
const parsed = JSON.parse(jsonEditor.value);
if (!isObject(parsed)) throw new Error("当前模块必须是 JSON 对象");
validateRemoteMediaTree(parsed);
jsonStatus.textContent = "JSON 有效";
jsonStatus.className = "json-status valid";
return parsed;
} catch (error) {
jsonStatus.textContent = "JSON 无效:" + error.message;
jsonStatus.className = "json-status invalid";
return null;
}
};
const storeActiveDraft = () => {
const parsed = validateEditor();
if (!parsed) return false;
editorDraft[activeModule] = parsed;
return true;
};
const selectModule = (name, force) => {
if (!force && !storeActiveDraft()) return;
activeModule = name;
qsa(".module-tab").forEach((tab) => tab.classList.toggle("active", tab.dataset.module === name));
qs("#editorModuleTitle").textContent = MODULE_META[name][0];
jsonEditor.value = JSON.stringify(editorDraft[name], null, 2);
validateEditor();
};
const renderModuleTabs = () => {
qs("#moduleTabs").innerHTML = "<h3>页面模块</h3>" + MODULES.map((name) => '<button class="module-tab' + (name === activeModule ? " active" : "") + '" data-module="' + name + '"><strong>' + MODULE_META[name][0] + "</strong><span>" + MODULE_META[name][1] + "</span></button>").join("");
qsa(".module-tab").forEach((tab) => tab.addEventListener("click", () => selectModule(tab.dataset.module, false)));
};
const openSettings = () => {
editorDraft = clone(pageData);
activeModule = MODULES[0];
renderModuleTabs();
selectModule(activeModule, true);
settingsOverlay.classList.add("open");
settingsOverlay.setAttribute("aria-hidden", "false");
document.body.style.overflow = "hidden";
window.setTimeout(() => jsonEditor.focus(), 80);
};
const closeSettings = () => {
settingsOverlay.classList.remove("open");
settingsOverlay.setAttribute("aria-hidden", "true");
document.body.style.overflow = "";
qs("#openSettings").focus();
};
qs("#openSettings").addEventListener("click", openSettings);
qs("#closeSettings").addEventListener("click", closeSettings);
settingsOverlay.addEventListener("click", (event) => { if (event.target === settingsOverlay) closeSettings(); });
jsonEditor.addEventListener("input", validateEditor);
jsonEditor.addEventListener("keydown", (event) => {
if (event.key === "Tab") {
event.preventDefault();
jsonEditor.setRangeText(" ", jsonEditor.selectionStart, jsonEditor.selectionEnd, "end");
validateEditor();
}
});
qs("#applyJson").addEventListener("click", () => {
if (!storeActiveDraft() || !isCompleteData(editorDraft)) {
note("请先修正 JSON 再应用");
return;
}
pageData = clone(editorDraft);
saveData();
renderAll();
note("JSON 已应用到页面");
});
qs("#resetJson").addEventListener("click", () => {
pageData = clone(initialData);
editorDraft = clone(initialData);
removeStorage(storageKey);
removeStorage(themeKey);
themeInitialized = false;
activePriority = "";
activeMonth = 0;
renderAll();
renderModuleTabs();
selectModule(activeModule, true);
note("已恢复初始 JSON");
});
qs("#copyJson").addEventListener("click", async () => {
if (!storeActiveDraft()) return;
const text = JSON.stringify(editorDraft, null, 2);
try {
if (navigator.clipboard) await navigator.clipboard.writeText(text);
note("完整 JSON 已复制");
} catch (_error) {
jsonEditor.focus();
jsonEditor.select();
note("已选中当前模块,可手动复制");
}
});
qs("#downloadJson").addEventListener("click", () => {
if (!storeActiveDraft()) return;
const blob = new Blob([JSON.stringify(editorDraft, null, 2) + "\n"], {type: "application/json"});
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "white-house-page-data.json";
link.click();
window.setTimeout(() => URL.revokeObjectURL(link.href), 0);
note("JSON 已下载");
});
document.addEventListener("keydown", (event) => {
if (event.key === "Escape") {
[menuOverlay, searchOverlay, liveOverlay].forEach((layer) => { if (layer.classList.contains("open")) closeLayer(layer); });
if (settingsOverlay.classList.contains("open")) closeSettings();
}
});
renderAll();
function installJsonMediaUpload(){
const editor=document.getElementById("jsonEditor"),apply=document.getElementById("applyJson");if(!editor||!apply||document.getElementById("uploadJsonMedia"))return;
const actions=apply.parentElement,button=document.createElement("button"),input=document.createElement("input"),reference=actions.querySelector("#downloadJson,#copyJson,#validateJson,#resetJson");button.type="button";button.id="uploadJsonMedia";button.className=reference?reference.className:apply.className;button.textContent="上传图片/视频";button.title="先把光标放进要替换的内容对象,再选择图片或视频";input.type="file";input.accept="image/*,video/*";input.hidden=true;actions.insertBefore(button,apply);actions.appendChild(input);
const report=(message)=>{const status=document.getElementById("settingsStatus")||document.getElementById("jsonError")||document.getElementById("jsonStatus");if(status)status.textContent=message};
const findTarget=(text,cursor)=>{const stack=[],matches=[];let quoted=false,escaped=false;for(let index=0;index<text.length;index+=1){const char=text[index];if(quoted){if(escaped)escaped=false;else if(char==="\\")escaped=true;else if(char==='"')quoted=false;continue}if(char==='"'){quoted=true;continue}if(char==="{")stack.push(index);else if(char==="}"){const start=stack.pop();if(start===undefined||cursor<start||cursor>index+1)continue;try{const value=JSON.parse(text.slice(start,index+1)),own=(key)=>Object.prototype.hasOwnProperty.call(value,key);if(value&&!Array.isArray(value)&&(own("media")||own("visual")||(own("id")&&(own("text")||own("title"))&&(own("author")||own("channel")||own("user")))))matches.push({start,end:index+1,value})}catch(_error){/* full validator handles malformed JSON */}}}return matches.sort((left,right)=>(left.end-left.start)-(right.end-right.start))[0]||null};
button.addEventListener("click",()=>{input.value="";report("请选择图片或视频;文件会写入光标所在内容对象的 media 字段。");input.click()});
input.addEventListener("change",()=>{const file=input.files&&input.files[0];if(!file)return;const type=file.type.startsWith("image/")?"image":file.type.startsWith("video/")?"video":"";if(!type){report("仅支持图片或视频文件。");return}const target=findTarget(editor.value,editor.selectionStart);if(!target){report("请先把光标放进带 visual/media 的内容对象,或带 id 的帖子/视频对象内。");return}const reader=new FileReader();reader.onerror=()=>report("文件读取失败,请重新选择。");reader.onload=()=>{const previous=target.value.media&&typeof target.value.media==="object"?target.value.media:{},media={type,mediaUrl:String(reader.result)};for(const key of ["alt","label","caption","pageUrl"])if(typeof previous[key]==="string")media[key]=previous[key];if(!media.alt)media.alt=type==="image"?"用户上传的图片":"用户上传的视频";target.value.media=media;const lineStart=editor.value.lastIndexOf("\n",target.start-1)+1,indent=(editor.value.slice(lineStart,target.start).match(/^\s*/)||[""])[0],replacement=JSON.stringify(target.value,null,2).split("\n").map((line,index)=>index?indent+line:line).join("\n");editor.value=editor.value.slice(0,target.start)+replacement+editor.value.slice(target.end);editor.dispatchEvent(new Event("input",{bubbles:true}));const mediaIndex=replacement.indexOf('"media"');editor.focus();editor.setSelectionRange(target.start+Math.max(mediaIndex,0),target.start+Math.max(mediaIndex,0));report(`已把 ${file.name} 写入 JSON,请点击“应用并渲染”。${file.size>2*1024*1024?" 文件较大,建议同时下载 JSON 保存。":""}`)};reader.readAsDataURL(file)});
}
installJsonMediaUpload();
function installInlineMediaReplace() {
if (document.getElementById("dfInlineMediaInput")) return;
const visualHostSelector = ".post-media,.video-visual,.thumbnail-visual,.short-thumb,.watch-visual,.thread-media,.visual,.lead-visual,.mini-visual,.compact-media,.card-art,.story-visual,.art,.video-art,.media-art,.player-stage,.thumbnail,.thumb,.list-thumb,.focus-thumb,.involve-bg,.hero-art,#heroArt,#adminArt";
const getRootData = () => {
if (typeof pageData !== "undefined") return pageData;
if (typeof data !== "undefined") return data;
return null;
};
const input = document.createElement("input");
input.id = "dfInlineMediaInput";
input.type = "file";
input.hidden = true;
document.body.appendChild(input);
const style = document.createElement("style");
style.dataset.dfInlineMediaReplace = "true";
style.textContent = ".df-inline-media-host{position:relative!important}.df-inline-media-button{position:absolute;z-index:40;top:10px;right:10px;width:40px;height:40px;padding:0;border:1px solid rgba(255,255,255,.55);border-radius:50%;display:grid;place-items:center;color:#fff;background:rgba(8,15,28,.78);box-shadow:0 8px 24px rgba(0,0,0,.28);backdrop-filter:blur(8px);cursor:pointer;opacity:0;transform:translateY(-4px);transition:opacity .16s,transform .16s,background .16s}.df-inline-media-button:hover{background:rgba(20,110,240,.92)}.df-inline-media-button svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.df-inline-media-host:hover>.df-inline-media-button,.df-inline-media-host:focus-within>.df-inline-media-button,.df-inline-media-button:focus-visible{opacity:1;transform:none}@media(hover:none){.df-inline-media-button{opacity:1;transform:none}}.df-inline-media-toast{position:fixed;z-index:2147483647;left:50%;bottom:28px;max-width:min(88vw,520px);padding:10px 14px;border-radius:10px;color:#fff;background:rgba(15,23,42,.94);box-shadow:0 12px 32px rgba(0,0,0,.28);font:600 13px/1.45 system-ui,sans-serif;transform:translateX(-50%)}";
document.head.appendChild(style);
const notify = (message) => {
if (typeof showToast === "function") { showToast(message); return; }
if (typeof toast === "function") { toast(message); return; }
let notice = document.getElementById("dfInlineMediaToast");
if (!notice) {
notice = document.createElement("div");
notice.id = "dfInlineMediaToast";
notice.className = "df-inline-media-toast";
document.body.appendChild(notice);
}
notice.textContent = message;
window.clearTimeout(notice._timer);
notice._timer = window.setTimeout(() => notice.remove(), 2600);
};
const sameSource = (value, source, absolute) => {
if (typeof value !== "string") return false;
if (value === source || value === absolute) return true;
try { return new URL(value, location.href).href === absolute; } catch (_error) { return false; }
};
const findMatches = (source, absolute) => {
const matches = [];
const stack = [];
const visit = (value) => {
if (Array.isArray(value)) { value.forEach(visit); return; }
if (!value || typeof value !== "object") return;
stack.push(value);
Object.entries(value).forEach(([key, item]) => {
if ((key === "mediaUrl" || key === "posterUrl") && sameSource(item, source, absolute)) {
const ancestors = stack.slice(0, -1).reverse();
const owner = ancestors.find((candidate) => candidate && typeof candidate === "object" && !Array.isArray(candidate) && ("id" in candidate || "title" in candidate || "text" in candidate || "name" in candidate || "author" in candidate)) || ancestors[0] || value;
matches.push({ owner, previous: value, key });
}
if (item && typeof item === "object") visit(item);
});
stack.pop();
};
visit(getRootData());
return matches;
};
const visualOwners = () => {
const owners = [];
const seen = new Set();
const visit = (value) => {
if (Array.isArray(value)) { value.forEach(visit); return; }
if (!value || typeof value !== "object") return;
const hasVisual = Object.prototype.hasOwnProperty.call(value, "visual") || (value.media && typeof value.media === "object");
const hasIdentity = ["id", "title", "text", "leadTitle", "feature", "name", "author"].some((key) => typeof value[key] === "string" && value[key].trim());
if (hasVisual && hasIdentity && !seen.has(value)) { seen.add(value); owners.push(value); }
Object.values(value).forEach((item) => { if (item && typeof item === "object") visit(item); });
};
visit(getRootData());
return owners;
};
const domIdentifiers = (element) => {
const values = new Set();
let cursor = element;
for (let depth = 0; cursor && cursor !== document.body && depth < 8; depth += 1, cursor = cursor.parentElement) {
Object.values(cursor.dataset || {}).forEach((value) => { if (value) values.add(String(value)); });
}
return values;
};
const chooseVisualTarget = (element) => {
const identifiers = domIdentifiers(element);
const context = element.closest("article,button,[data-post-id],[data-video-id],[data-short-id],.post,.video-card,.news-card,.story-card,.lead-story,.hero") || element.parentElement || element;
const contextText = String(context.textContent || "").replace(/\s+/g, " ").trim();
const visualNode = element.closest("[data-visual]") || element.querySelector && element.querySelector("[data-visual]");
const visualValue = visualNode && visualNode.dataset ? visualNode.dataset.visual : "";
let best = null;
let bestScore = 0;
visualOwners().forEach((owner) => {
let score = 0;
Object.entries(owner).forEach(([key, value]) => {
if (/id$/i.test(key) && identifiers.has(String(value))) score += 100;
});
["title", "text", "leadTitle", "feature", "visualLabel", "label", "author", "name", "summary"].forEach((key) => {
const value = typeof owner[key] === "string" ? owner[key].trim() : "";
if (value.length >= 2 && contextText.includes(value)) score += Math.min(40, value.length);
});
if (visualValue && owner.visual === visualValue) score += 20;
if (score > bestScore) { best = owner; bestScore = score; }
});
if (!best || bestScore <= 0) return null;
return { owner: best, previous: best.media && typeof best.media === "object" ? best.media : { type: "image" }, key: "mediaUrl" };
};
const chooseTarget = (element) => {
const source = element.getAttribute("src") || "";
const absolute = element.currentSrc || element.src || source;
const matches = findMatches(source, absolute);
if (!matches.length) return null;
const identifiers = domIdentifiers(element);
return matches.find(({ owner }) => Object.entries(owner).some(([key, value]) => /id$/i.test(key) && identifiers.has(String(value)))) || matches[0];
};
const persist = () => {
const root = getRootData();
if (typeof saveData === "function") return saveData();
if (typeof writeStorage === "function" && typeof storageKey !== "undefined") return writeStorage(storageKey, JSON.stringify(root));
if (typeof writeStorage === "function" && typeof dataKey !== "undefined") return writeStorage(dataKey, JSON.stringify(root));
return false;
};
let active = null;
const attachButton = (host, target) => {
if (!host || !target || host.querySelector(":scope > .df-inline-media-button")) return;
host.classList.add("df-inline-media-host");
const button = document.createElement("button");
button.type = "button";
button.className = "df-inline-media-button";
button.setAttribute("aria-label", "替换图片或视频");
button.title = "上传图片或视频并替换";
button.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 16V4m0 0L7.5 8.5M12 4l4.5 4.5"/><path d="M5 14v4a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-4"/></svg>';
button.addEventListener("click", (event) => {
event.preventDefault();
event.stopPropagation();
active = { ...target };
input.accept = "image/*,video/*";
input.value = "";
input.click();
});
host.appendChild(button);
};
const decorateBuiltInVisuals = () => {
document.querySelectorAll(visualHostSelector).forEach((host) => {
if (host.querySelector("img[src],video[src],iframe[src],:scope > .df-inline-media-button")) return;
if (!host.querySelector("svg") && !host.dataset.visual) return;
const target = chooseVisualTarget(host);
if (!target) return;
attachButton(host, target);
});
};
const decorate = () => {
decorateBuiltInVisuals();
document.querySelectorAll("img[src],video[src]").forEach((media) => {
if (media.dataset.dfInlineMediaReady === "true") return;
const target = chooseTarget(media);
if (!target) return;
const host = media.closest(visualHostSelector) || media.parentElement;
if (!host) return;
media.dataset.dfInlineMediaReady = "true";
attachButton(host, target);
});
};
input.addEventListener("change", () => {
const file = input.files && input.files[0];
if (!file || !active) return;
const uploadedType = file.type.startsWith("image/") ? "image" : file.type.startsWith("video/") ? "video" : "";
if (!uploadedType) {
notify("请选择图片或视频文件。");
return;
}
const reader = new FileReader();
reader.onerror = () => notify("文件读取失败,请重新选择。");
reader.onload = () => {
const next = { ...(active.previous || {}) };
const result = String(reader.result);
next.type = uploadedType;
next.mediaUrl = result;
delete next.posterUrl;
if (!next.alt) next.alt = uploadedType === "video" ? "用户上传的视频" : "用户上传的图片";
active.owner.media = next;
const stored = persist();
renderAll();
notify(stored === false ? "媒体已替换;浏览器未能缓存,请下载 JSON 留存。" : "媒体已替换并写入页面 JSON。");
active = null;
};
reader.readAsDataURL(file);
});
let queued = false;
const queueDecorate = () => {
if (queued) return;
queued = true;
requestAnimationFrame(() => { queued = false; decorate(); });
};
new MutationObserver(queueDecorate).observe(document.body, { childList: true, subtree: true });
decorate();
}
installInlineMediaReplace();
})();
@@ -0,0 +1,62 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="A White House-style civic government portal concept.">
<meta name="theme-color" content="#0b1f3b">
<title>美国白宫——公共事务门户概念页</title>
<style>
:root{--navy:#0a1f3b;--navy2:#102f55;--cream:#f5f0e7;--paper:#fff;--ink:#122033;--muted:#5e6875;--gold:#c9a45c;--red:#a7282f;--line:#d8d4cc;--soft:#eef2f5;--max:1320px;--serif:Georgia,"Times New Roman",serif;--sans:Arial,Helvetica,sans-serif;--shadow:0 24px 70px rgba(4,17,34,.22)}
*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:var(--paper);color:var(--ink);font:16px/1.55 var(--sans)}body.dark{--paper:#0d1722;--ink:#f2f0e9;--cream:#172331;--soft:#152331;--line:#344553;--muted:#abb5bf}a{color:inherit;text-decoration:none}button,input,textarea{font:inherit}button{border:0;background:none;color:inherit}button,a{cursor:pointer}svg{display:block;width:100%;height:100%}:focus-visible{outline:3px solid #e9bd65;outline-offset:3px}.wrap{width:min(var(--max),calc(100% - 48px));margin:auto}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.skip{position:fixed;left:12px;top:calc(var(--df-generated-header-height,0px) + 10px);z-index:500;background:#fff;color:#111;padding:10px 14px;font-weight:800;transform:translateY(-160%);transition:.2s}.skip:focus{transform:none}.tricolor{height:6px;background:linear-gradient(90deg,var(--red) 0 33.333%,#fff 33.333% 66.666%,var(--navy) 66.666%)}
.site-head{position:absolute;top:calc(var(--df-generated-header-height,0px) + 6px);left:0;right:0;z-index:40;color:#fff;border-bottom:1px solid rgba(255,255,255,.35)}.site-head.scrolled{position:fixed;top:var(--df-generated-header-height,0px);background:var(--paper);color:var(--ink);border-bottom:1px solid var(--line);box-shadow:0 4px 18px rgba(0,0,0,.1)}.nav-row{height:96px;display:grid;grid-template-columns:1fr auto 1fr;align-items:center}.nav-side{display:flex;align-items:center;gap:22px}.nav-side.right{justify-content:flex-end}.nav-link{font-size:13px;text-transform:uppercase;letter-spacing:.13em;font-weight:800;padding:13px 0;border-bottom:2px solid transparent}.nav-link:hover{border-color:var(--gold)}.icon-link{width:46px;height:46px;display:grid;place-items:center;border:1px solid currentColor;border-radius:50%;transition:background .2s,color .2s}.icon-link:hover{background:#fff;color:var(--navy)}.scrolled .icon-link:hover{background:var(--navy);color:#fff}.icon-link svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.8}.wordmark{text-align:center;text-transform:uppercase;min-width:310px}.seal{display:block;width:54px;height:54px;margin:0 auto 5px;border:1px solid currentColor;border-radius:50%;padding:5px}.wordmark strong{display:block;font:700 15px/1 var(--serif);letter-spacing:.18em}.wordmark small{font-size:8px;letter-spacing:.29em}.menu-label{display:flex;align-items:center;gap:8px}.menu-label svg{width:20px;height:20px}.settings-trigger{position:fixed;right:18px;top:calc(var(--df-generated-header-height,0px) + 120px);z-index:86;width:46px;height:46px;border-radius:50%;display:grid;place-items:center;background:rgba(7,27,50,.94);color:#fff;border:1px solid rgba(255,255,255,.5);box-shadow:0 8px 25px rgba(0,0,0,.25);transition:.2s}.settings-trigger:hover{background:var(--red);transform:translateY(-1px)}.settings-trigger svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.9}
.hero{height:min(880px,100svh);min-height:690px;position:relative;background:#15293b;color:#fff;overflow:hidden}.hero-art{position:absolute;inset:0}.hero-art::after{content:"";position:absolute;inset:0;background:linear-gradient(90deg,rgba(5,16,31,.78) 0%,rgba(5,16,31,.35) 49%,rgba(5,16,31,.12) 70%),linear-gradient(0deg,rgba(5,16,31,.86),transparent 46%)}.hero-content{position:relative;z-index:2;height:100%;display:flex;align-items:center;padding-top:90px}.hero-copy{max-width:770px}.hero-kicker{text-transform:uppercase;letter-spacing:.28em;font-size:12px;color:#f0d28f;font-weight:800;margin-bottom:15px}.hero h1{font:500 clamp(58px,8.4vw,126px)/.84 var(--serif);letter-spacing:-.045em;text-transform:uppercase;margin:0 0 24px;text-wrap:balance}.hero h1 span{display:block;font-style:italic;font-size:.47em;letter-spacing:.02em;margin-top:13px;color:#f1e8d8}.hero-dek{font-family:var(--serif);font-size:21px;line-height:1.5;max-width:640px;color:#f5f1e9;margin:0 0 28px}.hero-actions{display:flex;gap:12px;flex-wrap:wrap}.btn{min-height:48px;padding:0 22px;display:inline-flex;align-items:center;justify-content:center;gap:9px;text-transform:uppercase;letter-spacing:.12em;font-size:12px;font-weight:900;transition:background .2s,color .2s,border .2s}.btn.light{background:#fff;color:var(--navy)}.btn.light:hover{background:var(--gold)}.btn.outline{border:1px solid rgba(255,255,255,.7);color:#fff}.btn.outline:hover{background:#fff;color:var(--navy)}.btn svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2}.hero-brief{position:absolute;z-index:3;right:max(24px,calc((100vw - var(--max))/2));bottom:30px;width:330px;background:rgba(10,31,59,.9);border:1px solid rgba(255,255,255,.35);padding:19px;backdrop-filter:blur(10px)}.brief-top{display:flex;justify-content:space-between;align-items:center;color:#e9cc89;font-size:11px;text-transform:uppercase;letter-spacing:.13em}.live-dot{width:8px;height:8px;border-radius:50%;background:#ef4452;display:inline-block;margin-right:7px;box-shadow:0 0 0 4px rgba(239,68,82,.2)}.hero-brief h2{font:500 23px/1.18 var(--serif);margin:11px 0 8px}.hero-brief p{font-size:12px;color:#d6dee6;margin:0}.scroll-note{position:absolute;z-index:3;left:50%;bottom:28px;transform:translateX(-50%);font-size:9px;text-transform:uppercase;letter-spacing:.2em;display:flex;flex-direction:column;align-items:center;gap:8px}.scroll-line{height:32px;width:1px;background:#fff}
.alert{background:var(--red);color:#fff}.alert .wrap{min-height:52px;display:grid;grid-template-columns:auto 1fr auto;align-items:center}.alert b{text-transform:uppercase;letter-spacing:.12em;font-size:11px;padding-right:18px}.alert a{padding:0 18px;border-left:1px solid rgba(255,255,255,.35);font-family:var(--serif);font-size:15px;font-weight:700}.alert time{font-size:11px;opacity:.8}
.section{padding:78px 0}.section.cream{background:var(--cream)}.section.navy{background:var(--navy);color:#fff}.eyebrow{font-size:10px;text-transform:uppercase;letter-spacing:.25em;font-weight:900;color:var(--red);margin-bottom:12px}.navy .eyebrow{color:#edcc87}.section-head{display:flex;justify-content:space-between;align-items:end;margin-bottom:32px}.section-head h2{font:500 clamp(43px,5.4vw,78px)/.94 var(--serif);letter-spacing:-.035em;text-transform:uppercase;margin:0}.section-head p{max-width:430px;color:var(--muted);margin:0;font-family:var(--serif);font-size:17px}.navy .section-head p{color:#c8d3dd}
.news-grid{display:grid;grid-template-columns:1.3fr 1fr 1fr;gap:20px}.news-card{border-top:1px solid var(--ink);padding-top:13px}.news-card.feature{grid-row:span 2}.card-art{aspect-ratio:16/10;background:#c5d1d8;margin-bottom:15px;overflow:hidden}.news-card.feature .card-art{aspect-ratio:4/3}.news-type{font-size:10px;color:var(--red);text-transform:uppercase;letter-spacing:.16em;font-weight:900}.news-card h3{font:600 23px/1.16 var(--serif);margin:8px 0}.news-card.feature h3{font-size:35px}.news-card p{font-size:13px;color:var(--muted);margin:0 0 9px}.news-card time{font-size:10px;text-transform:uppercase;letter-spacing:.1em;color:var(--muted)}.news-card:hover h3{color:var(--red)}
.priority-intro{display:grid;grid-template-columns:.8fr 1.2fr;gap:60px;align-items:end;margin-bottom:35px}.priority-intro h2{font:500 clamp(50px,7vw,98px)/.88 var(--serif);letter-spacing:-.04em;text-transform:uppercase;margin:0}.priority-intro p{font-family:var(--serif);font-size:19px;line-height:1.55;color:#c5d1db;max-width:630px}.priority-grid{display:grid;grid-template-columns:repeat(4,1fr);border-top:1px solid rgba(255,255,255,.3);border-bottom:1px solid rgba(255,255,255,.3)}.priority{padding:27px 22px;min-height:260px;border-right:1px solid rgba(255,255,255,.3);position:relative;transition:background .2s}.priority:last-child{border-right:0}.priority:hover,.priority.active{background:rgba(255,255,255,.08)}.priority-no{font:italic 48px/1 var(--serif);color:#d5b46e;display:block;margin-bottom:43px}.priority h3{font:600 24px/1.1 var(--serif);text-transform:uppercase;margin:0 0 12px}.priority p{font-size:13px;color:#c7d3dc;margin:0}.priority-arrow{position:absolute;right:20px;top:25px;width:30px;height:30px;border:1px solid rgba(255,255,255,.4);border-radius:50%;display:grid;place-items:center}.priority-arrow svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:2}.priority-detail{margin-top:25px;display:grid;grid-template-columns:1fr auto;align-items:center;padding:20px 22px;border:1px solid rgba(255,255,255,.3);min-height:86px}.priority-detail b{font:500 20px var(--serif)}.priority-detail span{font-size:13px;color:#c8d3dc}.priority-detail a{color:#efd18e;text-transform:uppercase;letter-spacing:.12em;font-size:11px;font-weight:900}
.admin{display:grid;grid-template-columns:1fr 1fr;min-height:650px}.admin-art{background:#ddd2c0;overflow:hidden}.admin-copy{padding:70px max(42px,calc((100vw - var(--max))/2));padding-right:max(42px,calc((100vw - var(--max))/2));display:flex;flex-direction:column;justify-content:center;background:var(--cream)}.admin-copy h2{font:500 clamp(48px,5.7vw,82px)/.93 var(--serif);text-transform:uppercase;letter-spacing:-.04em;margin:0 0 22px}.admin-copy .lead{font:italic 22px/1.45 var(--serif);margin:0 0 22px}.admin-copy p{color:var(--muted);max-width:590px}.signature{font:italic 33px/1 var(--serif);color:var(--navy);margin:22px 0}.dark .signature{color:#e6c77e}.admin-links{display:flex;gap:16px;flex-wrap:wrap}.admin-links a{font-size:11px;text-transform:uppercase;letter-spacing:.12em;font-weight:900;border-bottom:2px solid var(--red);padding-bottom:5px}
.calendar-head{display:flex;justify-content:space-between;align-items:end;margin-bottom:32px}.calendar-head h2{font:500 clamp(48px,6vw,86px)/.9 var(--serif);text-transform:uppercase;margin:0}.countdown{text-align:right}.countdown b{display:block;font:500 45px/1 var(--serif);color:var(--red)}.countdown span{text-transform:uppercase;letter-spacing:.14em;font-size:10px}.calendar-shell{display:grid;grid-template-columns:1fr 1.8fr;border:1px solid var(--line)}.calendar-info{background:var(--navy);color:#fff;padding:35px}.calendar-info h3{font:500 34px/1.08 var(--serif);margin:0 0 13px}.calendar-info p{font-size:13px;color:#cbd6df}.month-controls{display:flex;align-items:center;gap:12px;margin-top:35px}.month-controls button{width:44px;height:44px;border:1px solid rgba(255,255,255,.4);display:grid;place-items:center}.month-controls button:hover{background:#fff;color:var(--navy)}.month-controls svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2}.month-label{font:500 18px var(--serif);min-width:120px;text-align:center}.events{padding:18px 28px}.event{display:grid;grid-template-columns:90px 1fr auto;gap:20px;align-items:center;padding:18px 0;border-bottom:1px solid var(--line)}.event:last-child{border-bottom:0}.event-date b{font:500 32px/1 var(--serif)}.event-date span{font-size:10px;text-transform:uppercase;letter-spacing:.12em;display:block;color:var(--muted)}.event h3{font:600 20px var(--serif);margin:0 0 4px}.event p{font-size:12px;color:var(--muted);margin:0}.event-tag{font-size:9px;text-transform:uppercase;letter-spacing:.13em;border:1px solid var(--line);padding:6px 8px}
.involve-grid{display:grid;grid-template-columns:1.3fr 1fr 1fr;gap:17px}.involve-card{position:relative;min-height:350px;padding:28px;display:flex;flex-direction:column;justify-content:flex-end;overflow:hidden;color:#fff;background:var(--navy)}.involve-card:first-child{min-height:470px;grid-row:span 2}.involve-bg{position:absolute;inset:0}.involve-bg::after{content:"";position:absolute;inset:0;background:linear-gradient(0deg,rgba(5,18,35,.9),rgba(5,18,35,.06) 70%)}.involve-copy{position:relative;z-index:2}.involve-copy span{font-size:10px;text-transform:uppercase;letter-spacing:.16em;color:#efcf88}.involve-copy h3{font:500 31px/1.05 var(--serif);text-transform:uppercase;margin:8px 0 11px}.involve-card:first-child h3{font-size:45px}.involve-copy p{font-size:13px;color:#d6e0e8;max-width:390px}.involve-copy a{display:inline-flex;align-items:center;gap:8px;text-transform:uppercase;letter-spacing:.12em;font-size:10px;font-weight:900;border-bottom:1px solid #fff;padding-bottom:5px}
.newsletter{background:var(--red);color:#fff;padding:55px 0}.newsletter .wrap{display:grid;grid-template-columns:1fr 1fr;gap:60px;align-items:center}.newsletter h2{font:500 clamp(39px,4.6vw,67px)/.95 var(--serif);text-transform:uppercase;margin:0}.newsletter p{font-family:var(--serif);font-size:17px;margin:10px 0 0;color:#f5dde0}.sub-form{display:grid;grid-template-columns:1fr auto;gap:8px}.sub-form input{height:54px;min-width:0;border:1px solid rgba(255,255,255,.7);background:transparent;color:#fff;padding:0 15px;font-size:16px}.sub-form input::placeholder{color:#f5dadd}.sub-form button{height:54px;background:#fff;color:var(--red);padding:0 22px;text-transform:uppercase;letter-spacing:.12em;font-size:11px;font-weight:900}.sub-status{grid-column:1/-1;min-height:18px;font-size:12px;color:#fff}
footer{background:#06182e;color:#fff;padding:55px 0 25px}.foot-top{display:grid;grid-template-columns:1.2fr repeat(3,1fr);gap:44px}.foot-brand .seal{margin:0 0 12px;width:66px;height:66px}.foot-brand strong{font:500 25px/1.15 var(--serif);text-transform:uppercase}.foot-brand p{font-size:12px;color:#b9c7d2;max-width:250px}.foot-col h3{text-transform:uppercase;letter-spacing:.13em;color:#e9c97f;font-size:10px;margin:0 0 14px}.foot-col a{display:block;font-size:13px;margin:9px 0;color:#dce5ec}.foot-col a:hover{color:#fff;text-decoration:underline}.foot-bottom{margin-top:42px;padding-top:17px;border-top:1px solid rgba(255,255,255,.2);display:flex;justify-content:space-between;font-size:10px;text-transform:uppercase;letter-spacing:.1em;color:#aebfcb}
.menu-overlay,.search-overlay,.live-overlay{position:fixed;inset:0;z-index:150;background:rgba(5,17,32,.96);color:#fff;display:none}.menu-overlay.open,.search-overlay.open{display:block}.overlay-head{height:92px;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;border-bottom:1px solid rgba(255,255,255,.25)}.overlay-head .wordmark{grid-column:2}.overlay-close{justify-self:end;width:48px;height:48px;border:1px solid rgba(255,255,255,.45);border-radius:50%;font-size:27px}.menu-body{height:calc(100% - 92px);overflow:auto;padding:55px 0}.menu-grid{display:grid;grid-template-columns:1fr 2fr;gap:70px}.menu-feature{border-right:1px solid rgba(255,255,255,.25);padding-right:50px}.menu-feature h2{font:500 48px/1 var(--serif);text-transform:uppercase;margin:0 0 18px}.menu-feature p{color:#bfcbd4}.menu-main{display:grid;grid-template-columns:repeat(3,1fr);gap:32px}.menu-col h3{font-size:10px;text-transform:uppercase;letter-spacing:.15em;color:#e6c678;margin:0 0 13px}.menu-col a{display:block;font:500 23px/1.2 var(--serif);margin:13px 0}.menu-col a:hover{color:#e9cb85}.search-body{height:calc(100% - 92px);display:grid;place-items:center}.search-form{width:min(850px,calc(100% - 40px))}.search-form label{display:block;font:500 48px var(--serif);text-transform:uppercase;margin-bottom:20px}.search-line{display:flex;border-bottom:2px solid #fff}.search-line input{flex:1;min-width:0;background:transparent;border:0;color:#fff;font-size:24px;padding:14px 0}.search-line button{width:56px;color:#fff}.search-line svg{width:25px;height:25px;fill:none;stroke:currentColor;stroke-width:2}.search-result{min-height:24px;color:#c5d2db;margin-top:13px}.live-overlay{background:rgba(0,0,0,.9);padding:20px;align-items:center;justify-content:center}.live-overlay.open{display:flex}.live-modal{width:min(950px,100%);background:#071b32;box-shadow:var(--shadow)}.live-head{height:62px;padding:0 18px;display:flex;align-items:center;border-bottom:1px solid rgba(255,255,255,.25)}.live-head b{font-size:13px;text-transform:uppercase;letter-spacing:.14em}.live-head .overlay-close{margin-left:auto}.live-player{aspect-ratio:16/9;background:radial-gradient(circle at center,#28445f,#030b13 70%);display:grid;place-items:center;position:relative;overflow:hidden}.live-player::before,.live-player::after{content:"";position:absolute;border:1px solid rgba(255,255,255,.12);width:55%;height:55%;transform:rotate(45deg)}.live-player::after{width:31%;height:31%}.live-copy{text-align:center;position:relative;z-index:2}.live-copy strong{display:block;font:500 38px var(--serif);text-transform:uppercase}.live-copy span{color:#c1ced8}.live-foot{padding:14px 18px;display:flex;justify-content:space-between;color:#bbc9d4;font-size:12px}.toast{position:fixed;right:18px;bottom:18px;background:#07192e;color:#fff;padding:13px 17px;z-index:200;transform:translateY(100px);opacity:0;transition:.22s}.toast.show{transform:none;opacity:1}
.settings-overlay{position:fixed;inset:0;z-index:400;display:none;align-items:center;justify-content:center;padding:30px;background:rgba(4,12,23,.88);backdrop-filter:blur(5px)}.settings-overlay.open{display:flex}.json-settings-modal{width:min(1360px,100%);height:min(830px,calc(100vh - 60px));background:#09182a;color:#eef6ff;border:1px solid #927847;box-shadow:0 24px 85px rgba(0,0,0,.55);display:grid;grid-template-rows:auto 1fr auto}.settings-head{min-height:108px;padding:22px 28px;border-bottom:1px solid #344861;display:flex;align-items:center}.settings-kicker{display:block;color:#e6c678;font-size:13px;font-weight:900;letter-spacing:.11em}.settings-head h2{margin:5px 0 0;font:500 29px var(--serif);text-transform:uppercase}.settings-close{margin-left:auto;width:48px;height:48px;border:1px solid #8c7549;color:#fff;font-size:29px}.settings-body{min-height:0;display:grid;grid-template-columns:285px 1fr;gap:22px;padding:22px 28px}.module-tabs{min-height:0;overflow:auto}.module-tabs h3{margin:0 0 10px;color:#aabbd0;font-size:14px}.module-tab{display:block;width:100%;padding:11px 14px;margin-bottom:7px;text-align:left;border:1px solid #344d69;background:#0d2138;color:#d9e6f2}.module-tab strong,.module-tab span{display:block}.module-tab strong{font-size:15px}.module-tab span{margin-top:2px;color:#8fa4bb;font-size:11px}.module-tab.active{border-color:#d1ac62;background:#18314d;box-shadow:inset 3px 0 #d1ac62}.editor-pane{min-width:0;min-height:0;display:grid;grid-template-rows:auto 1fr auto}.editor-title{display:flex;justify-content:space-between;align-items:center;margin-bottom:9px}.editor-title span,.editor-hint{color:#8fa4bb;font-size:12px}.json-editor{width:100%;min-height:0;resize:none;border:1px solid #586f8a;background:#020910;color:#e5f2ff;padding:18px;font:14px/1.55 Consolas,"Courier New",monospace;tab-size:2}.editor-hint{display:flex;justify-content:space-between;margin-top:9px}.json-status.valid{color:#69e2b5}.json-status.invalid{color:#ff8e8e}.settings-foot{min-height:86px;border-top:1px solid #344861;padding:18px 28px;display:flex;justify-content:flex-end;align-items:center;gap:10px}.editor-button{height:44px;padding:0 20px;border:1px solid #607a99;color:#eef6ff;background:#0d2138}.editor-button.primary{background:#d3ad63;color:#071426;border-color:#d3ad63;font-weight:900}
@media(max-width:1000px){.nav-link{display:none}.wordmark{min-width:240px}.hero-brief{width:290px}.news-grid{grid-template-columns:1.3fr 1fr}.news-card:last-child{display:none}.priority-grid{grid-template-columns:1fr 1fr}.priority:nth-child(2){border-right:0}.priority:nth-child(-n+2){border-bottom:1px solid rgba(255,255,255,.3)}.admin{grid-template-columns:.9fr 1.1fr}.calendar-shell{grid-template-columns:1fr 1.5fr}.involve-grid{grid-template-columns:1.2fr 1fr}.involve-card:last-child{display:none}.foot-top{grid-template-columns:1.2fr repeat(2,1fr)}.foot-col:last-child{display:none}.settings-body{grid-template-columns:235px 1fr}}
@media(max-width:720px){.wrap{width:calc(100% - 28px)}.site-head{top:6px}.nav-row{height:76px;grid-template-columns:1fr auto 1fr}.wordmark{min-width:0}.wordmark .seal{width:42px;height:42px}.wordmark strong{font-size:11px}.wordmark small{display:none}.nav-side{gap:4px}.menu-label span,.nav-side.right .nav-link{display:none}.icon-link{width:42px;height:42px;border:0}.settings-trigger{right:10px;top:94px;width:42px;height:42px}.hero{height:760px;min-height:0}.hero-content{align-items:flex-start;padding-top:170px}.hero-copy{max-width:100%}.hero h1{font-size:55px;line-height:.9}.hero h1 span{font-size:.5em}.hero-dek{font-size:18px}.hero-brief{left:14px;right:14px;bottom:25px;width:auto}.scroll-note{display:none}.alert .wrap{width:100%;grid-template-columns:auto 1fr}.alert time{display:none}.alert a{font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.section{padding:52px 0}.section-head{display:block}.section-head h2{font-size:43px}.section-head p{margin-top:15px}.news-grid{display:block}.news-card{margin-bottom:25px}.news-card.feature h3{font-size:29px}.news-card:last-child{display:block}.priority-intro{display:block}.priority-intro h2{font-size:51px}.priority-intro p{margin-top:20px}.priority-grid{display:block}.priority{border-right:0;border-bottom:1px solid rgba(255,255,255,.3)!important;min-height:210px}.priority:last-child{border-bottom:0!important}.priority-no{margin-bottom:27px}.priority-detail{display:block}.priority-detail a{display:block;margin-top:12px}.admin{display:block}.admin-art{height:460px}.admin-copy{padding:50px 22px}.admin-copy h2{font-size:51px}.calendar-head{display:block}.countdown{text-align:left;margin-top:19px}.calendar-shell{display:block}.events{padding:10px 17px}.event{grid-template-columns:66px 1fr}.event-tag{display:none}.involve-grid{display:block}.involve-card,.involve-card:first-child{min-height:400px;margin-bottom:13px}.involve-card:last-child{display:flex}.newsletter .wrap{grid-template-columns:1fr;gap:24px}.sub-form{display:block}.sub-form input,.sub-form button{width:100%;margin-bottom:8px}.foot-top{grid-template-columns:1fr 1fr}.foot-brand{grid-column:1/-1}.foot-col:last-child{display:block}.foot-bottom{display:block;line-height:1.8}.overlay-head{height:76px}.menu-body{height:calc(100% - 76px);padding:34px 0}.menu-grid{display:block}.menu-feature{border-right:0;border-bottom:1px solid rgba(255,255,255,.25);padding:0 0 25px;margin-bottom:25px}.menu-feature h2{font-size:38px}.menu-main{grid-template-columns:1fr 1fr}.search-form label{font-size:34px}.settings-overlay{padding:0}.json-settings-modal{height:100vh;width:100%;border:0}.settings-head{min-height:78px;padding:14px 16px}.settings-head h2{font-size:22px}.settings-body{display:block;padding:14px 16px;overflow:auto}.module-tabs{display:flex;gap:7px;overflow-x:auto;margin-bottom:12px}.module-tabs h3{display:none}.module-tab{min-width:150px;margin:0}.json-editor{height:54vh}.settings-foot{padding:10px 16px;overflow-x:auto;justify-content:flex-start}.editor-button{white-space:nowrap}}
@media(max-width:720px){.site-head{top:calc(var(--df-generated-header-height,0px) + 6px)}.settings-trigger{top:calc(var(--df-generated-header-height,0px) + 94px)}}
@media(max-width:400px){.hero h1{font-size:50px}.hero-actions{display:block}.hero-actions .btn{width:100%;margin-bottom:8px}.foot-top{display:block}.foot-col{margin-top:25px}.menu-main{display:block}.menu-col{margin-bottom:25px}.live-copy strong{font-size:28px}.live-foot{display:block}.live-foot button{margin-top:8px}}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;animation:none!important;transition:none!important}}
.skip{transform:translateY(calc(-100% - var(--df-generated-header-height,0px) - 24px))}.skip:focus{transform:none}
.menu-overlay,.search-overlay,.live-overlay{z-index:1200}.settings-overlay{z-index:1300}
</style>
</head>
<body id="top">
<a class="skip" id="skipLink" href="#main"></a><div class="tricolor"></div>
<header class="site-head" id="siteHead"><div class="wrap nav-row"><div class="nav-side"><button class="icon-link menu-label" id="menuOpen"><svg viewBox="0 0 24 24"><path d="M4 7h16M4 12h16M4 17h16"/></svg><span id="menuButtonLabel"></span></button><nav class="nav-side" id="leftNav"></nav></div><a class="wordmark" id="wordmark" href="#top"><span class="seal"><svg viewBox="0 0 64 64" aria-hidden="true"><path d="M9 48h46M15 45V28h34v17M12 28h40L32 14Z" fill="none" stroke="currentColor" stroke-width="2.3"/><path d="M20 31v12m8-12v12m8-12v12m8-12v12M8 52h48" stroke="currentColor" stroke-width="2"/></svg></span><strong id="brandName"></strong><small id="officeName"></small></a><div class="nav-side right"><nav class="nav-side" id="rightNav"></nav><button class="icon-link" id="searchOpen"><svg viewBox="0 0 24 24"><circle cx="10.8" cy="10.8" r="6.8"/><path d="m19.5 19.5-4-4"/></svg></button><button class="icon-link" id="themeToggle" aria-label="切换深色模式"><svg viewBox="0 0 24 24"><path d="M20.5 14.4A8.6 8.6 0 0 1 9.6 3.5a8.7 8.7 0 1 0 10.9 10.9Z"/></svg></button></div></div></header>
<button class="settings-trigger" id="openSettings" aria-label="编辑页面 JSON" title="编辑页面 JSON"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="3.5"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1-2.8 2.8-.1-.1a1.7 1.7 0 0 0-1.9-.3A1.7 1.7 0 0 0 14 21v.2h-4V21a1.7 1.7 0 0 0-1-1.6 1.7 1.7 0 0 0-1.9.3l-.1.1L4.2 17l.1-.1a1.7 1.7 0 0 0 .3-1.9A1.7 1.7 0 0 0 3 14H2.8v-4H3a1.7 1.7 0 0 0 1.6-1 1.7 1.7 0 0 0-.3-1.9L4.2 7 7 4.2l.1.1a1.7 1.7 0 0 0 1.9.3A1.7 1.7 0 0 0 10 3V2.8h4V3a1.7 1.7 0 0 0 1 1.6 1.7 1.7 0 0 0 1.9-.3l.1-.1L19.8 7l-.1.1a1.7 1.7 0 0 0 .3-1.9 1.7 1.7 0 0 0 1.6 1h.2v4H21a1.7 1.7 0 0 0-1.6 1Z"/></svg></button>
<main id="main" tabindex="-1">
<section class="hero"><div class="hero-art" id="heroArt"></div><div class="wrap hero-content"><div class="hero-copy"><div class="hero-kicker" id="heroKicker"></div><h1 id="heroTitle"></h1><p class="hero-dek" id="heroSummary"></p><div class="hero-actions"><a class="btn light" id="heroPrimary"></a><button class="btn outline open-live" id="heroLive"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="8"/><path d="m10 8 6 4-6 4Z"/></svg><span></span></button></div></div></div><aside class="hero-brief"><div class="brief-top"><span><i class="live-dot"></i><span id="briefLabel"></span></span><time id="briefTime"></time></div><h2 id="briefTitle"></h2><p id="briefSummary"></p></aside><div class="scroll-note"><span id="scrollLabel"></span><i class="scroll-line"></i></div></section>
<div class="alert"><div class="wrap"><b id="noticeLabel"></b><a id="noticeText"></a><time id="noticeDate"></time></div></div>
<section class="section wrap" id="news"><div class="section-head"><div><div class="eyebrow" id="updatesEyebrow"></div><h2 id="updatesTitle"></h2></div><p id="updatesSummary"></p></div><div class="news-grid" id="newsGrid"></div></section>
<section class="section navy" id="priorities"><div class="wrap"><div class="priority-intro"><div><div class="eyebrow" id="prioritiesEyebrow"></div><h2 id="prioritiesTitle"></h2></div><p id="prioritiesSummary"></p></div><div class="priority-grid" id="priorityGrid"></div><div class="priority-detail"><div><b id="priorityTitle"></b><br><span id="priorityText"></span></div><a id="priorityAgenda"></a></div></div></section>
<section class="admin" id="administration"><div class="admin-art" id="adminArt"></div><div class="admin-copy"><div class="eyebrow" id="adminEyebrow"></div><h2 id="adminTitle"></h2><p class="lead" id="adminQuote"></p><p id="adminDescription"></p><div class="signature" id="adminSignature"></div><div class="admin-links" id="adminLinks"></div></div></section>
<section class="section cream" id="calendar"><div class="wrap"><div class="calendar-head"><div><div class="eyebrow" id="calendarEyebrow"></div><h2 id="calendarTitle"></h2></div><div class="countdown"><b id="countdownValue"></b><span id="countdownLabel"></span></div></div><div class="calendar-shell"><div class="calendar-info"><div class="eyebrow" id="calendarPanelEyebrow"></div><h3 id="calendarPanelTitle"></h3><p id="calendarPanelText"></p><div class="month-controls"><button id="prevMonth" aria-label="上一个月"><svg viewBox="0 0 24 24"><path d="m15 6-6 6 6 6"/></svg></button><span class="month-label" id="monthLabel"></span><button id="nextMonth" aria-label="下一个月"><svg viewBox="0 0 24 24"><path d="m9 6 6 6-6 6"/></svg></button></div></div><div class="events" id="events"></div></div></div></section>
<section class="section wrap" id="involved"><div class="section-head"><div><div class="eyebrow" id="participationEyebrow"></div><h2 id="participationTitle"></h2></div><p id="participationSummary"></p></div><div class="involve-grid" id="participationGrid"></div></section>
<section class="newsletter"><div class="wrap"><div><h2 id="newsletterTitle"></h2><p id="newsletterText"></p></div><form class="sub-form" id="subForm"><label class="sr-only" for="email">电子邮箱</label><input id="email" type="email" required><button id="newsletterButton"></button><div class="sub-status" id="subStatus" aria-live="polite"></div></form></div></section>
</main>
<footer id="footer"><div class="wrap"><div class="foot-top"><div class="foot-brand"><span class="seal"><svg viewBox="0 0 64 64" aria-hidden="true"><path d="M9 48h46M15 45V28h34v17M12 28h40L32 14Z" fill="none" stroke="currentColor" stroke-width="2.3"/><path d="M20 31v12m8-12v12m8-12v12m8-12v12M8 52h48" stroke="currentColor" stroke-width="2"/></svg></span><strong id="footerBrand"></strong><p id="footerDescription"></p></div><div id="footerColumns" style="display:contents"></div></div><div class="foot-bottom"><span id="copyright"></span><span id="legal"></span></div></div></footer>
<div class="menu-overlay" id="menuOverlay" role="dialog" aria-modal="true" aria-labelledby="menuTitle"><div class="wrap overlay-head"><span></span><div class="wordmark"><span class="seal"><svg viewBox="0 0 64 64"><path d="M9 48h46M15 45V28h34v17M12 28h40L32 14Z" fill="none" stroke="currentColor" stroke-width="2.3"/></svg></span><strong id="menuBrand"></strong></div><button class="overlay-close" id="menuClose" aria-label="关闭菜单">×</button></div><div class="menu-body"><div class="wrap menu-grid"><div class="menu-feature"><div class="eyebrow" id="menuEyebrow"></div><h2 id="menuTitle"></h2><p id="menuText"></p><a class="btn outline" id="menuCta" data-close-menu></a></div><div class="menu-main" id="menuColumns"></div></div></div></div>
<div class="search-overlay" id="searchOverlay" role="dialog" aria-modal="true" aria-labelledby="searchTitle"><div class="wrap overlay-head"><span></span><div class="wordmark"><span class="seal"><svg viewBox="0 0 64 64"><path d="M9 48h46M15 45V28h34v17M12 28h40L32 14Z" fill="none" stroke="currentColor" stroke-width="2.3"/></svg></span><strong id="searchBrand"></strong></div><button class="overlay-close" id="searchClose" aria-label="关闭搜索">×</button></div><div class="search-body"><form class="search-form" id="searchForm"><label id="searchTitle" for="searchInput"></label><div class="search-line"><input id="searchInput" type="search"><button aria-label="提交搜索"><svg viewBox="0 0 24 24"><circle cx="10.8" cy="10.8" r="6.8"/><path d="m19.5 19.5-4-4"/></svg></button></div><div class="search-result" id="searchResult" aria-live="polite"></div></form></div></div>
<div class="live-overlay" id="liveOverlay" role="dialog" aria-modal="true" aria-labelledby="liveTitle"><div class="live-modal"><div class="live-head"><span class="live-dot"></span><b id="liveTitle"></b><button class="overlay-close" id="liveClose" aria-label="关闭直播">×</button></div><div class="live-player"><div class="live-copy"><strong id="liveStreamTitle"></strong><span id="liveStreamSubtitle"></span></div></div><div class="live-foot"><span id="liveLocation"></span><button id="captionToggle"></button></div></div></div>
<div class="toast" id="toast" role="status" aria-live="polite"></div>
<div class="settings-overlay" id="settingsOverlay" aria-hidden="true"><section class="json-settings-modal" role="dialog" aria-modal="true" aria-labelledby="settingsTitle"><header class="settings-head"><div><span class="settings-kicker">白宫页面模板控制台</span><h2 id="settingsTitle">JSON 编辑器</h2></div><button class="settings-close" id="closeSettings" aria-label="关闭 JSON 编辑器">×</button></header><div class="settings-body"><nav class="module-tabs" id="moduleTabs" aria-label="JSON 模块"><h3>页面模块</h3></nav><div class="editor-pane"><div class="editor-title"><strong id="editorModuleTitle">站点信息</strong><span>仅编辑当前选中的模块</span></div><textarea class="json-editor" id="jsonEditor" spellcheck="false" aria-label="当前模块 JSON"></textarea><div class="editor-hint"><span>先校验修改,再应用到页面。</span><span class="json-status valid" id="jsonStatus">JSON 有效</span></div></div></div><footer class="settings-foot"><button class="editor-button" id="resetJson">重置</button><button class="editor-button" id="copyJson">复制 JSON</button><button class="editor-button" id="downloadJson">下载 JSON</button><button class="editor-button primary" id="applyJson">应用并渲染</button></footer></section></div>
<script type="application/json" id="whiteHousePageData">__WHITE_HOUSE_PAGE_DATA__</script>
<script>__WHITE_HOUSE_PAGE_RUNTIME__</script>
</body>
</html>
@@ -0,0 +1,28 @@
# 白宫官网页面 JSON 契约
顶层必须完整包含 `site`、`navigation`、`hero`、`notice`、`updates`、`priorities`、`administration`、`calendar`、`participation`、`footer`。弹窗按十个模块分别编辑,应用时重新校验完整文档。
## 通用规则
- `site.language` 固定为 `zh-CN`。
- 所有标题、标签、摘要、按钮、日期、活动、机构名和页脚等读者可见文案必须使用简体中文;英文来源先翻译后再写入 JSON。
- JSON 键名以及 `id`、`href`、`visual`、`theme` 等技术值按契约保留英文,不要翻译或改名。
- 所有标题、标签、摘要和日期为字符串;关键展示字段不能为空。
- 列表有数量上限,同一业务列表中的 `id` 必须唯一。
- `href` 只允许以 `#` 开头的页面内锚点。
- JSON 文本不能包含 HTML、脚本、直接 iframe 或可执行代码。`hero` 以及具有 `visual` 的内容对象可增加 `media` 替换视觉:图片 `{type:"image", mediaUrl, alt?, pageUrl?}`;视频 `{type:"video", mediaUrl, posterUrl?, alt?, pageUrl?}`;网页 `{type:"webpage", pageUrl, title, description?, mediaUrl?, embed?}`。仅这些媒体 URL 字段允许 `http(s)`,图片/视频也允许对应的 `data:` URL。
## 模块
- `site`:机构名称、办公室名称、页面标题、描述、语言、`theme`(`light`/`dark`/`auto`)和跳转正文文案。
- `navigation`:左右主导航、菜单/搜索/主题按钮文案;全屏菜单含说明、CTA 和 1–4 个链接列;搜索含标题、占位和结果文案。
- `hero`:主视觉标签、两行标题、摘要、主要 CTA、直播 CTA、简报卡、滚动提示和直播弹窗;`visual` 固定为 `executive-house`。
- `notice`:公告标签、标题、日期和锚点。
- `updates.items`:1–8 条官方动态,`visual` 为 `hall`、`mobility`、`science`、`statement`、`action`;首条自动采用主卡布局。
- `priorities.items`:1–6 个优先事项,每项含标题、摘要和点击后展示的详情。
- `administration`:标题、引语、说明、签名、1–6 个链接和 `portrait` 视觉。
- `calendar.months`:1–6 个月份;每月含 1–8 个日期、月份缩写、标题、说明和标签。
- `participation.cards`:1–6 个公众参与入口,`visual` 为 `visit`、`letter`、`service`;另含订阅标题、说明、占位、按钮和成功提示。
- `footer.columns`:1–4 个链接列,每列 1–8 个锚点;另有机构说明、版权和法律文案。
JSON 使用双引号,不允许注释、Markdown 围栏或尾逗号。`assets/default-data.json` 是全中文结构示例和概念内容,不是事实来源。
@@ -0,0 +1,11 @@
#!/usr/bin/env python3
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "_shared"))
import render_white_house_page as renderer
from fast_patch_page import run
if __name__ == "__main__":
sys.exit(run(renderer, output_stem="white-house-page"))
@@ -0,0 +1,574 @@
#!/usr/bin/env python3
"""Validate White House page data and render the bundled template."""
from __future__ import annotations
import argparse
import json
import sys
from pathlib import Path
from typing import Any
from urllib.parse import urlparse
SKILL_DIR = Path(__file__).resolve().parents[1]
ASSETS_DIR = SKILL_DIR / "assets"
DEFAULT_DATA_PATH = ASSETS_DIR / "default-data.json"
TEMPLATE_PATH = ASSETS_DIR / "white-house-template.html"
RUNTIME_PATH = ASSETS_DIR / "white-house-runtime.js"
MODULES = (
"site",
"navigation",
"hero",
"notice",
"updates",
"priorities",
"administration",
"calendar",
"participation",
"footer",
)
UPDATE_VISUALS = {"hall", "mobility", "science", "statement", "action"}
PARTICIPATION_VISUALS = {"visit", "letter", "service"}
FORBIDDEN_TEXT = ("<script", "<iframe", "javascript:", "http://", "https://")
REMOTE_MEDIA_TYPES = {"image", "video", "webpage"}
MEDIA_URL_KEYS = {"mediaUrl", "posterUrl", "pageUrl"}
TECHNICAL_TEXT_KEYS = {"id", "href", "visual", "theme", "language", "day", "countdownValue", "type", "mediaUrl", "posterUrl", "pageUrl"}
class DataValidationError(ValueError):
"""Raised when JSON does not satisfy the fixed page contract."""
def _read_json(path: Path) -> dict[str, Any]:
try:
value = json.loads(path.read_text(encoding="utf-8"))
except FileNotFoundError as exc:
raise DataValidationError(f"input file does not exist: {path}") from exc
except json.JSONDecodeError as exc:
raise DataValidationError(
f"invalid JSON at line {exc.lineno}, column {exc.colno}: {exc.msg}"
) from exc
if not isinstance(value, dict):
raise DataValidationError("top-level JSON value must be an object")
return value
def _mapping(value: Any, path: str, errors: list[str]) -> dict[str, Any]:
if not isinstance(value, dict):
errors.append(f"{path} must be an object")
return {}
return value
def _array(
value: Any,
path: str,
errors: list[str],
*,
minimum: int,
maximum: int,
) -> list[Any]:
if not isinstance(value, list):
errors.append(f"{path} must be an array")
return []
if len(value) < minimum:
errors.append(f"{path} must contain at least {minimum} item(s)")
if len(value) > maximum:
errors.append(f"{path} must contain at most {maximum} item(s)")
return value
def _required_string(value: Any, path: str, errors: list[str]) -> None:
if not isinstance(value, str) or not value.strip():
errors.append(f"{path} must be a non-empty string")
def _href(value: Any, path: str, errors: list[str]) -> None:
_required_string(value, path, errors)
if isinstance(value, str) and not value.startswith("#"):
errors.append(f"{path} must be an in-page anchor beginning with #")
def _unique_id(item: dict[str, Any], path: str, seen: set[str], errors: list[str]) -> None:
item_id = item.get("id")
_required_string(item_id, f"{path}.id", errors)
if isinstance(item_id, str):
if item_id in seen:
errors.append(f"{path}.id duplicates {item_id!r}")
seen.add(item_id)
def _links(
value: Any,
path: str,
errors: list[str],
*,
minimum: int,
maximum: int,
) -> list[Any]:
items = _array(value, path, errors, minimum=minimum, maximum=maximum)
for index, raw in enumerate(items):
item = _mapping(raw, f"{path}[{index}]", errors)
_required_string(item.get("label"), f"{path}[{index}].label", errors)
_href(item.get("href"), f"{path}[{index}].href", errors)
return items
def _validate_no_remote_or_markup(value: Any, path: str, errors: list[str]) -> None:
if isinstance(value, dict):
for key, item in value.items():
if key in MEDIA_URL_KEYS:
continue
_validate_no_remote_or_markup(item, f"{path}.{key}", errors)
elif isinstance(value, list):
for index, item in enumerate(value):
_validate_no_remote_or_markup(item, f"{path}[{index}]", errors)
elif isinstance(value, str):
lowered = value.lower()
if any(token in lowered for token in FORBIDDEN_TEXT):
errors.append(f"{path} must not contain HTML, script, iframe, or remote URLs")
def _remote_url(value: Any, path: str, errors: list[str], *, required: bool = False, data_prefix: str = "") -> None:
if value in (None, "") and not required:
return
if not isinstance(value, str) or not value.strip():
errors.append(f"{path} must be a non-empty URL")
return
candidate = value.strip()
if data_prefix and candidate.lower().startswith(data_prefix):
return
parsed = urlparse(candidate)
if parsed.scheme not in {"http", "https"} or not parsed.netloc:
errors.append(f"{path} must use an http(s) URL")
def _validate_remote_media_tree(value: Any, path: str, errors: list[str]) -> None:
if isinstance(value, list):
for index, item in enumerate(value):
_validate_remote_media_tree(item, f"{path}[{index}]", errors)
return
if not isinstance(value, dict):
return
media = value.get("media")
if isinstance(media, dict) and "type" in media:
media_path = f"{path}.media"
media_data = _mapping(media, media_path, errors)
media_type = media_data.get("type")
if media_type not in REMOTE_MEDIA_TYPES:
errors.append(f"{media_path}.type must be one of: {', '.join(sorted(REMOTE_MEDIA_TYPES))}")
elif media_type in {"image", "video"}:
_remote_url(media_data.get("mediaUrl"), f"{media_path}.mediaUrl", errors, required=True, data_prefix=f"data:{media_type}/")
if media_type == "video":
_remote_url(media_data.get("posterUrl"), f"{media_path}.posterUrl", errors, data_prefix="data:image/")
if media_type == "webpage":
_remote_url(media_data.get("pageUrl"), f"{media_path}.pageUrl", errors, required=True)
_remote_url(media_data.get("mediaUrl"), f"{media_path}.mediaUrl", errors, data_prefix="data:image/")
if "embed" in media_data and not isinstance(media_data.get("embed"), bool):
errors.append(f"{media_path}.embed must be a boolean")
elif media_type in {"image", "video"}:
_remote_url(media_data.get("pageUrl"), f"{media_path}.pageUrl", errors)
for key, item in value.items():
if key != "media":
_validate_remote_media_tree(item, f"{path}.{key}", errors)
def _validate_chinese_reader_copy(
value: Any,
path: str,
errors: list[str],
*,
key: str | None = None,
) -> None:
if isinstance(value, dict):
for child_key, item in value.items():
_validate_chinese_reader_copy(
item,
f"{path}.{child_key}",
errors,
key=child_key,
)
elif isinstance(value, list):
for index, item in enumerate(value):
_validate_chinese_reader_copy(item, f"{path}[{index}]", errors, key=key)
elif (
isinstance(value, str)
and key not in TECHNICAL_TEXT_KEYS
and not (key and key.lower().endswith(("id", "href", "url")))
):
if not any("\u3400" <= character <= "\u9fff" for character in value):
errors.append(f"{path} must use Simplified Chinese reader-facing copy")
def validate_document(data: dict[str, Any]) -> dict[str, int]:
errors: list[str] = []
missing = [name for name in MODULES if name not in data]
extra = [name for name in data if name not in MODULES]
if missing:
errors.append("missing top-level module(s): " + ", ".join(missing))
if extra:
errors.append("unknown top-level module(s): " + ", ".join(extra))
site = _mapping(data.get("site"), "site", errors)
for key in (
"brandName",
"officeName",
"pageTitle",
"description",
"language",
"skipLabel",
):
_required_string(site.get(key), f"site.{key}", errors)
if site.get("language") != "zh-CN":
errors.append("site.language must be zh-CN")
if site.get("theme") not in {"light", "dark", "auto"}:
errors.append("site.theme must be light, dark, or auto")
navigation = _mapping(data.get("navigation"), "navigation", errors)
for key in ("menuLabel", "searchLabel", "themeLightLabel", "themeDarkLabel"):
_required_string(navigation.get(key), f"navigation.{key}", errors)
left_links = _links(
navigation.get("leftLinks"),
"navigation.leftLinks",
errors,
minimum=1,
maximum=5,
)
right_links = _links(
navigation.get("rightLinks"),
"navigation.rightLinks",
errors,
minimum=1,
maximum=5,
)
menu = _mapping(navigation.get("menu"), "navigation.menu", errors)
for key in ("eyebrow", "title", "text", "ctaLabel"):
_required_string(menu.get(key), f"navigation.menu.{key}", errors)
_href(menu.get("ctaHref"), "navigation.menu.ctaHref", errors)
menu_columns = _array(
menu.get("columns"),
"navigation.menu.columns",
errors,
minimum=1,
maximum=4,
)
seen_menu: set[str] = set()
menu_links = 0
for index, raw in enumerate(menu_columns):
item_path = f"navigation.menu.columns[{index}]"
item = _mapping(raw, item_path, errors)
_unique_id(item, item_path, seen_menu, errors)
_required_string(item.get("title"), f"{item_path}.title", errors)
menu_links += len(
_links(
item.get("links"),
f"{item_path}.links",
errors,
minimum=1,
maximum=8,
)
)
search = _mapping(navigation.get("search"), "navigation.search", errors)
for key in ("title", "placeholder", "emptyMessage", "resultPrefix"):
_required_string(search.get(key), f"navigation.search.{key}", errors)
hero = _mapping(data.get("hero"), "hero", errors)
if hero.get("visual") != "executive-house":
errors.append("hero.visual must be executive-house")
for key in (
"kicker",
"title",
"subtitle",
"summary",
"liveActionLabel",
"scrollLabel",
):
_required_string(hero.get(key), f"hero.{key}", errors)
primary = _mapping(hero.get("primaryAction"), "hero.primaryAction", errors)
_required_string(primary.get("label"), "hero.primaryAction.label", errors)
_href(primary.get("href"), "hero.primaryAction.href", errors)
brief = _mapping(hero.get("brief"), "hero.brief", errors)
for key in ("label", "time", "title", "summary"):
_required_string(brief.get(key), f"hero.brief.{key}", errors)
live_modal = _mapping(hero.get("liveModal"), "hero.liveModal", errors)
for key in (
"title",
"streamTitle",
"streamSubtitle",
"location",
"captionsOn",
"captionsOff",
):
_required_string(live_modal.get(key), f"hero.liveModal.{key}", errors)
notice = _mapping(data.get("notice"), "notice", errors)
for key in ("label", "text", "date"):
_required_string(notice.get(key), f"notice.{key}", errors)
_href(notice.get("href"), "notice.href", errors)
updates = _mapping(data.get("updates"), "updates", errors)
for key in ("eyebrow", "title", "summary"):
_required_string(updates.get(key), f"updates.{key}", errors)
update_items = _array(
updates.get("items"), "updates.items", errors, minimum=1, maximum=8
)
seen_updates: set[str] = set()
for index, raw in enumerate(update_items):
item_path = f"updates.items[{index}]"
item = _mapping(raw, item_path, errors)
_unique_id(item, item_path, seen_updates, errors)
for key in ("type", "title", "summary", "date"):
_required_string(item.get(key), f"{item_path}.{key}", errors)
if item.get("visual") not in UPDATE_VISUALS:
errors.append(f"{item_path}.visual must be one of {sorted(UPDATE_VISUALS)}")
priorities = _mapping(data.get("priorities"), "priorities", errors)
for key in ("eyebrow", "title", "summary", "agendaLabel"):
_required_string(priorities.get(key), f"priorities.{key}", errors)
_href(priorities.get("agendaHref"), "priorities.agendaHref", errors)
priority_items = _array(
priorities.get("items"),
"priorities.items",
errors,
minimum=1,
maximum=6,
)
seen_priorities: set[str] = set()
for index, raw in enumerate(priority_items):
item_path = f"priorities.items[{index}]"
item = _mapping(raw, item_path, errors)
_unique_id(item, item_path, seen_priorities, errors)
for key in ("title", "summary", "detail"):
_required_string(item.get(key), f"{item_path}.{key}", errors)
administration = _mapping(data.get("administration"), "administration", errors)
if administration.get("visual") != "portrait":
errors.append("administration.visual must be portrait")
for key in ("eyebrow", "title", "quote", "description", "signature"):
_required_string(administration.get(key), f"administration.{key}", errors)
admin_links = _links(
administration.get("links"),
"administration.links",
errors,
minimum=1,
maximum=6,
)
calendar = _mapping(data.get("calendar"), "calendar", errors)
for key in (
"eyebrow",
"title",
"countdownValue",
"countdownLabel",
"panelEyebrow",
"panelTitle",
"panelText",
):
_required_string(calendar.get(key), f"calendar.{key}", errors)
months = _array(
calendar.get("months"), "calendar.months", errors, minimum=1, maximum=6
)
seen_months: set[str] = set()
event_count = 0
for month_index, raw_month in enumerate(months):
month_path = f"calendar.months[{month_index}]"
month = _mapping(raw_month, month_path, errors)
_unique_id(month, month_path, seen_months, errors)
_required_string(month.get("label"), f"{month_path}.label", errors)
events = _array(
month.get("events"),
f"{month_path}.events",
errors,
minimum=1,
maximum=8,
)
event_count += len(events)
seen_events: set[str] = set()
for event_index, raw_event in enumerate(events):
event_path = f"{month_path}.events[{event_index}]"
event = _mapping(raw_event, event_path, errors)
_unique_id(event, event_path, seen_events, errors)
for key in ("day", "month", "title", "summary", "tag"):
_required_string(event.get(key), f"{event_path}.{key}", errors)
participation = _mapping(data.get("participation"), "participation", errors)
for key in ("eyebrow", "title", "summary"):
_required_string(participation.get(key), f"participation.{key}", errors)
cards = _array(
participation.get("cards"),
"participation.cards",
errors,
minimum=1,
maximum=6,
)
seen_cards: set[str] = set()
for index, raw in enumerate(cards):
item_path = f"participation.cards[{index}]"
item = _mapping(raw, item_path, errors)
_unique_id(item, item_path, seen_cards, errors)
for key in ("kicker", "title", "summary", "actionLabel"):
_required_string(item.get(key), f"{item_path}.{key}", errors)
_href(item.get("actionHref"), f"{item_path}.actionHref", errors)
if item.get("visual") not in PARTICIPATION_VISUALS:
errors.append(
f"{item_path}.visual must be one of {sorted(PARTICIPATION_VISUALS)}"
)
newsletter = _mapping(
participation.get("newsletter"), "participation.newsletter", errors
)
for key in ("title", "text", "placeholder", "button", "successPrefix"):
_required_string(newsletter.get(key), f"participation.newsletter.{key}", errors)
footer = _mapping(data.get("footer"), "footer", errors)
_required_string(footer.get("description"), "footer.description", errors)
footer_columns = _array(
footer.get("columns"), "footer.columns", errors, minimum=1, maximum=4
)
seen_footer: set[str] = set()
footer_links = 0
for index, raw in enumerate(footer_columns):
item_path = f"footer.columns[{index}]"
item = _mapping(raw, item_path, errors)
_unique_id(item, item_path, seen_footer, errors)
_required_string(item.get("title"), f"{item_path}.title", errors)
footer_links += len(
_links(
item.get("links"),
f"{item_path}.links",
errors,
minimum=1,
maximum=8,
)
)
_required_string(footer.get("copyright"), "footer.copyright", errors)
_required_string(footer.get("legal"), "footer.legal", errors)
_validate_remote_media_tree(data, "$", errors)
_validate_no_remote_or_markup(data, "$", errors)
_validate_chinese_reader_copy(data, "$", errors)
if errors:
raise DataValidationError("\n".join(f"- {error}" for error in errors))
return {
"header_links": len(left_links) + len(right_links),
"menu_columns": len(menu_columns),
"menu_links": menu_links,
"updates": len(update_items),
"priorities": len(priority_items),
"administration_links": len(admin_links),
"months": len(months),
"events": event_count,
"participation_cards": len(cards),
"footer_columns": len(footer_columns),
"footer_links": footer_links,
}
def render_document(data: dict[str, Any], template: str, runtime: str) -> str:
validate_document(data)
data_text = json.dumps(data, ensure_ascii=False, separators=(",", ":"))
data_text = data_text.replace("</script", "<\\/script")
if template.count("__WHITE_HOUSE_PAGE_DATA__") != 1:
raise DataValidationError(
"template must contain one __WHITE_HOUSE_PAGE_DATA__ marker"
)
if template.count("__WHITE_HOUSE_PAGE_RUNTIME__") != 1:
raise DataValidationError(
"template must contain one __WHITE_HOUSE_PAGE_RUNTIME__ marker"
)
rendered = template.replace("__WHITE_HOUSE_PAGE_DATA__", data_text).replace(
"__WHITE_HOUSE_PAGE_RUNTIME__", runtime
)
if "__WHITE_HOUSE_PAGE_" in rendered:
raise DataValidationError("unresolved template marker remains in rendered HTML")
return rendered
def _write_new(path: Path, content: str) -> None:
if path.exists():
raise DataValidationError(
f"refusing to overwrite existing file: {path}; choose a new path"
)
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(content, encoding="utf-8", newline="\n")
def _emit(payload: dict[str, Any]) -> None:
print(json.dumps(payload, ensure_ascii=False))
def _command_init(output: Path) -> dict[str, Any]:
data = _read_json(DEFAULT_DATA_PATH)
counts = validate_document(data)
_write_new(output, json.dumps(data, ensure_ascii=False, indent=2) + "\n")
return {
"status": "ok",
"action": "init",
"output": str(output),
"modules": list(MODULES),
"counts": counts,
}
def _command_validate(input_path: Path) -> dict[str, Any]:
counts = validate_document(_read_json(input_path))
return {
"status": "ok",
"action": "validate",
"input": str(input_path),
"modules": list(MODULES),
"counts": counts,
}
def _command_render(input_path: Path, output: Path) -> dict[str, Any]:
data = _read_json(input_path)
counts = validate_document(data)
template = TEMPLATE_PATH.read_text(encoding="utf-8")
runtime = RUNTIME_PATH.read_text(encoding="utf-8")
_write_new(output, render_document(data, template, runtime))
return {
"status": "ok",
"action": "render",
"input": str(input_path),
"output": str(output),
"modules": list(MODULES),
"counts": counts,
}
def _build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
description="Initialize, validate, and render White House-style portal JSON."
)
subparsers = parser.add_subparsers(dest="command", required=True)
init_parser = subparsers.add_parser("init", help="write a fresh default JSON file")
init_parser.add_argument("--output", required=True, type=Path)
validate_parser = subparsers.add_parser("validate", help="validate a JSON file")
validate_parser.add_argument("--input", required=True, type=Path)
render_parser = subparsers.add_parser(
"render", help="render validated JSON into the fixed HTML template"
)
render_parser.add_argument("--input", required=True, type=Path)
render_parser.add_argument("--output", required=True, type=Path)
return parser
def main(argv: list[str] | None = None) -> int:
parser = _build_parser()
args = parser.parse_args(argv)
try:
if args.command == "init":
payload = _command_init(args.output)
elif args.command == "validate":
payload = _command_validate(args.input)
else:
payload = _command_render(args.input, args.output)
_emit(payload)
return 0
except (DataValidationError, OSError) as exc:
_emit({"status": "error", "action": args.command, "message": str(exc)})
return 1
if __name__ == "__main__":
sys.exit(main())