| | |
| | | |
| | | const BaseView = () => { |
| | | const { styles } = useStyles(); |
| | | |
| | | // 头像组件 方便以后独立,增加裁剪之类的功能 |
| | | const AvatarView = ({ avatar }) => ( |
| | | <> |
| | |
| | | </Upload> |
| | | </> |
| | | ); |
| | | |
| | | const { data: currentUser, loading } = useRequest(() => { |
| | | return queryCurrent(); |
| | | }); |
| | | |
| | | const getAvatarURL = () => { |
| | | if (currentUser) { |
| | | if (currentUser.avatar) { |
| | |
| | | } |
| | | return ''; |
| | | }; |
| | | |
| | | const handleFinish = async () => { |
| | | message.success('更新基本信息成功'); |
| | | }; |
| | | |
| | | return ( |
| | | <div className={styles.baseView}> |
| | | {loading ? null : ( |
| | |
| | | </div> |
| | | ); |
| | | }; |
| | | |
| | | export default BaseView; |
| | |
| | | import SecurityView from './components/security'; |
| | | import useStyles from './style.style'; |
| | | |
| | | const menuMap = { |
| | | base: '基本设置', |
| | | security: '安全设置', |
| | | }; |
| | | |
| | | const getMenu = () => { |
| | | return Object.keys(menuMap).map((item) => ({ key: item, label: menuMap[item] })); |
| | | }; |
| | | |
| | | const Settings = () => { |
| | | const { styles } = useStyles(); |
| | | const menuMap = { |
| | | base: '基本设置', |
| | | security: '安全设置', |
| | | binding: '账号绑定', |
| | | notification: '新消息通知', |
| | | }; |
| | | const [initConfig, setInitConfig] = useState({ |
| | | mode: 'inline', |
| | | selectKey: 'base', |
| | | }); |
| | | |
| | | 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; |