Files
wagtailcms-frontend/components/layout/Footer.tsx
T

57 lines
3.2 KiB
TypeScript

import { getSiteSettings } from "@/services/site-settings.service";
import { getNavigationMenu } from "@/services/navigation.service";
import Image from "next/image";
// 合规要求:中国大陆网站需展示 ICP 备案号并链接至工信部备案查询。
// 详见 documents/设计方案分析与完善版.md §2.15。
const FALLBACK_ICP_NUMBER = "冀ICP备2025130506号-1";
const FALLBACK_ICP_URL = "https://beian.miit.gov.cn/";
export default async function Footer() {
// 优先使用后台配置的站点设置(apps.core.SiteSettings),
// 接口不可用时回退到硬编码的备案信息,保证构建/渲染始终可用。
const [siteSettings, menu] = await Promise.all([getSiteSettings(), getNavigationMenu("footer")]);
const icpNumber = siteSettings?.icp_number || FALLBACK_ICP_NUMBER;
const icpUrl = siteSettings?.icp_url || FALLBACK_ICP_URL;
const qrcode = siteSettings?.wechat_qrcode;
const qrcodeUrl = qrcode?.url ? new URL(qrcode.url, process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000").href : null;
const navItems = menu?.items.length ? menu.items : [{ label: "隐私政策", url: "/privacy-policy", open_in_new_tab: false }];
return (
<footer className="mt-auto border-t border-slate-100 bg-slate-950 py-10 text-slate-400">
<div className="mx-auto max-w-7xl px-6 text-center text-sm">
<nav aria-label="页脚导航" className="mb-6 flex flex-wrap justify-center gap-x-6 gap-y-3">
{navItems.map((item, index) => <a key={`${item.url}-${index}`} href={item.url} target={item.open_in_new_tab ? "_blank" : undefined} rel={item.open_in_new_tab ? "noreferrer" : undefined} className="break-words hover:text-white">{item.label}</a>)}
</nav>
<address className="mb-6 space-y-2 break-words not-italic">
{siteSettings?.contact_phone && <p><a href={`tel:${siteSettings.contact_phone}`} className="hover:text-white">{siteSettings.contact_phone}</a></p>}
{siteSettings?.contact_email && <p><a href={`mailto:${siteSettings.contact_email}`} className="break-all hover:text-white">{siteSettings.contact_email}</a></p>}
{siteSettings?.address && <p>{siteSettings.address}</p>}
</address>
{(siteSettings?.wechat_account || qrcodeUrl || siteSettings?.weibo_url) && (
<div className="mb-6 space-y-3">
{qrcodeUrl && <Image src={qrcodeUrl} alt={qrcode?.title || "微信公众号二维码"} width={128} height={128} className="mx-auto h-32 w-32 object-contain" />}
{siteSettings?.wechat_account && <p className="break-words">{siteSettings.wechat_account}</p>}
{siteSettings?.weibo_url && <a href={siteSettings.weibo_url} target="_blank" rel="noreferrer" className="inline-block hover:text-white">微博</a>}
</div>
)}
<p>
&copy; {new Date().getFullYear()}{" "}
{siteSettings?.company_name || "企业官网"}. All rights reserved.
</p>
<p className="mt-2">
<a
href={icpUrl}
target="_blank"
rel="noreferrer"
className="hover:text-white"
>
{icpNumber}
</a>
</p>
</div>
</footer>
);
}