forked from le0pard/pgtune
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.jsx
48 lines (39 loc) · 1.08 KB
/
main.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import '@css/app.css'
import React from 'react'
import ReactDOM from 'react-dom/client'
import { Provider } from 'react-redux'
import { configureAppStore } from '@app/store'
import { initServiceWorker } from '@features/sw/swWindow'
import { LocalStorage } from '@common/utils/localStorage'
import { onDomReady } from '@common/utils/onDomReady'
import { APP_THEMES_LIGHT, APP_THEMES_DARK } from '@features/settings/constants'
import App from './App.jsx'
const preloadedState = () => {
if (!window) {
return {}
}
let theme = LocalStorage.getItem('theme')
if (!theme) {
if (window.matchMedia('(prefers-color-scheme: dark)')?.matches) {
theme = APP_THEMES_DARK
}
}
return {
settings: {
theme: theme || APP_THEMES_LIGHT
}
}
}
const start = () => {
const rootElement = document.getElementById('root')
const store = configureAppStore(preloadedState())
initServiceWorker(store)
ReactDOM.createRoot(rootElement).render(
<React.StrictMode>
<Provider store={store}>
<App />
</Provider>
</React.StrictMode>
)
}
onDomReady(start)