From 77950e48c76f4a3b29d01831d43039caba29888a Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期二, 18 十一月 2025 14:12:42 +0800
Subject: [PATCH] 修改
---
context/app-context.tsx | 31 ++++++++++++++++++++++++-------
1 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/context/app-context.tsx b/context/app-context.tsx
index 79cc246..7addfb8 100644
--- a/context/app-context.tsx
+++ b/context/app-context.tsx
@@ -8,13 +8,15 @@
import Loading from '@/app/components/base/loading'
import { fetchCurrentWorkspace, fetchLanggeniusVersion, fetchUserProfile, getSystemFeatures } from '@/service/common'
import type { App } from '@/types/app'
+import { Theme } from '@/types/app'
import type { ICurrentWorkspace, LangGeniusVersionResponse, UserProfileResponse } from '@/models/common'
import MaintenanceNotice from '@/app/components/header/maintenance-notice'
import type { SystemFeatures } from '@/types/feature'
import { defaultSystemFeatures } from '@/types/feature'
-import { noop } from 'lodash-es'
export type AppContextValue = {
+ theme: Theme
+ setTheme: (theme: Theme) => void
apps: App[]
systemFeatures: SystemFeatures
mutateApps: VoidFunction
@@ -50,18 +52,20 @@
created_at: 0,
role: 'normal',
providers: [],
+ in_trail: true,
}
const AppContext = createContext<AppContextValue>({
+ theme: Theme.light,
systemFeatures: defaultSystemFeatures,
+ setTheme: () => { },
apps: [],
- mutateApps: noop,
+ mutateApps: () => { },
userProfile: {
id: '',
name: '',
email: '',
avatar: '',
- avatar_url: '',
is_password_set: false,
},
currentWorkspace: initialWorkspaceInfo,
@@ -69,8 +73,8 @@
isCurrentWorkspaceOwner: false,
isCurrentWorkspaceEditor: false,
isCurrentWorkspaceDatasetOperator: false,
- mutateUserProfile: noop,
- mutateCurrentWorkspace: noop,
+ mutateUserProfile: () => { },
+ mutateCurrentWorkspace: () => { },
pageContainerRef: createRef(),
langeniusVersionInfo: initialLangeniusVersionInfo,
useSelector,
@@ -123,11 +127,24 @@
setCurrentWorkspace(currentWorkspaceResponse)
}, [currentWorkspaceResponse])
+ const [theme, setTheme] = useState<Theme>(Theme.light)
+ const handleSetTheme = useCallback((theme: Theme) => {
+ setTheme(theme)
+ globalThis.document.documentElement.setAttribute('data-theme', theme)
+ }, [])
+
+ useEffect(() => {
+ globalThis.document.documentElement.setAttribute('data-theme', theme)
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [])
+
if (!appList || !userProfile)
return <Loading type='app' />
return (
<AppContext.Provider value={{
+ theme,
+ setTheme: handleSetTheme,
apps: appList.data,
systemFeatures: { ...defaultSystemFeatures, ...systemFeatures },
mutateApps,
@@ -144,9 +161,9 @@
mutateCurrentWorkspace,
isLoadingCurrentWorkspace,
}}>
- <div className='flex h-full flex-col overflow-y-auto'>
+ <div className='flex flex-col h-full overflow-y-auto'>
{globalThis.document?.body?.getAttribute('data-public-maintenance-notice') && <MaintenanceNotice />}
- <div ref={pageContainerRef} className='relative flex grow flex-col overflow-y-auto overflow-x-hidden bg-background-body'>
+ <div ref={pageContainerRef} className='grow relative flex flex-col overflow-y-auto overflow-x-hidden bg-background-body'>
{children}
</div>
</div>
--
Gitblit v1.8.0