@antscorp/antsomi-ui 1.3.5-beta.605 → 1.3.5-beta.607
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,7 +15,6 @@ import { useCustomRouter, useDeepCompareEffect } from '@antscorp/antsomi-ui/es/h
|
|
|
15
15
|
import { useNavigatePath } from './useNavigatePath';
|
|
16
16
|
const cookies = new ReactCookies();
|
|
17
17
|
export const useLeftMenu = (props) => {
|
|
18
|
-
// Props
|
|
19
18
|
const { objectType = DASHBOARD_MODULE_CONFIG.objectType, objectId = DASHBOARD_MODULE_CONFIG.objectId, isGrouped = DASHBOARD_MODULE_CONFIG.isGrouped, appConfig, customization, onActiveMenuCodeChange, } = props;
|
|
20
19
|
const { defaultExpandMenu, type, items, activeKey, onMenuItemClick } = customization || {};
|
|
21
20
|
const mappedActiveKey = useMemo(() => {
|
|
@@ -46,37 +45,29 @@ export const useLeftMenu = (props) => {
|
|
|
46
45
|
const { auth, env } = appConfig || {};
|
|
47
46
|
const timeoutPopover = useRef(null);
|
|
48
47
|
const openLeftMenuCookies = cookies.get('_leftmenu_state');
|
|
49
|
-
const isOpenMenu = !isNil(openLeftMenuCookies) ? Boolean(openLeftMenuCookies) :
|
|
48
|
+
const isOpenMenu = !isNil(openLeftMenuCookies) ? Boolean(openLeftMenuCookies) : false;
|
|
50
49
|
const [state, setState] = useState({
|
|
51
50
|
hoverItem: '',
|
|
52
51
|
isShowPopover: false,
|
|
53
|
-
isExpandMenu:
|
|
52
|
+
isExpandMenu: isBoolean(defaultExpandMenu) ? defaultExpandMenu : isOpenMenu,
|
|
54
53
|
});
|
|
55
54
|
const { mappingChildrenMenu, flattenMenuPermission, menuListPermission, permissionMenu, activeItemPath, } = usePermission();
|
|
56
|
-
useDeepCompareEffect(() => {
|
|
57
|
-
if (isBoolean(defaultExpandMenu)) {
|
|
58
|
-
setState(prev => (Object.assign(Object.assign({}, prev), { isExpandMenu: defaultExpandMenu })));
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
setState(prev => (Object.assign(Object.assign({}, prev), { isExpandMenu: isOpenMenu })));
|
|
62
|
-
}
|
|
63
|
-
}, [defaultExpandMenu, isOpenMenu]);
|
|
64
55
|
const onMenuClick = useCallback((key, keyPath) => {
|
|
65
56
|
if (type === 'recommendation') {
|
|
66
57
|
setLeftMenuContextState({ customActiveCurrentKey: key });
|
|
67
58
|
}
|
|
68
59
|
onMenuItemClick === null || onMenuItemClick === void 0 ? void 0 : onMenuItemClick(key, [...keyPath, customActiveAppKey]);
|
|
69
60
|
}, [customActiveAppKey, onMenuItemClick, setLeftMenuContextState, type]);
|
|
70
|
-
|
|
61
|
+
useDeepCompareEffect(() => {
|
|
71
62
|
if (defaultExpandMenu === undefined) {
|
|
72
63
|
cookies.set('_leftmenu_state', state.isExpandMenu ? 1 : 0, {
|
|
73
|
-
domain: `.${
|
|
64
|
+
domain: `.${origin.split('.').splice(-2).join('.')}`,
|
|
74
65
|
path: '/',
|
|
75
66
|
sameSite: 'none',
|
|
76
67
|
secure: true,
|
|
77
68
|
});
|
|
78
69
|
}
|
|
79
|
-
}, [defaultExpandMenu, state.isExpandMenu]);
|
|
70
|
+
}, [cookies, defaultExpandMenu, origin, state.isExpandMenu]);
|
|
80
71
|
useDeepCompareEffect(() => {
|
|
81
72
|
setLeftMenuContextState({
|
|
82
73
|
appConfig,
|