14 lines
501 B
TypeScript
Raw Normal View History

2024-11-18 19:40:44 +08:00
import type { RouteLocationNormalized, RouteRecordNameGeneric } from "vue-router"
/** 免登录白名单(匹配路由 path */
const whiteListByPath: string[] = ["/login"]
/** 免登录白名单(匹配路由 name */
const whiteListByName: RouteRecordNameGeneric[] = []
/** 判断是否在白名单 */
export function isWhiteList(to: RouteLocationNormalized) {
// path 和 name 任意一个匹配上即可
2024-11-18 19:40:44 +08:00
return whiteListByPath.includes(to.path) || whiteListByName.includes(to.name)
}