分离设置页面

This commit is contained in:
IndieKKY
2024-10-04 19:31:09 +08:00
parent e238d83f78
commit cf737b9976
4 changed files with 19 additions and 22 deletions

View File

@@ -4,11 +4,10 @@ import {useAppDispatch, useAppSelector} from './hooks/redux'
import {setEnvData, setEnvReady, setTempData, setTempReady} from './redux/envReducer'
import {cloneDeep} from 'lodash-es'
import {STORAGE_ENV, STORAGE_TEMP} from './const'
import Settings from './biz/Settings'
import OptionsPage from './pages/OptionsPage'
import {handleJson} from '@kky002/kky-util'
import {useLocalStorage} from '@kky002/kky-hooks'
import {Toaster} from 'react-hot-toast'
import {setTheme} from './util/biz_util'
import useMessagingService from './hooks/useMessagingService'
import MainPage from './pages/MainPage'
@@ -17,6 +16,8 @@ function App() {
const envData = useAppSelector(state => state.env.envData)
const tempData = useAppSelector(state => state.env.tempData)
const path = useAppSelector(state => state.env.path)
const envReady = useAppSelector(state => state.env.envReady)
const tempReady = useAppSelector(state => state.env.tempReady)
// env数据
const savedEnvData = useMemo(() => {
@@ -42,18 +43,13 @@ function App() {
}, [dispatch])
useLocalStorage<TempData>('chrome_client', STORAGE_TEMP, savedTempData, onLoadTemp)
// theme改变时设置主题
useEffect(() => {
setTheme(envData.theme)
}, [envData.theme])
// services
useMessagingService()
return <div>
<Toaster position={path === 'app'?'bottom-center':'top-center'}/>
{path === 'app' && <MainPage/>}
{path === 'options' && <Settings/>}
{path === 'options' && envReady && tempReady && <OptionsPage/>}
</div>
}