const status = 'notFound-404' // 刷新标识 export const setFresh = () => { if (localStorage.getItem(status)) { localStorage.setItem(status, (Number(localStorage.getItem(status)) + 1).toString()) } else { localStorage.setItem(status, '1') } } // 清空 export const clearFresh = () => { if (localStorage.getItem(status)) { localStorage.removeItem(status) } } // 获取 export const getFresh = () => { if (localStorage.getItem(status)) { return Number(localStorage.getItem(status)) } else { return 0 } } // 逻辑函数 export const handlerPro = (route: any, agree: any) => { if (route.name === 'notFound') { setFresh() agree('/index') if (getFresh() >= 2) { clearFresh() location.reload() } } else { clearFresh() } }