123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- import {
- CommentOutlined,
- ProjectOutlined,
- SettingOutlined,
- TeamOutlined,
- UsergroupAddOutlined,
- BankOutlined,
- GoldOutlined,
- EnvironmentOutlined,
- BranchesOutlined,
- NodeIndexOutlined,
- } from '@ant-design/icons';
- import { Outlet } from 'react-router-dom';
- import AuthLayout from "@/layouts/AuthLayout";
- import Login from '@/pages/login';
- import Page404 from '@/pages/404';
- import Role from '@/pages/role/index';
- import User from '@/pages/user/index';
- import UserEdit from '@/pages/user/Edit';
- import CheckList from '@/pages/check';
- import CheckEdit from '@/pages/check/Edit';
- import OrgList from "@/pages/org/index";
-
- import Index from '@/pages/index';
- import Home from "@/pages/sample/home";
- import BasicForm from '@/pages/sample/form';
- import BasicTable from '@/pages/sample/table';
-
- import PositionList from "@/pages/position/list";
- import PositionEdit from "@/pages/position/edit";
- import LocTypeList from "@/pages/locType/list";
- import LocTypeEdit from "@/pages/locType/edit";
- import IssueTypeList from "@/pages/issueType/list";
- import IssueTypeEdit from "@/pages/issueType/edit";
- import QuestionList from "@/pages/question/list";
- import IssueList from '@/pages/issue';
-
- /**
- * meta 用来扩展自定义数据数据
- * {
- * title: 用于页面或者菜单的标题, 没有此字段, 菜单不会显示
- * hideInMenu: 布尔值, 如果为 false, 菜单不会显示
- * noLayout: 布尔值, 如果为 true, 将不会使用默认布局
- * noSiderBar: 布尔值, 如果为 true, 将没有左侧菜单栏
- * noFooter: 布尔值, 如果为 true, 将没有底部 footer
- * target: 字符串, 如果为 _blank, 将在新窗口打开
- * permission: 对应服务器端权限名称
- * menuType: ANTD 的 menuItem 的 type 属性,
- * }
- */
-
- export const authRoutes = [
- {
- path: "",
- element: <Outlet />,
- meta: {
- title: '业务管理',
- menuType: 'group',
- },
- children: [
- {
- path: "issue",
- element: <IssueList />,
- meta: {
- title: '问 题 单',
- icon: <CommentOutlined />,
- }
- },
- {
- path: "check",
- element: <CheckList />,
- meta: {
- title: '模拟测评',
- icon: <ProjectOutlined />,
- }
- },
- {
- path: "check/edit",
- element: <CheckEdit />,
- meta: {
- hideInMenu: true,
- title: '模拟测评',
- icon: <ProjectOutlined />,
- }
- },
- ],
- },
- {
- path: "system",
- element: <Outlet />,
- meta: {
- title: '基础字典',
- icon: <ProjectOutlined />,
- menuType: 'group',
- // permission: 'form',
- },
- children: [
-
- {
- path: "locType/list",
- element: <LocTypeList />,
- meta: {
- title: '点位分类',
- icon: <EnvironmentOutlined />,
- // permission: 'form',
- },
- },
- {
- path: "locType/edit",
- element: <LocTypeEdit />,
- meta: {
- hideInMenu: true,
- title: '点位分类编辑',
- // icon: <AppstoreOutlined />,
- // permission: 'form',
- },
- },
-
- {
- path: "issueType/list",
- element: <IssueTypeList />,
- meta: {
- title: '问题分类',
- icon: <BranchesOutlined />,
- // permission: 'form',
- },
- },
- {
- path: "issueType/edit",
- element: <IssueTypeEdit />,
- meta: {
- hideInMenu: true,
- title: '问题分类编辑',
- // icon: <AppstoreOutlined />,
- // permission: 'form',
- },
- },
- {
- path: "question/list",
- element: <QuestionList />,
- meta: {
- title: '点位问题',
- icon: <NodeIndexOutlined />,
- // permission: 'form',
- },
- },
- ]
- },
- {
- path: "system",
- element: <Outlet />,
- meta: {
- title: '系统管理',
- icon: <SettingOutlined />,
- menuType: 'group',
- // permission: 'form',
- },
- children: [
- {
- path: "user",
- element: <User />,
- meta: {
- title: '人员管理',
- icon: <TeamOutlined />,
- // permission: 'form',
- },
- },
- {
- path: "user/edit",
- element: <UserEdit />,
- meta: {
- title: '人员维护',
- hideInMenu: true,
- // icon: <AppstoreOutlined />,
- // permission: 'form',
- },
- },
- {
- path: "role",
- element: <Role />,
- meta: {
- title: '角色管理',
- icon: <UsergroupAddOutlined />,
- // permission: 'form',
- },
- },
- {
- path: "org",
- element: <OrgList />,
- meta: {
- title: '机构管理',
- icon: <BankOutlined />,
- // permission: 'form',
- },
- },
- {
- path: "position/list",
- element: <PositionList />,
- meta: {
- title: '岗位管理',
- icon: <GoldOutlined />,
- // permission: 'form',
- },
- },
- {
- path: "position/edit",
- element: <PositionEdit />,
- meta: {
- hideInMenu: true,
- title: '岗位管理编辑',
- // icon: <AppstoreOutlined />,
- // permission: 'form',
- },
- },
- ]
- },
-
- // {
- // path: "form",
- // element: <BasicForm />,
- // meta: {
- // title: '表单',
- // icon: <AppstoreOutlined />,
- // permission: 'form',
- // },
- // },
- // {
- // path: "table",
- // element: <BasicTable />,
- // meta: {
- // title: '表格',
- // icon: <ContainerOutlined />,
- // permission: 'table',
- // },
- // },
- ];
-
- export const defaultRoutes = [
- {
- path: "/",
- element: <AuthLayout />,
- children: [
- {
- index: true,
- element: <Home />,
- },
- {
- path: '*',
- element: <Page404 />
- }
- ],
- },
- {
- path: '/login',
- element: <Login />,
- },
- {
- path: '*',
- element: <Page404 />
- }
- ]
-
- export function mergeAuthRoutes (r1, r2) {
- const r = r1.slice();
- const children = r1[0].children.slice();
- r[0].children = children.concat(r2);
- return r;
- }
-
- // 全部路由
- export const routes = mergeAuthRoutes(defaultRoutes, authRoutes);
- function getPath (parent = "/", current = "") {
- if (current.indexOf("/") === 0 || current.indexOf("http") === 0)
- return current;
- return `${parent}/${current}`.replace(/\/\//g, "/");
- }
-
- // 路由数组, 一维数组
- export const routeArr = (() => {
- const flatten = (routes, parentPath = "/") => {
- return routes.reduce((acc, route) => {
- const path = getPath(parentPath, route.path);
- const children = route.children ? flatten(route.children, path) : [];
-
- return acc.concat([{ ...route, path }].concat(children));
- }, []);
- };
-
- return flatten(routes);
- })();
|