chore: version info modal

This commit is contained in:
jialin
2024-07-12 12:06:17 +08:00
parent c5327d3e56
commit 320db56fbe
38 changed files with 334 additions and 108 deletions
+8 -3
View File
@@ -1,9 +1,13 @@
import { defineConfig } from '@umijs/max';
import theme from './theme';
const CompressionWebpackPlugin = require('compression-webpack-plugin');
import proxy from './proxy';
import routes from './routes';
import theme from './theme';
import { getBranchInfo } from './utils';
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const versionInfo = getBranchInfo();
process.env.VERSION = JSON.stringify(versionInfo);
const env = process.env.NODE_ENV;
const isProduction = env === 'production';
@@ -15,6 +19,7 @@ export default defineConfig({
history: {
type: 'hash'
},
base: process.env.npm_config_base || '/',
...(isProduction
? {
+3 -3
View File
@@ -1,16 +1,16 @@
const proxyTableList = ['cli', 'v1', 'auth', 'v1-openai'];
const proxyTableList = ['cli', 'v1', 'auth', 'v1-openai', 'version'];
// @ts-ingore
export default function createProxyTable(target?: string) {
const proxyTable = proxyTableList.reduce(
(obj: Record<string, object>, api) => {
const newTarget = target || 'http://localhost';
obj[`/${api}/`] = {
obj[`/${api}`] = {
target: newTarget,
changeOrigin: true,
secure: false,
ws: true,
pathRewrite: (pth: string) => pth.replace(`/^/${api}/`, `/${api}`),
pathRewrite: (pth: string) => pth.replace(`/^/${api}`, `/${api}`),
// onProxyRes: (proxyRes: any, req: any, res: any) => {
// if (req.headers.accept === 'text/event-stream') {
// res.writeHead(res.statusCode, {
+1 -1
View File
@@ -9,5 +9,5 @@ export const getBranchInfo = () => {
.execSync(`git tag --contains ${latestCommit}`)
.toString()
.trim();
return { version: versionTag, commitId: latestCommit };
return { version: versionTag || 'dev', commitId: latestCommit.slice(0, 7) };
};