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: '登录',
        },
    },
];

/**
 * 管理后台的路由
 *
 * 菜单分组说明：
 *   信息总览   — 首页仪表盘
 *   站点管理   — 站点清单、设备、站点账户、故障订阅
 *   用户管理   — 用户列表、用户资金流
 *   订单管理   — 订单记录
 *   财务管理   — 充值、退款、提现、结算、分账、线下充值
 *   营销管理   — 横幅广告、专属优惠活动
 *   平台配置   — 平台费率、设备配置、充值配置
 *   系统管理   — 运维用户、角色权限、数据字典、操作日志
 *   运营管理   — 公告、消息、模板、FAQ、反馈
 */
export const adminRoutes: Array<RouteRecordRaw> = [
    {
        path: '/',
        name: 'admin',
        component: () => import('/@/layout/index.vue'),
        redirect: '/home',
        meta: {
            isKeepAlive: true,
            title: 'Yeswash管理后台'
        },
        children: [

            // ==================== 1. 信息总览 ====================
            {
                path: '/home',
                name: 'adminHome1',
                component: () => import('/@/views/admin/index.vue'),
                meta: {
                    title: '信息总览',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Monitor',
                }
            },

            // ==================== 2. 站点管理 ====================
            {
                path: '/station',
                name: 'adminStation',
                component: () => import('/@/layout/routerView/parent.vue'),
                redirect: '/station/list',
                meta: {
                    title: '站点管理',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-MapLocation',
                    perm: "washDevice.list,washStation.list,faultSubscriber.list,faultRecord.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: "washStation.list",
                            icon: 'ele-OfficeBuilding',
                        },
                    },
                    {
                        path: '/station/device/:id',
                        name: 'adminStationDevice',
                        component: () => import('/@/views/admin/station/device/index.vue'),
                        meta: {
                            title: '设备清单',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm: "washDevice.list",
                            icon: 'ele-Cpu',
                        },
                    },
                    {
                        path: '/station/account',
                        name: 'adminStationAccount',
                        component: () => import('/@/views/admin/station/account/index.vue'),
                        meta: {
                            title: '站点账户',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm: "washDevice.list",
                            icon: 'ele-Wallet',
                        },
                    },
                    {
                        path: '/station/fault',
                        name: 'adminStationFault',
                        component: () => import('/@/views/admin/station/fault/index.vue'),
                        meta: {
                            title: '故障订阅',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm: "faultSubscriber.list",
                            icon: 'ele-Bell',
                        },
                    },
                ]
            },

            // ==================== 3. 用户管理 ====================
            {
                path: '/user',
                name: 'adminUser',
                component: () => import('/@/layout/routerView/parent.vue'),
                redirect: '/account',
                meta: {
                    title: '用户管理',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-User',
                    perm: "account.list",
                },
                children: [
                    {
                        path: '/account',
                        name: 'adminAccount',
                        component: () => import('/@/views/admin/account/index.vue'),
                        meta: {
                            title: '用户列表',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-List',
                            perm: "account.list",
                        }
                    },
                    {
                        path: '/walletFlow',
                        name: 'adminFinanceWalletFlow',
                        component: () => import('/@/views/admin/finance/wallet-flow.vue'),
                        meta: {
                            title: '用户资金流',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-Money',
                            perm: "",
                        },
                    },
                ]
            },

            // ==================== 4. 订单管理 ====================
            {
                path: '/ordering',
                name: 'adminOrdering',
                component: () => import('/@/views/admin/ordering/index.vue'),
                meta: {
                    title: '订单管理',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Document',
                    perm: "washOrder.list",
                }
            },

            // ==================== 5. 财务管理 ====================
            {
                path: '/finance',
                name: 'adminFinance',
                component: () => import('/@/layout/routerView/parent.vue'),
                redirect: '/finance/recharge',
                meta: {
                    title: '财务管理',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Money',
                    perm: "recharge.list,refundLog.list,withdrawnRecord.list,settlement.list,offlineRecharge",
                },
                children: [
                    {
                        path: '/finance/recharge',
                        name: 'adminFinanceRecharge',
                        component: () => import('/@/views/admin/finance/index.vue'),
                        meta: {
                            title: '充值记录',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-Finished',
                            perm: "recharge.list",
                        },
                    },
                    {
                        path: '/offlineRecharge',
                        name: 'adminOfflineRecharge',
                        component: () => import('/@/views/admin/finance/offline-recharge.vue'),
                        meta: {
                            title: '线下充值',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-Sell',
                            perm: "offlineRecharge",
                        },
                    },
                    {
                        path: '/refund',
                        name: 'adminFinanceRefund',
                        component: () => import('/@/views/admin/finance/refund.vue'),
                        meta: {
                            title: '退款清单',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-Warning',
                            perm: "refundLog.list",
                        },
                    },
                    {
                        path: '/withdraw',
                        name: 'adminFinanceWithdraw',
                        component: () => import('/@/views/admin/finance/withdraw.vue'),
                        meta: {
                            title: '提现记录',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-Wallet',
                            perm: "withdrawnRecord.list",
                        },
                    },
                    {
                        path: '/finance/settlement',
                        name: 'adminFinanceSettlement',
                        component: () => import('/@/views/admin/finance/settlement.vue'),
                        meta: {
                            title: '结算记录',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-Calendar',
                            perm: "settlement.list",
                        },
                    },
                    {
                        path: '/financeSR',
                        name: 'adminSplitRecord',
                        component: () => import('/@/views/admin/finance/splitRecord.vue'),
                        meta: {
                            title: '分账记录',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-Connection',
                            perm: "recharge.list",
                        },
                    },
                ]
            },

            // ==================== 6. 数据统计 ====================
            {
                path: '/statistics',
                name: 'adminStatistics',
                component: () => import('/@/layout/routerView/parent.vue'),
                redirect: '/statistics/dailyStat',
                meta: {
                    title: '数据统计',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-DataAnalysis',
                    perm: "dailyStat.list,monthStat.list",
                },
                children: [
                    {
                        path: '/statistics/dailyStat',
                        name: 'adminStatisticsDailyStat',
                        component: () => import('/@/views/admin/statistics/daily-stat.vue'),
                        meta: {
                            title: '日统计',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-DataLine',
                            perm: "dailyStat.list",
                        },
                    },
                    {
                        path: '/statistics/monthStat',
                        name: 'adminStatisticsMonthStat',
                        component: () => import('/@/views/admin/statistics/month-stat.vue'),
                        meta: {
                            title: '月统计',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-PieChart',
                            perm: "monthStat.list",
                        },
                    },
                ]
            },

            // ==================== 7. 营销管理 ====================
            {
                path: '/marketing',
                name: 'adminMarketing',
                component: () => import('/@/layout/routerView/parent.vue'),
                redirect: '/banner',
                meta: {
                    title: '营销管理',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Promotion',
                    perm: "banner.list,promotion.list,parkingCouponRecord.list",
                },
                children: [
                    {
                        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: '/platform/rechargePromotion',
                        name: 'adminPlatformRechargePromotion',
                        component: () => import('/@/views/admin/platform/rechargePromotion/index.vue'),
                        meta: {
                            title: '专属优惠活动',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm: "promotion.list",
                            icon: 'ele-Present',
                        },
                    },
                    {
                        path: '/marketing/parkingCouponRecord',
                        name: 'adminParkingCouponRecord',
                        component: () => import('/@/views/admin/parking-coupon-record/index.vue'),
                        meta: {
                            title: '停车券发放记录',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm: "parkingCouponRecord.list",
                            icon: 'ele-Tickets',
                        },
                    },
                ]
            },

            // ==================== 7. 平台配置 ====================
            {
                path: '/platform',
                name: 'adminPlatform',
                component: () => import('/@/layout/routerView/parent.vue'),
                redirect: '/platform/rate',
                meta: {
                    title: '平台配置',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Setting',
                    perm: "platformFeeRate.list,rechargeConfig.list",
                },
                children: [
                    {
                        path: '/platform/rate',
                        name: 'adminPlatformRate',
                        component: () => import('/@/views/admin/platform/rate/index.vue'),
                        meta: {
                            title: '平台费率',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm: "platformFeeRate.list",
                            icon: 'ele-Money',
                        },
                    },
                    {
                        path: '/platform/deviceConfig',
                        name: 'adminPlatformDeviceConfig',
                        component: () => import('/@/views/admin/platform/deviceConfig/index.vue'),
                        meta: {
                            title: '设备配置',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm: "platformFeeRate.list",
                            icon: 'ele-Cpu',
                        },
                    },
                    {
                        path: '/platform/rechargeConfig',
                        name: 'adminPlatformRechargeConfig',
                        component: () => import('/@/views/admin/platform/rechargeConfig/index.vue'),
                        meta: {
                            title: '充值配置',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            perm: "rechargeConfig.list",
                            icon: 'ele-Tickets',
                        },
                    },
                ]
            },

            // ==================== 8. 系统管理 ====================
            {
                path: '/system',
                name: 'adminSystem',
                component: () => import('/@/layout/routerView/parent.vue'),
                redirect: '/org/user',
                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: '/org/log',
                        name: 'adminLog',
                        component: () => import('/@/views/admin/log/opt/index.vue'),
                        meta: {
                            title: '操作日志',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-Document',
                            perm: "",
                        },
                    },
                ]
            },

            // ==================== 9. 运营管理 ====================
            {
                path: '/operation',
                name: 'adminOperation',
                component: () => import('/@/layout/routerView/parent.vue'),
                redirect: '/org/notice',
                meta: {
                    title: '运营管理',
                    isLink: '',
                    isHide: false,
                    isKeepAlive: true,
                    isAffix: false,
                    isIframe: false,
                    icon: 'ele-Notification',
                    perm: "",
                },
                children: [
                    {
                        path: '/org/notice',
                        name: 'adminNotice',
                        component: () => import('/@/views/admin/notice/index.vue'),
                        meta: {
                            title: '系统公告',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-Bell',
                            perm: "",
                        },
                    },
                    {
                        path: '/org/message',
                        name: 'adminMessage',
                        component: () => import('/@/views/admin/message/index.vue'),
                        meta: {
                            title: '消息管理',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-Message',
                            perm: "",
                        },
                    },
                    {
                        path: '/org/template',
                        name: 'adminTemplate',
                        component: () => import('/@/views/admin/template/index.vue'),
                        meta: {
                            title: '消息模板',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-Files',
                            perm: "",
                        },
                    },
                    {
                        path: '/org/faq',
                        name: 'adminFaq',
                        component: () => import('/@/views/admin/faq/index.vue'),
                        meta: {
                            title: '常见问题',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-Tickets',
                            perm: "",
                        },
                    },
                    {
                        path: '/org/feedback',
                        name: 'adminFeedback',
                        component: () => import('/@/views/admin/feedback/index.vue'),
                        meta: {
                            title: '反馈上报',
                            isLink: '',
                            isHide: false,
                            isKeepAlive: true,
                            isAffix: false,
                            isIframe: false,
                            icon: 'ele-ChatLineSquare',
                            perm: "",
                        },
                    },
                ]
            },

        ],
    },
]
