基础设置 内容接入保存接口 ,再登录界面 就调用 接口 显示 默认 的 保存设置
This commit is contained in:
26
src/App.tsx
26
src/App.tsx
@@ -8,6 +8,10 @@ import utils from './lib/utils';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { I18nextProvider } from 'react-i18next';
|
||||
import i18n from './i18n';
|
||||
import { useEffect } from 'react';
|
||||
import { useAppDispatch } from './store';
|
||||
import { setSettingField, setGlobalParams } from './store/basicSettingsSlice';
|
||||
import { getSystemParam } from './api/global';
|
||||
|
||||
// 用于静态注入 message/modal/notification
|
||||
const StaticAntd = () => {
|
||||
@@ -50,6 +54,28 @@ const AntdConfigWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
};
|
||||
|
||||
export default function App() {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
useEffect(() => {
|
||||
getSystemParam()
|
||||
.then((res: any) => {
|
||||
if (res?.code === 200 && res?.data?.global) {
|
||||
const globalArr = res.data.global;
|
||||
// 存储完整数组,保存时基于此结构更新 paramValue
|
||||
dispatch(setGlobalParams(globalArr));
|
||||
// 同时提取 systemName 用于登录页和平台头部显示
|
||||
const systemNameItem = globalArr.find((item: any) => item.paramKey === 'systemName');
|
||||
if (systemNameItem?.paramValue) {
|
||||
dispatch(setSettingField({ systemName: systemNameItem.paramValue }));
|
||||
}
|
||||
console.log('[System] global config loaded:', globalArr);
|
||||
}
|
||||
})
|
||||
.catch((err: any) => {
|
||||
console.error('[System] Failed to load global config:', err);
|
||||
});
|
||||
}, [dispatch]);
|
||||
|
||||
return (
|
||||
<I18nextProvider i18n={i18n}>
|
||||
<AntdConfigWrapper>
|
||||
|
||||
Reference in New Issue
Block a user