feat: 发布三笙AI情报局独立版公司研发基线
同步家纺情报 v2 数据、59 个严格权威源、趋势图库、移动端交互、Google/Yandex 翻译门控及静态 SEO/GEO 构建。 补充面向 C# 研发的 README,明确当前无 LLM、多模态与生图模型,记录翻译请求参数、缓存与失败策略、数据处理边界、前端职责和无 GitHub Pages 部署流程。 新增按日期倒序维护的 CHANGELOG,记录影响、验证与代码/数据/dist 回滚方法。 验证:11 个 Python 契约测试、13 个 Node 前端测试通过;静态构建生成 1096 个 Sitemap URL。
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import { getIntelligenceSection, renderIntelligence, setIntelligenceSection, shareIntelligence } from "./render-intelligence.js?v=20260814n";
|
||||
|
||||
const DATA_ROOT = "./data";
|
||||
|
||||
async function json(name) {
|
||||
const response = await fetch(`${DATA_ROOT}/${name}?t=${Date.now()}`, { cache: "no-store" });
|
||||
if (!response.ok) throw new Error(`${name} 加载失败:HTTP ${response.status}`);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
function showToast(message) {
|
||||
const toast = document.getElementById("toast");
|
||||
toast.textContent = message;
|
||||
toast.classList.add("visible");
|
||||
window.setTimeout(() => toast.classList.remove("visible"), 2200);
|
||||
}
|
||||
|
||||
function applyTheme(theme) {
|
||||
document.documentElement.dataset.theme = theme;
|
||||
localStorage.setItem("sansheng-intelligence-theme", theme);
|
||||
const button = document.getElementById("themeBtn");
|
||||
const label = theme === "dark" ? "切换到亮色主题" : "切换到暗色主题";
|
||||
button?.setAttribute("aria-label", label);
|
||||
if (button) button.title = label;
|
||||
document.querySelector('meta[name="theme-color"]')?.setAttribute("content", theme === "dark" ? "#091119" : "#f5f8fb");
|
||||
}
|
||||
|
||||
function syncUrl(value) {
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.set("intel", value || getIntelligenceSection());
|
||||
history.replaceState(null, "", url);
|
||||
}
|
||||
|
||||
async function init() {
|
||||
try {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
setIntelligenceSection(params.get("intel") || "today");
|
||||
applyTheme(localStorage.getItem("sansheng-intelligence-theme") || "light");
|
||||
const [intelligence, trends] = await Promise.all([json("textile-intelligence.json"), json("textile-trends.json")]);
|
||||
renderIntelligence({ ...intelligence, trends }, {
|
||||
root: document.getElementById("intelligencePanel"),
|
||||
onStateChange: syncUrl,
|
||||
});
|
||||
syncUrl(getIntelligenceSection());
|
||||
} catch (error) {
|
||||
console.error("[三笙AI情报局] 初始化失败:", error);
|
||||
document.getElementById("intelligenceList").innerHTML = `<div class="intelligence-empty">${error.message}。请先运行 update.bat。</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.getElementById("themeBtn").addEventListener("click", () => applyTheme(document.documentElement.dataset.theme === "dark" ? "light" : "dark"));
|
||||
document.getElementById("shareBtn").addEventListener("click", async () => {
|
||||
try { showToast(await shareIntelligence()); }
|
||||
catch (error) { console.error("[三笙AI情报局] 分享失败:", error); showToast("分享失败,请复制地址栏链接"); }
|
||||
});
|
||||
init();
|
||||
});
|
||||
Reference in New Issue
Block a user