|
|
@@ -31,6 +31,8 @@
|
|
31
|
31
|
</template>
|
|
32
|
32
|
|
|
33
|
33
|
<script>
|
|
|
34
|
+ import storage from '@/utils/storage'
|
|
|
35
|
+
|
|
34
|
36
|
export default {
|
|
35
|
37
|
data() {
|
|
36
|
38
|
return {
|
|
|
@@ -45,7 +47,57 @@
|
|
45
|
47
|
this.$modal.showToast('模块建设中~')
|
|
46
|
48
|
},
|
|
47
|
49
|
handleCleanTmp() {
|
|
48
|
|
- this.$modal.showToast('模块建设中~')
|
|
|
50
|
+ this.$modal.confirm('确定要清理缓存吗?').then(() => {
|
|
|
51
|
+ // 1. 清除用户缓存数据(storage_data)
|
|
|
52
|
+ storage.clean()
|
|
|
53
|
+
|
|
|
54
|
+ // 2. 清除字典缓存
|
|
|
55
|
+ this.$store.dispatch('dict/cleanDict')
|
|
|
56
|
+
|
|
|
57
|
+ // 3. 清除eikon统计数据
|
|
|
58
|
+ this.$store.dispatch('eikonLevel/resetLevel')
|
|
|
59
|
+
|
|
|
60
|
+ // 4. 清除已保存的临时文件
|
|
|
61
|
+ uni.getSavedFileList({
|
|
|
62
|
+ success: (res) => {
|
|
|
63
|
+ if (res.fileList && res.fileList.length > 0) {
|
|
|
64
|
+ res.fileList.forEach(file => {
|
|
|
65
|
+ uni.removeSavedFile({ filePath: file.filePath })
|
|
|
66
|
+ })
|
|
|
67
|
+ }
|
|
|
68
|
+ }
|
|
|
69
|
+ })
|
|
|
70
|
+
|
|
|
71
|
+ // 5. 清除所有本地存储(包括 token),确保旧样式缓存失效
|
|
|
72
|
+ uni.clearStorageSync()
|
|
|
73
|
+
|
|
|
74
|
+ // 6. 根据平台清除资源缓存
|
|
|
75
|
+ const platform = uni.getSystemInfoSync().uniPlatform
|
|
|
76
|
+ if (platform === 'app') {
|
|
|
77
|
+ // App 端:清除 Webview 缓存
|
|
|
78
|
+ plus.cache.clear(() => {
|
|
|
79
|
+ console.log('App webview cache cleared')
|
|
|
80
|
+ })
|
|
|
81
|
+ } else {
|
|
|
82
|
+ // H5 端:清除浏览器 Cache API(service worker 缓存的 CSS/JS)
|
|
|
83
|
+ if (window.caches) {
|
|
|
84
|
+ caches.keys().then(names => {
|
|
|
85
|
+ names.forEach(name => caches.delete(name))
|
|
|
86
|
+ })
|
|
|
87
|
+ }
|
|
|
88
|
+ }
|
|
|
89
|
+
|
|
|
90
|
+ this.$modal.msgSuccess('缓存清理完成,即将重启')
|
|
|
91
|
+
|
|
|
92
|
+ // 7. 重启/刷新,强制加载最新资源
|
|
|
93
|
+ setTimeout(() => {
|
|
|
94
|
+ if (platform === 'app') {
|
|
|
95
|
+ plus.runtime.restart()
|
|
|
96
|
+ } else {
|
|
|
97
|
+ window.location.reload()
|
|
|
98
|
+ }
|
|
|
99
|
+ }, 1500)
|
|
|
100
|
+ })
|
|
49
|
101
|
},
|
|
50
|
102
|
handleLogout() {
|
|
51
|
103
|
this.$modal.confirm('确定注销并退出系统吗?').then(() => {
|