@@ -3,7 +3,7 @@ import '../styles/globals.less';
3
3
import { HTTPError } from 'koajax' ;
4
4
import { configure } from 'mobx' ;
5
5
import { enableStaticRendering , observer } from 'mobx-react' ;
6
- import App , { AppContext , AppProps } from 'next/app' ;
6
+ import App , { AppContext } from 'next/app' ;
7
7
import Head from 'next/head' ;
8
8
import { Image } from 'react-bootstrap' ;
9
9
@@ -13,10 +13,9 @@ import { isServer } from '../models/configuration';
13
13
import {
14
14
createI18nStore ,
15
15
I18nContext ,
16
- LanguageCode ,
17
- loadLanguage ,
16
+ I18nProps ,
17
+ loadSSRLanguage ,
18
18
} from '../models/Translation' ;
19
- import zhCN from '../translation/zh-CN' ;
20
19
21
20
configure ( { enforceActions : 'never' } ) ;
22
21
@@ -31,20 +30,16 @@ globalThis.addEventListener?.('unhandledrejection', ({ reason }) => {
31
30
if ( tips ) alert ( tips ) ;
32
31
} ) ;
33
32
34
- interface AppShellProps extends AppProps {
35
- language : LanguageCode ;
36
- languageData : typeof zhCN ;
37
- }
38
-
39
33
@observer
40
- export default class AppShell extends App < AppShellProps > {
34
+ export default class AppShell extends App < I18nProps > {
41
35
static async getInitialProps ( context : AppContext ) {
42
- const props = await App . getInitialProps ( context ) ;
43
-
44
- return { ...props , ...( await loadLanguage ( context . ctx . req ! . headers ) ) } ;
36
+ return {
37
+ ...( await App . getInitialProps ( context ) ) ,
38
+ ...( await loadSSRLanguage ( context . ctx . req ! . headers ) ) ,
39
+ } ;
45
40
}
46
41
47
- i18nStore = createI18nStore ( this . props . language , this . props . languageData ) ;
42
+ i18nStore = createI18nStore ( this . props . language , this . props . languageMap ) ;
48
43
49
44
render ( ) {
50
45
const { Component, pageProps, router } = this . props ,
0 commit comments