import {createWebHashHistory,createRouter} from "vue-router";
import {useRootStore} from "@/stores/useStore";
import {showMessage} from "@/unit/element-ui/tip";
const router = createRouter({
 history:createWebHashHistory(),
 routes:[
  {
   path:'/',
   redirect:'/login'
  },
  {
   path:'/login',
   name:'login',
   component:() => import('@/view/login/Login.vue')
  },
  {
   path:'/layout',
   component:() => import('../view/layout/Layout.vue'),
   children:[
    {
     path:'/home',
     name:'home',
     component:() =>import("@/view/home/Home.vue")

    },
    {
     path:'/other',
     name:'other',
     redirect:'/other/data-handle',

    },
    {
     path:'/other/data-handle',

     component:() => import('@/view/other/Other.vue'),
     children:[
      {
       path:'/other/data-handle',
       name:'data-handle',
       redirect:'/other/data-handle/data-handle-main'
      },
      // {
      //  path:'/other/data-handle/data-dir',
      //  name:'data-dir',
      //  component:() => import("@/view/other/c-views/data-handle/zsk/data-dictionary/DataDictionary.vue")
      // },
      {
       path:'/other/data-handle/data-handle-main',
       name:'data-handle-main',
       component:() => import("@/view/other/c-views/data-handle/data-handlle-main/DataHandleMain.vue"),

      },
      { path: '/:pathMatch(.*)*', name: 'NotFound', component: () =>import('../components/NotFound.vue') },
      // {
      //  path:'/other/data-handle/base-rule-rule',
      //  name:'base-rule',
      //  component:() => import("@/view/other/c-views/data-handle/zsk/base-rule/BaseRule.vue")
      // },
      // {
      //  path:'/other/data-handle/process-mb',
      //  name:'process-mb',
      //  component:() => import('@/view/other/c-views/data-handle/zsk/process-mb/ProcessMb.vue')
      // },
      // {
      //  path:'/other/data-handle/report-mb',
      //  name:'report-mb',
      //  component:() => import('@/view/other/c-views/data-handle/zsk/report-mb/ReportMb.vue')
      // },
      // {
      //  path:'/other/data-handle/sync-rule',
      //  name:'sync-rule',
      //  component:() => import('@/view/other/c-views/data-handle/zsk/sync-rule/SyncRule.vue')
      // },
      // {
      //  path:'/other/data-handle/quality-check-rule',
      //  name:'quality-check-rule',
      //  component:() => import('@/view/other/c-views/data-handle/zsk/quality-check-rule/QualityCheckRule.vue')
      // },
      // {
      //  path:'/other/data-handle/clear-rule',
      //  name:'clear-rule',
      //  component:() => import('@/view/other/c-views/data-handle/zsk/clear-rule/ClearRule.vue')
      // },
      // {
      //  path:'/other/data-handle/label-rule',
      //  name:'label-rule',
      //  component:() => import('@/view/other/c-views/data-handle/zsk/label-rule/LabelRule.vue')
      // },
      // {
      //  path:'/other/data-handle/safe-rule',
      //  name:'safe-rule',
      //  component:() => import('@/view/other/c-views/data-handle/zsk/safe-rule/SafeRule.vue')
      // },
      // {
      //  path:'/other/data-handle/label-task',
      //  name:'label-task',
      //  component:() => import('@/view/other/c-views/data-handle/data-label/label-task/LabelTask.vue')
      // },
      // {
      //  path:'/other/data-handle/label-record',
      //  name:'label-record',
      //  component:() => import('@/view/other/c-views/data-handle/data-label/label-record/LabelRecord.vue')
      // },
      // {
      //  path:'/other/data-handle/label-sta',
      //  name:'label-sta',
      //  component:() => import('@/view/other/c-views/data-handle/data-label/label-sta/LabelSta.vue')
      // },
      // {
      //  path:'/other/data-handle/safe-task',
      //  name:'safe-task',
      //  component:() => import('@/view/other/c-views/data-handle/data-safe/safe-task/SateTask.vue')
      // },
      // {
      //  path:'/other/data-handle/safe-check',
      //  name:'safe-check',
      //  component:() => import('@/view/other/c-views/data-handle/data-safe/safe-check/SafeCheck.vue')
      // },
      // {
      //  path:'/other/data-handle/safe-record',
      //  name:'safe-record',
      //  component:() => import('@/view/other/c-views/data-handle/data-safe/safe-record/SafeRecord.vue')
      // },
      // {
      //  path:'/other/data-handle/safe-report',
      //  name:'safe-report',
      //  component:() => import('@/view/other/c-views/data-handle/data-safe/safe-report/SafeReport.vue')
      // },
      // {
      //  path:'/other/data-handle/check-report',
      //  name:'check-report',
      //  component:() => import('@/view/other/c-views/data-handle/data-safe/check-report/CheckReport.vue')
      // },
      // {
      //  path:'/other/data-handle/handle-clear-task',
      //  name:'handle-clear-task',
      //  component:() => import('@/view/other/c-views/data-handle/data-clear/data-task/DataTask.vue')
      // },
      // {
      //  path:'/other/data-handle/clear-record',
      //  name:'clear-record',
      //  component:() => import('@/view/other/c-views/data-handle/data-clear/clear-record/ClearRecord.vue')
      // },
      // {
      //  path:'/other/data-handle/quality-check-task',
      //  name:'quality-check-task',
      //  component:() => import('@/view/other/c-views/data-handle/data-quelity-check/quality-check-task/QualityCheckTask.vue')
      // },
      // {
      //  path:'/other/data-handle/quality-check-record',
      //  name:'quality-check-record',
      //  component:() => import('@/view/other/c-views/data-handle/data-quelity-check/quality-check-record/QualityCheckRecord.vue')
      // },
      // {
      //  path:'/other/data-handle/quality-check-report',
      //  name:'quality-check-report',
      //  component:() => import('@/view/other/c-views/data-handle/data-quelity-check/qiality-check-report/QualityCheckReport.vue')
      // },
      // {
      //  path:'/other/data-handle/quality-check-sta',
      //  name:'quality-check-sta',
      //  component:() => import('@/view/other/c-views/data-handle/data-quelity-check/quality-check-sta/QualityCheckSta.vue')
      // },
      // {
      //  path:'/other/data-handle/data-imputation-task',
      //  name:'data-imputation-task',
      //  component:() => import('@/view/other/c-views/data-handle/data-imputation/data-imputation-task/DataImputationTask.vue')
      // },
      // {
      //  path:'/other/data-handle/data-imputation-record',
      //  name:'data-imputation-record',
      //  component:() => import('@/view/other/c-views/data-handle/data-imputation/data-imputation-record/DataImputationRecord.vue')
      // },
      // {
      //  path:'/other/data-handle/task-set',
      //  name:'task-set',
      //  component:() => import('@/view/other/c-views/data-handle/task-manage/task-set/TaskSet.vue')
      // },
      // {
      //  path:'/other/data-handle/task-execute',
      //  name:'task-execute',
      //  component:() => import('@/view/other/c-views/data-handle/task-manage/task-execute/TaskExecute.vue')
      // },
      // {
      //  path:'/other/data-handle/task-watch',
      //  name:'task-watch',
      //  component:() => import('@/view/other/c-views/data-handle/task-manage/task-watch/TaskWatch.vue')
      // },
     ]
    },
    {
     path:'/other/data-watch',
     name:'data-watch',
     children:[
      {
       path:'/other/data-watch',
       name:'data-watch',
       redirect:'/other/data-watch/sync-handle-charts'
      }
      // {
      //  path: '/other/data-watch/process-state-charts',
      //  name:'process-state-charts',
      //  component:() => import('@/view/other/c-views/data-watch/data-gather-watch/process-charts/ProcessCharts.vue'),
      // },
      // {
      //  path: '/other/data-watch/process-state-table',
      //  name:'process-state-table',
      //  component:() => import('@/view/other/c-views/data-watch/data-gather-watch/process-table/ProcessTable.vue'),
      // },
      // {
      //  path: '/other/data-watch/unit-watch',
      //  name:'unit-watch',
      //  component:() => import('@/view/other/c-views/data-watch/data-gather-watch/unit-watch/UnitWatch.vue'),
      // },
      // {
      //  path: '/other/data-watch/sync-handle-charts',
      //  name:'sync-handle-charts',
      //  component:() => import('@/view/other/c-views/data-watch/data-sync-handle-watch/data-sync-handle-charts/DataSyncHandleCharts.vue'),
      // },
      // {
      //  path: '/other/data-watch/data-life-cycle',
      //  name:'data-life-cycle',
      //  component:() => import('@/view/other/c-views/data-watch/data-sync-handle-watch/data-life-cycle/DataLifeCycle.vue'),
      // },
      // {
      //  path: '/other/data-watch/sync-handle-table',
      //  name:'sync-handle-table',
      //  component:() => import('@/view/other/c-views/data-watch/data-sync-handle-watch/data-sync-handle-table/DataSyncHandleTable.vue'),
      // },
      // {
      //  path: '/other/data-watch/data-service-state-watch',
      //  name:'data-service-state-watch',
      //  component:() => import('@/view/other/c-views/data-watch/data-service-watch/data-service-state-watch/DataServiceStateWatch.vue'),
      // },
      // {
      //  path: '/other/data-watch/person-watch',
      //  name:'person-watch',
      //  component:() => import('@/view/other/c-views/data-watch/data-service-watch/person-watch/PersonWatch.vue'),
      // },
      // {
      //  path: '/other/data-watch/share-exchange-sta',
      //  name:'share-exchange-sta',
      //  component:() => import('@/view/other/c-views/data-watch/data-service-watch/share-exchange-sta/ShareExchangeSta.vue'),
      // },
      // {
      //  path: '/other/data-watch/share-use-sta',
      //  name:'share-use-sta',
      //  component:() => import('@/view/other/c-views/data-watch/data-service-watch/share-use-sta/ShareUseSta.vue'),
      // },
      // {
      //  path: '/other/data-watch/service-use-sta',
      //  name:'service-use-sta',
      //  component:() => import('@/view/other/c-views/data-watch/data-service-watch/service-use-sta/ServiceUseSta.vue'),
      // },
      // {
      //  path: '/other/data-watch/year-use-sta',
      //  name:'year-use-sta',
      //  component:() => import('@/view/other/c-views/data-watch/data-service-watch/year-use-sta/YearUseSta.vue'),
      // },
      // {
      //  path: '/other/data-watch/tool-use-sta',
      //  name:'tool-use-sta',
      //  component:() => import('@/view/other/c-views/data-watch/data-service-watch/tool-use-sta/ToolUseSta.vue'),
      // },
     ],
     component:() => import('@/view/other/Other.vue'),
    },
    {
     path:'/other/process-watch',
     name:'process-watch',
     component:() => import('@/view/other/Other.vue'),
     children:[
      // {path: "/other/process-watch/database-watch",  name:'database-watch',component:()=>import("@/view/other/c-views/process-watch/database-watch/DataBaseWatch.vue")},
      // {path: "/other/process-watch/app-arrange",  name:'app-arrange',component:()=>import("@/view/other/c-views/process-watch/app-arramge/AppArrange.vue")},
      // {path: "/other/process-watch/gis",  name:'gis',component:()=>import("@/view/other/c-views/process-watch/gis/Gis.vue")},
     ]
    },
    {
     path:'/other/system-manage',
     name:'system-manage',
     component:() => import('@/view/other/Other.vue'),
     children:[
      // {path:'/other/system-manage/unit-manage',name:'unit-manage',component:() => import('@/view/other/c-views/system-manage/system-manage/unit-manage/UnitManage.vue')},
      // {path:'/other/system-manage/root-manage',name:'root-manage',component:() => import('@/view/other/c-views/system-manage/system-manage/root-manage/RootManage.vue')},
      // {path:'/other/system-manage/user-manage',name:'user-manage',component:() => import('@/view/other/c-views/system-manage/system-manage/user-manage/UserManage.vue')},
      // {path:'/other/system-manage/module-manage',name:'module-manage',component:() => import('@/view/other/c-views/system-manage/system-manage/module-manage/ModuleManage.vue')},
      // {path:'/other/system-manage/interface-manage',name:'interface-manage',component:() => import('@/view/other/c-views/system-manage/interface-manage/interface-manage/InterfaceManage.vue')},
      // {path:'/other/system-manage/interface-order',name:'interface-order',component:() => import('@/view/other/c-views/system-manage/interface-manage/interface-order/InterfaceOrder.vue')},
      // {path:'/other/system-manage/log-manage',name:'log-manage',component:() => import('@/view/other/c-views/system-manage/system-manage/log-manage/LogManage.vue')},
      // {path:'/other/system-manage/invoke-log',name:'invoke-log',component:() => import('@/view/other/c-views/system-manage/system-manage/log-manage/LogManage.vue')},
     ]
    },
   ]
  },
  // {
  //  path:'/home',
  //  name:'home',
  //  component:() =>import("@/view/home/Home.vue")
  //
  // },
  // {
  //  path:'/other',
  //  redirect:'/other/data-handle'
  // },




  // {
  //  path:'/other',
  //
  //  component:() => import('@/view/other/Other.vue'),
  //
  // }
 ]
})

router.beforeEach((to,from) => {
 console.log('变化； ',to.path,from)
 let userInfo =  localStorage.getItem('dataWatchLoginUserInfo')
 if ( (to.path !== '/login' || (useRootStore().userInfo.ptjk_usercode)) &&  !userInfo){

  return ('/login')
 }else if ( to.path === '/login' &&  userInfo){
  //  退出
  localStorage.removeItem('dataWatchLoginUserInfo')
  const store = useRootStore()
  store.userInfo = {}
  store.leftMenuList = []
 }else if (to.name === 'data-watch'){
  return ('/other/data-watch/sync-handle-charts')
 }

})
export default router
