import { api } from '@shared/api/client' import type { AboutDto, BuildDto } from '@shared/api/types' import { fmtBuiltAt, frontendBuild } from '@shared/buildInfo' import { useQuery } from '@shared/hooks' /** 「0.1.1 · v0.1.1-5-gabc123 · 2026-10-06 20:30」:版本、tag(和版本一样就不重复写)、构建时间。 */ function buildText(b: { version: string; tag?: string | null; built_at?: string | null }): string { const parts = [b.version] if (b.tag && b.tag.replace(/^v/, '') !== b.version) parts.push(b.tag) const at = fmtBuiltAt(b.built_at) if (at) parts.push(at) return parts.join(' · ') } /** * 页面底部的构建信息:后端和前端的版本、tag、构建时间。要管理员在设置里打开「site.show_build」才显示; * 关着的时候(或者后端太旧没有这个接口)什么也不画,前端自己的信息也不单独露出来。 */ export function BuildFooter() { const about = useQuery(() => api.get('/api/public/about'), [], 5 * 60_000) if (!about.data?.show_build || !about.data.backend) return null const backend: BuildDto = about.data.backend return (
后端 {buildText(backend)} 前端 {buildText({ version: frontendBuild.version, tag: frontendBuild.tag, built_at: frontendBuild.builtAt })}
) }