diff --git a/frontend/src/pages/UsersPage.tsx b/frontend/src/pages/UsersPage.tsx index 4d1b068..e00330e 100644 --- a/frontend/src/pages/UsersPage.tsx +++ b/frontend/src/pages/UsersPage.tsx @@ -902,13 +902,21 @@ function BatchImportModal({ onClose, onImported }: { onClose: () => void; onImpo const [creatingOu, setCreatingOu] = useState(false); const [deleteConfirm, setDeleteConfirm] = useState<{msg: string; onConfirm: () => void} | null>(null); - // Check LDAP readiness + // Check LDAP readiness + load OUs useEffect(() => { if (tab === 'to-ldap' || tab === 'from-ldap') { + setLdapLoading(true); ldapApi.getConfig().then((res: any) => { - setLdapReady(!!res?.ldap_host); - }).catch(() => setLdapReady(false)); - if (ldapOus.length === 0) loadLdapOus(); + const ready = !!res?.ldap_host; + setLdapReady(ready); + if (ready && ldapOus.length === 0) { + return loadLdapOus(); + } + setLdapLoading(false); + }).catch(() => { + setLdapReady(false); + setLdapLoading(false); + }); } }, [tab]); @@ -1025,7 +1033,7 @@ function BatchImportModal({ onClose, onImported }: { onClose: () => void; onImpo ]; return ( -
+
e.stopPropagation()}> {/* Header */}
@@ -1093,12 +1101,13 @@ function BatchImportModal({ onClose, onImported }: { onClose: () => void; onImpo {/* ── Import to LDAP ── */} {tab === 'to-ldap' && ( <> - {!ldapReady && ( + {ldapLoading &&

加载中...

} + {!ldapLoading && !ldapReady && (
LDAP 未配置,请先在「平台配置 → LDAP」中配置 LDAP 连接
)} - {ldapReady && ( + {!ldapLoading && ldapReady && ( <> {/* OU selector */}
@@ -1163,12 +1172,12 @@ function BatchImportModal({ onClose, onImported }: { onClose: () => void; onImpo {/* ── From LDAP Import ── */} {tab === 'from-ldap' && ( <> - {!ldapReady && ( + {ldapLoading &&

加载中...

} + {!ldapLoading && !ldapReady && (
LDAP 未配置,请先在「平台配置 → LDAP」中配置 LDAP 连接
)} - {ldapLoading &&

加载中...

} {!ldapLoading && ldapReady && ldapOus.length > 0 && ldapUsers.length === 0 && (

选择组织单元: