提交 1bd437a1 authored 作者: lidongxu's avatar lidongxu

fix(navbar): 修复:版本通知效果的已知问题

上级 4be359fa
......@@ -99,21 +99,19 @@ const settingsStore = useSettingsStore()
const versionStore = useVersionStore()
const { proxy } = getCurrentInstance()
const showVersionList = ref([])
const name = userStore.name;
const showQuit = !window.h5sdk; // 判断飞书客户端内,则不显示退出登录
const showVersionNoticeVisible = ref(false) // 判断版本通知是否出现
const nowVersion = ref('') // 当前最新版本
// 判断是否有新版本出现(监听 pinia 值的变化)
watch(() => versionStore.version, (newVal, oldVal) => {
const oldVersion = proxy.$cache.local.get('version')
const versionObj = versionStore.version[0]
nowVersion.value = versionObj.version
if (oldVersion !== nowVersion.value) {
handleVersionList()
const nowVersion = computed(() => versionStore.version)
const showVersionNoticeVisible = computed({
get() {
return versionStore.versionChange
},
set(val) {
versionStore.versionChange = val
}
})
}) // 判断版本通知是否出现
const showVersionList = computed(() => versionStore.versionList)
// 展示版本通知弹框
const showVersionFn = () => {
......@@ -122,22 +120,15 @@ const showVersionFn = () => {
// 处理版本通知数据结构
const handleVersionList = () => {
console.log(versionStore)
const versionObj = versionStore.version[0]
nowVersion.value = versionObj.version
showVersionNoticeVisible.value = true
// 组织版本内容数据
showVersionList.value = versionObj.changes.map(o => {
return {
title: o.type,
content: o.desc
}
})
}
// 保存当前版本
const saveNowVersion = () => {
proxy.$cache.local.set('version', nowVersion.value)
// 保存给 localStorage
proxy.$cache.local.set('version', versionStore.version)
// 关闭版本通知弹框
showVersionNoticeVisible.value = false
}
function toggleSideBar() {
......
......@@ -53,7 +53,6 @@ router.beforeEach((to, from, next) => {
next({ path: '/' })
})
})
} else {
next()
}
......
import { getVersionAPI } from '@/api'
import cache from '@/plugins/cache'
export default defineStore(
'version',
{
state: () => ({
version: {}
version: cache.local.get('version') || '',
versionChange: false, // 版本号是否发生变化
versionList: [] // 版本说明信息列表(最新版)
}),
actions: {
// 获取版本信息
getVersion() {
return new Promise((resolve, reject) => {
getVersionAPI().then(res => {
this.version = res.data
this.versionChange = !(this.version === res.data[0].version)
this.version = res.data[0].version
// 组织版本内容数据
this.versionList = res.data[0]?.changes.map(o => {
return {
title: o.type,
content: o.desc
}
})
resolve(res)
}).catch(error => {
reject(error)
})
resolve()
})
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论