mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-06 23:56:37 +08:00
fix(frontend): resolve login redirect loop and clean up info tab
- Prevent infinite session probe requests on the login page by guarding the check with the authenticated user state and using the Latest Ref pattern. - Decouple useEffect from resolveRedirectTarget by using resolveRedirectTargetRef to avoid searchParams dependency loops. - Remove the unused '服务连接' Card from the settings info tab and clean up unused imports, queries, and properties.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
"use client"
|
||||
|
||||
import {useMutation, useQuery} from "@tanstack/react-query"
|
||||
import {ExternalLink, RefreshCw, Server, Sparkles} from "lucide-react"
|
||||
import {ExternalLink, RefreshCw, Sparkles} from "lucide-react"
|
||||
import {toast} from "sonner"
|
||||
|
||||
import {AdminService, apiConfig} from "@/lib/services"
|
||||
import {AdminService} from "@/lib/services"
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -30,12 +30,7 @@ function InfoRow({ label, value }: { label: string; value: React.ReactNode }) {
|
||||
)
|
||||
}
|
||||
|
||||
interface InfoTabProps {
|
||||
systemConfigsLength: number
|
||||
authSourcesLength: number
|
||||
}
|
||||
|
||||
export function InfoTab({ systemConfigsLength, authSourcesLength }: InfoTabProps) {
|
||||
export function InfoTab() {
|
||||
const updateQuery = useQuery({
|
||||
queryKey: ["admin", "update"],
|
||||
queryFn: () => AdminService.getUpdateStatus(),
|
||||
@@ -163,27 +158,6 @@ export function InfoTab({ systemConfigsLength, authSourcesLength }: InfoTabProps
|
||||
) : null}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="border border-dashed shadow-sm">
|
||||
<CardHeader className="border-b border-dashed pb-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="p-1.5 rounded-lg bg-muted text-muted-foreground">
|
||||
<Server className="size-4" />
|
||||
</div>
|
||||
<div>
|
||||
<CardTitle className="text-base font-semibold">服务连接</CardTitle>
|
||||
<CardDescription className="text-xs">前端 API 客户端的基础连接参数</CardDescription>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="pt-4">
|
||||
<InfoRow label="API Base URL" value={apiConfig.baseURL || "同源"} />
|
||||
<InfoRow label="请求超时" value={`${apiConfig.timeout}ms`} />
|
||||
<InfoRow label="携带凭证" value={apiConfig.withCredentials ? "是" : "否"} />
|
||||
<InfoRow label="系统配置项" value={`${systemConfigsLength} 项`} />
|
||||
<InfoRow label="认证源数量" value={`${authSourcesLength} 个`} />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -35,12 +35,6 @@ export function SystemSettingsMain() {
|
||||
enabled: !!user?.is_admin,
|
||||
})
|
||||
|
||||
const authSourcesQuery = useQuery({
|
||||
queryKey: ["auth", "sources"],
|
||||
queryFn: () => AdminService.listAuthSources(),
|
||||
enabled: !!user?.is_admin,
|
||||
})
|
||||
|
||||
const configs = useMemo(
|
||||
() => systemConfigMap(systemConfigsQuery.data ?? []),
|
||||
[systemConfigsQuery.data],
|
||||
@@ -112,10 +106,7 @@ export function SystemSettingsMain() {
|
||||
<OtherTab configs={configs} />
|
||||
</TabsContent>
|
||||
<TabsContent value="info" className="pt-4">
|
||||
<InfoTab
|
||||
systemConfigsLength={systemConfigsQuery.data?.length ?? 0}
|
||||
authSourcesLength={authSourcesQuery.data?.length ?? 0}
|
||||
/>
|
||||
<InfoTab />
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</motion.div>
|
||||
|
||||
Reference in New Issue
Block a user