Skip to content

Commit cc23857

Browse files
author
Taois
committed
feat: 更新版本号
1 parent 8bded97 commit cc23857

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

dashboard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "drplayer",
33
"private": true,
4-
"version": "1.0.0",
4+
"version": "1.0.1 20251016",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

dashboard/src/components/About.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<h1 class="about-title">DrPlayer</h1>
2626
<p class="about-subtitle">新一代智能视频播放器</p>
2727
<div class="about-version">
28-
<span class="version-badge">v1.0.0</span>
28+
<span class="version-badge">v{{ appVersion }}</span>
2929
</div>
3030
</div>
3131
</div>
@@ -153,6 +153,7 @@
153153
</template>
154154

155155
<script setup>
156+
import { computed } from 'vue'
156157
import {
157158
IconPlayCircle,
158159
IconInfoCircle,
@@ -177,6 +178,12 @@ defineProps({
177178
178179
// 定义emits
179180
defineEmits(['update:visible'])
181+
182+
// 获取应用版本号
183+
const appVersion = computed(() => {
184+
// 从 Vite 全局变量中获取版本号
185+
return __APP_VERSION__ || '1.0.0'
186+
})
180187
</script>
181188

182189
<style scoped>

dashboard/src/types/global.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// 全局类型声明
2+
declare const __APP_VERSION__: string

dashboard/vite.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import {defineConfig, loadEnv} from 'vite'
22
import vue from '@vitejs/plugin-vue'
3-
import path from 'path';
3+
import path from 'path'
4+
import { readFileSync } from 'fs'
5+
6+
// 读取 package.json 中的版本号
7+
const packageJson = JSON.parse(readFileSync('./package.json', 'utf-8'))
8+
const version = packageJson.version
49

510
// https://vite.dev/config/
611
export default defineConfig(({ command, mode }) => {
@@ -11,6 +16,11 @@ export default defineConfig(({ command, mode }) => {
1116
// 基础路径配置,支持子目录部署
1217
// 开发环境使用 '/',生产环境可以通过环境变量设置
1318
base: mode.includes('production') ? (env.VITE_BASE_PATH || './') : '/',
19+
20+
// 定义全局变量
21+
define: {
22+
__APP_VERSION__: JSON.stringify(version)
23+
},
1424

1525
plugins: [
1626
vue(),

0 commit comments

Comments
 (0)