From 9ad87d3b6d6aeb315c81ce7db5f0a0295fb634af Mon Sep 17 00:00:00 2001 From: yms Date: Thu, 31 Oct 2024 14:41:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.tsx | 53 ++++++++++++++++++++++++-------------------- src/router/root.tsx | 7 +++--- vite.config.ts | 4 ++-- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/src/router/index.tsx b/src/router/index.tsx index fb50703..4f9ee40 100644 --- a/src/router/index.tsx +++ b/src/router/index.tsx @@ -5,30 +5,35 @@ import ManagementMain from "@/pages/Management/Main"; import PendingReviewList from "@/pages/Management/PendingReviewList"; import Root from "./root"; -const router = createBrowserRouter([ - { - path: "/approval", - element: , - children: [ - { - path: "/approval/apply", +const router = createBrowserRouter( + [ + { + path: "/", + element: , + children: [ + { + path: "/apply", - element: , - }, - { - path: "/approval/apply-record", - element: , - }, - { - path: "/approval/management", - element: , - }, - { - path: "/approval/management/:thingId", - element: , - }, - ], - }, -]); + element: , + }, + { + path: "/apply-record", + element: , + }, + { + path: "/management", + element: , + }, + { + path: "/management/:thingId", + element: , + }, + ], + }, + ], + { + basename: "/approval", + } +); export default router; diff --git a/src/router/root.tsx b/src/router/root.tsx index 7ed1f36..ed10bbc 100644 --- a/src/router/root.tsx +++ b/src/router/root.tsx @@ -2,7 +2,7 @@ import service from "@/service"; import useUserStore from "@/store/useUserStore"; import autofit from "autofit.js"; import { useEffect } from "react"; -import { Navigate, Outlet } from "react-router-dom"; +import { Navigate, Outlet, useLocation } from "react-router-dom"; const Root = () => { autofit.init({ @@ -12,6 +12,7 @@ const Root = () => { resize: true, }); const { updateAdminInfo, updateUserInfo } = useUserStore(); + const location = useLocation(); const adminToken = localStorage.getItem("admin_token"); const userToken = localStorage.getItem("user_token"); @@ -36,9 +37,7 @@ const Root = () => { return ( <> - {location.pathname === "/approval" && ( - - )} + {location.pathname === "/" && } ); diff --git a/vite.config.ts b/vite.config.ts index f38f8a4..70ad1ea 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -23,9 +23,9 @@ export default defineConfig({ // target: "http://172.23.0.46:21610", // target: "http://192.168.31.172:21610", // target: "http://192.168.31.172:33011", - // target: "http://171.217.92.33:33011", + target: "http://171.217.92.33:33011", // target: "http://192.168.2.21:21601/approval", // 测试服务 - target: "http://172.23.0.140:33011", // 唐 + // target: "http://172.23.0.140:33011", // 唐 changeOrigin: true, rewrite: (path) => path.replace(/^\/apis/, ""), }, -- GitLab