Commit 54672637 by lxyang

feat:解决

parent 3cba8180
{
"name": "adsdesk-admin-ui",
"version": "1.0.3",
"version": "1.0.4",
"description": "adsdesk-admin-ui",
"author": "adsdesk",
"license": "MIT",
......
......@@ -59,7 +59,29 @@ Vue.use(permission)
*
* */
importFilter(Vue)
router.onError((error) => {
const jsPattern = /Loading chunk (\S)+ failed/g
const cssPattern = /Loading CSS chunk (\S)+ failed/g
const isChunkLoadFailed = error.message.match(jsPattern || cssPattern)
const targetPath = router.history.pending.fullPath
if (isChunkLoadFailed) {
localStorage.setItem('targetPath', targetPath)
window.location.reload()
}
})
router.onReady(() => {
const targetPath = localStorage.getItem('targetPath')
const tryReload = localStorage.getItem('tryReload')
if (targetPath) {
localStorage.removeItem('targetPath')
if (!tryReload) {
router.replace(targetPath)
localStorage.setItem('tryReload', true)
} else {
localStorage.removeItem('tryReload')
}
}
})
/**
* If you don't want to use mock-server
* you want to use MockJs for mock api
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment