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,134 @@
{
"site": {
"brand": "X",
"pageTitle": "X · 正在发生",
"description": "一个 X 风格的中文社交时间线示例页面。",
"timelineTitle": "首页",
"searchPlaceholder": "搜索",
"tabs": ["为你推荐", "正在关注"],
"currentUser": {
"name": "林小满",
"handle": "@linxiaoman",
"initial": "林",
"colors": ["#5662f6", "#9f45d8"]
}
},
"navigation": {
"primary": [
{"label": "首页", "icon": "i-home", "href": "#mainFeed"},
{"label": "探索", "icon": "i-search", "href": "#explore"},
{"label": "通知", "icon": "i-bell", "href": "#notifications", "badge": 4},
{"label": "私信", "icon": "i-message", "href": "#messages"},
{"label": "圈子", "icon": "i-users", "href": "#circle"},
{"label": "书签", "icon": "i-bookmark", "href": "#bookmarks"},
{"label": "个人资料", "icon": "i-user", "href": "#profile"},
{"label": "更多", "icon": "i-more", "href": "#more"}
],
"postLabel": "发布",
"mobile": [
{"label": "首页", "icon": "i-home"},
{"label": "探索", "icon": "i-search"},
{"label": "通知", "icon": "i-bell"},
{"label": "私信", "icon": "i-message"},
{"label": "书签", "icon": "i-bookmark"}
],
"footerLinks": [
{"label": "服务条款", "href": "#terms"},
{"label": "隐私政策", "href": "#privacy"},
{"label": "Cookie", "href": "#cookies"},
{"label": "无障碍", "href": "#accessibility"}
],
"copyright": "© 2026 X"
},
"composer": {
"audience": "所有人",
"placeholder": "有什么新鲜事?",
"replyPermission": "所有人都可以回复",
"draftsLabel": "草稿",
"maxLength": 280
},
"posts": {
"replyUI": {
"defaultSort": "hot",
"initialVisible": 10,
"pageSize": 10,
"hotLabel": "热门",
"latestLabel": "最新",
"showMoreLabel": "查看更多",
"showAllLabel": "查看全部"
},
"items": [
{
"id": "city-sky",
"author": "许知夏",
"handle": "@summerxu",
"initial": "许",
"colors": ["#15a88b", "#2e88cc"],
"verified": true,
"time": "32 分钟",
"text": "今天的天空像一封刚拆开的蓝色情书。",
"tags": ["城市漫步"],
"media": {"type": "skyline", "caption": "南浦大桥 · 06:42", "alt": "蓝色天空与城市大桥的抽象插画"},
"metrics": {"replies": 18, "reposts": 34, "likes": 276, "views": 84000}
},
{
"id": "design-restraint",
"author": "陈默",
"handle": "@modesign",
"initial": "陈",
"colors": ["#0f7d78", "#51b35e"],
"verified": false,
"time": "1 小时",
"text": "设计并不是不断加东西。更多时候,是在所有“还可以再做一点”的时刻,知道什么时候停下。",
"tags": [],
"media": {"type": "quote", "author": "周野", "handle": "@zhouye", "initial": "周", "colors": ["#f97316", "#db2777"], "time": "昨天", "text": "复杂很容易,克制才需要勇气。"},
"metrics": {"replies": 12, "reposts": 91, "likes": 538, "views": 120000}
},
{
"id": "bookstore-map",
"author": "光合计划",
"handle": "@photosynthesis",
"initial": "光",
"colors": ["#ff8a37", "#d93f7b"],
"verified": true,
"time": "3 小时",
"text": "我们把城市里 12 家小书店画成了一张散步地图。这个周末,选一条从没走过的街,去遇见一本意料之外的书吧。",
"tags": ["独立书店", "城市阅读"],
"media": {"type": "map", "caption": "独立书店散步地图", "alt": "城市书店散步地图抽象插画"},
"metrics": {"replies": 46, "reposts": 182, "likes": 902, "views": 240000}
},
{
"id": "commute-playlist",
"author": "宋可心",
"handle": "@kexin",
"initial": "宋",
"colors": ["#8b5cf6", "#3b82f6"],
"verified": false,
"time": "5 小时",
"text": "下班路上的随机播放,总会精准地挑中你今天最需要听到的那一句。你们最近单曲循环的是哪首?",
"tags": ["通勤歌单"],
"metrics": {"replies": 68, "reposts": 21, "likes": 309, "views": 56000}
}
]
},
"trends": {
"title": "正在发生",
"showMoreLabel": "显示更多",
"items": [
{"category": "中国 · 热门", "title": "#秋日城市漫步", "count": "2.8 万条动态", "href": "#trend1"},
{"category": "科技 · 热门", "title": "AI 产品设计", "count": "1.7 万条动态", "href": "#trend2"},
{"category": "文化 · 热门", "title": "独立书店地图", "count": "8,942 条动态", "href": "#trend3"},
{"category": "音乐 · 趋势", "title": "通勤歌单", "count": "5,610 条动态", "href": "#trend4"}
]
},
"recommendations": {
"title": "推荐关注",
"showMoreLabel": "显示更多",
"items": [
{"name": "周野", "handle": "@zhouye", "initial": "周", "colors": ["#f97316", "#db2777"]},
{"name": "顾念", "handle": "@gunian", "initial": "顾", "colors": ["#0ea5e9", "#10b981"]},
{"name": "理想生活研究所", "handle": "@betterlife", "initial": "理", "colors": ["#6366f1", "#ec4899"]}
]
}
}
@@ -0,0 +1,855 @@
(() => {
"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 MODULES = ["site", "navigation", "composer", "posts", "trends", "recommendations"];
const MODULE_META = {
site: ["站点信息", "品牌、标题与当前账号"],
navigation: ["导航", "主导航、移动导航与页脚"],
composer: ["发布框", "占位语与字数限制"],
posts: ["动态", "时间线内容与互动量"],
trends: ["趋势", "右栏热门话题"],
recommendations: ["推荐关注", "右栏推荐账号"]
};
const ALLOWED_ICONS = new Set(["i-home", "i-search", "i-bell", "i-message", "i-users", "i-bookmark", "i-user", "i-more"]);
const embeddedData = JSON.parse(qs("#xPageData").textContent);
const initialData = clone(embeddedData);
const fingerprint = (text) => {
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(36);
};
const pageFingerprint = fingerprint(JSON.stringify(initialData));
const storageKey = "x-page-data-v1:" + pageFingerprint;
const themeKey = "x-page-theme-v1:" + pageFingerprint;
const readStorage = (key) => {
try {
return window.localStorage ? window.localStorage.getItem(key) : null;
} catch (_error) {
return null;
}
};
const writeStorage = (key, value) => {
try {
if (window.localStorage) window.localStorage.setItem(key, value);
return true;
} catch (_error) {
return false;
}
};
const removeStorage = (key) => {
try {
if (window.localStorage) window.localStorage.removeItem(key);
} catch (_error) {
/* Sandboxed previews may intentionally deny storage. */
}
};
const isCompleteData = (value) => Boolean(value && MODULES.every((name) => value[name] && typeof value[name] === "object"));
const cachedData = readStorage(storageKey);
let pageData = initialData;
if (cachedData) {
try {
const parsed = JSON.parse(cachedData);
if (isCompleteData(parsed)) pageData = parsed;
} catch (_error) {
pageData = initialData;
}
}
const escapeHTML = (value) => String(value == null ? "" : value).replace(/[&<>'"]/g, (character) => ({
"&": "&amp;", "<": "&lt;", ">": "&gt;", "'": "&#39;", '"': "&quot;"
})[character]);
const safeHref = (value) => {
const href = String(value || "#");
return /^(#|https?:\/\/)/i.test(href) ? escapeHTML(href) : "#";
};
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 url.protocol === "http:" || url.protocol === "https:" ? url.href : "";
} catch (_error) { return ""; }
};
const validateRemoteMediaTree = (value, path = "当前模块") => {
if (Array.isArray(value)) return value.forEach((item, index) => validateRemoteMediaTree(item, path + "[" + index + "]"));
if (!value || typeof value !== "object") return;
const media = value.media;
if (media && ["image", "video", "webpage"].includes(media.type)) {
if ((media.type === "image" || media.type === "video") && !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 safeColor = (value, fallback) => /^#[0-9a-f]{3,8}$/i.test(String(value || "")) ? value : fallback;
const safeIcon = (value) => ALLOWED_ICONS.has(value) ? value : "i-more";
const icon = (id, className) => '<svg' + (className ? ' class="' + className + '"' : "") + ' aria-hidden="true"><use href="#' + id + '"/></svg>';
const colors = (person) => {
const list = person && Array.isArray(person.colors) ? person.colors : [];
return [safeColor(list[0], "#5662f6"), safeColor(list[1], "#9f45d8")];
};
const avatar = (person, className) => {
const pair = colors(person || {});
return '<span class="avatar ' + (className || "") + '" style="--a:' + pair[0] + ";--b:" + pair[1] + '">' + escapeHTML((person && person.initial) || "X") + "</span>";
};
const formatCount = (value) => {
const number = Number(value) || 0;
if (number >= 10000) return (number / 10000).toFixed(1).replace(".0", "") + "万";
return String(number);
};
const toast = qs("#toast");
let toastTimer = 0;
const showToast = (message) => {
toast.textContent = message;
toast.classList.add("show");
window.clearTimeout(toastTimer);
toastTimer = window.setTimeout(() => toast.classList.remove("show"), 2800);
};
const skylineSvg = '<svg viewBox="0 0 800 500" preserveAspectRatio="xMidYMid slice"><defs><linearGradient id="g-sky" x1="0" y1="0" x2="0" y2="1"><stop stop-color="#82c9ff"/><stop offset="1" stop-color="#d8efff"/></linearGradient></defs><rect width="800" height="500" fill="url(#g-sky)"/><circle cx="640" cy="110" r="45" fill="#fff" opacity=".75"/><path d="M0 370C180 310 330 340 470 300s230-5 330 35v165H0Z" fill="#5c8fae"/><path d="M40 355h720M130 355l110-130m430 130L560 225M240 225h320" fill="none" stroke="#e9f6ff" stroke-width="13"/><path d="M130 355V208m540 147V208" stroke="#325d7c" stroke-width="18"/><path d="M80 400c150-30 260 10 380-4 120-13 210-1 340 38" fill="none" stroke="#bfe4f7" stroke-width="8" opacity=".7"/></svg>';
const mapSvg = '<svg viewBox="0 0 800 500" preserveAspectRatio="xMidYMid slice"><rect width="800" height="500" fill="#f4ead9"/><path d="M80 70c110 90 90 220 220 250s160-100 250-30 60 120 170 140" fill="none" stroke="#df6d5a" stroke-width="12" stroke-linecap="round"/><path d="M20 390c150-80 230 10 345-60s180-210 410-165" fill="none" stroke="#497d83" stroke-width="14" stroke-linecap="round"/><path d="M160 20c40 140 180 120 180 250s-90 130-65 230M580 0c-70 150 40 215-50 330s30 110 130 170" fill="none" stroke="#e3b55a" stroke-width="10"/><g fill="#fff" stroke="#1f2937" stroke-width="4"><rect x="123" y="114" width="70" height="54" rx="8"/><rect x="339" y="277" width="70" height="54" rx="8"/><rect x="563" y="142" width="70" height="54" rx="8"/><rect x="604" y="371" width="70" height="54" rx="8"/></g><g fill="#1f2937"><path d="m141 127 17 8 17-8v27l-17 7-17-7Z"/><path d="m357 290 17 8 17-8v27l-17 7-17-7Z"/><path d="m581 155 17 8 17-8v27l-17 7-17-7Z"/><path d="m622 384 17 8 17-8v27l-17 7-17-7Z"/></g><circle cx="94" cy="388" r="15" fill="#df6d5a"/><circle cx="742" cy="166" r="15" fill="#497d83"/></svg>';
document.head.insertAdjacentHTML("beforeend", '<style data-external-media>.external-media{position:relative}.external-media>img,.external-media>video,.external-media>iframe{width:100%;height:100%;display:block;border:0;object-fit:cover;background:#000}.external-media>iframe{object-fit:initial}.external-open{position:absolute;right:10px;bottom:10px;padding:7px 11px;border-radius:999px;color:#fff!important;background:rgba(0,0,0,.72);text-decoration:none;font-size:12px;font-weight:700}.external-page{margin-top:12px;overflow:hidden;border:1px solid var(--border-strong);border-radius:16px;background:var(--surface)}.external-page>img,.external-page>iframe{width:100%;height:240px;display:block;border:0;object-fit:cover;background:#000}.external-page>a{display:block;padding:12px 14px;color:var(--text);text-decoration:none}.external-page>a strong,.external-page>a span{display:block}.external-page>a span{margin-top:4px;color:var(--muted);font-size:13px}</style>');
const renderMedia = (media) => {
if (!media || !media.type) return "";
if (media.type === "quote") {
return '<div class="quote-post"><div class="quote-author">' + avatar(media, "avatar-sm") + "<strong>" + escapeHTML(media.author) + '</strong><span class="handle">' + escapeHTML(media.handle) + " · " + escapeHTML(media.time) + "</span></div><p>" + escapeHTML(media.text) + "</p></div>";
}
if (media.type === "image") {
const source = safeRemoteUrl(media.mediaUrl, "image");
if (!source) return "";
const pageUrl = safeRemoteUrl(media.pageUrl);
return '<div class="post-media external-media"><img src="' + escapeHTML(source) + '" alt="' + escapeHTML(media.alt || media.caption || "动态图片") + '" loading="lazy" referrerpolicy="no-referrer"/>' + (pageUrl ? '<a class="external-open" href="' + escapeHTML(pageUrl) + '" target="_blank" rel="noopener noreferrer">打开来源</a>' : "") + "</div>";
}
if (media.type === "video") {
const source = safeRemoteUrl(media.mediaUrl, "video");
if (!source) return "";
const poster = safeRemoteUrl(media.posterUrl, "image");
const pageUrl = safeRemoteUrl(media.pageUrl);
return '<div class="post-media external-media"><video src="' + escapeHTML(source) + '"' + (poster ? ' poster="' + escapeHTML(poster) + '"' : "") + ' controls playsinline preload="metadata" aria-label="' + escapeHTML(media.alt || media.caption || "动态视频") + '"></video>' + (pageUrl ? '<a class="external-open" href="' + escapeHTML(pageUrl) + '" target="_blank" rel="noopener noreferrer">打开来源</a>' : "") + "</div>";
}
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 '<div class="external-page">' + body + '<a href="' + escapeHTML(pageUrl) + '" target="_blank" rel="noopener noreferrer"><strong>' + escapeHTML(media.title || pageUrl) + '</strong><span>' + escapeHTML(media.description || "打开网页") + "</span></a></div>";
}
const artwork = media.type === "map" ? mapSvg : skylineSvg;
return '<div class="post-media" role="img" aria-label="' + escapeHTML(media.alt || media.caption || "动态配图") + '">' + artwork + '<span class="media-caption">' + escapeHTML(media.caption || "") + "</span></div>";
};
const replyUI = () => Object.assign({
defaultSort: "hot",
initialVisible: 10,
pageSize: 10,
hotLabel: "热门",
latestLabel: "最新",
showMoreLabel: "查看更多",
showAllLabel: "查看全部"
}, pageData.posts && pageData.posts.replyUI ? pageData.posts.replyUI : {});
const replyMarkup = (reply) => {
const replyLikes = Math.max(0, Number(reply.likes) || 0);
const replyCount = Math.max(0, Number(reply.replyCount) || 0);
return '<div class="reply-item">' + avatar(reply, "avatar-sm") + '<div class="reply-content"><header><strong>' + escapeHTML(reply.author) + "</strong>" +
(reply.verified ? icon("i-verified", "verified") : "") +
(reply.handle ? '<span class="handle">' + escapeHTML(reply.handle) + "</span>" : "") +
(reply.time ? '<span class="dot">·</span><time>' + escapeHTML(reply.time) + "</time>" : "") +
'</header><p>' + escapeHTML(reply.text) + '</p><div class="reply-meta"><button type="button">回复</button><span>' + formatCount(replyLikes) + ' 个赞</span>' +
(replyCount ? '<span>' + formatCount(replyCount) + ' 条回复</span>' : "") + "</div></div></div>";
};
const postSource = (post) => {
const sourceUrl = safeRemoteUrl(post.sourceUrl);
if (!sourceUrl) return "";
return '<div class="post-source"><a href="' + escapeHTML(sourceUrl) + '" target="_blank" rel="noopener noreferrer">查看原帖</a></div>';
};
const renderReplyList = (postElement, postData, state) => {
const replies = Array.isArray(postData.replies) ? postData.replies : [];
const ui = replyUI();
const sorted = replies.map((reply, index) => ({ reply, index }));
if (state.sort === "hot") {
sorted.sort((left, right) => (Number(right.reply.likes) || 0) - (Number(left.reply.likes) || 0) || (Number(right.reply.replyCount) || 0) - (Number(left.reply.replyCount) || 0) || left.index - right.index);
}
state.visible = Math.min(Math.max(1, state.visible), Math.max(1, replies.length));
qs(".reply-list", postElement).innerHTML = sorted.slice(0, state.visible).map(({ reply }) => replyMarkup(reply)).join("");
const tools = qs(".reply-tools", postElement);
tools.hidden = replies.length === 0;
qs(".reply-summary", postElement).textContent = replies.length + " 条回复";
qsa(".reply-sort", postElement).forEach((button) => {
button.textContent = button.dataset.sort === "latest" ? ui.latestLabel : ui.hotLabel;
const active = button.dataset.sort === state.sort;
button.classList.toggle("active", active);
button.setAttribute("aria-pressed", String(active));
});
const remaining = Math.max(0, replies.length - state.visible);
const moreButton = qs(".reply-more", postElement);
const allButton = qs(".reply-all", postElement);
moreButton.hidden = remaining === 0;
allButton.hidden = remaining === 0 || remaining <= Math.max(1, Number(ui.pageSize) || 10);
moreButton.textContent = ui.showMoreLabel + " " + Math.min(remaining, Math.max(1, Number(ui.pageSize) || 10)) + " 条";
allButton.textContent = ui.showAllLabel + " " + replies.length + " 条";
};
const postMarkup = (post) => {
const metrics = post.metrics || {};
const tags = Array.isArray(post.tags) ? post.tags : [];
const tagMarkup = tags.map((tag) => ' <a href="#tag-' + encodeURIComponent(String(tag)) + '">#' + escapeHTML(tag) + "</a>").join("");
return '<article class="post" data-post-id="' + escapeHTML(post.id) + '" data-search="' + escapeHTML([post.author, post.handle, post.text].concat(tags).join(" ")) + '">' +
avatar(post, "avatar-lg") +
'<div class="post-main"><header class="post-head"><strong>' + escapeHTML(post.author) + "</strong>" +
(post.verified ? icon("i-verified", "verified") : "") +
'<span class="handle">' + escapeHTML(post.handle) + '</span><span class="dot">·</span><time>' + escapeHTML(post.time) + '</time><button class="more" aria-label="更多操作">' + icon("i-more") + "</button></header>" +
postSource(post) + '<p class="post-text">' + escapeHTML(post.text) + tagMarkup + "</p>" + renderMedia(post.media) +
'<div class="post-actions"><button class="action reply"><span class="action-icon">' + icon("i-comment") + '</span><span class="action-count">' + formatCount(metrics.replies) + '</span></button><button class="action repost"><span class="action-icon">' + icon("i-repost") + '</span><span class="action-count">' + formatCount(metrics.reposts) + '</span></button><button class="action like"><span class="action-icon">' + icon("i-heart") + '</span><span class="action-count">' + formatCount(metrics.likes) + '</span></button><button class="action views"><span class="action-icon">' + icon("i-chart") + '</span><span class="action-count">' + formatCount(metrics.views) + '</span></button><button class="action bookmark-action" aria-label="收藏"><span class="action-icon">' + icon("i-bookmark") + '</span></button><button class="action share" aria-label="分享"><span class="action-icon">' + icon("i-share") + "</span></button></div></div>" +
'<div class="reply-section' + (post.repliesExpanded === true ? " open" : "") + '"><div class="reply-tools" hidden><strong class="reply-summary"></strong><div><button type="button" class="reply-sort" data-sort="hot">热门</button><button type="button" class="reply-sort" data-sort="latest">最新</button></div></div><div class="reply-list"></div><div class="reply-pagination"><button type="button" class="reply-more"></button><button type="button" class="reply-all"></button></div><form class="reply-form"><label class="sr-only">回复内容</label><input maxlength="160" placeholder="发布你的回复" /><button class="reply-send" aria-label="发送回复">' + icon("i-send") + '</button></form></div><div class="post-menu"><button>' + icon("i-bookmark") + "收藏这条动态</button><button>" + icon("i-volume-off") + "不再关注此话题</button></div></article>";
};
const renderSite = () => {
const site = pageData.site;
const user = site.currentUser || {};
document.title = site.pageTitle || site.brand || "X";
qs('meta[name="description"]').content = site.description || "";
qs("#brandLink").setAttribute("aria-label", (site.brand || "X") + " 首页");
qs("#timelineHeading").textContent = (site.brand || "X") + " " + (site.timelineTitle || "首页") + "时间线";
qs("#mobileTitle").textContent = site.timelineTitle || "首页";
qs("#mobileUser").innerHTML = avatar(user, "avatar-sm");
qs("#composerAvatar").innerHTML = avatar(user, "avatar-lg");
qs("#modalAvatar").innerHTML = avatar(user, "avatar-lg");
qs("#accountSwitcher").innerHTML = avatar(user, "") + '<span class="account-copy"><strong>' + escapeHTML(user.name) + "</strong><span>" + escapeHTML(user.handle) + '</span></span>' + icon("i-more");
qs("#searchInput").placeholder = site.searchPlaceholder || "搜索";
const tabs = Array.isArray(site.tabs) ? site.tabs : [];
qs("#feedTabs").innerHTML = tabs.map((label, index) => '<button class="tab' + (index === 0 ? " active" : "") + '" role="tab" aria-selected="' + (index === 0 ? "true" : "false") + '">' + escapeHTML(label) + "</button>").join("");
qsa(".tab").forEach((tab) => tab.addEventListener("click", () => {
qsa(".tab").forEach((item) => {
item.classList.remove("active");
item.setAttribute("aria-selected", "false");
});
tab.classList.add("active");
tab.setAttribute("aria-selected", "true");
qs("#timelineStatus").classList.add("show");
window.setTimeout(() => qs("#timelineStatus").classList.remove("show"), 1600);
}));
};
const renderNavigation = () => {
const navigation = pageData.navigation;
const primary = Array.isArray(navigation.primary) ? navigation.primary : [];
qs("#primaryNav").innerHTML = primary.map((item, index) => '<a class="nav-item' + (index === 0 ? " active" : "") + '" href="' + safeHref(item.href) + '">' + icon(safeIcon(item.icon)) + "<span>" + escapeHTML(item.label) + "</span>" + (item.badge ? '<b class="nav-badge">' + escapeHTML(item.badge) + "</b>" : "") + "</a>").join("");
qs("#postCta").textContent = navigation.postLabel || "发布";
const mobile = Array.isArray(navigation.mobile) ? navigation.mobile : [];
qs("#mobileNav").innerHTML = mobile.map((item, index) => '<button class="' + (index === 0 ? "active" : "") + '" aria-label="' + escapeHTML(item.label) + '">' + icon(safeIcon(item.icon)) + "<span>" + escapeHTML(item.label) + "</span></button>").join("");
qsa("#mobileNav button").forEach((button) => button.addEventListener("click", () => {
qsa("#mobileNav button").forEach((item) => item.classList.remove("active"));
button.classList.add("active");
}));
const footerLinks = Array.isArray(navigation.footerLinks) ? navigation.footerLinks : [];
qs("#rightFooter").innerHTML = footerLinks.map((item) => '<a href="' + safeHref(item.href) + '">' + escapeHTML(item.label) + "</a>").join("") + "<span>" + escapeHTML(navigation.copyright || "") + "</span>";
};
const renderComposer = () => {
const composer = pageData.composer;
const maxLength = Math.max(1, Number(composer.maxLength) || 280);
["#composerText", "#modalText"].forEach((selector) => {
const field = qs(selector);
field.maxLength = maxLength;
field.placeholder = composer.placeholder || "有什么新鲜事?";
});
qs("#composerAudience").textContent = composer.audience || "所有人";
qs("#modalAudience").textContent = composer.audience || "所有人";
qs("#replyPermission span").textContent = composer.replyPermission || "";
qs("#modalReplyPermission").textContent = composer.replyPermission || "";
qs("#draftsLabel").textContent = composer.draftsLabel || "草稿";
updateCounter(qs("#composerText"), qs("#charCounter"), qs("#publishButton"));
updateCounter(qs("#modalText"), qs("#modalCounter"), qs("#modalPublish"));
};
const bindPost = (post, postData) => {
const ui = replyUI();
const state = {
sort: ui.defaultSort === "latest" ? "latest" : "hot",
visible: Math.max(1, Number(ui.initialVisible) || 10)
};
const paintReplies = () => renderReplyList(post, postData, state);
const numberFrom = (text) => Number(String(text).replace(/[^0-9.]/g, "")) || 0;
const like = qs(".like", post);
like.addEventListener("click", () => {
const count = qs(".action-count", like);
const active = like.classList.toggle("liked");
count.textContent = formatCount(Math.max(0, numberFrom(count.textContent) + (active ? 1 : -1)));
like.setAttribute("aria-pressed", String(active));
});
const repost = qs(".repost", post);
repost.addEventListener("click", () => {
const count = qs(".action-count", repost);
const active = repost.classList.toggle("reposted");
count.textContent = formatCount(Math.max(0, numberFrom(count.textContent) + (active ? 1 : -1)));
showToast(active ? "已转发" : "已撤销转发");
});
qs(".bookmark-action", post).addEventListener("click", (event) => {
const active = event.currentTarget.classList.toggle("bookmarked");
showToast(active ? "已添加到书签" : "已从书签移除");
});
qs(".reply", post).addEventListener("click", () => {
const section = qs(".reply-section", post);
section.classList.toggle("open");
if (section.classList.contains("open")) qs("input", section).focus();
});
qsa(".reply-sort", post).forEach((button) => button.addEventListener("click", () => {
state.sort = button.dataset.sort === "latest" ? "latest" : "hot";
state.visible = Math.max(1, Number(replyUI().initialVisible) || 10);
paintReplies();
}));
qs(".reply-more", post).addEventListener("click", () => {
state.visible += Math.max(1, Number(replyUI().pageSize) || 10);
paintReplies();
});
qs(".reply-all", post).addEventListener("click", () => {
state.visible = Array.isArray(postData.replies) ? postData.replies.length : 0;
paintReplies();
});
qs(".reply-form", post).addEventListener("submit", (event) => {
event.preventDefault();
const input = qs("input", event.currentTarget);
const value = input.value.trim();
if (!value) return;
if (!Array.isArray(postData.replies)) postData.replies = [];
const user = pageData.site.currentUser || {};
postData.replies.unshift({
id: "local-" + Date.now(),
author: user.name || "我",
handle: user.handle || "",
initial: user.initial || "我",
colors: user.colors || ["#5662f6", "#9f45d8"],
time: "刚刚",
text: value,
likes: 0,
replyCount: 0
});
postData.metrics = postData.metrics || {};
postData.metrics.replies = Math.max(Number(postData.metrics.replies) || 0, postData.replies.length - 1) + 1;
qs(".reply .action-count", post).textContent = formatCount(postData.metrics.replies);
state.visible += 1;
paintReplies();
input.value = "";
showToast("回复已发布");
});
qs(".share", post).addEventListener("click", async () => {
try {
if (navigator.share) await navigator.share({ title: document.title, text: qs(".post-text", post).textContent });
else if (navigator.clipboard) {
await navigator.clipboard.writeText(location.href);
showToast("链接已复制");
} else showToast("分享暂时不可用");
} catch (error) {
if (!error || error.name !== "AbortError") showToast("分享暂时不可用");
}
});
const menu = qs(".post-menu", post);
qs(".more", post).addEventListener("click", (event) => {
event.stopPropagation();
qsa(".post-menu.open").forEach((other) => {
if (other !== menu) other.classList.remove("open");
});
menu.classList.toggle("open");
});
paintReplies();
};
const applySearch = () => {
const query = qs("#searchInput").value.trim().toLocaleLowerCase();
let visible = 0;
qsa(".post").forEach((post) => {
const match = !query || post.dataset.search.toLocaleLowerCase().includes(query) || post.textContent.toLocaleLowerCase().includes(query);
post.hidden = !match;
if (match) visible += 1;
});
qs("#emptyState").style.display = visible ? "none" : "block";
};
const renderPosts = () => {
const items = Array.isArray(pageData.posts.items) ? pageData.posts.items : [];
qs("#posts").innerHTML = items.map(postMarkup).join("");
qsa(".post").forEach((post, index) => bindPost(post, items[index]));
applySearch();
};
const renderTrends = () => {
const data = pageData.trends;
const items = Array.isArray(data.items) ? data.items : [];
qs("#trendsCard").innerHTML = "<h2>" + escapeHTML(data.title) + "</h2>" + items.map((item) => '<a class="trend" href="' + safeHref(item.href) + '"><span class="trend-head">' + escapeHTML(item.category) + icon("i-more") + "</span><strong>" + escapeHTML(item.title) + "</strong><small>" + escapeHTML(item.count) + "</small></a>").join("") + '<a class="show-more" href="#more-trends">' + escapeHTML(data.showMoreLabel || "显示更多") + "</a>";
};
const renderRecommendations = () => {
const data = pageData.recommendations;
const items = Array.isArray(data.items) ? data.items : [];
qs("#recommendationsCard").innerHTML = "<h2>" + escapeHTML(data.title) + "</h2>" + items.map((person) => '<div class="follow-row">' + avatar(person, "avatar-sm") + '<span class="follow-copy"><strong>' + escapeHTML(person.name) + "</strong><span>" + escapeHTML(person.handle) + '</span></span><button class="follow-button">关注</button></div>').join("") + '<a class="show-more" href="#more-people">' + escapeHTML(data.showMoreLabel || "显示更多") + "</a>";
qsa("#recommendationsCard .follow-button").forEach((button) => button.addEventListener("click", () => {
const following = button.classList.toggle("following");
button.textContent = following ? "正在关注" : "关注";
showToast(following ? "已关注" : "已取消关注");
}));
};
const renderAll = () => {
renderSite();
renderNavigation();
renderComposer();
renderPosts();
renderTrends();
renderRecommendations();
};
const updateCounter = (textarea, counter, button) => {
const maximum = Math.max(1, Number(pageData.composer.maxLength) || 280);
const left = maximum - textarea.value.length;
counter.textContent = left;
counter.classList.toggle("warn", left <= Math.min(20, Math.floor(maximum * 0.1)));
button.disabled = !textarea.value.trim() || left < 0;
};
const saveData = () => writeStorage(storageKey, JSON.stringify(pageData));
const createPost = (rawText) => {
const user = pageData.site.currentUser;
const item = {
id: "user-" + Date.now(),
author: user.name,
handle: user.handle,
initial: user.initial,
colors: clone(user.colors || []),
verified: false,
time: "刚刚",
text: rawText,
tags: [],
metrics: { replies: 0, reposts: 0, likes: 0, views: 0 }
};
pageData.posts.items.unshift(item);
saveData();
renderPosts();
qs(".post").scrollIntoView({ behavior: "smooth", block: "center" });
showToast("动态已发布");
};
const composerText = qs("#composerText");
const publishButton = qs("#publishButton");
composerText.addEventListener("focus", () => qs("#replyPermission").classList.add("visible"));
composerText.addEventListener("input", () => updateCounter(composerText, qs("#charCounter"), publishButton));
publishButton.addEventListener("click", () => {
const value = composerText.value.trim();
if (!value) return;
createPost(value);
composerText.value = "";
qs("#replyPermission").classList.remove("visible");
updateCounter(composerText, qs("#charCounter"), publishButton);
});
qs("#searchInput").addEventListener("input", applySearch);
qs("#timelineStatus").addEventListener("click", () => qs("#timelineStatus").classList.remove("show"));
const composeModal = qs("#composeModal");
const modalText = qs("#modalText");
const modalPublish = qs("#modalPublish");
let modalOpener = null;
const openCompose = (event) => {
modalOpener = event.currentTarget;
composeModal.classList.add("open");
composeModal.setAttribute("aria-hidden", "false");
document.body.classList.add("modal-open");
window.setTimeout(() => modalText.focus(), 40);
};
const closeCompose = () => {
composeModal.classList.remove("open");
composeModal.setAttribute("aria-hidden", "true");
document.body.classList.remove("modal-open");
if (modalOpener) modalOpener.focus();
};
qsa("[data-open-modal]").forEach((button) => button.addEventListener("click", openCompose));
qs("#closeModal").addEventListener("click", closeCompose);
composeModal.addEventListener("click", (event) => {
if (event.target === composeModal) closeCompose();
});
modalText.addEventListener("input", () => updateCounter(modalText, qs("#modalCounter"), modalPublish));
modalPublish.addEventListener("click", () => {
const value = modalText.value.trim();
if (!value) return;
createPost(value);
modalText.value = "";
updateCounter(modalText, qs("#modalCounter"), modalPublish);
closeCompose();
});
const desktopTheme = qs("#themeToggle");
const mobileTheme = qs("#mobileTheme");
const storedTheme = readStorage(themeKey);
if (storedTheme === "dark" || (!storedTheme && typeof matchMedia === "function" && matchMedia("(prefers-color-scheme: dark)").matches)) {
document.documentElement.dataset.theme = "dark";
}
const syncTheme = () => {
const dark = document.documentElement.dataset.theme === "dark";
desktopTheme.textContent = dark ? "切换浅色模式" : "切换深色模式";
mobileTheme.innerHTML = icon(dark ? "i-sun" : "i-moon");
qs('meta[name="theme-color"]').content = dark ? "#000000" : "#ffffff";
};
const toggleTheme = () => {
const next = document.documentElement.dataset.theme === "dark" ? "light" : "dark";
document.documentElement.dataset.theme = next;
writeStorage(themeKey, next);
syncTheme();
};
desktopTheme.addEventListener("click", toggleTheme);
mobileTheme.addEventListener("click", toggleTheme);
const settingsModal = qs("#settingsModal");
const moduleTabs = qs("#moduleTabs");
const jsonEditor = qs("#jsonEditor");
const jsonStatus = qs("#jsonStatus");
let activeModule = "site";
let editorDrafts = clone(pageData);
let settingsOpener = null;
const setEditorStatus = (valid, message) => {
jsonStatus.textContent = message;
jsonStatus.classList.toggle("valid", valid);
jsonStatus.classList.toggle("invalid", !valid);
};
const readEditor = () => {
try {
const parsed = JSON.parse(jsonEditor.value);
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("模块必须是 JSON 对象");
validateRemoteMediaTree(parsed);
setEditorStatus(true, "JSON 有效");
return parsed;
} catch (error) {
setEditorStatus(false, "JSON 无效:" + error.message);
return null;
}
};
const saveActiveDraft = () => {
const parsed = readEditor();
if (!parsed) return false;
editorDrafts[activeModule] = parsed;
return true;
};
const renderModuleTabs = () => {
qsa(".module-tab", moduleTabs).forEach((button) => button.remove());
MODULES.forEach((name) => {
const button = document.createElement("button");
button.className = "module-tab" + (name === activeModule ? " active" : "");
button.type = "button";
button.dataset.module = name;
button.innerHTML = "<span>" + MODULE_META[name][0] + "</span><small>" + name + "</small>";
button.addEventListener("click", () => {
if (name === activeModule || !saveActiveDraft()) return;
activeModule = name;
renderModuleTabs();
loadEditor();
});
moduleTabs.appendChild(button);
});
};
const loadEditor = () => {
qs("#editorModuleTitle").textContent = MODULE_META[activeModule][0];
jsonEditor.value = JSON.stringify(editorDrafts[activeModule], null, 2);
setEditorStatus(true, "JSON 有效");
};
const openSettings = (event) => {
settingsOpener = event.currentTarget;
editorDrafts = clone(pageData);
activeModule = "site";
renderModuleTabs();
loadEditor();
settingsModal.classList.add("open");
settingsModal.setAttribute("aria-hidden", "false");
document.body.classList.add("modal-open");
window.setTimeout(() => jsonEditor.focus(), 40);
};
const closeSettings = () => {
settingsModal.classList.remove("open");
settingsModal.setAttribute("aria-hidden", "true");
document.body.classList.remove("modal-open");
if (settingsOpener) settingsOpener.focus();
};
jsonEditor.addEventListener("input", readEditor);
qs("#openSettings").addEventListener("click", openSettings);
qs("#closeSettings").addEventListener("click", closeSettings);
settingsModal.addEventListener("click", (event) => {
if (event.target === settingsModal) closeSettings();
});
qs("#applyJson").addEventListener("click", () => {
if (!saveActiveDraft() || !isCompleteData(editorDrafts)) return;
pageData = clone(editorDrafts);
saveData();
renderAll();
closeSettings();
showToast("JSON 已应用到页面");
});
qs("#resetJson").addEventListener("click", () => {
editorDrafts = clone(initialData);
activeModule = "site";
removeStorage(storageKey);
renderModuleTabs();
loadEditor();
showToast("已恢复初始 JSON,点击应用后生效");
});
qs("#copyJson").addEventListener("click", async () => {
if (!saveActiveDraft()) return;
const text = JSON.stringify(editorDrafts, null, 2);
try {
if (navigator.clipboard) await navigator.clipboard.writeText(text);
else throw new Error("clipboard unavailable");
showToast("完整 JSON 已复制");
} catch (_error) {
const temporary = document.createElement("textarea");
temporary.value = text;
document.body.appendChild(temporary);
temporary.select();
document.execCommand("copy");
temporary.remove();
showToast("完整 JSON 已复制");
}
});
qs("#downloadJson").addEventListener("click", () => {
if (!saveActiveDraft()) return;
const blob = new Blob([JSON.stringify(editorDrafts, null, 2)], { type: "application/json;charset=utf-8" });
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "x-page-data.json";
link.click();
window.setTimeout(() => URL.revokeObjectURL(link.href), 1000);
});
document.addEventListener("click", (event) => {
if (!event.target.closest(".post-menu") && !event.target.closest(".more")) {
qsa(".post-menu.open").forEach((menu) => menu.classList.remove("open"));
}
const link = event.target.closest('a[href^="#"]');
if (link && !qs(link.getAttribute("href"))) {
event.preventDefault();
showToast("此页面正在准备中");
}
});
document.addEventListener("keydown", (event) => {
if (event.key !== "Escape") return;
qsa(".post-menu.open").forEach((menu) => menu.classList.remove("open"));
if (settingsModal.classList.contains("open")) closeSettings();
else if (composeModal.classList.contains("open")) closeCompose();
});
renderAll();
syncTheme();
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,453 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#ffffff" />
<meta name="description" content="X 风格的可编辑中文社交时间线。" />
<title>X · 正在发生</title>
<style>
:root {
color-scheme: light;
--bg: #fff;
--surface: #fff;
--surface-hover: #f7f8f8;
--soft: #eff3f4;
--text: #0f1419;
--muted: #536471;
--border: #eff3f4;
--border-strong: #cfd9de;
--accent: #1d9bf0;
--accent-hover: #1a8cd8;
--accent-soft: #e8f5fd;
--danger: #f91880;
--success: #00ba7c;
--focus: 0 0 0 3px rgba(29, 155, 240, .28);
--nav-w: 258px;
--feed-w: 600px;
--aside-w: 350px;
}
[data-theme="dark"] {
color-scheme: dark;
--bg: #000;
--surface: #000;
--surface-hover: #080808;
--soft: #16181c;
--text: #e7e9ea;
--muted: #71767b;
--border: #2f3336;
--border-strong: #536471;
--accent-soft: #031b2b;
--focus: 0 0 0 3px rgba(29, 155, 240, .34);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
margin: 0; min-width: 320px; background: var(--bg); color: var(--text);
font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
font-size: 16px; line-height: 1.45;
}
body.modal-open { overflow: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button, [role="button"] { cursor: pointer; touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--focus); }
svg { display: block; }
.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-link { position: fixed; z-index: 500; left: 12px; top: calc(var(--df-generated-header-height, 0px) + 8px); padding: 10px 16px; border-radius: 999px; color: #fff; background: var(--accent); transform: translateY(-160%); text-decoration: none; }
.skip-link:focus { transform: translateY(0); }
.app { width: min(1265px, 100%); min-height: 100dvh; margin: 0 auto; display: grid; grid-template-columns: var(--nav-w) var(--feed-w) var(--aside-w); gap: 28px; }
.left-rail { position: relative; }
.left-fixed { position: fixed; top: var(--df-generated-header-height, 0px); width: var(--nav-w); height: calc(100dvh - var(--df-generated-header-height, 0px)); padding: 8px 18px 12px 4px; display: flex; flex-direction: column; }
.brand { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; color: var(--text); text-decoration: none; transition: background .18s; }
.brand:hover { background: var(--soft); }
.brand svg { width: 30px; height: 30px; }
.primary-nav { display: grid; gap: 4px; margin-top: 5px; }
.nav-item { width: fit-content; min-height: 50px; padding: 0 17px 0 12px; border-radius: 999px; display: flex; align-items: center; gap: 19px; color: var(--text); text-decoration: none; font-size: 20px; transition: background .18s; }
.nav-item:hover { background: var(--soft); }
.nav-item.active { font-weight: 750; }
.nav-item svg { width: 26px; height: 26px; }
.nav-item.active svg { fill: currentColor; }
.nav-badge { min-width: 18px; height: 18px; margin-left: -26px; margin-top: -25px; padding: 0 5px; display: grid; place-items: center; border: 2px solid var(--bg); border-radius: 9px; color: #fff; background: var(--accent); font-size: 10px; font-weight: 800; }
.post-cta { width: 218px; height: 52px; margin-top: 14px; border: 0; border-radius: 999px; color: #fff; background: var(--accent); font-size: 17px; font-weight: 750; box-shadow: 0 8px 18px rgba(29,155,240,.18); transition: background .18s, transform .18s; }
.post-cta:hover { background: var(--accent-hover); transform: translateY(-1px); }
.account-switcher { min-height: 64px; margin-top: auto; padding: 9px 10px; border: 0; border-radius: 999px; display: flex; align-items: center; gap: 10px; background: transparent; text-align: left; transition: background .18s; }
.account-switcher:hover { background: var(--soft); }
.account-copy { min-width: 0; flex: 1; }
.account-copy strong, .account-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy span { color: var(--muted); font-size: 14px; }
.account-switcher > svg { width: 19px; height: 19px; }
.avatar { --a: #4f46e5; --b: #a855f7; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, var(--a), var(--b)); font-weight: 800; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.avatar-sm { width: 38px; height: 38px; font-size: 13px; }
.avatar-lg { width: 48px; height: 48px; }
.feed { min-width: 0; border-inline: 1px solid var(--border); }
.feed-header { position: sticky; z-index: 30; top: var(--df-generated-header-height, 0px); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
.mobile-title { display: none; height: 52px; padding: 0 16px; align-items: center; justify-content: space-between; }
.mobile-title .brand { width: 42px; height: 42px; }
.tabs { height: 53px; display: grid; grid-template-columns: 1fr 1fr; }
.tab { position: relative; border: 0; background: transparent; color: var(--muted); font-size: 15px; font-weight: 550; transition: background .18s; }
.tab:hover { background: color-mix(in srgb, var(--soft) 70%, transparent); }
.tab.active { color: var(--text); font-weight: 750; }
.tab.active::after { content: ""; position: absolute; left: 50%; bottom: 0; width: 58px; height: 4px; border-radius: 2px; background: var(--accent); transform: translateX(-50%); }
.composer { padding: 12px 16px 8px; display: grid; grid-template-columns: 48px 1fr; gap: 12px; border-bottom: 1px solid var(--border); }
.composer-main { min-width: 0; }
.audience-button { min-height: 44px; margin-bottom: 3px; padding: 1px 11px; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--accent); background: transparent; font-size: 13px; font-weight: 750; }
.composer textarea { width: 100%; min-height: 74px; max-height: 220px; padding: 8px 0; resize: vertical; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 20px; line-height: 1.45; }
.composer textarea::placeholder { color: var(--muted); }
.reply-permission { display: none; width: fit-content; align-items: center; gap: 6px; min-height: 28px; margin: 0 0 8px; color: var(--accent); font-size: 13px; font-weight: 650; }
.reply-permission.visible { display: flex; }
.reply-permission svg { width: 14px; height: 14px; }
.composer-footer { min-height: 42px; padding-top: 8px; border-top: 1px solid transparent; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.composer-tools { display: flex; align-items: center; gap: 1px; }
.tool-button { width: 44px; height: 44px; border: 0; border-radius: 50%; display: grid; place-items: center; color: var(--accent); background: transparent; transition: background .18s; }
.tool-button:hover { background: var(--accent-soft); }
.tool-button svg { width: 19px; height: 19px; }
.composer-submit { display: flex; align-items: center; gap: 10px; }
.char-counter { width: 26px; height: 26px; display: grid; place-items: center; border: 2px solid var(--border-strong); border-radius: 50%; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.char-counter.warn { color: #f4212e; border-color: #f4212e; }
.send-button { min-width: 74px; height: 44px; padding: 0 17px; border: 0; border-radius: 999px; color: #fff; background: var(--accent); font-weight: 750; transition: opacity .18s, background .18s; }
.send-button:hover:not(:disabled) { background: var(--accent-hover); }
.send-button:disabled { opacity: .5; cursor: not-allowed; }
.timeline-status { display: none; min-height: 48px; border-bottom: 1px solid var(--border); color: var(--accent); background: var(--surface); font-size: 14px; font-weight: 600; text-align: center; }
.timeline-status.show { display: grid; place-items: center; }
.post { position: relative; display: grid; grid-template-columns: 48px 1fr; gap: 10px; padding: 12px 16px 5px; border-bottom: 1px solid var(--border); transition: background .15s; }
.post:hover { background: var(--surface-hover); }
.post-main { min-width: 0; }
.post-head { min-width: 0; display: flex; align-items: center; gap: 4px; line-height: 1.25; }
.post-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.verified { width: 16px; height: 16px; flex: 0 0 auto; color: var(--accent); }
.handle, .dot, time { color: var(--muted); font-size: 15px; white-space: nowrap; }
.more { width: 44px; height: 44px; margin: -12px -8px -12px auto; flex: 0 0 auto; border: 0; border-radius: 50%; display: grid; place-items: center; color: var(--muted); background: transparent; transition: color .18s, background .18s; }
.more:hover { color: var(--accent); background: var(--accent-soft); }
.more svg { width: 18px; height: 18px; }
.post-text { margin: 2px 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-text a { color: var(--accent); text-decoration: none; }
.post-text a:hover { text-decoration: underline; }
.context-label { margin: -4px 0 8px; color: var(--muted); font-size: 13px; }
.post-source { margin: 2px 0 8px; font-size: 12px; line-height: 1.45; }
.post-source a { color: var(--accent); font-weight: 700; text-decoration: none; }
.post-media { position: relative; width: 100%; aspect-ratio: 16/10; overflow: hidden; border: 1px solid var(--border-strong); border-radius: 16px; background: var(--soft); }
.post-media svg { width: 100%; height: 100%; }
.media-caption { position: absolute; right: 10px; bottom: 10px; padding: 5px 8px; border-radius: 6px; color: #fff; background: rgba(0,0,0,.68); font-size: 11px; }
.quote-post { margin: 8px 0 5px; padding: 12px; border: 1px solid var(--border-strong); border-radius: 16px; }
.quote-post:hover { background: color-mix(in srgb, var(--soft) 45%, transparent); }
.quote-author { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.quote-post p { margin: 7px 0 0; font-size: 15px; }
.post-actions { max-width: 440px; height: 44px; margin-top: 5px; display: flex; justify-content: space-between; align-items: center; }
.action { min-width: 48px; height: 44px; padding: 0; border: 0; border-radius: 999px; display: flex; align-items: center; gap: 5px; color: var(--muted); background: transparent; font-size: 12px; transition: color .18s; }
.action-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; transition: background .18s; }
.action svg { width: 18px; height: 18px; }
.action:hover { color: var(--accent); }
.action:hover .action-icon { background: var(--accent-soft); }
.action.repost:hover, .action.reposted { color: var(--success); }
.action.repost:hover .action-icon { background: color-mix(in srgb, var(--success) 12%, transparent); }
.action.like:hover, .action.liked { color: var(--danger); }
.action.like:hover .action-icon { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.action.liked svg, .action.bookmarked svg { fill: currentColor; }
.bookmark-action { min-width: 44px; }
.post-menu { position: absolute; z-index: 20; top: 40px; right: 12px; width: 220px; padding: 7px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 10px 32px rgba(0,0,0,.16); display: none; }
.post-menu.open { display: block; }
.post-menu button { width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-radius: 8px; display: flex; align-items: center; gap: 10px; background: transparent; text-align: left; }
.post-menu button:hover { background: var(--soft); }
.post-menu svg { width: 18px; height: 18px; }
.reply-section { display: none; grid-column: 2; padding: 7px 0 9px; }
.reply-section.open { display: block; }
.reply-tools { min-height: 38px; margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.reply-tools[hidden] { display: none; }
.reply-summary { font-size: 14px; }
.reply-tools > div { display: flex; gap: 4px; }
.reply-sort { padding: 6px 10px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-weight: 700; }
.reply-sort:hover, .reply-sort.active { color: var(--accent); background: var(--accent-soft); }
.reply-list { display: grid; gap: 0; margin-bottom: 8px; }
.reply-item { padding: 10px 0; display: flex; align-items: flex-start; gap: 10px; border-top: 1px solid var(--border); }
.reply-content { min-width: 0; flex: 1; }
.reply-content header { min-height: 20px; display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.reply-content header strong { overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.reply-content header svg { width: 15px; height: 15px; flex: 0 0 auto; }
.reply-content p { margin: 3px 0 0; font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
.reply-meta { min-height: 24px; margin-top: 3px; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.reply-meta button { padding: 0; border: 0; color: inherit; background: transparent; font-weight: 700; }
.reply-meta button:hover { color: var(--accent); }
.reply-pagination { margin: 0 0 9px 50px; display: flex; flex-wrap: wrap; gap: 8px; }
.reply-pagination button { min-height: 34px; padding: 0 13px; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--accent); background: var(--surface); font-weight: 700; }
.reply-pagination button:hover { background: var(--accent-soft); }
.reply-pagination button[hidden] { display: none; }
.reply-form { display: flex; gap: 8px; }
.reply-form input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--text); background: var(--surface); font-size: 16px; }
.reply-send { width: 44px; height: 44px; border: 0; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--accent); }
.reply-send svg { width: 18px; height: 18px; }
.empty-state { display: none; padding: 48px 24px; border-bottom: 1px solid var(--border); text-align: center; }
.empty-state svg { width: 38px; height: 38px; margin: 0 auto 12px; color: var(--muted); }
.empty-state h2 { margin: 0 0 5px; font-size: 24px; }
.empty-state p { margin: 0; color: var(--muted); }
.right-rail { min-width: 0; }
.right-fixed { position: sticky; top: var(--df-generated-header-height, 0px); max-height: calc(100dvh - var(--df-generated-header-height, 0px)); padding-top: 5px; overflow-y: auto; scrollbar-width: none; }
.right-fixed::-webkit-scrollbar { display: none; }
.search-box { position: sticky; z-index: 20; top: 0; padding: 0 0 10px; background: var(--bg); }
.search-label { position: relative; display: block; }
.search-label svg { position: absolute; left: 17px; top: 50%; width: 18px; height: 18px; color: var(--muted); transform: translateY(-50%); }
.search-input { width: 100%; height: 44px; padding: 0 16px 0 47px; border: 1px solid transparent; border-radius: 999px; color: var(--text); background: var(--soft); outline: 0; font-size: 16px; }
.search-input:focus { border-color: var(--accent); background: var(--surface); }
.side-card { margin: 7px 0 16px; overflow: hidden; border-radius: 16px; background: var(--soft); }
.side-card h2 { margin: 0; padding: 12px 16px 6px; font-size: 20px; line-height: 1.25; }
.trend { min-height: 76px; padding: 10px 16px; display: block; color: inherit; text-decoration: none; transition: background .15s; }
.trend:hover { background: color-mix(in srgb, var(--muted) 8%, transparent); }
.trend-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.trend-head svg { width: 16px; height: 16px; }
.trend strong { display: block; margin: 2px 0; font-size: 15px; }
.trend small { color: var(--muted); }
.show-more { display: block; min-height: 48px; padding: 14px 16px; color: var(--accent); text-decoration: none; font-size: 14px; }
.show-more:hover { background: color-mix(in srgb, var(--muted) 8%, transparent); }
.follow-row { min-height: 66px; padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.follow-row:hover { background: color-mix(in srgb, var(--muted) 8%, transparent); }
.follow-copy { min-width: 0; flex: 1; }
.follow-copy strong, .follow-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.follow-copy span { color: var(--muted); font-size: 14px; }
.follow-button { min-width: 72px; height: 44px; padding: 0 15px; border: 1px solid var(--text); border-radius: 999px; color: var(--bg); background: var(--text); font-size: 14px; font-weight: 750; }
.follow-button.following { color: var(--text); background: transparent; }
.right-footer { padding: 0 13px 24px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.right-footer a { margin-right: 8px; color: inherit; text-decoration: none; }
.right-footer a:hover { text-decoration: underline; }
.mobile-nav { display: none; }
.floating-compose { display: none; }
.modal-backdrop { position: fixed; z-index: 100; inset: 0; padding: 20px; display: grid; place-items: start center; background: rgba(91,112,131,.42); opacity: 0; visibility: hidden; transition: opacity .18s, visibility .18s; }
.modal-backdrop.open { opacity: 1; visibility: visible; }
.compose-modal { width: min(600px, 100%); min-height: 270px; margin-top: 5vh; padding: 10px 16px 16px; border-radius: 16px; background: var(--surface); box-shadow: 0 20px 70px rgba(0,0,0,.22); transform: translateY(-8px); transition: transform .2s; }
.modal-backdrop.open .compose-modal { transform: translateY(0); }
.modal-top { min-height: 44px; display: flex; align-items: center; justify-content: space-between; }
.close-button { width: 44px; height: 44px; border: 0; border-radius: 50%; display: grid; place-items: center; background: transparent; }
.close-button:hover { background: var(--soft); }
.close-button svg { width: 20px; height: 20px; }
.drafts { border: 0; padding: 10px; color: var(--accent); background: transparent; font-weight: 700; }
.modal-compose-row { display: grid; grid-template-columns: 48px 1fr; gap: 12px; padding-top: 8px; }
.modal-textarea { width: 100%; min-height: 115px; padding: 7px 0; resize: none; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 20px; line-height: 1.5; }
.modal-footer { margin-left: 60px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 25px; padding: 10px 17px; border-radius: 6px; color: #fff; background: var(--accent); box-shadow: 0 8px 28px rgba(0,0,0,.22); opacity: 0; visibility: hidden; transform: translate(-50%, 12px); transition: opacity .18s, visibility .18s, transform .18s; }
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%,0); }
@media (max-width: 1120px) {
:root { --nav-w: 78px; --aside-w: 330px; }
.app { width: min(1040px, 100%); gap: 18px; }
.left-fixed { width: var(--nav-w); padding-right: 8px; align-items: center; }
.nav-item { width: 52px; padding: 0; justify-content: center; }
.nav-item span, .account-copy, .account-switcher > svg { display: none; }
.post-cta { width: 52px; height: 52px; font-size: 0; }
.post-cta::after { content: "+"; font-size: 28px; font-weight: 400; }
.account-switcher { padding: 6px; }
}
@media (max-width: 960px) {
:root { --feed-w: min(600px, calc(100vw - 100px)); }
.app { grid-template-columns: var(--nav-w) var(--feed-w); width: fit-content; gap: 0; }
.right-rail { display: none; }
}
@media (max-width: 680px) {
body { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
.app { display: block; width: 100%; }
.left-rail { display: none; }
.feed { width: 100%; border-inline: 0; }
.mobile-title { display: flex; }
.mobile-title strong { font-size: 18px; }
.desktop-composer { display: none; }
.post { padding-inline: 12px; }
.post-head { flex-wrap: nowrap; }
.handle { max-width: 95px; overflow: hidden; text-overflow: ellipsis; }
.mobile-nav { position: fixed; z-index: 60; inset: auto 0 0; height: calc(58px + env(safe-area-inset-bottom)); padding: 3px 10px max(3px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5,1fr); border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(15px); }
.mobile-nav button { min-height: 50px; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--muted); background: transparent; font-size: 10px; }
.mobile-nav button.active { color: var(--text); }
.mobile-nav svg { width: 22px; height: 22px; }
.floating-compose { position: fixed; z-index: 55; right: 18px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 54px; height: 54px; border: 0; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--accent); box-shadow: 0 8px 24px rgba(29,155,240,.36); }
.floating-compose svg { width: 23px; height: 23px; }
.compose-modal { min-height: 100dvh; margin: 0; border-radius: 0; }
.modal-backdrop { padding: 0; }
.post-actions { max-width: none; }
.action { min-width: 40px; }
.action-count { font-size: 11px; }
}
@media (max-width: 410px) {
.post { grid-template-columns: 42px 1fr; gap: 8px; }
.avatar-lg { width: 42px; height: 42px; }
.post-head { gap: 3px; }
.handle { max-width: 72px; }
.post-text { font-size: 15px; }
.action.views { display: none; }
.modal-footer { margin-left: 54px; }
}
.settings-trigger { position: fixed; z-index: 90; top: calc(var(--df-generated-header-height, 0px) + 16px); right: 18px; width: 46px; height: 46px; border: 1px solid var(--border-strong); border-radius: 50%; display: grid; place-items: center; color: var(--text); background: color-mix(in srgb, var(--surface) 90%, transparent); box-shadow: 0 8px 24px rgba(15,20,25,.14); backdrop-filter: blur(12px); transition: transform .18s, background .18s; }
.settings-trigger:hover { background: var(--soft); transform: rotate(12deg); }
.settings-trigger svg { width: 21px; height: 21px; }
.settings-backdrop { position: fixed; z-index: 300; inset: 0; padding: 28px; display: grid; place-items: center; background: rgba(15,20,25,.72); opacity: 0; visibility: hidden; transition: opacity .18s, visibility .18s; }
.settings-backdrop.open { opacity: 1; visibility: visible; }
.settings-panel { width: min(1180px, 100%); height: min(780px, calc(100dvh - 56px)); overflow: hidden; display: grid; grid-template-rows: auto minmax(0,1fr) auto; border: 1px solid #536471; border-radius: 18px; color: #e7e9ea; background: #000; box-shadow: 0 32px 100px rgba(0,0,0,.54); }
.settings-head { min-height: 82px; padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #2f3336; }
.settings-kicker { color: #1d9bf0; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.settings-head h2 { margin: 2px 0 0; font-size: 26px; }
.settings-close { width: 44px; height: 44px; border: 1px solid #536471; border-radius: 12px; display: grid; place-items: center; color: #e7e9ea; background: #0f1419; }
.settings-close:hover { background: #16181c; }
.settings-close svg { width: 22px; height: 22px; }
.settings-body { min-height: 0; display: grid; grid-template-columns: 250px minmax(0,1fr); }
.module-tabs { min-height: 0; padding: 18px; overflow-y: auto; border-right: 1px solid #2f3336; background: #080808; }
.module-tabs h3 { margin: 0 0 12px; color: #71767b; font-size: 13px; font-weight: 650; }
.module-tab { width: 100%; min-height: 54px; margin-bottom: 8px; padding: 8px 12px; border: 1px solid transparent; border-radius: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #e7e9ea; background: transparent; text-align: left; }
.module-tab:hover { background: #16181c; }
.module-tab.active { border-color: #1d9bf0; color: #fff; background: #031b2b; }
.module-tab small { color: #71767b; font-size: 11px; }
.editor-pane { min-width: 0; min-height: 0; padding: 18px 20px 16px; display: grid; grid-template-rows: auto minmax(0,1fr) auto; gap: 10px; }
.editor-title { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.editor-title strong { font-size: 17px; }
.editor-title span { color: #71767b; font-size: 13px; }
.json-editor { width: 100%; min-height: 0; padding: 16px; resize: none; border: 1px solid #2f3336; border-radius: 12px; outline: 0; color: #d6f1ff; background: #05090d; font: 14px/1.62 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; tab-size: 2; }
.json-editor:focus { border-color: #1d9bf0; box-shadow: 0 0 0 3px rgba(29,155,240,.18); }
.editor-hint { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #71767b; font-size: 12px; }
.json-status { font-weight: 750; }
.json-status.valid { color: #00ba7c; }
.json-status.invalid { color: #f4212e; }
.settings-actions { min-height: 76px; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid #2f3336; }
.action-group { display: flex; flex-wrap: wrap; gap: 10px; }
.settings-button { min-height: 44px; padding: 0 17px; border: 1px solid #536471; border-radius: 999px; color: #e7e9ea; background: transparent; font-weight: 700; }
.settings-button:hover { background: #16181c; }
.settings-button.primary { border-color: #1d9bf0; color: #fff; background: #1d9bf0; }
.settings-button.primary:hover { background: #1a8cd8; }
.settings-button.danger { color: #f4212e; }
@media (max-width: 760px) {
.settings-trigger { top: calc(var(--df-generated-header-height, 0px) + 7px); right: 60px; width: 40px; height: 40px; }
.settings-backdrop { padding: 0; }
.settings-panel { width: 100%; height: 100dvh; border: 0; border-radius: 0; }
.settings-head { min-height: 68px; padding: 12px 14px; }
.settings-head h2 { font-size: 21px; }
.settings-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr); }
.module-tabs { padding: 10px 12px 2px; display: flex; gap: 8px; overflow-x: auto; border-right: 0; border-bottom: 1px solid #2f3336; }
.module-tabs h3 { display: none; }
.module-tab { width: auto; min-width: max-content; min-height: 40px; margin: 0 0 8px; padding: 6px 10px; }
.module-tab small { display: none; }
.editor-pane { padding: 12px; }
.settings-actions { min-height: 70px; padding: 10px 12px; }
.settings-button { min-height: 42px; padding: 0 13px; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
.skip-link { transform: translateY(calc(-100% - var(--df-generated-header-height, 0px) - 24px)); }
.skip-link:focus { transform: translateY(0); }
.modal-backdrop { z-index: 1200; }
.settings-backdrop { z-index: 1300; }
</style>
</head>
<body>
<a href="#mainFeed" class="skip-link">跳到时间线</a>
<svg aria-hidden="true" width="0" height="0" style="position:absolute">
<symbol id="i-x-brand" viewBox="0 0 24 24"><path d="M4.2 3h4.9l4.1 5.5L18 3h2l-5.9 6.9L21 21h-4.9l-4.5-6-5.2 6h-2l6.3-7.4L4.2 3Zm4 1.7 8.8 14.6h2.1L10.3 4.7H8.2Z" fill="currentColor"/></symbol>
<symbol id="i-settings" viewBox="0 0 24 24"><path d="M12 15.2a3.2 3.2 0 1 0 0-6.4 3.2 3.2 0 0 0 0 6.4Z" fill="none" stroke="currentColor" stroke-width="2"/><path d="M19.4 15a1.7 1.7 0 0 0 .34 1.88l.06.06-2.86 2.86-.06-.06A1.7 1.7 0 0 0 15 19.4a1.7 1.7 0 0 0-1 .6 1.7 1.7 0 0 0-.4 1.1V21H9.55v-.09A1.7 1.7 0 0 0 8.5 19.4a1.7 1.7 0 0 0-1.88.34l-.06.06-2.86-2.86.06-.06A1.7 1.7 0 0 0 4.1 15a1.7 1.7 0 0 0-.6-1 1.7 1.7 0 0 0-1.1-.4H2.3V9.55h.09A1.7 1.7 0 0 0 4.1 8.5a1.7 1.7 0 0 0-.34-1.88l-.06-.06L6.56 3.7l.06.06A1.7 1.7 0 0 0 8.5 4.1a1.7 1.7 0 0 0 1-.6 1.7 1.7 0 0 0 .4-1.1V2.3h4.05v.09A1.7 1.7 0 0 0 15 4.1a1.7 1.7 0 0 0 1.88-.34l.06-.06 2.86 2.86-.06.06A1.7 1.7 0 0 0 19.4 8.5a1.7 1.7 0 0 0 .6 1c.3.26.7.4 1.1.4h.1v4.05h-.09A1.7 1.7 0 0 0 19.4 15Z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></symbol>
<symbol id="i-home" viewBox="0 0 24 24"><path d="m3 10 9-7 9 7v10a1 1 0 0 1-1 1h-5v-7H9v7H4a1 1 0 0 1-1-1Z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/></symbol>
<symbol id="i-search" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7" fill="none" stroke="currentColor" stroke-width="2"/><path d="m16.2 16.2 4.2 4.2" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></symbol>
<symbol id="i-bell" viewBox="0 0 24 24"><path d="M18 8a6 6 0 0 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9ZM10 21h4" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></symbol>
<symbol id="i-message" viewBox="0 0 24 24"><path d="M4 5h16v12H8l-4 4Z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/></symbol>
<symbol id="i-users" viewBox="0 0 24 24"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm13 10v-2a4 4 0 0 0-3-3.87" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></symbol>
<symbol id="i-bookmark" viewBox="0 0 24 24"><path d="M6 3h12a1 1 0 0 1 1 1v17l-7-4-7 4V4a1 1 0 0 1 1-1Z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/></symbol>
<symbol id="i-user" viewBox="0 0 24 24"><circle cx="12" cy="8" r="4" fill="none" stroke="currentColor" stroke-width="2"/><path d="M4 21a8 8 0 0 1 16 0" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></symbol>
<symbol id="i-more" viewBox="0 0 24 24"><circle cx="5" cy="12" r="1.7" fill="currentColor"/><circle cx="12" cy="12" r="1.7" fill="currentColor"/><circle cx="19" cy="12" r="1.7" fill="currentColor"/></symbol>
<symbol id="i-image" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2" fill="none" stroke="currentColor" stroke-width="2"/><circle cx="8.5" cy="9" r="1.5" fill="currentColor"/><path d="m4 17 5-5 4 4 2-2 5 4" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/></symbol>
<symbol id="i-gif" viewBox="0 0 24 24"><rect x="3" y="5" width="18" height="14" rx="2" fill="none" stroke="currentColor" stroke-width="2"/><path d="M8.5 10H7a2 2 0 0 0 0 4h2v-2H7.7m4.3-2v4m3-4h3m-3 4v-4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></symbol>
<symbol id="i-poll" viewBox="0 0 24 24"><path d="M5 20V10m7 10V4m7 16v-7" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></symbol>
<symbol id="i-smile" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="2"/><path d="M8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></symbol>
<symbol id="i-calendar" viewBox="0 0 24 24"><rect x="3" y="5" width="18" height="16" rx="2" fill="none" stroke="currentColor" stroke-width="2"/><path d="M16 3v4M8 3v4M3 11h18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></symbol>
<symbol id="i-globe" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="2"/><path d="M3 12h18M12 3a14 14 0 0 1 0 18M12 3a14 14 0 0 0 0 18" fill="none" stroke="currentColor" stroke-width="1.5"/></symbol>
<symbol id="i-comment" viewBox="0 0 24 24"><path d="M21 12a8.5 8.5 0 0 1-9 8.5 9 9 0 0 1-3.7-.8L4 21l1.2-3.8A8.5 8.5 0 1 1 21 12Z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/></symbol>
<symbol id="i-repost" viewBox="0 0 24 24"><path d="m17 3 4 4-4 4M3 7h18M7 21l-4-4 4-4m14 4H3" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></symbol>
<symbol id="i-heart" viewBox="0 0 24 24"><path d="M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1.1-1.1a5.5 5.5 0 0 0-7.8 7.8l1.1 1.1L12 21l7.8-7.5 1.1-1.1a5.5 5.5 0 0 0-.1-7.8Z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/></symbol>
<symbol id="i-chart" viewBox="0 0 24 24"><path d="M4 20V10m5 10V4m6 16v-7m5 7V7" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></symbol>
<symbol id="i-share" viewBox="0 0 24 24"><path d="M12 16V3m0 0L7 8m5-5 5 5M5 13v7h14v-7" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></symbol>
<symbol id="i-verified" viewBox="0 0 24 24"><path d="m12 2 2.2 2.1 3-.4.9 2.9 2.7 1.4-1.3 2.8 1.3 2.8-2.7 1.4-.9 2.9-3-.4L12 22l-2.2-2.1-3 .4-.9-2.9L3.2 16l1.3-2.8-1.3-2.8L5.9 9l.9-2.9 3 .4Z" fill="currentColor"/><path d="m8.5 12 2.2 2.2 4.8-5" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></symbol>
<symbol id="i-pen" viewBox="0 0 24 24"><path d="m4 20 4.5-1 10.8-10.8a2.1 2.1 0 0 0-3-3L5.5 16Zm9.8-12.3 3 3M13 20h7" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></symbol>
<symbol id="i-close" viewBox="0 0 24 24"><path d="m6 6 12 12M18 6 6 18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></symbol>
<symbol id="i-sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4" fill="none" stroke="currentColor" stroke-width="2"/><path d="M12 2v2m0 16v2M4.9 4.9l1.5 1.5m11.2 11.2 1.5 1.5M2 12h2m16 0h2M4.9 19.1l1.5-1.5M17.6 6.4l1.5-1.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></symbol>
<symbol id="i-moon" viewBox="0 0 24 24"><path d="M21 12.8A9 9 0 1 1 11.2 3 7 7 0 0 0 21 12.8Z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/></symbol>
<symbol id="i-send" viewBox="0 0 24 24"><path d="m22 2-7 20-4-9-9-4Z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><path d="M22 2 11 13" fill="none" stroke="currentColor" stroke-width="2"/></symbol>
<symbol id="i-volume-off" viewBox="0 0 24 24"><path d="M11 5 6 9H2v6h4l5 4Zm4 5 6 6m0-6-6 6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></symbol>
</svg>
<div class="app">
<aside class="left-rail" aria-label="主导航">
<div class="left-fixed">
<a class="brand" id="brandLink" href="#mainFeed" aria-label="X 首页"><svg><use href="#i-x-brand"/></svg></a>
<nav class="primary-nav" id="primaryNav"></nav>
<button class="post-cta" id="postCta" data-open-modal>发布</button>
<button class="account-switcher" id="accountSwitcher" aria-label="账户菜单"></button>
</div>
</aside>
<main class="feed" id="mainFeed">
<h1 class="sr-only" id="timelineHeading">X 首页时间线</h1>
<header class="feed-header">
<div class="mobile-title"><span id="mobileUser"></span><strong id="mobileTitle">首页</strong><button class="tool-button" id="mobileTheme" aria-label="切换主题"><svg><use href="#i-moon"/></svg></button></div>
<div class="tabs" id="feedTabs" role="tablist"></div>
</header>
<section class="composer desktop-composer" aria-label="发布动态">
<span id="composerAvatar"></span>
<div class="composer-main">
<button class="audience-button" id="composerAudience">所有人</button>
<label class="sr-only" for="composerText">动态内容</label>
<textarea id="composerText" maxlength="280" placeholder="有什么新鲜事?"></textarea>
<div class="reply-permission" id="replyPermission"><svg><use href="#i-globe"/></svg><span></span></div>
<div class="composer-footer">
<div class="composer-tools"><button class="tool-button" aria-label="添加图片"><svg><use href="#i-image"/></svg></button><button class="tool-button" aria-label="添加 GIF"><svg><use href="#i-gif"/></svg></button><button class="tool-button" aria-label="添加投票"><svg><use href="#i-poll"/></svg></button><button class="tool-button" aria-label="添加表情"><svg><use href="#i-smile"/></svg></button><button class="tool-button" aria-label="定时发布"><svg><use href="#i-calendar"/></svg></button></div>
<div class="composer-submit"><span class="char-counter" id="charCounter">280</span><button class="send-button" id="publishButton" disabled>发布</button></div>
</div>
</div>
</section>
<button class="timeline-status" id="timelineStatus">已切换时间线</button>
<section id="posts" aria-label="动态列表"></section>
<section class="empty-state" id="emptyState"><svg><use href="#i-search"/></svg><h2>没有找到结果</h2><p>换一个关键词,看看正在发生的其他事情。</p></section>
</main>
<aside class="right-rail" aria-label="趋势与推荐">
<div class="right-fixed">
<div class="search-box"><label class="search-label"><span class="sr-only">搜索动态</span><svg><use href="#i-search"/></svg><input id="searchInput" class="search-input" type="search" placeholder="搜索" autocomplete="off" /></label></div>
<section class="side-card" id="trendsCard"></section>
<section class="side-card" id="recommendationsCard"></section>
<button class="follow-button following" id="themeToggle" style="margin:0 12px 18px;min-width:112px">切换深色模式</button>
<footer class="right-footer" id="rightFooter"></footer>
</div>
</aside>
</div>
<nav class="mobile-nav" id="mobileNav" aria-label="移动端导航"></nav>
<button class="floating-compose" data-open-modal aria-label="发布动态"><svg><use href="#i-pen"/></svg></button>
<div class="modal-backdrop" id="composeModal" aria-hidden="true">
<section class="compose-modal" role="dialog" aria-modal="true" aria-labelledby="modalTitle">
<div class="modal-top"><button class="close-button" id="closeModal" aria-label="关闭发布窗口"><svg><use href="#i-close"/></svg></button><strong id="modalTitle" class="sr-only">发布动态</strong><button class="drafts" id="draftsLabel">草稿</button></div>
<div class="modal-compose-row"><span id="modalAvatar"></span><div><button class="audience-button" id="modalAudience">所有人</button><label class="sr-only" for="modalText">动态内容</label><textarea id="modalText" class="modal-textarea" maxlength="280" placeholder="有什么新鲜事?"></textarea><div class="reply-permission visible"><svg><use href="#i-globe"/></svg><span id="modalReplyPermission"></span></div></div></div>
<div class="modal-footer"><div class="composer-tools"><button class="tool-button" aria-label="添加图片"><svg><use href="#i-image"/></svg></button><button class="tool-button" aria-label="添加 GIF"><svg><use href="#i-gif"/></svg></button><button class="tool-button" aria-label="添加投票"><svg><use href="#i-poll"/></svg></button><button class="tool-button" aria-label="添加表情"><svg><use href="#i-smile"/></svg></button></div><div class="composer-submit"><span class="char-counter" id="modalCounter">280</span><button class="send-button" id="modalPublish" disabled>发布</button></div></div>
</section>
</div>
<button class="settings-trigger" id="openSettings" aria-label="编辑页面 JSON" title="编辑页面 JSON"><svg><use href="#i-settings"/></svg></button>
<div class="settings-backdrop" id="settingsModal" aria-hidden="true">
<section class="settings-panel" role="dialog" aria-modal="true" aria-labelledby="settingsTitle">
<header class="settings-head"><div><div class="settings-kicker">X 页面控制台</div><h2 id="settingsTitle">JSON 编辑器</h2></div><button class="settings-close" id="closeSettings" aria-label="关闭 JSON 编辑器"><svg><use href="#i-close"/></svg></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-actions"><div class="action-group"><button class="settings-button" id="copyJson">复制完整 JSON</button><button class="settings-button" id="downloadJson">下载 JSON</button><button class="settings-button danger" id="resetJson">恢复初始数据</button></div><button class="settings-button primary" id="applyJson">应用并渲染</button></footer>
</section>
</div>
<div class="toast" id="toast" role="status" aria-live="polite"></div>
<script type="application/json" id="xPageData">__X_PAGE_DATA__</script>
<script>__X_PAGE_RUNTIME__</script>
</body>
</html>