7a27684e3c
- 在顶部导航栏和用户状态组件中集成版本更新弹窗 - 实现版本检查钩子,支持检查最新版本和更新日志 - 解析 CHANGELOG.md 文件并展示版本更新时间线 - 添加版本更新弹窗 UI 组件,显示当前版本和最新版本 - 在 Dockerfile 中更新 bun 版本依赖 - 调整 Next.js 配置以解析版本信息并注入环境变量 - 更新待测试文档中的版本更新功能描述
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import type { NextConfig } from "next";
|
|
import { PHASE_DEVELOPMENT_SERVER } from "next/constants";
|
|
import { loadEnvConfig } from "@next/env";
|
|
import { readFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { dirname, resolve } from "node:path";
|
|
import { parseChangelog } from "./src/lib/release-info";
|
|
|
|
const webDir = dirname(fileURLToPath(import.meta.url));
|
|
const localVersion = readFileSync(resolve(webDir, "../VERSION"), "utf8").trim() || "dev";
|
|
const localChangelog = readFileSync(resolve(webDir, "../CHANGELOG.md"), "utf8");
|
|
|
|
export default function nextConfig(phase: string): NextConfig {
|
|
const isDev = phase === PHASE_DEVELOPMENT_SERVER;
|
|
loadEnvConfig(resolve(webDir, ".."), isDev, undefined, true);
|
|
const apiBaseUrl = process.env.API_BASE_URL || "http://127.0.0.1:8080";
|
|
const releases = parseChangelog(localChangelog);
|
|
|
|
return {
|
|
allowedDevOrigins: isDev ? ["*.*.*.*"] : [],
|
|
typescript: {
|
|
ignoreBuildErrors: true,
|
|
},
|
|
env: {
|
|
NEXT_PUBLIC_APP_VERSION: localVersion,
|
|
NEXT_PUBLIC_APP_RELEASES: JSON.stringify(releases),
|
|
},
|
|
async rewrites() {
|
|
return [{ source: "/api/:path*", destination: `${apiBaseUrl}/api/:path*` }];
|
|
},
|
|
};
|
|
}
|