Skip to content

Commit 16aaf9a

Browse files
author
zhaoshiwei1
committed
refactor: 调整动态导入方式改为静态导入
1 parent fb22ecf commit 16aaf9a

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

src/components/admin/fullscreen-editor.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,9 @@ import { useState, useEffect, useCallback } from "react";
44
import { X, Send, Save } from "lucide-react";
55
import { Button } from "@/components/ui/button";
66
import { Badge } from "@/components/ui/badge";
7-
import dynamic from "next/dynamic";
7+
import MDEditor from "@uiw/react-md-editor";
88
import PublishDialog from "./publish-dialog";
99

10-
// 动态导入MDEditor以避免SSR问题
11-
const MDEditor = dynamic(() => import("@uiw/react-md-editor"), {
12-
ssr: false,
13-
loading: () => (
14-
<div className="h-full flex items-center justify-center">
15-
<div className="text-muted-foreground">正在加载编辑器...</div>
16-
</div>
17-
),
18-
});
19-
2010
interface FullscreenEditorProps {
2111
title: string;
2212
content: string;

src/components/posts/post-list.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useState, useEffect, useCallback } from "react";
44
import Link from "next/link";
55
import { format } from "date-fns";
66
import { zhCN } from "date-fns/locale";
7-
import dynamic from "next/dynamic";
7+
import { BackgroundImage } from "@/components/optimized/image-with-fallback";
88

99
// 类型定义
1010
interface PostListProps {
@@ -27,18 +27,6 @@ interface Post {
2727
}>;
2828
}
2929

30-
// 动态导入优化的图片组件,减少初始包大小
31-
const BackgroundImage = dynamic(
32-
() =>
33-
import("@/components/optimized/image-with-fallback").then(
34-
(mod) => mod.BackgroundImage
35-
),
36-
{
37-
loading: () => <div className="w-full h-full bg-gray-200 animate-pulse" />,
38-
ssr: true, // 改为 true 以支持服务端渲染
39-
}
40-
);
41-
4230
export default function PostList({
4331
className = "",
4432
categorySlug,

0 commit comments

Comments
 (0)