| | |
| | | import { GridContent } from '@ant-design/pro-components'; |
| | | import { Menu } from 'antd'; |
| | | import React, { useLayoutEffect, useRef, useState } from 'react'; |
| | | import { FormattedMessage, useIntl } from '@umijs/max'; |
| | | import BaseView from './components/base'; |
| | | import SecurityView from './components/security'; |
| | | import useStyles from './style.style'; |
| | | |
| | | const Settings = () => { |
| | | const intl = useIntl(); |
| | | const { styles } = useStyles(); |
| | | const menuMap = { |
| | | base: '基本设置', |
| | | security: '安全设置', |
| | | binding: '账号绑定', |
| | | notification: '新消息通知', |
| | | }; |
| | | const [initConfig, setInitConfig] = useState({ |
| | | mode: 'inline', |
| | | selectKey: 'base', |
| | | }); |
| | | |
| | | const menuMap = { |
| | | base: intl.formatMessage({ id: 'personal.base.setting', defaultMessage: '基本设置' }), |
| | | security: intl.formatMessage({ id: 'personal.security.setting', defaultMessage: '安全设置' }), |
| | | }; |
| | | |
| | | const getMenu = () => { |
| | | return Object.keys(menuMap).map((item) => ({ key: item, label: menuMap[item] })); |
| | | }; |
| | | |
| | | const dom = useRef(); |
| | | |
| | | const resize = () => { |
| | | requestAnimationFrame(() => { |
| | | if (!dom.current) { |
| | |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | useLayoutEffect(() => { |
| | | if (dom.current) { |
| | | window.addEventListener('resize', resize); |
| | |
| | | window.removeEventListener('resize', resize); |
| | | }; |
| | | }, [dom.current]); |
| | | const getMenu = () => { |
| | | return Object.keys(menuMap).map((item) => ({ key: item, label: menuMap[item] })); |
| | | }; |
| | | |
| | | const renderChildren = () => { |
| | | const { selectKey } = initConfig; |
| | | switch (selectKey) { |
| | |
| | | return null; |
| | | } |
| | | }; |
| | | |
| | | return ( |
| | | <GridContent> |
| | | <div |
| | |
| | | </GridContent> |
| | | ); |
| | | }; |
| | | |
| | | export default Settings; |