From dbb1b5ebecd40b6b718cc867a5064ffa1d36d992 Mon Sep 17 00:00:00 2001 From: ZeroDeng Date: Wed, 29 May 2024 14:38:21 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20Fix=20the=20issue=20of=20?= =?UTF-8?q?default=20logo=20still=20loading=20after=20user=20customizes=20?= =?UTF-8?q?LOGO=20(#238)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/config.js | 3 ++- web/src/store/siteInfoReducer.js | 3 ++- web/src/ui-component/Logo.js | 10 ++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/web/src/config.js b/web/src/config.js index 9a252fbf..d8211766 100644 --- a/web/src/config.js +++ b/web/src/config.js @@ -25,7 +25,8 @@ const config = { wechat_qrcode: '', lark_login: false, lark_client_id: '', - telegram_bot: '' + telegram_bot: '', + isLoading: true, // 添加加载状态 } }; diff --git a/web/src/store/siteInfoReducer.js b/web/src/store/siteInfoReducer.js index e14bc245..2132c0e3 100644 --- a/web/src/store/siteInfoReducer.js +++ b/web/src/store/siteInfoReducer.js @@ -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; diff --git a/web/src/ui-component/Logo.js b/web/src/ui-component/Logo.js index 52e61f4f..93e8d053 100644 --- a/web/src/ui-component/Logo.js +++ b/web/src/ui-component/Logo.js @@ -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 {siteInfo.system_name}; + if (siteInfo.isLoading) { + return null; // 数据加载未完成时不显示 logo + } + + const logoToDisplay = siteInfo.logo ? siteInfo.logo : defaultLogo; + + return {siteInfo.system_name}; }; export default Logo;