ray-template/apps/admin/src/__ray-template/valid/valid-app-root-path.ts
XiaoDaiGua-Ray 403fdd589a feat!: rebuild Ray Template as a monorepo
Share workspace packages between Ray Admin and the interactive docs.

BREAKING CHANGE: v6 is a new major line. v5 stays on legacy/v5.
2026-11-04 14:01:28 +08:00

29 lines
996 B
TypeScript

import { useVueRouter } from '@/hooks'
import { useSettingGetters } from '@/store'
/**
*
* @description
* 检查 appRootRoute.path 是否存配置正确。如果配置错误,将抛出错误。
*
* 如果配置错误可以检查: [src/store/modules/setting/index.ts] 中的 appRootRoute 配置。
*
* 该方法会通过调用 getRoutes 方法获取所有路由,也就意味着检查的路由格式是铺开之后的格式。当你的路由是嵌套路由时,需要注意检查完整的路径。
*/
export const validAppRootPath = async () => {
const { getAppRootRoute } = useSettingGetters()
const {
router: { getRoutes },
} = useVueRouter()
const find = getRoutes().find(
(curr) => curr.path === getAppRootRoute.value.path,
)
if (!find) {
throw new Error(
`[validAppRootPath]: 'store setting appRootRoute path: ' '${getAppRootRoute.value.path}' not found in router, please check the 'appRootRoute' setting in the store setting module.`,
)
}
}