fix(desktop): fall back to package version when app.getVersion returns 0.0.0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
diguaandClaude Sonnet 4.6 authored and digua committed 2026-05-23 16:28:50 +08:00
1 parent 5aaf1ce331
commit f55fb9cf00
3 files changed
+8 -1

No files matched your search

+4
View File
@@ -1,9 +1,12 @@
import { resolve } from 'path'
import { readFileSync } from 'fs'
import { defineConfig } from 'electron-vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
const rootDir = resolve(__dirname, '../..')
const rootPkg = JSON.parse(readFileSync(resolve(rootDir, 'package.json'), 'utf-8'))
const appVersion: string = rootPkg.version
export default defineConfig({
main: {
@@ -13,6 +16,7 @@ export default defineConfig({
},
},
define: {
__APP_VERSION__: JSON.stringify(appVersion),
'process.env.APTABASE_APP_KEY': JSON.stringify(process.env.APTABASE_APP_KEY || ''),
// ws 的原生加速依赖是可选项;主进程打包时禁用它们,避免 Vite 将缺失的可选依赖改写为启动即抛错。
'process.env.WS_NO_BUFFER_UTIL': JSON.stringify('true'),
+2
View File
@@ -1,3 +1,5 @@
declare const __APP_VERSION__: string
declare module '*.md?raw' {
const content: string
export default content
+2 -1
View File
@@ -98,7 +98,8 @@ export function registerWindowHandlers(ctx: IpcContext): void {
// ==================== 应用信息 ====================
ipcMain.handle('app:getVersion', () => {
return app.getVersion()
const v = app.getVersion()
return v && v !== '0.0.0' ? v : typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : v
})
// 重启应用