| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- import { createRouter, createWebHistory } from 'vue-router'
- import Temp404 from '@/views/global/temp/404.vue'
- import RouterView from '@/layout/router-view.vue'
- // @ts-ignore
- import Layout from '@/layout/index.vue'
- import { useMenuStore } from '@/stores'
- const routes = [
- { path: '/:pathMatch(.*)*', name: 'NotFound', component: Temp404 },
- {
- name: 'root',
- path: '/',
- component: Layout,
- redirect: '/home',
- children: [],
- },
- {
- name: 'home',
- path: '/home',
- component: () => import('@/views/study/home/index.vue'),
- meta: {
- isMenu: true,
- title: '首页',
- fa: 'fa-home',
- },
- },
- {
- name: 'chinese',
- path: '/chinese',
- component: () => import('@/views/study/chinese/index.vue'),
- meta: {
- isMenu: true,
- title: '语文',
- fa: 'fa-book',
- },
- },
- {
- name: 'chinese-question',
- path: '/chinese-question',
- component: () => import('@/views/study/chinese/question/index.vue'),
- meta: {
- root: 'chinese',
- title: '语文题目',
- },
- },
- {
- name: 'chinese-question-only',
- path: '/chinese-question-only',
- component: () => import('@/views/study/chinese/question/only.vue'),
- meta: {
- root: 'chinese',
- title: '语文题目',
- },
- },
- {
- name: 'math',
- path: '/math',
- component: () => import('@/views/study/chinese/index.vue'),
- meta: {
- isMenu: true,
- title: '数学',
- fa: 'fa-calculator',
- },
- },
- {
- name: 'english',
- path: '/english',
- component: () => import('@/views/study/chinese/index.vue'),
- meta: {
- isMenu: true,
- title: '英语',
- fa: 'fa-language',
- },
- },
- ]
- const router = createRouter({
- // @ts-ignore
- history: createWebHistory(import.meta.env.BASE_URL),
- routes,
- })
- router.beforeEach((to, from, next) => {
- next()
- document.getElementById('loader').style.display = 'none'
- })
- export const initRoutes = () => {
- const MenuStore = useMenuStore()
- return new Promise((resolve, reject) => {
- setTimeout(() => {
- MenuStore.initRoutes(MenuStore.mockApi)
- resolve(null)
- }, 2000)
- })
- }
- export default router
|