2023-06-29 18:00:03 +08:00
|
|
|
|
import { type RouteLocationNormalized } from "vue-router"
|
2022-04-21 18:20:39 +08:00
|
|
|
|
|
2023-06-29 18:00:03 +08:00
|
|
|
|
/** 免登录白名单(匹配路由 path) */
|
|
|
|
|
const whiteListByPath: string[] = ["/login"]
|
|
|
|
|
|
|
|
|
|
/** 免登录白名单(匹配路由 name) */
|
|
|
|
|
const whiteListByName: string[] = []
|
|
|
|
|
|
|
|
|
|
/** 判断是否在白名单 */
|
|
|
|
|
const isWhiteList = (to: RouteLocationNormalized) => {
|
|
|
|
|
// path 和 name 任意一个匹配上即可
|
|
|
|
|
return whiteListByPath.indexOf(to.path) !== -1 || whiteListByName.indexOf(to.name as any) !== -1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default isWhiteList
|