Squashed commit of the following:
commit 908d87357c4e22868eff85f377bb8cd22f3785d7 Author: Sun <95302870@qq.com> Date: Thu Jan 25 13:12:14 2024 +0800 增加前端版本号 commit 8ed2b636476c7a14ae4e1761f7712949b7ce60fc Author: Sun <95302870@qq.com> Date: Thu Jan 25 12:29:49 2024 +0800 增加自动获取前端版本号的git tag
This commit is contained in:
parent
ba7d70f9ca
commit
52a81e5f55
28
add-frontend-version.js
Normal file
28
add-frontend-version.js
Normal file
@ -0,0 +1,28 @@
|
||||
const fs = require('fs')
|
||||
// const { execSync } = require('child_process')
|
||||
const moment = require('moment')
|
||||
|
||||
// git 最新标签
|
||||
// const latestTag = execSync('git describe --tags --abbrev=0').toString().trim()
|
||||
const packDate = moment().format('YYYYMMDD-HH')
|
||||
|
||||
// 要追加的内容
|
||||
const contentToAppend = `\nVITE_APP_VERSION=${packDate}`
|
||||
// 读取文件原始内容
|
||||
const envFilePath = '.env'
|
||||
let envContent = fs.readFileSync(envFilePath, 'utf-8')
|
||||
|
||||
const versionRegex = /^VITE_APP_VERSION=.*$/m
|
||||
if (versionRegex.test(envContent)) {
|
||||
// 使用正则表达式查找并替换 VITE_APP_VERSION=* 这一行
|
||||
envContent = envContent.replace(versionRegex, contentToAppend)
|
||||
}
|
||||
else {
|
||||
// 追加内容
|
||||
envContent = envContent + contentToAppend
|
||||
}
|
||||
|
||||
// 将新内容写回 .env 文件
|
||||
fs.writeFileSync(envFilePath, envContent)
|
||||
|
||||
console.log('update to .env file.', contentToAppend)
|
@ -10,7 +10,8 @@
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "run-p type-check build-only",
|
||||
"build": "run-p add-version type-check build-only",
|
||||
"add-version": "node ./add-frontend-version.js",
|
||||
"preview": "vite preview",
|
||||
"build-only": "vite build",
|
||||
"type-check": "vue-tsc --noEmit",
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { NDivider, NGradientText } from 'naive-ui'
|
||||
import { NDivider, NGradientText, NTag } from 'naive-ui'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { get } from '@/api/system/about'
|
||||
import { useAppStore } from '@/store'
|
||||
@ -20,7 +20,7 @@ interface Version {
|
||||
const appStore = useAppStore()
|
||||
const versionName = ref('')
|
||||
const qqGroupQRShow = ref(false)
|
||||
const frontVersion = import.meta.env.VITE_APP_VERSION || '未知版本'
|
||||
const frontVersion = import.meta.env.VITE_APP_VERSION || 'unknown'
|
||||
|
||||
onMounted(() => {
|
||||
get<Version>().then((res) => {
|
||||
@ -33,7 +33,6 @@ onMounted(() => {
|
||||
<template>
|
||||
<div class="pt-5">
|
||||
<div class="flex flex-col items-center justify-center">
|
||||
<div>{{ frontVersion }}</div>
|
||||
<img :src="srcSvglogo" width="100" height="100" alt="">
|
||||
<div class="text-3xl font-semibold">
|
||||
{{ $t('common.appName') }}
|
||||
@ -93,6 +92,12 @@ onMounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-5">
|
||||
<NTag :bordered="false" size="small">
|
||||
{{ $t("apps.about.frontVersionText") }}: FV-{{ frontVersion }}
|
||||
</NTag>
|
||||
</div>
|
||||
|
||||
<RoundCardModal v-model:show="qqGroupQRShow" title="交流群二维码" style="width: 300px;">
|
||||
<div class="text-center">
|
||||
- 如果失效请返回联系作者 -
|
||||
|
@ -46,6 +46,7 @@
|
||||
"checkUpdate": "Check for new version",
|
||||
"discussions": "Discussions:",
|
||||
"donate": "☕Donate",
|
||||
"frontVersionText": "Front-end version number",
|
||||
"issue": "Feedback:",
|
||||
"viewUpdateLog": "Click here to view update log"
|
||||
},
|
||||
|
@ -46,6 +46,7 @@
|
||||
"checkUpdate": "检查新版本",
|
||||
"discussions": "交流社区:",
|
||||
"donate": "🧧打赏",
|
||||
"frontVersionText": "前端版本号",
|
||||
"issue": "建议反馈:",
|
||||
"viewUpdateLog": "点此查看更新说明"
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user