import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import {useStore}  from "store/main"
const routes: Array<RouteRecordRaw> = [

    {
        path: '/',
        name: 'home',
        component: () => import('views/AppMain.vue'),
        meta: {
            title: '主页面',
            keepAlive: true,
            AuthFlag: true,
            routeListRoot: true
        },
        children: [],
        redirect: '/index/enterpriseType',
    },
    {
        path: '/index',
        name: 'index',
        component: () => import('views/AppMain.vue'),

        meta: {
            title: '主页面',
            keepAlive: true,
            AuthFlag: true,
            routeListRoot: true
        },
        children: [
            {
                path: 'swiperConfig',
                name: 'swiperConfig',
                component: () => import('views/configuration/swiperConfig/index.vue'),
                meta: {
                    title: '轮播图配置',
                    keepAlive: true,
                    AuthFlag: true
                }


            },
            {
                path: 'specialInformationConfiguration',
                name: 'specialInformationConfiguration',
                component: () => import('views/configuration/specialInformationConfiguration/index.vue'),
                meta: {
                    title: '专题资讯配置',
                    keepAlive: true,
                    AuthFlag: true
                }
            },
            {
                path: 'privacyAgreement',
                name: 'privacyAgreement',
                component: () => import('views/configuration/privacyAgreement/index.vue'),
                meta: {
                    title: '隐私协议模板管理',
                    keepAlive: true,
                    AuthFlag: true
                }
            },

            {
                path: 'enterpriseManagement',
                name: 'enterpriseManagement',
                component: () => import('views/enterpriseManagement/index.vue'),
                meta: {
                    title: '企业管理',
                    keepAlive: true,
                    AuthFlag: true
                },   
            },

            {
                path: 'enterpriseType',
                name: 'enterpriseType',
                component: () => import('views/enterpriseManagement/enterpriseType/index.vue'),
                meta: {
                    title: '企业类型',
                    keepAlive: true,
                    AuthFlag: true
                }
            },
            {
                path: 'enterpriseEntryReview',
                name: 'enterpriseEntryReview',
                component: () => import('views/enterpriseManagement/enterpriseEntryReview/index.vue'),
                meta: {
                    title: '企业入驻审核',
                    keepAlive: true,
                    AuthFlag: true
                },

            },
            {
                path: 'businessReview',
                name: 'businessReview',
                component: () => import('views/enterpriseManagement/businessReview/index.vue'),
                meta: {
                    title: '企业业务开通审核',
                    keepAlive: true,
                    AuthFlag: true
                }
            },
            {
                path: 'enterpriseInfo',
                name: 'enterpriseInfo',
                component: () => import('views/enterpriseManagement/enterpriseInfo/index.vue'),
                meta: {
                    title: '企业信息',
                    keepAlive: true,
                    AuthFlag: true
                }
            },
            // 企业装备管理
            {
                path: 'equipmentTypeTemplate',
                name: 'equipmentTypeTemplate',
                component: () => import('views/enterpriseEquipmentManage/equipmentTypeTemplate/index.vue'),
                meta: {
                    title: '装备类型模板',
                    keepAlive: true,
                    AuthFlag: true
                },

            },
            {
                path: 'equipmentListingApproval',
                name: 'equipmentListingApproval',
                component: () => import('views/enterpriseEquipmentManage/equipmentListingApproval/index.vue'),
                meta: {
                    title: '装备上架审批',
                    keepAlive: true,
                    AuthFlag: true
                }
            },
            {
                path: 'iotEquipmentManagement',
                name: 'iotEquipmentManagement',
                component: () => import('views/enterpriseEquipmentManage/iotEquipmentManagement/index.vue'),
                meta: {
                    title: 'iot设备管理',
                    keepAlive: true,
                    AuthFlag: true
                }
            },
            {
                path: 'orderManagement',
                name: 'orderManagement',
                component: () => import('views/enterpriseEquipmentManage/iotEquipmentManagement/index.vue'),
                meta: {
                    title: 'iot设备管理',
                    keepAlive: true,
                    AuthFlag: true
                }
            },
            {
                name: "orderManagement",
                path: 'orderManagement',
                component: () => import('views/orderManagement/index.vue'),
                meta: {
                    title: '订单管理',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            },
            // 111
            {
                name: "systemVersion",
                path: 'systemVersion',
                component: () => import('views/systemManage/systemVersion/index.vue'),
                meta: {
                    title: '系统版本管理',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            },
            {
                name: "userManage",
                path: 'userManage',
                component: () => import('views/systemManage/userManage/index.vue'),
                meta: {
                    title: '用户管理',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            },

            {
                name: "systemLog",
                path: 'systemLog',
                component: () => import('views/systemManage/systemLog/index.vue'),
                meta: {
                    title: '系统日志',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            },
            {
                name: "systemLog",
                path: 'systemLog',
                component: () => import('views/systemManage/systemLog/index.vue'),
                meta: {
                    title: '系统日志',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            },
            {
                name: "entryAuditDetails",
                path: 'entryAuditDetails',
                component: () => import('views/enterpriseManagement/enterpriseEntryReview/details.vue'),
                meta: {
                    title: '审批详情',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            },
            {
                name: "businessReviewDetails",
                path: 'businessReviewDetails',
                component: () => import('views/enterpriseManagement/businessReview/details.vue'),
                meta: {
                    title: '审批详情',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            }, {
                name: "enterpriseInfoDetails",
                path: 'enterpriseInfoDetails',
                component: () => import('views/enterpriseManagement/enterpriseInfo/details.vue'),
                meta: {
                    title: '审批详情',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            }, {
                name: "lonLatPick",
                path: 'lonLatPick',
                component: () => import('views/enterpriseManagement/lonLatPick/index.vue'),
                meta: {
                    title: '经纬度拾取',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            }
        ]
    },
    {
        name: "Login",
        path: '/Login',
        component: () => import('views/Login.vue'),
        meta: {
            title: '登录',
            keepAlive: true,
            AuthFlag: true
        },
        children: []
    }



]

const router = createRouter({
    // 路由模式
    history: createWebHashHistory(),
    routes
})

router.beforeEach((to, from, next) => {
    const store = useStore()
    if (store.token || to.path == '/Login') {
        next()
    } else {
        next('/Login')
    }
    // chrome
    document.body.scrollTop = 0;
    // firefox 兼容火狐
    document.documentElement.scrollTop = 0;
})

export default router
 