From e97ea2e6a1be7715325229e7528e7a0a8741c696 Mon Sep 17 00:00:00 2001 From: jianghao <332515344@qq.com> Date: Thu, 26 Feb 2026 09:43:53 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E6=8F=90=E4=BE=9B=E9=80=BB=E8=BE=91=E5=B9=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将主题提供逻辑从独立组件移至布局包装器,简化组件结构 同时更新 dexie 依赖至 4.3.0 版本 --- package.json | 2 +- src/app.tsx | 83 +++++++++++++++++++-------------------------- src/types/sync.d.ts | 1 - 3 files changed, 35 insertions(+), 51 deletions(-) diff --git a/package.json b/package.json index 7a41363..69d5ebe 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "antd-style": "^3.6.1", "classnames": "^2.5.1", "dayjs": "^1.11.10", - "dexie": "^4.0.0", + "dexie": "^4.3.0", "numeral": "^2.0.6", "omit.js": "^2.0.2", "querystring": "^0.2.1", diff --git a/src/app.tsx b/src/app.tsx index 6702e82..22416e9 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -32,26 +32,43 @@ function LayoutChildrenWrapper({ setInitialState: any; }) { const isMobile = useIsMobile(); + const { effectiveTheme, getCurrentColorScheme, fetchThemePreferences } = useModel('theme'); + + useEffect(() => { + fetchThemePreferences(); + }, [fetchThemePreferences]); + + const colorScheme = getCurrentColorScheme(); + useNotifications(); return ( - <> - {children} - {isMobile && } - {isDev && ( - { - setInitialState((preInitialState: any) => ({ - ...preInitialState, - settings, - })); - }} - /> - )} - + + <> + {children} + {isMobile && } + {isDev && ( + { + setInitialState((preInitialState: any) => ({ + ...preInitialState, + settings, + })); + }} + /> + )} + + ); } @@ -128,35 +145,3 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) = export const request: RequestConfig = { ...errorConfig, }; - -/** - * Theme Provider Wrapper - * Wraps the entire app with ConfigProvider to apply theme - */ -export function rootContainer(container: any) { - return {container}; -} - -function ThemeProvider({ children }: { children: React.ReactNode }) { - const { effectiveTheme, getCurrentColorScheme, fetchThemePreferences } = useModel('theme'); - - // Fetch theme preferences on mount - useEffect(() => { - fetchThemePreferences(); - }, [fetchThemePreferences]); - - const colorScheme = getCurrentColorScheme(); - - return ( - - {children} - - ); -} diff --git a/src/types/sync.d.ts b/src/types/sync.d.ts index 55a1467..22a6252 100644 --- a/src/types/sync.d.ts +++ b/src/types/sync.d.ts @@ -154,7 +154,6 @@ declare namespace API { updatedAt: Date; syncStatus: SyncStatus; } -} /** * Sync status