feat: 新增重置密码页面

This commit is contained in:
landaiqing
2024-05-30 00:41:51 +08:00
parent 4ce065214a
commit fec48a8e74
11 changed files with 1897 additions and 1433 deletions

View File

@@ -12,7 +12,11 @@ import {
} from "react-router-dom";
import { getStorageFromKey } from "@/utils/localStorage/config.ts";
//递归查询对应的路由
/**
* 递归查询对应的路由
* @param path
* @param routes
*/
export function searchRouteDetail(path: string, routes: RouteObject[]): RouteObject | null {
for (const item of routes) {
if (item.path === path) return item;
@@ -23,7 +27,12 @@ export function searchRouteDetail(path: string, routes: RouteObject[]): RouteObj
return null;
}
//全局路由守卫
/**
* 全局路由守卫
* @param location
* @param navigate
* @param routes
*/
async function guard(location: Location, navigate: NavigateFunction, routes: RouteObject[]) {
const { pathname } = location;
@@ -40,7 +49,8 @@ async function guard(location: Location, navigate: NavigateFunction, routes: Rou
routerDetail.path !== "/login" &&
routerDetail.path !== "/register" &&
routerDetail.path !== "/" &&
routerDetail.path !== "/404"
routerDetail.path !== "/404" &&
routerDetail.path !== "/forget"
) {
const token: string | null = getStorageFromKey("token");
if (!token) {
@@ -52,6 +62,11 @@ async function guard(location: Location, navigate: NavigateFunction, routes: Rou
return true;
}
/**
* 路由守卫
* @param routes
* @constructor
*/
export const RouterGuard = (routes: RouteObject[]) => {
const location: Location<any> = useLocation();
const navigate: NavigateFunction = useNavigate();

View File

@@ -0,0 +1,11 @@
/** @format */
import { lazy } from "react";
const forget = lazy(
() =>
new Promise((resolve: any) => {
setTimeout(() => resolve(import("@/views/User/Forget")), 500);
}),
);
export default forget;

View File

@@ -9,6 +9,7 @@ import home from "./modules/home/index.ts";
import Main from "./modules/main/index.ts";
import ComponentLoading from "@/components/ComponentLoading";
import Loading from "./modules/loading";
import Forget from "@/router/modules/forget";
const routes: RouteObject[] = [
{
@@ -27,6 +28,10 @@ const routes: RouteObject[] = [
path: "/login",
Component: (props) => ComponentLoading(Login, props),
},
{
path: "/forget",
Component: (props) => ComponentLoading(Forget, props),
},
{
path: "/main",
Component: (props) => ComponentLoading(Main, props),