import { PageTemplateView, TabsTemplateView } from '@/pages/frame/view/template';
import { RouterView } from '@/layout';

export const globalRoutes = [
    {
        path: '/login',
        name: '登录页',
        component: () => import('@/pages/frame/view/login'),
    },
    {
        path: '/403',
        name: '403',
        component: () => import('@/pages/frame/view/exception/403'),
    },
    {
        path: '/500',
        name: '500',
        component: () => import('@/pages/frame/view/exception/500'),
    },
];

const hasAuthorityRoutes = [
    {
        path: '/',
        component: TabsTemplateView,
        redirect: '/home',
        name: '首页',
        children: [
            {
                path: 'home',
                name: '首页',
                meta: { icon: 'home' },
                component: () => import('@/pages/home/index.vue'),
            },
            {
                path: 'dashboard',
                name: 'Dashboard',
                meta: {
                    icon: 'dashboard',
                },
                children: [
                    {
                        path: 'workbench',
                        name: '工作台',
                        meta: {
                            page: {
                                closable: false,
                            },
                        },
                        component: () => import('@/pages/dashboard/workbench'),
                    },
                    {
                        path: 'analysis',
                        name: '分析页',
                        component: () => import('@/pages/dashboard/analysis'),
                    },
                ],
            },
            {
                path: 'system',
                name: '系统管理',
                meta: {
                    icon: 'setting',
                    page: {
                        cacheAble: true,
                    },
                },
                component: PageTemplateView,
                children: [
                    {
                        path: 'menu',
                        name: '菜单管理',
                        component: () => import('@/pages/system/view/menu'),
                    },
                    {
                        path: 'organization',
                        name: '组织管理',
                        component: RouterView,
                        children: [
                            {
                                path: 'job',
                                name: '岗位管理',
                                component: () =>
                                    import('@/pages/system/view/organization/jobsmanagement/Jobs.vue'),
                            },
                            {
                                path: 'user',
                                name: '用户管理',
                                component: () =>
                                    import('@/pages/system/view/organization/usermanagement/User.vue'),
                            },
                            {
                                path: 'org',
                                name: '机构管理',
                                component: () =>
                                    import('@/pages/system/view/organization/orgmanagement/Org.vue'),
                            },
                        ],
                    },
                    {
                        path: 'role',
                        name: '角色管理',
                        component: () => import('@/pages/system/view/role'),
                    },
                    {
                        path: 'parameter',
                        name: '参数管理',
                        component: RouterView,
                        children: [
                            {
                                path: 'business',
                                name: '业务参数',
                                component: () => import('@/pages/system/view/parameter/business/index.vue'),
                            },
                            {
                                path: 'operation',
                                name: '运维参数',
                                component: () => import('@/pages/system/view/parameter/operation/index.vue'),
                            },
                        ],
                    },
                    {
                        path: 'log',
                        name: '日志管理',
                        component: RouterView,
                        children: [
                            {
                                path: 'login',
                                name: '登录日志',
                                component: () => import('@/pages/system/view/log/login_log'),
                            },
                            {
                                path: 'operation',
                                name: '操作日志',
                                component: () => import('@/pages/system/view/log/operation/index.vue'),
                            },
                        ],
                    },
                    {
                        path: 'task',
                        name: '任务管理',
                        component: () => import('@/pages/system/view/task/index.vue'),
                    },
                ],
            },
            {
                path: 'user',
                name: '个人中心',
                meta: { icon: 'user' },
                component: () => import('@/pages/user/index.vue'),
            },
        ],
    },
];

// 路由配置
const options = {
    mode: 'history',
    routes: [...globalRoutes, ...hasAuthorityRoutes],
};

export default options;
