refactor: 重构主题提供逻辑并更新依赖
All checks were successful
test/timeline-frontend/pipeline/head This commit looks good

将主题提供逻辑从独立组件移至布局包装器,简化组件结构
同时更新 dexie 依赖至 4.3.0 版本
This commit is contained in:
2026-02-26 09:43:53 +08:00
parent 5a0aa2b3c1
commit e97ea2e6a1
3 changed files with 35 additions and 51 deletions

View File

@@ -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",

View File

@@ -32,9 +32,25 @@ function LayoutChildrenWrapper({
setInitialState: any;
}) {
const isMobile = useIsMobile();
const { effectiveTheme, getCurrentColorScheme, fetchThemePreferences } = useModel('theme');
useEffect(() => {
fetchThemePreferences();
}, [fetchThemePreferences]);
const colorScheme = getCurrentColorScheme();
useNotifications();
return (
<ConfigProvider
theme={{
algorithm: effectiveTheme === 'dark' ? antdTheme.darkAlgorithm : antdTheme.defaultAlgorithm,
token: {
colorPrimary: colorScheme.primaryColor,
},
}}
>
<>
{children}
{isMobile && <BottomNav />}
@@ -52,6 +68,7 @@ function LayoutChildrenWrapper({
/>
)}
</>
</ConfigProvider>
);
}
@@ -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 <ThemeProvider>{container}</ThemeProvider>;
}
function ThemeProvider({ children }: { children: React.ReactNode }) {
const { effectiveTheme, getCurrentColorScheme, fetchThemePreferences } = useModel('theme');
// Fetch theme preferences on mount
useEffect(() => {
fetchThemePreferences();
}, [fetchThemePreferences]);
const colorScheme = getCurrentColorScheme();
return (
<ConfigProvider
theme={{
algorithm: effectiveTheme === 'dark' ? antdTheme.darkAlgorithm : antdTheme.defaultAlgorithm,
token: {
colorPrimary: colorScheme.primaryColor,
},
}}
>
{children}
</ConfigProvider>
);
}

1
src/types/sync.d.ts vendored
View File

@@ -154,7 +154,6 @@ declare namespace API {
updatedAt: Date;
syncStatus: SyncStatus;
}
}
/**
* Sync status