mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-09-21 05:43:43 +08:00
Inject the frontend package.json version at build time via Vite and render it as a dedicated "UI Version" row in System Info, alongside the existing app (backend) version returned by /system/info. When the two versions differ a warning tag is shown so users can tell at a glance that their weknora-ui image is out of sync with weknora-app (e.g. missing config fields for newer providers like SearXNG). Rename the existing version row label from "System Version" to "App Version" to distinguish it from the new UI version row in all four locales (zh-CN, en-US, ko-KR, ru-RU).
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import { fileURLToPath, URL } from 'node:url'
|
|
import { resolve, dirname } from 'node:path'
|
|
import { existsSync } from 'node:fs'
|
|
import { createRequire } from 'node:module'
|
|
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
const require = createRequire(import.meta.url)
|
|
|
|
const pkg = require('./package.json') as { version?: string }
|
|
const FRONTEND_VERSION = pkg.version ?? 'unknown'
|
|
|
|
function resolveVueOfficePptxEntry(): string {
|
|
try {
|
|
const pkgDir = dirname(require.resolve('@vue-office/pptx/package.json'))
|
|
const candidates = [
|
|
resolve(pkgDir, 'lib/v3/index.js'),
|
|
resolve(pkgDir, 'lib/index.js'),
|
|
resolve(pkgDir, 'lib/v3/vue-office-pptx.mjs'),
|
|
]
|
|
const matched = candidates.find((candidate) => existsSync(candidate))
|
|
return matched ?? '@vue-office/pptx'
|
|
} catch {
|
|
return '@vue-office/pptx'
|
|
}
|
|
}
|
|
|
|
export default defineConfig({
|
|
define: {
|
|
__FRONTEND_VERSION__: JSON.stringify(FRONTEND_VERSION),
|
|
},
|
|
plugins: [
|
|
vue(),
|
|
vueJsx(),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
'@vue-office/pptx': resolveVueOfficePptxEntry(),
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
host: true,
|
|
// 代理配置,用于开发环境
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
secure: false,
|
|
},
|
|
'/files': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
secure: false,
|
|
}
|
|
}
|
|
}
|
|
})
|