fix menu activation
This commit is contained in:
parent
59c8ddc716
commit
ea70eaab22
|
|
@ -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<LYTChild> = (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) => {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ export const Menu: FC<MenuProp> = (props) => {
|
|||
role = props.on_init();
|
||||
let menu = get(imenu, role) || [];
|
||||
const ref = useRef<HTMLDivElement>(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 (
|
||||
<div
|
||||
|
|
|
|||
Loading…
Reference in New Issue