mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-11-20 10:13:35 +08:00
Share workspace packages between Ray Admin and the interactive docs. BREAKING CHANGE: v6 is a new major line. v5 stays on legacy/v5.
29 lines
996 B
TypeScript
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.`,
|
|
)
|
|
}
|
|
}
|