| | |
| | | import { AppRouteModule } from '/@/router/types'; |
| | | import type { MenuModule, Menu, AppRouteRecordRaw } from '/@/router/types'; |
| | | import { findPath, treeMap } from '/@/utils/helper/treeHelper'; |
| | | import { AppRouteModule } from '@/router/types'; |
| | | import type { MenuModule, Menu, AppRouteRecordRaw } from '@/router/types'; |
| | | import { findPath, treeMap } from '@/utils/helper/treeHelper'; |
| | | import { cloneDeep } from 'lodash-es'; |
| | | import { isUrl } from '/@/utils/is'; |
| | | import { isHttpUrl } from '@/utils/is'; |
| | | import { RouteParams } from 'vue-router'; |
| | | import { toRaw } from 'vue'; |
| | | |
| | |
| | | // 请注意,以 / 开头的嵌套路径将被视为根路径。 |
| | | // This allows you to leverage the component nesting without having to use a nested URL. |
| | | // 这允许你利用组件嵌套,而无需使用嵌套 URL。 |
| | | if (!(menu.path.startsWith('/') || isUrl(menu.path))) { |
| | | if (!(menu.path.startsWith('/') || isHttpUrl(menu.path))) { |
| | | // path doesn't start with /, nor is it a url, join parent path |
| | | // 路径不以 / 开头,也不是 url,加入父路径 |
| | | menu.path = `${parentPath}/${menu.path}`; |
| | |
| | | |
| | | // Parsing the menu module |
| | | export function transformMenuModule(menuModule: MenuModule): Menu { |
| | | const { menu } = menuModule; |
| | | |
| | | const menuList = [menu]; |
| | | const menuList = [menuModule]; |
| | | |
| | | joinParentPath(menuList); |
| | | return menuList[0]; |
| | |
| | | // 提取树指定结构 |
| | | const list = treeMap(routeList, { |
| | | conversion: (node: AppRouteRecordRaw) => { |
| | | const { meta: { title, hideMenu = false } = {} } = node; |
| | | const { meta: { hideMenu = false } = {}, name } = node; |
| | | |
| | | return { |
| | | ...(node.meta || {}), |
| | | meta: node.meta, |
| | | name: title, |
| | | name, |
| | | hideMenu, |
| | | path: node.path, |
| | | ...(node.redirect ? { redirect: node.redirect } : {}), |