mirror of
https://github.com/lingke-net/koring-space.git
synced 2026-09-12 05:45:17 +08:00
feat: 新增站点版本与编译时间页脚展示,添加构建信息模块
创建站点构建信息模块,从package.json读取版本号,格式化编译时间为上海时区展示文案,添加异常容错并在页脚展示相关信息。
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,5 +1,6 @@
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { SITE_BUILD_LABEL, SITE_VERSION } from "@/lib/site-build";
|
||||||
|
|
||||||
function Footer() {
|
function Footer() {
|
||||||
return (
|
return (
|
||||||
@@ -7,6 +8,9 @@ function Footer() {
|
|||||||
<div className="px-4 py-4 text-center text-sm text-muted-foreground">
|
<div className="px-4 py-4 text-center text-sm text-muted-foreground">
|
||||||
© {new Date().getFullYear()} Koring Team. All rights reserved. | 棱镜视界,创造超越想象的视界
|
© {new Date().getFullYear()} Koring Team. All rights reserved. | 棱镜视界,创造超越想象的视界
|
||||||
</div>
|
</div>
|
||||||
|
<div className="px-4 pb-4 text-center text-xs text-muted-foreground/70">
|
||||||
|
本站版本 v{SITE_VERSION} · 编译于 {SITE_BUILD_LABEL}(UTC+8)
|
||||||
|
</div>
|
||||||
<div className="px-4 py-4 text-center text-sm text-muted-foreground">
|
<div className="px-4 py-4 text-center text-sm text-muted-foreground">
|
||||||
Koring Launcher 是一个非官方的 Minecraft 启动器,与 Mojang Studios、Microsoft 或他们位于中国大陆的代理公司之间并无任何从属或关联。
|
Koring Launcher 是一个非官方的 Minecraft 启动器,与 Mojang Studios、Microsoft 或他们位于中国大陆的代理公司之间并无任何从属或关联。
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import pkg from "../package.json";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 站点自身构建信息(仅服务端使用)
|
||||||
|
*
|
||||||
|
* - SITE_VERSION 版本号:读取 package.json
|
||||||
|
* - SITE_BUILD_ISO 编译时间:模块首次求值时刻(静态页在 next build 预渲染时烘焙冻结;
|
||||||
|
* dev 模式下为每次服务启动/重载时刻,属预期行为)
|
||||||
|
*/
|
||||||
|
export const SITE_VERSION: string = pkg.version || "0.0.0";
|
||||||
|
|
||||||
|
export const SITE_BUILD_ISO: string = new Date().toISOString();
|
||||||
|
|
||||||
|
/** 编译时间展示文案(固定 Asia/Shanghai,与服务端时区无关) */
|
||||||
|
export const SITE_BUILD_LABEL: string = (() => {
|
||||||
|
try {
|
||||||
|
const d = new Date(SITE_BUILD_ISO);
|
||||||
|
const fmt = new Intl.DateTimeFormat("zh-CN", {
|
||||||
|
timeZone: "Asia/Shanghai",
|
||||||
|
year: "numeric",
|
||||||
|
month: "2-digit",
|
||||||
|
day: "2-digit",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
hour12: false,
|
||||||
|
});
|
||||||
|
const parts = fmt.formatToParts(d);
|
||||||
|
const get = (type: string) =>
|
||||||
|
parts.find((x) => x.type === type)?.value || "";
|
||||||
|
return `${get("year")}-${get("month")}-${get("day")} ${get("hour")}:${get(
|
||||||
|
"minute"
|
||||||
|
)}`;
|
||||||
|
} catch {
|
||||||
|
// 兜底:本地时间
|
||||||
|
const d = new Date(SITE_BUILD_ISO);
|
||||||
|
const p2 = (n: number) => String(n).padStart(2, "0");
|
||||||
|
return `${d.getFullYear()}-${p2(d.getMonth() + 1)}-${p2(d.getDate())} ${p2(
|
||||||
|
d.getHours()
|
||||||
|
)}:${p2(d.getMinutes())}`;
|
||||||
|
}
|
||||||
|
})();
|
||||||
Reference in New Issue
Block a user