fix: 版本号问题修复。

This commit is contained in:
tianyongbao
2026-07-12 14:48:55 +08:00
parent 88cf663855
commit 68da3c0101
2 changed files with 52 additions and 1 deletions

View File

@@ -36,7 +36,23 @@ import { computed } from 'vue'
import config from '@/config.js'
const url = config.appInfo.site_url
const version = config.appInfo.version
// 动态获取版本号
// - 微信小程序:优先读取小程序后台提交发布时填写的版本号,为空时回退到 config
// 注:在微信开发者工具中调用时 miniProgram.version 通常为空字符串,
// 只有体验版/正式版发布后才有真实值
// - 其他端H5/APP使用 config 中的版本号
let version = config.appInfo.version
// #ifdef MP-WEIXIN
try {
const accountInfo = uni.getAccountInfoSync()
const mpVersion = accountInfo && accountInfo.miniProgram && accountInfo.miniProgram.version
if (mpVersion) {
version = mpVersion
}
} catch (e) {
console.warn('getAccountInfoSync 调用失败,使用 config 中的版本号:', e)
}
// #endif
// 动态显示当前年份
const currentYear = new Date().getFullYear()