2024-11-18 19:40:44 +08:00
|
|
|
|
import type { RouteLocationNormalized, RouteRecordNameGeneric } 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) */
|
2024-11-12 20:10:09 +08:00
|
|
|
|
const whiteListByName: RouteRecordNameGeneric[] = []
|
2023-06-29 18:00:03 +08:00
|
|
|
|
|
|
|
|
|
/** 判断是否在白名单 */
|
2024-11-25 17:42:52 +08:00
|
|
|
|
export function isWhiteList(to: RouteLocationNormalized) {
|
2023-06-29 18:00:03 +08:00
|
|
|
|
// path 和 name 任意一个匹配上即可
|
2024-11-18 19:40:44 +08:00
|
|
|
|
return whiteListByPath.includes(to.path) || whiteListByName.includes(to.name)
|
2023-06-29 18:00:03 +08:00
|
|
|
|
}
|