fix: fetch user by @tanstack/react-query #1306 (#1709)

### What problem does this PR solve?

fix: fetch user by @tanstack/react-query #1306

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2024-07-25 18:53:10 +08:00
committed by GitHub
parent 375f621405
commit 935687998e
22 changed files with 107 additions and 340 deletions

View File

@ -7,7 +7,7 @@ import User from '../user';
import { LanguageList } from '@/constants/common';
import { useChangeLanguage } from '@/hooks/logic-hooks';
import { useSelector } from 'umi';
import { useFetchUserInfo } from '@/hooks/user-setting-hooks';
import styled from './index.less';
const Circle = ({ children, ...restProps }: React.PropsWithChildren) => {
@ -25,9 +25,9 @@ const handleGithubCLick = () => {
const RightToolBar = () => {
const { t } = useTranslate('common');
const changeLanguage = useChangeLanguage();
const { language = 'English' } = useSelector(
(state) => state.settingModel.userInfo,
);
const {
data: { language = 'English' },
} = useFetchUserInfo();
const handleItemClick: MenuProps['onClick'] = ({ key }) => {
changeLanguage(key);

View File

@ -1,7 +1,4 @@
import {
useFetchUserInfo,
useSelectUserInfo,
} from '@/hooks/user-setting-hooks';
import { useFetchUserInfo } from '@/hooks/user-setting-hooks';
import { Avatar } from 'antd';
import React from 'react';
import { history } from 'umi';
@ -9,14 +6,12 @@ import { history } from 'umi';
import styles from '../../index.less';
const App: React.FC = () => {
const userInfo = useSelectUserInfo();
const { data: userInfo } = useFetchUserInfo();
const toSetting = () => {
history.push('/user-setting');
};
useFetchUserInfo();
return (
<Avatar
size={32}