56 lines
1.2 KiB
JavaScript
56 lines
1.2 KiB
JavaScript
/**
|
|
* 版本控制工具类
|
|
* 用于在小程序中获取和管理版本相关信息
|
|
*/
|
|
|
|
const versionConfig = require('../config/version')
|
|
|
|
function getCurrentVersion() {
|
|
return versionConfig.getVersion()
|
|
}
|
|
|
|
function getVersionInfo() {
|
|
return versionConfig.getVersionInfo()
|
|
}
|
|
|
|
function isV2OrAbove() {
|
|
return versionConfig.isVersionOrAbove('2.0.0')
|
|
}
|
|
|
|
function isV1() {
|
|
const v = getCurrentVersion()
|
|
return v.startsWith('1.')
|
|
}
|
|
|
|
function getCategoryList() {
|
|
return versionConfig.getCategoryList()
|
|
}
|
|
|
|
function getFeatureFlag(featureName) {
|
|
return versionConfig.getFeatureFlag(featureName)
|
|
}
|
|
|
|
function logVersionInfo() {
|
|
const version = getCurrentVersion()
|
|
const info = getVersionInfo()
|
|
const features = info ? info.features : {}
|
|
|
|
console.log('========== 小程序版本信息 ==========')
|
|
console.log('当前版本:', version)
|
|
console.log('版本名称:', info ? info.name : '未知')
|
|
console.log('版本描述:', info ? info.description : '未知')
|
|
console.log('分类数量:', getCategoryList().length)
|
|
console.log('功能开关:', features)
|
|
console.log('====================================')
|
|
}
|
|
|
|
module.exports = {
|
|
getCurrentVersion,
|
|
getVersionInfo,
|
|
isV2OrAbove,
|
|
isV1,
|
|
getCategoryList,
|
|
getFeatureFlag,
|
|
logVersionInfo
|
|
}
|