From c1965cec885c8661ff4fa83907d8f6d460553ed9 Mon Sep 17 00:00:00 2001 From: 刘嘉威 <daidaibg@163.com> Date: 星期三, 11 十月 2023 11:17:16 +0800 Subject: [PATCH] perf: 升级依赖 --- src/router/index.ts | 65 +++++++++++--------------------- 1 files changed, 23 insertions(+), 42 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index d5f8849..3e9fdb9 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,49 +1,30 @@ -import type { RouteRecordRaw } from "vue-router"; -import { createRouter, createWebHistory } from "vue-router"; -import NProgress from "nprogress"; - -const routes: RouteRecordRaw[] = [ +import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router' +import type {RouteRecordRaw} from "vue-router" +const routes: Array<RouteRecordRaw> = [ { - path: "/", - component: () => import("~/views/home/index.vue"), + path: '/', + redirect: '/index', }, { - path: "/404", - name: "ErrorPage", - component: () => import("~/views/errorPages/index.vue"), + path: '/home', + name: 'home', + component: () => import('@/views/HomeView.vue'), + children:[ + { + path: '/index', + name: 'index', + component: () => import('@/views/index/index.vue'), + } + ] }, - { - path: "/home", - name: "Home", - component: () => import("~/views/home/index.vue"), - }, - { - path: "/hero", - name: "Hero", - component: () => import("~/views/home/components/Hero.vue"), - }, - { - path: "/StoreTest", - name: "StoreTest", - component: () => import("~/views/home/components/StoreTest.vue"), - }, - { - path: "/:pathMatch(.*)*", - redirect: "/404", - }, -]; - -const index = createRouter({ - history: createWebHistory(), +] +const router = createRouter({ + history: createWebHashHistory(import.meta.env.BASE_URL), routes, -}); -index.beforeEach(() => { - if (!NProgress.isStarted()) - NProgress.start(); -}); +}) -index.afterEach(() => { - NProgress.done(); -}); +router.beforeEach((to, from, next) => { + next(); +}) -export default index; +export default router -- Gitblit v1.8.0