diff --git a/preset/menu/Layout.tsx b/preset/menu/Layout.tsx index fb6d962..a6d3d9a 100755 --- a/preset/menu/Layout.tsx +++ b/preset/menu/Layout.tsx @@ -1,10 +1,10 @@ -import { getPathname } from "lib/utils/pathname"; -import { FC, ReactNode, useEffect, useLayoutEffect, useState } from "react"; -import { loadSession } from "../login/utils/load"; -import { useLocal } from "lib/utils/use-local"; -import { FieldLoading } from "lib/exports"; import { LinkParam } from "lib/comps/form/field/type/TypeLink"; +import { FieldLoading } from "lib/exports"; import { hashSum } from "lib/utils/hash-sum"; +import { getPathname } from "lib/utils/pathname"; +import { useLocal } from "lib/utils/use-local"; +import { FC, ReactNode, useLayoutEffect } from "react"; +import { loadSession } from "../login/utils/load"; const w = window as any; const initResponsive = function () { @@ -81,7 +81,6 @@ export const Layout: FC = (props) => { const newurl = new URL(`${url.protocol}//${url.host}${_href}`); const pathname = newurl.pathname; - let link_params = ""; if (params) { const prefix: LinkParam["prefix"] = params.breads?.map((e) => { diff --git a/preset/menu/Menu.tsx b/preset/menu/Menu.tsx index e178939..fdfdd8a 100755 --- a/preset/menu/Menu.tsx +++ b/preset/menu/Menu.tsx @@ -25,7 +25,9 @@ export const Menu: FC = (props) => { role = props.on_init(); let menu = get(imenu, role) || []; const ref = useRef(null); - const local = useLocal({ ...local_default }); + const local = useLocal({ ...local_default }, ({ setDelayedRender }) => { + setDelayedRender(true); + }); if (local.pathname !== getPathname()) { local.pathname = getPathname(); @@ -96,9 +98,11 @@ export const SideBar: FC<{ value: item[2], hash: hashMenu(item), }; + if (typeof item[2] === "string" && local.pathname === item[2]) { let should_render = false; - if (local.active !== menu.hash && !local.loading) { + + if (local.active !== menu.hash) { local.active = menu.hash; activate(menu.label); should_render = true; @@ -128,7 +132,7 @@ export const SideBar: FC<{ local.render(); } }); - }, []); + }, [getPathname({ hash: true })]); return (