pref(app): 修改系统默认语言为中文

master
钟良源 5 months ago
parent 5c8a36e10f
commit d80429f682

@ -29,7 +29,7 @@ interface RenderConfig {
export default function MyApp({ export default function MyApp({
pageProps, pageProps,
Component, Component,
renderConfig, renderConfig
}: AppProps & { renderConfig: RenderConfig }) { }: AppProps & { renderConfig: RenderConfig }) {
const { arcoLang, arcoTheme } = renderConfig; const { arcoLang, arcoTheme } = renderConfig;
const [lang, setLang] = useStorage('arco-lang', arcoLang || 'en-US'); const [lang, setLang] = useStorage('arco-lang', arcoLang || 'en-US');
@ -43,19 +43,19 @@ export default function MyApp({
case 'en-US': case 'en-US':
return enUS; return enUS;
default: default:
return enUS; return zhCN;
} }
}, [lang]); }, [lang]);
function fetchUserInfo() { function fetchUserInfo() {
store.dispatch({ store.dispatch({
type: 'update-userInfo', type: 'update-userInfo',
payload: { userLoading: true }, payload: { userLoading: true }
}); });
axios.get('/api/user/userInfo').then((res) => { axios.get('/api/user/userInfo').then((res) => {
store.dispatch({ store.dispatch({
type: 'update-userInfo', type: 'update-userInfo',
payload: { userInfo: res.data, userLoading: false }, payload: { userInfo: res.data, userLoading: false }
}); });
}); });
} }
@ -63,7 +63,8 @@ export default function MyApp({
useEffect(() => { useEffect(() => {
if (checkLogin()) { if (checkLogin()) {
fetchUserInfo(); fetchUserInfo();
} else if (window.location.pathname.replace(/\//g, '') !== 'login') { }
else if (window.location.pathname.replace(/\//g, '') !== 'login') {
window.location.pathname = '/login'; window.location.pathname = '/login';
} }
}, []); }, []);
@ -99,7 +100,7 @@ export default function MyApp({
lang, lang,
setLang, setLang,
theme, theme,
setTheme, setTheme
}; };
return ( return (
@ -116,14 +117,14 @@ export default function MyApp({
locale={locale} locale={locale}
componentConfig={{ componentConfig={{
Card: { Card: {
bordered: false, bordered: false
}, },
List: { List: {
bordered: false, bordered: false
}, },
Table: { Table: {
border: false, border: false
}, }
}} }}
> >
<Provider store={store}> <Provider store={store}>
@ -149,7 +150,7 @@ MyApp.getInitialProps = async (appContext) => {
return { return {
renderConfig: { renderConfig: {
arcoLang: serverCookies['arco-lang'], arcoLang: serverCookies['arco-lang'],
arcoTheme: serverCookies['arco-theme'], arcoTheme: serverCookies['arco-theme']
}, }
}; };
}; };

Loading…
Cancel
Save