页面结构修改
This commit is contained in:
1 parent
543d78e040
commit
8ecc32da6d
14 files changed
+87
-29
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useMemo } from "react";
|
||||
import { useContext, useMemo } from "react";
|
||||
import {
|
||||
useLocation,
|
||||
useNavigate,
|
||||
@@ -6,19 +6,24 @@ import {
|
||||
useSearchParams as useRouterSearchParams,
|
||||
} from "react-router-dom";
|
||||
|
||||
import { RouteBaseContext } from "@/core/route-base";
|
||||
|
||||
export function useRouter() {
|
||||
const navigate = useNavigate();
|
||||
const base = useContext(RouteBaseContext);
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
push: (href: string) => navigate(href),
|
||||
replace: (href: string) => navigate(href, { replace: true }),
|
||||
push: (href: string) =>
|
||||
navigate(href.replace("/page/workspace", base)),
|
||||
replace: (href: string) =>
|
||||
navigate(href.replace("/page/workspace", base), { replace: true }),
|
||||
back: () => navigate(-1),
|
||||
forward: () => navigate(1),
|
||||
refresh: () => window.location.reload(),
|
||||
prefetch: async () => {},
|
||||
}),
|
||||
[navigate],
|
||||
[navigate, base],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user