2021-12-17 11:55:42 +08:00
|
|
|
import { ResultEnum } from '@/enums/httpEnum'
|
|
|
|
import { ErrorPageNameMap } from '@/enums/pageEnum'
|
|
|
|
import router from '@/router'
|
2021-12-14 16:41:43 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* * 错误页重定向
|
2021-12-17 11:55:42 +08:00
|
|
|
* @param icon
|
|
|
|
* @returns
|
2021-12-14 16:41:43 +08:00
|
|
|
*/
|
|
|
|
export const redirectErrorPage = (code: ResultEnum) => {
|
2021-12-17 11:55:42 +08:00
|
|
|
if (!code) return false
|
2021-12-14 16:41:43 +08:00
|
|
|
const pageName = ErrorPageNameMap.get(code)
|
2021-12-17 11:55:42 +08:00
|
|
|
if (!pageName) return false
|
2021-12-14 16:41:43 +08:00
|
|
|
routerTurnByName(pageName)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* * 根据名字跳转路由
|
2021-12-17 11:55:42 +08:00
|
|
|
* @param pageName
|
2021-12-14 16:41:43 +08:00
|
|
|
*/
|
2021-12-17 11:55:42 +08:00
|
|
|
export const routerTurnByName = (pageName: string, isReplace?: boolean) => {
|
|
|
|
if (isReplace) {
|
|
|
|
router.replace({
|
|
|
|
name: pageName
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
2021-12-14 16:41:43 +08:00
|
|
|
router.push({
|
|
|
|
name: pageName
|
|
|
|
})
|
2021-12-17 11:55:42 +08:00
|
|
|
}
|