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: [],

    },
    {
        path: '/index',
        name: 'index',
        component: () => import('views/AppMain.vue'),

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


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

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

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

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

            },
            {
                path:'enterpriseEquipmentManage/equipmentListingApproval',
                name: 'equipmentListingApproval',
                component: () => import('views/enterpriseEquipmentManage/equipmentListingApproval/index.vue'),
                meta: {
                    title: '装备上架审批',
                    keepAlive: true,
                    AuthFlag: true
                }
            },
            {
                path:'enterpriseEquipmentManage/iotEquipmentManagement',
                name: 'iotEquipmentManagement',
                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:'systemManage/systemVersion',
                component: () => import('views/systemManage/systemVersion/index.vue'),
                meta: {
                    title: '系统版本管理',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            },
            {
                name: "userManage",
                path:'systemManage/userManage',
                component: () => import('views/systemManage/userManage/index.vue'),
                meta: {
                    title: '用户管理',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            },

            {
                name: "systemLog",
                path:'systemManage/systemLog',
                component: () => import('views/systemManage/systemLog/index.vue'),
                meta: {
                    title: '系统日志',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            },
 
            {
                name: "entryAuditDetails",
                path: 'enterpriseManagement/entryAuditDetails',
                component: () => import('views/enterpriseManagement/enterpriseEntryReview/details.vue'),
                meta: {
                    title: '审批详情',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            },
            {
                name: "businessReviewDetails",
                path: 'enterpriseManagement/businessReviewDetails',
                component: () => import('views/enterpriseManagement/businessReview/details.vue'),
                meta: {
                    title: '审批详情',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            }, {
                name: "enterpriseInfoDetails",
                path: 'enterpriseManagement/enterpriseInfoDetails',
                component: () => import('views/enterpriseManagement/enterpriseInfo/details.vue'),
                meta: {
                    title: '审批详情',
                    keepAlive: true,
                    AuthFlag: true
                },
                children: []
            }, {
                name: "lonLatPick",
                path: 'systemManage/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
 