fix: StatusBar 版本号改为从 package.json 动态注入
- electron.vite.config.ts 读取 package.json 注入 __APP_VERSION__ 全局常量 - StatusBar.vue 使用 __APP_VERSION__ 替代硬编码 v2.0 - env.d.ts 添加 __APP_VERSION__ 类型声明
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { resolve } from 'path'
|
||||
import { readFileSync } from 'fs'
|
||||
|
||||
const pkg = JSON.parse(readFileSync(resolve(__dirname, 'package.json'), 'utf-8'))
|
||||
|
||||
export default defineConfig({
|
||||
main: {
|
||||
@@ -17,6 +20,9 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
plugins: [vue()],
|
||||
define: {
|
||||
__APP_VERSION__: JSON.stringify(pkg.version),
|
||||
},
|
||||
server: {
|
||||
port: 5173,
|
||||
},
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import { computed } from 'vue'
|
||||
import { useConnectionStore } from '@renderer/stores/connection'
|
||||
import { useI18n } from '@renderer/i18n'
|
||||
import { version } from '../../../../package.json'
|
||||
|
||||
const connStore = useConnectionStore()
|
||||
const { t } = useI18n()
|
||||
@@ -31,7 +30,7 @@ const statusClass = computed(() => {
|
||||
<span class="status-dot" :class="statusClass" />
|
||||
{{ statusText }}
|
||||
</span>
|
||||
<span class="statusbar-right">JRedisDesktop v{{ version }}</span>
|
||||
<span class="statusbar-right">JRedisDesktop v{{ __APP_VERSION__ }}</span>
|
||||
</footer>
|
||||
</template>
|
||||
|
||||
|
||||
Vendored
+2
@@ -1,5 +1,7 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
declare const __APP_VERSION__: string
|
||||
|
||||
declare module '*.css' {
|
||||
const content: string
|
||||
export default content
|
||||
|
||||
Reference in New Issue
Block a user