diff --git a/packages/core/src/components/mode-toggle.tsx b/packages/core/src/components/mode-toggle.tsx index b260afb..767f1c5 100644 --- a/packages/core/src/components/mode-toggle.tsx +++ b/packages/core/src/components/mode-toggle.tsx @@ -2,10 +2,16 @@ import * as React from "react"; import { useTheme } from "next-themes"; -import { MoonIcon } from "lucide-react"; +import { MoonIcon, SunMedium } from "lucide-react"; import { IconSunLow } from "@tabler/icons-react"; import { motion } from "framer-motion"; +/** + * # 组件 ModeToggle + * 说明:深浅模式切换按钮。按钮**恒渲染**(固定 40px)——挂载前显示 Sun 占位图标 + * (next-themes 挂载前主题未知,图标以占位代替),挂载后切换为当前主题图标。 + * 消除旧实现(isClient 前不渲染)导致的 header 宽度抖动(CLS)。 + */ export function ModeToggle() { const { theme, setTheme } = useTheme(); @@ -15,56 +21,48 @@ export function ModeToggle() { setIsClient(true); }, []); - return ( - isClient && ( + // 挂载前:固定占位图标(与真实按钮同尺寸,无布局位移) + if (!isClient) { + return ( - ) + ); + } + + return ( + ); } diff --git a/packages/core/src/features/navigation/components/user-menu.tsx b/packages/core/src/features/navigation/components/user-menu.tsx index a966bad..3ee36c3 100644 --- a/packages/core/src/features/navigation/components/user-menu.tsx +++ b/packages/core/src/features/navigation/components/user-menu.tsx @@ -35,8 +35,16 @@ export function UserMenu() { }, [session.data?.user?.id]); if (session.isPending) { + // 占位与"未登录"终态同尺寸(Sign in 文字 + Sign Up 按钮),消除宽度抖动 return ( -
+
+ + {t('common.actions.signIn')} + + + {t('common.actions.signUp')} + +
); } diff --git a/sites/findai/tsconfig.json b/sites/findai/tsconfig.json index 95fd293..c20f005 100644 --- a/sites/findai/tsconfig.json +++ b/sites/findai/tsconfig.json @@ -15,7 +15,7 @@ "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "react-jsx", + "jsx": "preserve", "incremental": true, "plugins": [ { @@ -55,8 +55,7 @@ "next-env.d.ts", "**/*.ts", "**/*.tsx", - ".next/types/**/*.ts", - ".next/dev/types/**/*.ts" + ".next/types/**/*.ts" ], "exclude": [ "node_modules" diff --git a/sites/launchai/tsconfig.json b/sites/launchai/tsconfig.json index 95fd293..c20f005 100644 --- a/sites/launchai/tsconfig.json +++ b/sites/launchai/tsconfig.json @@ -15,7 +15,7 @@ "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "react-jsx", + "jsx": "preserve", "incremental": true, "plugins": [ { @@ -55,8 +55,7 @@ "next-env.d.ts", "**/*.ts", "**/*.tsx", - ".next/types/**/*.ts", - ".next/dev/types/**/*.ts" + ".next/types/**/*.ts" ], "exclude": [ "node_modules" diff --git a/sites/the-ai-ledger/tsconfig.json b/sites/the-ai-ledger/tsconfig.json index 95fd293..c20f005 100644 --- a/sites/the-ai-ledger/tsconfig.json +++ b/sites/the-ai-ledger/tsconfig.json @@ -15,7 +15,7 @@ "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "react-jsx", + "jsx": "preserve", "incremental": true, "plugins": [ { @@ -55,8 +55,7 @@ "next-env.d.ts", "**/*.ts", "**/*.tsx", - ".next/types/**/*.ts", - ".next/dev/types/**/*.ts" + ".next/types/**/*.ts" ], "exclude": [ "node_modules"