2026-02-24 20:44:16 +00:00
|
|
|
|
import type { CommonProps } from '@/proxy/common'
|
|
|
|
|
|
import ConfigProvider from '@/components/ui/ConfigProvider'
|
|
|
|
|
|
import { themeConfig } from '@/proxy/theme/theme.config'
|
|
|
|
|
|
import { useStoreActions, useStoreState } from '@/store'
|
|
|
|
|
|
import useDarkMode from '@/utils/hooks/useDarkmode'
|
|
|
|
|
|
import useNotification from '@/utils/hooks/useNotification'
|
|
|
|
|
|
import { useSetting } from '@/utils/hooks/useSetting'
|
|
|
|
|
|
import useTabFocus from '@/utils/hooks/useTabFocus'
|
|
|
|
|
|
import { useEffect } from 'react'
|
|
|
|
|
|
import { Helmet } from 'react-helmet'
|
2026-04-23 10:36:51 +00:00
|
|
|
|
import { useNavigate, useLocation } from 'react-router-dom'
|
|
|
|
|
|
import { getSetupStatus } from '@/services/setup.service'
|
|
|
|
|
|
import { ROUTES_ENUM } from '@/routes/route.constant'
|
2026-02-24 20:44:16 +00:00
|
|
|
|
|
|
|
|
|
|
let didInit = false
|
|
|
|
|
|
|
|
|
|
|
|
const Theme = (props: CommonProps) => {
|
|
|
|
|
|
// ABP App Config'i uygulama acilirken al
|
|
|
|
|
|
const { getConfig } = useStoreActions((a) => a.abpConfig)
|
2026-04-23 10:36:51 +00:00
|
|
|
|
const { setSetupMode } = useStoreActions((a) => a.base.common)
|
|
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
|
const location = useLocation()
|
2026-02-24 20:44:16 +00:00
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (!didInit) {
|
|
|
|
|
|
didInit = true
|
2026-04-23 10:36:51 +00:00
|
|
|
|
|
|
|
|
|
|
// Direkt /setup'a gelindiyse — hemen setupMode=true yap (loading gate açılsın)
|
|
|
|
|
|
if (location.pathname === ROUTES_ENUM.setup) {
|
|
|
|
|
|
setSetupMode(true)
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Veritabanı var mı kontrol et; yoksa setup sayfasına yönlendir
|
|
|
|
|
|
getSetupStatus()
|
|
|
|
|
|
.then((res) => {
|
|
|
|
|
|
if (!res.data.dbExists) {
|
|
|
|
|
|
setSetupMode(true)
|
|
|
|
|
|
navigate(ROUTES_ENUM.setup, { replace: true })
|
|
|
|
|
|
} else {
|
|
|
|
|
|
getConfig(false)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => {
|
|
|
|
|
|
getConfig(false)
|
|
|
|
|
|
})
|
2026-02-24 20:44:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
|
|
function getThemeStyle() {
|
|
|
|
|
|
const mode = theme.mode
|
|
|
|
|
|
const style = setting('App.SiteManagement.Theme.Style')
|
|
|
|
|
|
|
|
|
|
|
|
return style?.replace(mode === 'dark' ? 'light' : 'dark', mode)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const { setting } = useSetting()
|
|
|
|
|
|
|
|
|
|
|
|
const theme = useStoreState((state) => state.theme)
|
|
|
|
|
|
const locale = useStoreState(
|
|
|
|
|
|
(state) => state.abpConfig.config?.localization.currentCulture.cultureName,
|
|
|
|
|
|
)
|
|
|
|
|
|
useDarkMode()
|
|
|
|
|
|
useTabFocus()
|
|
|
|
|
|
useNotification()
|
|
|
|
|
|
|
|
|
|
|
|
const currentTheme = {
|
|
|
|
|
|
...themeConfig,
|
|
|
|
|
|
...theme,
|
|
|
|
|
|
...{ locale },
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<>
|
|
|
|
|
|
{setting('App.SiteManagement.Theme.Style') && (
|
|
|
|
|
|
<Helmet key="Devexpress stylesheet Helmet">
|
|
|
|
|
|
<link
|
|
|
|
|
|
key="Devexpress stylesheet Helmet link"
|
|
|
|
|
|
rel="stylesheet"
|
|
|
|
|
|
href={`/css/${getThemeStyle()}.css`}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Helmet>
|
|
|
|
|
|
)}
|
|
|
|
|
|
<ConfigProvider value={currentTheme}>{props.children}</ConfigProvider>
|
|
|
|
|
|
</>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default Theme
|