build: 优化 Docker/Workflow 构建,使用 Next.js 环境变量注入版本和构建时间,并移除对 package.json 的硬编码替换

This commit is contained in:
ryan
2026-06-11 20:18:49 +08:00
parent 7c125ccef2
commit 50533e1837
11 changed files with 37 additions and 46 deletions
@@ -2,6 +2,7 @@
import {Info, Server} from "lucide-react"
import packageJson from "../../../package.json"
import {APP_VERSION, APP_BUILD_DATE} from "@/lib/app-info"
import {apiConfig} from "@/lib/services"
import {Card, CardContent, CardDescription, CardHeader, CardTitle} from "@/components/ui/card"
@@ -36,8 +37,8 @@ export function InfoTab({ systemConfigsLength, authSourcesLength }: InfoTabProps
</CardHeader>
<CardContent className="pt-4">
<InfoRow label="应用名称" value={packageJson.name} />
<InfoRow label="版本号" value={packageJson.version} />
<InfoRow label="构建时间" value={packageJson.buildDate} />
<InfoRow label="版本号" value={APP_VERSION} />
{APP_BUILD_DATE && <InfoRow label="构建时间" value={APP_BUILD_DATE} />}
<InfoRow label="Next.js" value={(packageJson as { dependencies?: Record<string, string> }).dependencies?.next} />
<InfoRow label="React" value={(packageJson as { dependencies?: Record<string, string> }).dependencies?.react} />
</CardContent>
+3 -3
View File
@@ -3,7 +3,7 @@
import * as React from "react"
import Link from "next/link"
import {usePathname, useRouter} from "next/navigation"
import packageJson from "../../package.json"
import {APP_VERSION, APP_BUILD_DATE} from "@/lib/app-info"
import {toast} from "sonner"
import {Button} from "@/components/ui/button"
import {Spinner} from "@/components/ui/spinner"
@@ -384,8 +384,8 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
</SidebarContent>
<SidebarFooter className="mt-auto px-3 py-3 group-data-[collapsible=icon]:hidden">
<div className="border-t border-border/60 pt-3 text-[11px] leading-5 text-muted-foreground">
<div>Version {packageJson.version}</div>
<div>Build At {packageJson.buildDate}</div>
<div>Version {APP_VERSION}</div>
{APP_BUILD_DATE && <div>Build At {APP_BUILD_DATE}</div>}
</div>
</SidebarFooter>
</Sidebar>