Quellcode durchsuchen

performance: introduce lazy-loading for ChatList

Reduce the first load JS bundle size using next/dynamic.
xiaotianxt vor 1 Jahr
Ursprung
Commit
f920b2001d
1 geänderte Dateien mit 4 neuen und 1 gelöschten Zeilen
  1. 4 1
      app/components/home.tsx

+ 4 - 1
app/components/home.tsx

@@ -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);