feat: add del worker cache
parent
fc52444bd4
commit
93242679a3
24
src/app.tsx
24
src/app.tsx
|
@ -4,6 +4,30 @@ import './styles/global.less';
|
|||
import './styles/tailwind.css';
|
||||
import { routes as appRouters, loopMenuItem, type MenuItem } from './utils/router';
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', () => {
|
||||
// 获取所有注册的 Service Worker
|
||||
navigator.serviceWorker
|
||||
.getRegistrations()
|
||||
.then((registrations) => {
|
||||
for (let registration of registrations) {
|
||||
// 注销每个 Service Worker
|
||||
registration
|
||||
.unregister()
|
||||
.then(() => {
|
||||
console.log('Service Worker unregistered');
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Service Worker unregistration failed:', error);
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error fetching service worker registrations:', error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function patchClientRoutes({ routes }: any) {
|
||||
const routerIndex = routes.findIndex((item: MenuItem) => item.path === '/');
|
||||
const routers = loopMenuItem(appRouters);
|
||||
|
|
Loading…
Reference in New Issue