perf(webui): reduce initial loading delays

This commit is contained in:
DrSmoothl committed 2026-08-08 00:04:51 +08:00
1 parent c53c6651a5
commit 751217c13d
2 files changed
+13 -6

No files matched your search

+5 -2
View File
@@ -139,11 +139,14 @@ function AuthBoundary({ onboardingSteps }: { onboardingSteps: AdditionalOnboardi
if (ok) {
setAuthed(true);
setStatus('已连接');
setMustChange(await client.mustChangePassword());
const [nextMustChange] = await Promise.all([
client.mustChangePassword(),
refreshAgreements(),
]);
setMustChange(nextMustChange);
// Carry the URL password into the forced change-password gate so it
// needn't re-prompt for the old password (matches the login flow).
if (urlPassword) setLoginPassword(urlPassword);
await refreshAgreements();
}
setAuthChecked(true);
})();
@@ -55,7 +55,11 @@ export function useOneBotInstanceConfig(
): UseOneBotInstanceConfig {
const api = useApi();
const { runAction } = useActionFeedback();
const { selectedUin, onSelectedUinChange } = options;
const { onSelectedUinChange } = options;
// Start the first config request in the same render that receives the account
// list; publishing the selection upward remains an effect, but no longer adds
// an otherwise unnecessary render before the network request can begin.
const selectedUin = options.selectedUin ?? accounts[0]?.uin ?? null;
const [config, setConfigState] = useState<OneBotConfig | null>(null);
const [loadedUin, setLoadedUin] = useState<string | null>(null);
const [loading, setLoading] = useState(false);
@@ -71,10 +75,10 @@ export function useOneBotInstanceConfig(
const selectedUinRef = useRef(selectedUin);
selectedUinRef.current = selectedUin;
// Auto-select first account when none is selected yet.
// Publish the derived first selection so the sidebar and later routes retain it.
useEffect(() => {
if (!selectedUin && accounts.length > 0) onSelectedUinChange(accounts[0].uin);
}, [accounts, selectedUin, onSelectedUinChange]);
if (options.selectedUin === null && selectedUin) onSelectedUinChange(selectedUin);
}, [options.selectedUin, selectedUin, onSelectedUinChange]);
// Load on UIN change. The api client already runs normalizeOneBotConfig.
useEffect(() => {