feat: Add fallback language, modify React suspense settings, enable strict mode, and update dependencies

The changes include modifying the configuration file, package.json file, and several page files. The fallback language is added, React suspense is disabled, strict mode is enabled, and dependencies are updated. The getStaticProps function in index.page.tsx is replaced with getServerSideProps.
This commit is contained in:
canisminor1990
2023-07-16 12:32:31 +08:00
parent 853f18a87f
commit 8ecd401530
5 changed files with 21 additions and 15 deletions

View File

@@ -3,8 +3,15 @@ const i18n = require('./.i18nrc');
/** @type {import('next-i18next').UserConfig} */
module.exports = {
debug: process.env.NODE_ENV === 'development',
fallbackLng: {
default: ['en'],
zh_TW: ['zh_CN'],
},
i18n: {
defaultLocale: i18n.entryLocale,
locales: [i18n.entryLocale, ...i18n.outputLocales],
},
react: { useSuspense: false },
reloadOnPrerender: process.env.NODE_ENV === 'development',
strictMode: true,
};

View File

@@ -61,7 +61,7 @@
"@ant-design/colors": "^7",
"@ant-design/icons": "^5",
"@commitlint/cli": "^17",
"@lobehub/ui": "^1",
"@lobehub/ui": "lastest",
"@vercel/analytics": "^1",
"ahooks": "^3",
"antd": "^5",

View File

@@ -1,4 +1,5 @@
import isEqual from 'fast-deep-equal';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import Head from 'next/head';
import { useRouter } from 'next/router';
import { memo, useEffect } from 'react';
@@ -56,4 +57,14 @@ const ChatLayout = () => {
);
};
export async function getServerSideProps(context: any) {
const { locale } = context;
return {
props: {
// pass the translation props to the page component
...(await serverSideTranslations(locale)),
},
};
}
export default memo(ChatLayout);

View File

@@ -1 +1 @@
export { default } from './[id].page';
export { default, getServerSideProps } from './[id].page';

View File

@@ -1,13 +1 @@
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
export { default } from './chat/index.page';
export async function getStaticProps(context: any) {
const { locale } = context;
return {
props: {
// pass the translation props to the page component
...(await serverSideTranslations(locale)),
},
};
}
export { default, getServerSideProps } from './chat/index.page';