🐛 fix: Fix the issue of default logo still loading after user customizes LOGO (#238)

This commit is contained in:
ZeroDeng 2024-05-29 14:38:21 +08:00 committed by GitHub
parent 7d90e43492
commit dbb1b5ebec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 4 deletions

View File

@ -25,7 +25,8 @@ const config = {
wechat_qrcode: '',
lark_login: false,
lark_client_id: '',
telegram_bot: ''
telegram_bot: '',
isLoading: true, // 添加加载状态
}
};

View File

@ -8,7 +8,8 @@ const siteInfoReducer = (state = initialState, action) => {
case actionTypes.SET_SITE_INFO:
return {
...state,
...action.payload
...action.payload,
isLoading: false, // 添加加载状态
};
default:
return state;

View File

@ -17,9 +17,15 @@ import { useTheme } from '@mui/material/styles';
const Logo = () => {
const siteInfo = useSelector((state) => state.siteInfo);
const theme = useTheme();
const logo = theme.palette.mode === 'light' ? logoLight : logoDark;
const defaultLogo = theme.palette.mode === 'light' ? logoLight : logoDark;
return <img src={siteInfo.logo || logo} alt={siteInfo.system_name} height="50" />;
if (siteInfo.isLoading) {
return null; // 数据加载未完成时不显示 logo
}
const logoToDisplay = siteInfo.logo ? siteInfo.logo : defaultLogo;
return <img src={logoToDisplay} alt={siteInfo.system_name} height="50" />;
};
export default Logo;