import {createRouter, createWebHashHistory, createWebHistory} from 'vue-router' import {useSystemStore} from '@/stores/system.js'; export default function createRoutering() { const systemStore = useSystemStore(); if(['', '/'].includes(systemStore.state.defaultRoute)) { throw new Error('默认跳转路由不能为空!') } // console.log(systemStore.state.defaultRoute) const router = createRouter({ // 打包后就不能使用WebHistory了 // 要使用Hash // history: createWebHistory(import.meta.env.BASE_URL), history:createWebHashHistory(), routes: [ { path: '', redirect: systemStore.state.defaultRoute, }, { path: '/', name: '/', component: () => import('@/components/Hello/index.vue'), }, { path: '/initialization', name: 'initialization', component: () => import('@/views/Initialization/index.vue'), }, { path: '/login', name: 'login', component: () => import('@/views/Login/index.vue'), }, { path: '/deviceBinding', name: 'deviceBinding', component: () => import('@/views/DeviceBinding/index.vue'), }, { path: '/productionBatch', name: 'productionBatch', component: () => import('@/views/ProductionBatch/index.vue'), }, { path: '/home', name: 'home', component: () => import('@/views/Home/index.vue'), children: [ { path: 'workbench', name: 'workbench', component: () => import('@/components/Hello/index.vue'), }, { path: 'newspaperWorker', name: 'newspaperWorker', component: () => import('@/views/NewspaperWorker/index.vue'), }, { path: 'clockin', name: 'clockin', component: () => import('@/components/Hello/index.vue'), }, { path: 'setting', name: 'setting', component: () => import('@/components/Hello/index.vue'), }, ] }] }) return router }