Browse Source

fix:格式化版本号显示

master
白凤吉 5 days ago
parent
commit
70f09178bd
  1. 52
      src/pages/Index/Settings/Version.vue

52
src/pages/Index/Settings/Version.vue

@ -18,7 +18,7 @@
</div>
<div class="setting-item">
<span class="label">UI版本号</span>
<span class="value">v{{ version}}</span>
<span class="value">{{ formattedVersion }}</span>
</div>
<div class="setting-item">
<span class="label">设备IP</span>
@ -35,10 +35,10 @@
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in boardVersions" :key="index">
<td style="text-align:left">{{ item.boardName }}</td>
<td>{{ item.version }}</td>
</tr>
<tr v-for="(item, index) in boardVersions" :key="index">
<td style="text-align:left">{{ item.boardName }}</td>
<td>{{ item.version }}</td>
</tr>
</tbody>
</table>
</div>
@ -53,13 +53,21 @@
<script setup lang="ts">
import { DeviceInfo, getDeviceInfo, getMcuVersionDetailInfo } from '@/services'
import { onActivated, onMounted, ref } from 'vue';
import { eMessage } from '../utils';
import { onActivated, onMounted, ref, computed } from 'vue'
import { eMessage } from '../utils'
import { McuVersionInfo } from '@/types/Index'
const info = ref<DeviceInfo>()
const version = import.meta.env.VITE_APP_VERSION;
const mcuVisible = ref(false);
//
const rawVersion = (import.meta.env.VITE_APP_VERSION as string) || '0.0.0'
//
const formattedVersion = computed(() => {
const [maj = '0', min = '0', pat = '0'] = rawVersion.split('.')
const pad = (s: string) => s.padStart(2, '0')
return `F80.CN.${pad(maj)}.${pad(min)}.${pad(pat)}`
})
const mcuVisible = ref(false)
const boardVersions = ref<McuVersionInfo[]>()
const getInfo = async () => {
@ -70,23 +78,19 @@ const getInfo = async () => {
res && res.data && res.data.info && eMessage.error(res.data.info)
}
}
onMounted(() => {
getInfo()
})
onActivated(() => {
getInfo()
})
const onShowMCUDetail = () => {
getMcuVersionDetailInfo().then(res => {
if(res.success) {
boardVersions.value = res.data.boardVersions
mcuVisible.value = true;
}
})
onMounted(getInfo)
onActivated(getInfo)
const onShowMCUDetail = async () => {
const res = await getMcuVersionDetailInfo()
if (res.success) {
boardVersions.value = res.data.boardVersions
mcuVisible.value = true
}
}
</script>
<style lang="less" scoped>
.version-setting {
background-color: #f5f7fa;
@ -129,9 +133,6 @@ const onShowMCUDetail = () => {
color: #303133;
}
/* ==================================
MCU 版本详情弹窗 & 表格样式
================================== */
.mcu-detail {
background-color: #f4f4f4;
margin: 0;
@ -188,5 +189,4 @@ const onShowMCUDetail = () => {
width: 150px;
}
}
</style>
Loading…
Cancel
Save