From 0d0582cc5352a60e5f7042df81e6153e70a9715e Mon Sep 17 00:00:00 2001
From: WX <1377869194@qq.com>
Date: 星期二, 01 八月 2023 16:02:10 +0800
Subject: [PATCH] 改版

---
 src/router/index.js |   60 +++++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 49 insertions(+), 11 deletions(-)

diff --git a/src/router/index.js b/src/router/index.js
index 21c8fa2..0afdceb 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -1,26 +1,64 @@
-import { createRouter, createWebHashHistory } from "vue-router";
-import Home from "../views/Home.vue";
+import {
+  createRouter,
+  createWebHashHistory,
+  createWebHistory,
+} from "vue-router";
+import http from "../http.js";
+import index from "@/views/index.vue";
+import NotFound from "@/views/NotFound.vue";
 
 const routes = [
   {
     path: "/",
-    name: "Home",
-    component: Home,
+    component: index,
+    meta: {
+      title: "棣栭〉",
+      requireAuth: true, // 鏍囪瘑璇ヨ矾鐢辨槸鍚﹂渶瑕佺櫥褰�
+    },
   },
   {
-    path: "/about",
-    name: "About",
-    // route level code-splitting
-    // this generates a separate chunk (about.[hash].js) for this route
-    // which is lazy-loaded when the route is visited.
-    component: () =>
-      import(/* webpackChunkName: "about" */ "../views/About.vue"),
+    path: "/NotFound",
+    name: "NotFound",
+    component: NotFound,
   },
 ];
 
 const router = createRouter({
   history: createWebHashHistory(),
+  // history: createWebHistory(),
   routes,
 });
 
+//璺敱瀹堝崼
+router.beforeEach(async (to, from, next) => {
+  if (to.path == "/") {
+    next();
+    // var url = window.location.href;
+    // var url = window.location.href;
+
+    // var num = url.indexOf("?");
+    // if (num != -1) {
+    //   const dt = await http.get(getTokenUrl);
+    //   console.log(dt);
+    // }
+
+    // if (num == -1) {
+    //   // next("/NotFound");
+    //   alert("鏃犳潈闄愯闂紝璇疯仈绯荤鐞嗗憳");
+    //   // return;
+    // } else {
+    //   next();
+    //   const dt = await http.get(getTokenUrl);
+    //   console.log(dt);
+    //   // if (dt.status_code !== 200) {
+    //   //   // next("/NotFound");
+    //   //   alert("鏃犳潈闄愯闂紝璇疯仈绯荤鐞嗗憳");
+    //   // } else {
+    //   //   next("/");
+    //   // }
+    // }
+  } else {
+    next();
+  }
+});
 export default router;

--
Gitblit v1.9.3