Commit 85fac4e8 by 李伟康

feat(app): 添加应用缓存清理功能并更新版本配置

- 新增 clearAppCache 工具函数用于处理应用缓存清理
- 在 App.vue 的 onShow 生命周期中调用缓存清理功能
- 更新 manifest.json 中的版本号从 2.25.0 到 2.25.1
- 配置 manifest.json 中的缓存模式为 noCache
- 实现版本检测和自动重启逻辑以确保缓存清理生效
1 parent 17974848
......@@ -4,6 +4,7 @@
import { mapState } from 'vuex'
import { Ws } from '@/ws/Ws.js'
import { RecordSaveService, UploadService } from '@/utils/recordManager/index.js'
import { clearAppCache } from '@/utils/clearAppCache.js'
export default {
computed: {
...mapState('audio', ['isEnd', 'isStart'])
......@@ -48,6 +49,7 @@
}
},
onShow: async function () {
clearAppCache()
this.$store.dispatch('setBackgroundState', false)
this.$store.dispatch('setActivityWindowPopCount', 1) //冷启动重置活动弹框次数
// 触发轮询开始事件,通知上传管理重新开始轮询
......
......@@ -2,13 +2,18 @@
"name" : "展业助手",
"appid" : "__UNI__D3BD3DF",
"description" : "",
"versionName" : "2.25.0",
"versionCode" : 2250,
"versionName" : "2.25.1",
"versionCode" : 2251,
"transformPx" : false,
"sassImplementationName" : "node-sass",
/* 5+App特有相关 */
"app-plus" : {
"cache" : false,
"cache" : {
"mode" : "noCache"
},
"webview" : {
"cacheMode" : "noCache"
},
"bounce" : "none",
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
......
export default {
clearAppCache () {
// #ifdef APP-PLUS
try {
const currentVersion = plus.runtime.version;
const lastVersion = uni.$storage.get('storageVersion')
const webview = plus.webview.currentWebview();
uni.$logger.local.info(`=== 版本检查开始 ===`)
uni.$logger.local.info(`当前版本(currentVersion): ${currentVersion}`)
uni.$logger.local.info(`存储版本(lastVersion): ${lastVersion}`)
uni.$logger.local.info(`版本是否一致: ${lastVersion === currentVersion}`)
if (lastVersion && lastVersion !== currentVersion) {
uni.$logger.local.info(`检测到版本变化: ${lastVersion} -> ${currentVersion}`)
if (webview) {
uni.$logger.local.info('清除webview缓存');
webview.clear();
}
uni.clearStorage(); // 清除本地存储
uni.showLoading({
title: '检测到新版本,正在重启...',
mask: true
})
uni.$logger.local.info('清除应用缓存');
plus.cache.clear()
// 在重启前设置新版本号
uni.$storage.set('storageVersion', currentVersion)
uni.$logger.local.info(`已更新存储版本为: ${currentVersion}`)
uni.$logger.local.info('3秒后重启应用');
setTimeout(() => {
plus.runtime.restart();
}, 3e3);
} else {
uni.$logger.local.info('版本未变化,无需更新')
// 只在首次安装或版本一致时设置
if (!lastVersion) {
uni.$storage.set('storageVersion', currentVersion)
uni.$logger.local.info(`首次安装,设置版本为: ${currentVersion}`)
}
}
} catch (error) {
uni.$logger.local.error('setAPPVersion error:', error);
}
// #endif
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!