import {RouteRecordRaw} from 'vue-router';

/**
 * 建议：路由 path 路径与文件夹名称相同，找文件可浏览器地址找，方便定位文件位置
 *
 * 路由meta对象参数说明
 * meta: {
 *      title:          菜单栏及 tagsView 栏、菜单搜索名称（国际化）
 *      isLink：        是否超链接菜单，开启外链条件，`1、isLink: 链接地址不为空 2、isIframe:false`
 *      isHide：        是否隐藏此路由
 *      isKeepAlive：   是否缓存组件状态
 *      isAffix：       是否固定在 tagsView 栏上
 *      isIframe：      是否内嵌窗口，开启条件，`1、isIframe:true 2、isLink：链接地址不为空`
 *      roles：         当前路由权限标识，取角色管理。控制路由显示、隐藏。超级管理员：admin 普通角色：common
 *      icon：          菜单、tagsView 图标，阿里：加 `iconfont xxx`，fontawesome：加 `fa xxx`
 * }
 */

// 扩展 RouteMeta 接口
declare module 'vue-router' {
    interface RouteMeta {
        title?: string;
        isLink?: string;
        isHide?: boolean;
        isKeepAlive?: boolean;
        isAffix?: boolean;
        isIframe?: boolean;
        roles?: string[];
        icon?: string;
    }
}

/**
 * 定义404、401界面
 * @link 参考：https://next.router.vuejs.org/zh/guide/essentials/history-mode.html#netlify
 */
export const notFoundAndNoPower = [
    {
        path: '/:path(.*)*',
        name: 'notFound',
        component: () => import('/@/views/error/404.vue'),
        meta: {
            title: 'message.staticRoutes.notFound',
            isHide: true,
        },
    },
    {
        path: '/401',
        name: 'noPower',
        component: () => import('/@/views/error/401.vue'),
        meta: {
            title: 'message.staticRoutes.noPower',
            isHide: true,
        },
    },
];

/**
 * 前端路由
 * 此路由不要动，前端添加路由的话，请在 `dynamicRoutes 数组` 中添加
 * @description 前端控制直接改 dynamicRoutes 中的路由，后端控制不需要修改，请求接口路由数据时，会覆盖 dynamicRoutes 第一个顶级 children 的内容（全屏，不包含 layout 中的路由出口）
 * @returns 返回路由菜单数据
 */
export const staticRoutes: Array<RouteRecordRaw> = [
    {
        path: '/login',
        name: 'login',
        component: () => import('/@/views/login/index.vue'),
        meta: {
            title: '登录',
        },
    },
];

/**
 * 管理后台的路由    },
 */
