diff --git a/frontend/src/components/GlobalConfig.jsx b/frontend/src/components/GlobalConfig.jsx index 5bf07a0..43a21d0 100644 --- a/frontend/src/components/GlobalConfig.jsx +++ b/frontend/src/components/GlobalConfig.jsx @@ -206,6 +206,8 @@ const GlobalConfig = ({ currentUser }) => { const m = await api.getConfigMeta() setConfigMeta(m || null) } catch (e) { + // 静默失败,可能是权限问题 + console.error('loadConfigMeta failed:', e) setConfigMeta(null) } } @@ -281,15 +283,16 @@ const GlobalConfig = ({ currentUser }) => { useEffect(() => { loadUsers() loadAccounts() + // 只有管理员才加载配置和系统状态 if (isAdmin) { - loadConfigMeta() - loadConfigs() - loadSystemStatus() - loadBackendStatus() + loadConfigMeta().catch(() => {}) // 静默失败 + loadConfigs().catch(() => {}) // 静默失败 + loadSystemStatus().catch(() => {}) // 静默失败 + loadBackendStatus().catch(() => {}) // 静默失败 const timer = setInterval(() => { - loadSystemStatus() - loadBackendStatus() + loadSystemStatus().catch(() => {}) + loadBackendStatus().catch(() => {}) }, 3000) return () => clearInterval(timer) } @@ -681,6 +684,9 @@ const GlobalConfig = ({ currentUser }) => { } } + // 必须在所有使用之前定义 isAdmin + const isAdmin = (currentUser?.role || '') === 'admin' + if (loading) { return
加载中...
}