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 ( -
加载中...
} + {!ldapLoading && !ldapReady && (加载中...
} + {!ldapLoading && !ldapReady && (加载中...
} {!ldapLoading && ldapReady && ldapOus.length > 0 && ldapUsers.length === 0 && (选择组织单元: