diff --git a/src/config/global.d.ts b/src/config/global.d.ts index f6f4b77e..597a2bbf 100644 --- a/src/config/global.d.ts +++ b/src/config/global.d.ts @@ -20,6 +20,7 @@ declare namespace Global { full_name: string; require_password_change: boolean; id: number; + source: string; } interface BaseListItem { diff --git a/src/pages/profile/index.tsx b/src/pages/profile/index.tsx index 459534be..9be18921 100644 --- a/src/pages/profile/index.tsx +++ b/src/pages/profile/index.tsx @@ -1,9 +1,7 @@ -import { userAtom } from '@/atoms/user'; import useTabActive from '@/hooks/use-tab-active'; import { PageContainer } from '@ant-design/pro-components'; -import { useIntl } from '@umijs/max'; +import { useIntl, useModel } from '@umijs/max'; import { TabsProps } from 'antd'; -import { useAtom } from 'jotai'; import React, { useCallback, useMemo, useState } from 'react'; import styled from 'styled-components'; import Appearance from './components/appearance'; @@ -17,14 +15,16 @@ const Wrapper = styled.div` const Profile: React.FC = () => { const intl = useIntl(); - const [userInfo, setUserInfo] = useAtom(userAtom); + const { initialState, setInitialState } = useModel('@@initialState') || {}; const { setTabActive, getTabActive, tabsMap } = useTabActive(); const [activeKey, setActiveKey] = useState( - userInfo?.source === 'Local' ? 'modify-password' : 'appearance' + initialState?.currentUser?.source === 'Local' + ? 'modify-password' + : 'appearance' ); const items: TabsProps['items'] = useMemo(() => { - if (userInfo?.source !== 'Local') { + if (initialState?.currentUser?.source !== 'Local') { return [ { key: 'appearance', @@ -45,7 +45,7 @@ const Profile: React.FC = () => { children: } ]; - }, [userInfo?.source]); + }, [initialState?.currentUser?.source]); const handleChangeTab = useCallback((key: string) => { setActiveKey(key);