export const adminRoutes: Array<RouteRecordRaw> = [
    {
        path: '/',
        name: 'admin',
        component: () => import('/@/layout/index.vue'),
        redirect: '/home',
        meta: {
            isKeepAlive: true,
            title: '管理后台'
        },
        children: [
            {
                path: '/home',
                name: 'adminHome1',
                component: () => import('/@/views/admin/index.vue'),
                meta: {
                    title: '信息总览',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Monitor',
                    color: 'yellow'
                    // perm:'admin'
                }
            },
            {
                path: '/kanban',
                name: 'adminKanban',
                component: () => import('/@/views/admin/kanban/index.vue'),
                meta: {
                    title: '数据看板',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-PictureRounded',
                    perm:"kanban.list",
                }
            },
            {
                path: '/station',
                name: 'adminStation',
                component: () => import('/@/layout/routerView/parent.vue'),
                redirect: '/admin/station/list',
                meta: {
                    title: '电站电桩',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-MapLocation',
                    perm:"equipment.list,station.list,stationStatMonth.list,statement.list",
                },
                children: [
                    {
                        path: '/station/list',
                        name: 'adminStationList',
                        component: () => import('/@/views/admin/station/list/index.vue'),
                        meta: {
                            title: '电站监控',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm:"station.list",
                            icon: 'ele-OfficeBuilding',
                        },
                    },
                    {
                        path: '/station/endpoint/:id',
                        name: 'adminStationEndpoint',
                        component: () => import('/@/views/admin/station/endpoint/index.vue'),
                        meta: {
                            title: '电桩监控',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm:"equipment.list",
                            icon: 'ele-User',
                        },
                    },
                    {
                        path: '/station/statMonth',
                        name: 'adminStationStatMonth',
                        component: () => import('/@/views/admin/station/stat/index.vue'),
                        meta: {
                            title: '站点月表',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm:"stationStatMonth.list",
                            icon: 'ele-Histogram',
                        },
                    },
                    {
                        path: '/station/statement',
                        name: 'adminStatement',
                        component: () => import('/@/views/admin/station/statment/index.vue'),
                        meta: {
                            title: '对账单',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm:"statement.list",
                            icon: 'ele-CreditCard',
                        },
                    },
                    {
                        path: '/station/platform',
                        name: 'adminPlatform',
                        component: () => import('/@/views/admin/station/platform/index.vue'),
                        meta: {
                            title: '设备平台',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm:"equipment.list",
                            icon: 'ele-CreditCard',
                        },
                    },
                ]
            },
            {
                path: '/investor',
                name: 'adminInvestor',
                component: () => import('/@/views/admin/investor/index.vue'),
                meta: {
                    title: '投资者/物业',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Avatar',
                    perm:"investor.list",
                }
            },
            {
                path: '/banner',
                name: 'adminBanner',
                component: () => import('/@/views/admin/banner/index.vue'),
                meta: {
                    title: '横幅广告',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-PictureRounded',
                    perm:"banner.list",
                }
            },
            {
                path: '/activity',
                name: 'activity',
                component: () => import('/@/layout/routerView/parent.vue'),
                redirect: '/activity/list',
                meta: {
                    title: '营销活动',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Tools',
                    perm: "activity.list,coupon.list",
                },
                children: [
                    {
                        path: '/activity/list',
                        name: 'adminActivity',
                        component: () => import('/@/views/admin/activity/index.vue'),
                        meta: {
                            title: '活动列表',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-PieChart',
                            perm:"activity.list",
                        }
                    },
                    {
                        path: '/activity/coupon',
                        name: 'adminCoupon',
                        component: () => import('/@/views/admin/activity/coupon/index.vue'),
                        meta: {
                            title: '优惠券列表',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-PieChart',
                            // perm:"coupon.list",
                        }
                    },
                    {
                        path: '/activity/userCoupon',
                        name: 'adminUserCoupon',
                        component: () => import('/@/views/admin/activity/userCoupon/index.vue'),
                        meta: {
                            title: '用户优惠券',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-PieChart',
                            // perm:"coupon.list",
                        }
                    },
                ]
            },

            {
                path: '/ordering',
                name: 'adminOrdering',
                component: () => import('/@/views/admin/ordering/index.vue'),
                meta: {
                    title: '订单管理',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Money',
                    perm:"order.list",
                }
            },
            {
                path: '/account',
                name: 'adminAccount',
                component: () => import('/@/views/admin/account/index.vue'),
                meta: {
                    title: '用户列表',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-User',
                    perm:"account.list",
                }
            },
            {
                path: '/finance',
                name: 'adminFinance',
                component: () => import('/@/views/admin/finance/index.vue'),
                meta: {
                    title: '充值记录',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Wallet',
                    perm:"recharge.list",
                },
            },
            {
                path: '/refund',
                name: 'adminRefund',
                component: () => import('/@/views/admin/refund/index.vue'),
                meta: {
                    title: '退款记录',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Cloudy',
                    perm:"refund.list",
                },
            },
            {
                path: '/invoice',
                name: 'adminInvoice',
                component: () => import('/@/views/admin/invoice/index.vue'),
                meta: {
                    title: '发票管理',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Tickets',
                    perm:"invoice.list",
                },
            },
            {
                path: '/whitelist',
                name: 'adminWhitelist',
                component: () => import('/@/layout/routerView/parent.vue'),
                redirect: '/whitelist/config',
                meta: {
                    title: '白名单管理',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Stamp',
                    perm:"station.whitelist.list,station.whitelist.config.list",
                },
                children: [
                    {
                        path: '/whitelist/config',
                        name: 'whitelistConfig',
                        component: () => import('/@/views/admin/whitelist/config.vue'),
                        meta: {
                            title: '白名单配置',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm:"station.whitelist.config.list",
                            icon: 'ele-Setting',
                        },
                    },
                    {
                        path: '/whitelist/list',
                        name: 'whitelistList',
                        component: () => import('/@/views/admin/whitelist/index.vue'),
                        meta: {
                            title: '白名单用户',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm:"station.whitelist.list",
                            icon: 'ele-UserFilled',
                        },
                    },
                ]
            },
            {
                path: '/org',
                name: 'adminOrg',
                component: () => import('/@/layout/routerView/parent.vue'),
                redirect: '/admin/org/department',
                meta: {
                    title: '系统配置',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Tools',
                    perm:"user.list,role.list,dict.list",
                },
                children: [
                    {
                        path: '/org/user',
                        name: 'orgUser',
                        component: () => import('/@/views/admin/user/index.vue'),
                        meta: {
                            title: '运维用户',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm:"user.list",
                            icon: 'ele-User',
                        },
                    },
                    {
                        path: '/org/role',
                        name: 'orgRole',
                        component: () => import('/@/views/admin/role/index.vue'),
                        meta: {
                            title: '角色权限',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm:"role.list",
                            icon: 'ele-Compass',
                        },
                    },
                    {
                        path: '/org/dict',
                        name: 'orgDict',
                        component: () => import('/@/views/admin/dict/index.vue'),
                        meta: {
                            title: '数据字典',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm:"dict.list",
                            icon: 'ele-Collection',
                        },
                    },
                ]
            },
   /*         {
                path: '/optList',
                name: 'adminOptList',
                component: () => import('/@/views/admin/log/opt/index.vue'),
                meta: {
                    title: '操作日志',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,

                    icon: 'ele-Cpu',

                }
            },*/

        ],
    },

]
