performance: introduce lazy-loading for ChatList

Reduce the first load JS bundle size using next/dynamic.
This commit is contained in:
xiaotianxt 2023-04-06 02:41:27 +08:00
parent 301cbbfdfb
commit f920b2001d
No known key found for this signature in database
GPG Key ID: 66F5B0F68944334A
1 changed files with 4 additions and 1 deletions

View File

@ -19,7 +19,6 @@ import CloseIcon from "../icons/close.svg";
import { useChatStore } from "../store";
import { isMobileScreen } from "../utils";
import Locale from "../locales";
import { ChatList } from "./chat-list";
import { Chat } from "./chat";
import dynamic from "next/dynamic";
@ -39,6 +38,10 @@ const Settings = dynamic(async () => (await import("./settings")).Settings, {
loading: () => <Loading noLogo />,
});
const ChatList = dynamic(async () => (await import("./chat-list")).ChatList, {
loading: () => <Loading noLogo />,
});
function useSwitchTheme() {
const config = useChatStore((state) => state.config);