@@ -3,7 +3,7 @@ import '../styles/globals.less';
33import { HTTPError } from 'koajax' ;
44import { configure } from 'mobx' ;
55import { enableStaticRendering , observer } from 'mobx-react' ;
6- import App , { AppContext , AppProps } from 'next/app' ;
6+ import App , { AppContext } from 'next/app' ;
77import Head from 'next/head' ;
88import { Image } from 'react-bootstrap' ;
99
@@ -13,10 +13,9 @@ import { isServer } from '../models/configuration';
1313import {
1414 createI18nStore ,
1515 I18nContext ,
16- LanguageCode ,
17- loadLanguage ,
16+ I18nProps ,
17+ loadSSRLanguage ,
1818} from '../models/Translation' ;
19- import zhCN from '../translation/zh-CN' ;
2019
2120configure ( { enforceActions : 'never' } ) ;
2221
@@ -31,20 +30,16 @@ globalThis.addEventListener?.('unhandledrejection', ({ reason }) => {
3130 if ( tips ) alert ( tips ) ;
3231} ) ;
3332
34- interface AppShellProps extends AppProps {
35- language : LanguageCode ;
36- languageData : typeof zhCN ;
37- }
38-
3933@observer
40- export default class AppShell extends App < AppShellProps > {
34+ export default class AppShell extends App < I18nProps > {
4135 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+ } ;
4540 }
4641
47- i18nStore = createI18nStore ( this . props . language , this . props . languageData ) ;
42+ i18nStore = createI18nStore ( this . props . language , this . props . languageMap ) ;
4843
4944 render ( ) {
5045 const { Component, pageProps, router } = this . props ,
0 commit comments