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 { LinkParam } from "lib/comps/form/field/type/TypeLink";
|
||||||
|
import { FieldLoading } from "lib/exports";
|
||||||
import { hashSum } from "lib/utils/hash-sum";
|
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 w = window as any;
|
||||||
const initResponsive = function () {
|
const initResponsive = function () {
|
||||||
|
|
@ -81,7 +81,6 @@ export const Layout: FC<LYTChild> = (props) => {
|
||||||
const newurl = new URL(`${url.protocol}//${url.host}${_href}`);
|
const newurl = new URL(`${url.protocol}//${url.host}${_href}`);
|
||||||
const pathname = newurl.pathname;
|
const pathname = newurl.pathname;
|
||||||
|
|
||||||
let link_params = "";
|
|
||||||
if (params) {
|
if (params) {
|
||||||
const prefix: LinkParam["prefix"] =
|
const prefix: LinkParam["prefix"] =
|
||||||
params.breads?.map((e) => {
|
params.breads?.map((e) => {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,9 @@ export const Menu: FC<MenuProp> = (props) => {
|
||||||
role = props.on_init();
|
role = props.on_init();
|
||||||
let menu = get(imenu, role) || [];
|
let menu = get(imenu, role) || [];
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
const local = useLocal({ ...local_default });
|
const local = useLocal({ ...local_default }, ({ setDelayedRender }) => {
|
||||||
|
setDelayedRender(true);
|
||||||
|
});
|
||||||
|
|
||||||
if (local.pathname !== getPathname()) {
|
if (local.pathname !== getPathname()) {
|
||||||
local.pathname = getPathname();
|
local.pathname = getPathname();
|
||||||
|
|
@ -96,9 +98,11 @@ export const SideBar: FC<{
|
||||||
value: item[2],
|
value: item[2],
|
||||||
hash: hashMenu(item),
|
hash: hashMenu(item),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof item[2] === "string" && local.pathname === item[2]) {
|
if (typeof item[2] === "string" && local.pathname === item[2]) {
|
||||||
let should_render = false;
|
let should_render = false;
|
||||||
if (local.active !== menu.hash && !local.loading) {
|
|
||||||
|
if (local.active !== menu.hash) {
|
||||||
local.active = menu.hash;
|
local.active = menu.hash;
|
||||||
activate(menu.label);
|
activate(menu.label);
|
||||||
should_render = true;
|
should_render = true;
|
||||||
|
|
@ -128,7 +132,7 @@ export const SideBar: FC<{
|
||||||
local.render();
|
local.render();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, []);
|
}, [getPathname({ hash: true })]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue