From 949101293825da8a898a6fbdf892f1e8e352efb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=87=E8=96=87=E5=AE=89?= Date: Tue, 3 Feb 2026 15:44:29 +0800 Subject: [PATCH] 1 --- frontend/src/components/GlobalConfig.jsx | 53 +----------------------- 1 file changed, 2 insertions(+), 51 deletions(-) diff --git a/frontend/src/components/GlobalConfig.jsx b/frontend/src/components/GlobalConfig.jsx index fd1d95b..ea258d6 100644 --- a/frontend/src/components/GlobalConfig.jsx +++ b/frontend/src/components/GlobalConfig.jsx @@ -891,31 +891,7 @@ const GlobalConfig = () => { } - const loadUsersAndAccounts = async () => { - if (!isAdmin) return - try { - setBusy(true) - const [users, accounts] = await Promise.all([ - api.getUsersDetailed ? api.getUsersDetailed() : api.get('/admin/users/detailed').then(r => r.data), - api.getAccounts(), - ]) - setUsersDetailed(Array.isArray(users) ? users : []) - setAccountsAdmin(Array.isArray(accounts) ? accounts : []) - const initMap = {} - ;(Array.isArray(users) ? users : []).forEach(u => { - initMap[u.id] = '' - }) - setLinkAccountMap(initMap) - } catch (e) { - setMessage(e?.message || '加载失败') - } finally { - setBusy(false) - } - } - - useEffect(() => { - if (isAdmin) loadUsersAndAccounts() - }, [isAdmin]) + if (loading) { return
加载中...
@@ -1005,32 +981,7 @@ const GlobalConfig = () => { - const handleGrant = async (userId) => { - const aid = parseInt(String(linkAccountMap[userId] || ''), 10) - if (!Number.isFinite(aid) || aid <= 0) return - try { - setBusy(true) - await api.grantUserAccount(userId, aid, linkRole) - setMessage('已关联账号') - await loadUsersAndAccounts() - } catch (e) { - setMessage(e?.message || '关联失败') - } finally { - setBusy(false) - } - } - const handleRevoke = async (userId, accountId) => { - try { - setBusy(true) - await api.revokeUserAccount(userId, accountId) - setMessage('已取消关联') - await loadUsersAndAccounts() - } catch (e) { - setMessage(e?.message || '取消失败') - } finally { - setBusy(false) - } - } + return (