perf(frontend): split admin bundles and tighten data fetching

Add next/dynamic lazy loading for database, logs, and settings heavy
modules; migrate access-logs and task-executions to React Query; parallelize
login auth-sources with public config; consolidate users table tooltips;
enable lazy image decoding; and replace barrel @/lib/services imports with
direct module paths.
This commit is contained in:
ryan
2026-06-17 12:12:47 +08:00
parent 9550fa6ff3
commit a44043262e
43 changed files with 752 additions and 695 deletions
+8 -7
View File
@@ -16,7 +16,8 @@ import {Field, FieldGroup, FieldLabel} from "@/components/ui/field"
import {CapWidget} from "@/components/auth/cap-widget"
import {AuthHeading} from "@/components/auth/auth-shell"
import {OTPForm} from "./otp-form"
import services from "@/lib/services"
import {AuthService} from "@/lib/services/auth"
import {ConfigService} from "@/lib/services/config"
import type {LoginRequest} from "@/lib/services/auth/types"
import {safeRedirectTarget} from "@/lib/utils"
@@ -64,13 +65,12 @@ export function LoginForm({ onOTPStateChange }: { onOTPStateChange?: (show: bool
const publicConfigQuery = useQuery({
queryKey: ["public-config"],
queryFn: () => services.config.getPublicConfig(),
queryFn: () => ConfigService.getPublicConfig(),
})
const authSourcesQuery = useQuery({
queryKey: ["auth-sources"],
queryFn: () => services.auth.getAuthSources(),
enabled: configBool(publicConfigQuery.data?.oidc_login_enabled, true),
queryFn: () => AuthService.getAuthSources(),
})
const capEnabled = configBool(publicConfigQuery.data?.cap_login_enabled, false)
@@ -85,7 +85,7 @@ export function LoginForm({ onOTPStateChange }: { onOTPStateChange?: (show: bool
capTokenRef.current = null
setCapReady(false)
}
return services.auth.login(req, Object.keys(headers).length ? headers : undefined)
return AuthService.login(req, Object.keys(headers).length ? headers : undefined)
},
onSuccess: (user) => {
setUser(user)
@@ -170,7 +170,7 @@ export function LoginForm({ onOTPStateChange }: { onOTPStateChange?: (show: bool
try {
setErrorMessage("")
persistRedirectTarget(searchParams)
const { authorize_url } = await services.auth.getAuthorizeUrl(sourceName)
const { authorize_url } = await AuthService.getAuthorizeUrl(sourceName)
window.location.href = authorize_url
} catch (error) {
toast.error(error instanceof Error ? error.message : "第三方登录失败")
@@ -194,7 +194,8 @@ export function LoginForm({ onOTPStateChange }: { onOTPStateChange?: (show: bool
configBool(publicConfigQuery.data?.password_register_enabled, true)
const passwordLoginEnabled = configBool(publicConfigQuery.data?.password_login_enabled, true)
const authSources = authSourcesQuery.data ?? []
const oidcLoginEnabled = configBool(publicConfigQuery.data?.oidc_login_enabled, true)
const authSources = oidcLoginEnabled ? (authSourcesQuery.data ?? []) : []
const loginDisabled =
!passwordLoginEnabled ||
+2 -2
View File
@@ -9,7 +9,7 @@ import {LoginForm} from "@/components/auth/login-form"
import {AuthShell} from "@/components/auth/auth-shell"
import {Check} from "lucide-react"
import services from "@/lib/services"
import {AuthService} from "@/lib/services/auth"
import {useAuth} from "@/components/providers/auth-provider"
import {safeRedirectTarget} from "@/lib/utils"
@@ -84,7 +84,7 @@ export function LoginPage() {
setIsProcessingCallback(true)
try {
const result = await services.auth.handleCallback({ state, code })
const result = await AuthService.handleCallback({ state, code })
if (result.status === "need_bind") {
toast.info("您的第三方账号未绑定本地账号,系统已关闭注册。请登录已有本地账号进行绑定。")
setIsProcessingCallback(false)
+5 -4
View File
@@ -13,7 +13,8 @@ import {Spinner} from "@/components/ui/spinner"
import {Field, FieldGroup, FieldLabel} from "@/components/ui/field"
import {AuthHeading} from "@/components/auth/auth-shell"
import {CapWidget} from "@/components/auth/cap-widget"
import services from "@/lib/services"
import {AuthService} from "@/lib/services/auth"
import {ConfigService} from "@/lib/services/config"
import type {RegisterRequest} from "@/lib/services/auth/types"
import {safeRedirectTarget} from "@/lib/utils"
@@ -53,7 +54,7 @@ export function RegisterForm() {
const publicConfigQuery = useQuery({
queryKey: ["public-config"],
queryFn: () => services.config.getPublicConfig(),
queryFn: () => ConfigService.getPublicConfig(),
})
const redirectTarget = useMemo(
@@ -110,7 +111,7 @@ export function RegisterForm() {
capTokenRef.current = null
setCapReady(false)
}
return services.auth.register(req, Object.keys(headers).length ? headers : undefined)
return AuthService.register(req, Object.keys(headers).length ? headers : undefined)
},
onSuccess: (user) => {
setUser(user)
@@ -135,7 +136,7 @@ export function RegisterForm() {
capTokenRef.current = null
setCapReady(false)
}
return services.auth.sendEmailCode(targetEmail, "register", Object.keys(headers).length ? headers : undefined)
return AuthService.sendEmailCode(targetEmail, "register", Object.keys(headers).length ? headers : undefined)
},
onSuccess: () => {
setRegisterCooldown(60)