| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- import { menuToRoutes, eachTreeData } from 'ele-admin';
- import { HOME_PATH, LAYOUT_PATH, REDIRECT_PATH } from '@/config/setting';
- import EleLayout from '@/layout/index.vue';
- import RedirectLayout from '@/components/RedirectLayout';
- import { iframeMixins } from '@/utils/iframe-mixin';
- /**
- * 静态路由
- */
- export const routes = [
- {
- path: '/login',
- component: () => import('@/views/login/index.vue'),
- meta: {
- title: '登录'
- }
- },
- {
- path: '/forget',
- component: () => import('@/views/forget/index.vue'),
- meta: {
- title: '忘记密码'
- }
- },
- {
- path: '/sourceLink',
- component: () => import('@/views/sourceLink.vue'),
- meta: {
- title: ''
- }
- }
- // {
- // path: '/main-data/*',
- // component: EleLayout,
- // meta: { title: '忘记密码' }
- // }
- // 404
- // {
- // path: '*',
- // component: () => import('@/views/exception/404/index.vue')
- // }
- // {
- // path: '/system/role',
- // component: () => import('@/views/system/role/index.vue'),
- // meta: { title: '编码信息' }
- // }
- ];
- /**
- * 添加动态路由
- * @param menus 菜单数据
- * @param homePath 菜单数据的第一个页面地址
- */
- export function getMenuRoutes(menus, homePath) {
- const routes = [
- // 用于刷新的路由
- {
- path: REDIRECT_PATH + '/:path(.*)',
- component: RedirectLayout,
- meta: {
- hideFooter: true
- }
- }
- ];
- console.log(menus,'menus')
- // 路由铺平处理
- eachTreeData(
- menuToRoutes(menus, getComponent, [], null, null, iframeMixins),
- (route) => {
- routes.push({
- ...route,
- children: null
- });
- }
- );
- return {
- path: LAYOUT_PATH,
- component: EleLayout,
- redirect: HOME_PATH ?? homePath,
- children: routes
- };
- }
- /**
- * 获取路由组件
- * @param component 组件名称
- */
- function getComponent(component) {
- // console.log(component,'component111')
- if (component) {
- return () => import('@/views/' + component);
- }
- }
|