({
initialState,
setInitialState,
}: InitDataType)
| 44 | const { Paragraph } = Typography; |
| 45 | |
| 46 | export const BasiLayout: RunTimeLayoutConfig = ({ |
| 47 | initialState, |
| 48 | setInitialState, |
| 49 | }: InitDataType) => { |
| 50 | const { formatMessage } = useIntl(); |
| 51 | /* 获取 LAYOUT 的值 */ |
| 52 | const LAYOUT = getLocalStorageItem<LayoutSettings>(LOCAL_STORAGE.LAYOUT); |
| 53 | // 获取 ACCESS_TOKEN |
| 54 | const ACCESS_TOKEN = getLocalStorageItem<string>(LOCAL_STORAGE.ACCESS_TOKEN); |
| 55 | /* 是否显示锁屏弹窗 */ |
| 56 | const [openLockModal, { setTrue: setLockModalTrue, setFalse: setLockModalFalse }] = |
| 57 | useBoolean(false); |
| 58 | |
| 59 | // 渲染菜单图标 |
| 60 | const renderMenuicon = (icon) => <Icon icon={toString(icon)} style={{ fontSize: 16, display: 'flex' }} />; |
| 61 | return { |
| 62 | /* 水印 */ |
| 63 | waterMarkProps: { |
| 64 | content: initialState?.CurrentUser?.cn_name, |
| 65 | }, |
| 66 | /* 用户头像 */ |
| 67 | avatarProps: avatarProps(setLockModalTrue), |
| 68 | /* 自定义操作列表 */ |
| 69 | actionsRender, |
| 70 | /* 底部版权 */ |
| 71 | footerRender: () => <Footer />, |
| 72 | /* 页面切换时触发 */ |
| 73 | onPageChange: ({ pathname = '' }) => { |
| 74 | // 如果没有登录,重定向到 login |
| 75 | if (!ACCESS_TOKEN && !eq(pathname, ROUTES.LOGIN)) { |
| 76 | history.push(ROUTES.LOGIN); |
| 77 | } |
| 78 | // 中文状态下,绑定 umami 事件 |
| 79 | if (eq(getLocale(), 'zh-CN') && !eq(pathname, '/')) { |
| 80 | umami.track(formatMessage({ id: formatPerfix(pathname, '', true) })); |
| 81 | } |
| 82 | }, |
| 83 | menu: { |
| 84 | request: async () => initialState?.RouteMenu, |
| 85 | }, |
| 86 | /* 自定义面包屑 */ |
| 87 | breadcrumbProps: { |
| 88 | itemRender: (route) => { |
| 89 | return ( |
| 90 | <Space align='center'> |
| 91 | <Icon icon={MenuRemixIconMap[route.linkPath as ROUTES]} style={{ display: 'flex' }} /> |
| 92 | <span>{route.breadcrumbName}</span> |
| 93 | </Space> |
| 94 | ); |
| 95 | }, |
| 96 | }, |
| 97 | /* 自定义菜单项的 render 方法 */ |
| 98 | menuItemRender: ({ icon, pro_layout_parentKeys, isUrl, path = '', locale }, defaultDom) => { |
| 99 | const renderMenuDom = () => { |
| 100 | const isGroup = LAYOUT?.siderMenuType === 'group'; |
| 101 | const isCollapsed = initialState?.Collapsed; |
| 102 | return ( |
| 103 | <Space size={4}> |
nothing calls this directly
no test coverage detected