|
|
|
|
@ -3,15 +3,12 @@ import { useRouter } from 'next/router';
|
|
|
|
|
import cookies from 'next-cookies';
|
|
|
|
|
import Head from 'next/head';
|
|
|
|
|
import type { AppProps } from 'next/app';
|
|
|
|
|
import { createStore } from 'redux';
|
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
|
import '../style/global.less';
|
|
|
|
|
import { ConfigProvider, Message } from '@arco-design/web-react';
|
|
|
|
|
import zhCN from '@arco-design/web-react/es/locale/zh-CN';
|
|
|
|
|
import enUS from '@arco-design/web-react/es/locale/en-US';
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
import NProgress from 'nprogress';
|
|
|
|
|
import rootReducer from '../store';
|
|
|
|
|
import { GlobalContext } from '../context';
|
|
|
|
|
import checkLogin from '@/utils/checkLogin';
|
|
|
|
|
import '@/api'; // 全局挂载axios拦截器
|
|
|
|
|
@ -21,8 +18,9 @@ import Layout from './layout';
|
|
|
|
|
import '../mock';
|
|
|
|
|
import { getUserInfo } from '@/api/user';
|
|
|
|
|
import { setSessionUserInfo } from '@/utils/auth';
|
|
|
|
|
import store from '@/store'; // 只导入 store
|
|
|
|
|
import { updateUserInfo } from '@/store'; // 导入 action
|
|
|
|
|
|
|
|
|
|
const store = createStore(rootReducer);
|
|
|
|
|
|
|
|
|
|
interface RenderConfig {
|
|
|
|
|
arcoLang?: string;
|
|
|
|
|
@ -51,16 +49,10 @@ export default function MyApp({
|
|
|
|
|
}, [lang]);
|
|
|
|
|
|
|
|
|
|
async function fetchUserInfo() {
|
|
|
|
|
store.dispatch({
|
|
|
|
|
type: 'update-userInfo',
|
|
|
|
|
payload: { userLoading: true }
|
|
|
|
|
});
|
|
|
|
|
store.dispatch(updateUserInfo({ userLoading: true }));
|
|
|
|
|
const res: any = await getUserInfo();
|
|
|
|
|
setSessionUserInfo(res.data);
|
|
|
|
|
store.dispatch({
|
|
|
|
|
type: 'update-userInfo',
|
|
|
|
|
payload: { userInfo: { ...res.data } }
|
|
|
|
|
});
|
|
|
|
|
store.dispatch(updateUserInfo({ userInfo: { ...res.data } }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|