部署后不轮询通知用户更新页面
用户使用系统时获取 js 出错就会触发
window.addEventListener('error',(event) => {
if ((event.target as HTMLScriptElement).localName === 'script' ||
(event.target as HTMLScriptElement).localName=== 'link') {
ElementUI.MessageBox.alert('检测到系统功能已升级,点击“确定”自动刷新获取更新','提示',{
confirmButtonText:'确定
showClose: false,
callback: action =>{
//https证书正常情况下,也就是浏览器显示安全标识才会有 caches 对象,不安全则没有
if('caches'in window){
caches.keys().then(function(cacheNames){
console.log(cacheNames)
const arr = cacheNames.map(function(cacheName){
console.log(cacheName)
return caches.delete(cacheName)
})
return arr
}).then(function(res){
(window as any).reloadWindow()
})
} else {
(window as any).reloadwindow()
}
}
})
}
event.preventDefault()
}, true)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
最近更新时间: 2025/05/20 02:43:33
- 01
- 2025/05/05 00:00:00
- 02
- 2025/05/01 00:00:00
- 03
- 2025/03/15 00:00:00