"use client"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { Button } from "@/components/ui/button"; import { formatBytes } from "@/app/(main)/account/storage/format"; import { getStatusView } from "@/app/(main)/apps/deployment-status"; import { presentSessionCreateError } from "@/lib/api/balance-error"; import { type AppDetail, createAppSession, refreshAppQueries } from "@/lib/apps"; import { liveUrl as toLiveUrl } from "@/lib/deployments/live-url"; import { formatRelativeTime } from "@/lib/format/relative-time"; import { SESSION_ROUTE } from "@/lib/sessions"; import { SectionCard, SettingsRow } from "../SettingsRow"; import { sectionHref } from "../nav"; import { DeployTabLink } from "./DeployTabLink"; import { useResumeDeployment } from "./use-resume-deployment"; /** 概览: 一行一件事, 值在左、说明在下、次要动作靠右. */ export const OverviewSection = ({ detail }: { detail: AppDetail }) => { const router = useRouter(); const queryClient = useQueryClient(); const deployment = detail.deployment ?? null; const liveUrl = toLiveUrl(detail.custom_domain, deployment?.url); const resume = useResumeDeployment(detail.id); const newSession = useMutation({ mutationFn: () => createAppSession(detail.id), onSuccess: (session) => { void refreshAppQueries(queryClient, detail.id); router.push(`${SESSION_ROUTE}?session_id=${session.id}`); }, onError: (err) => presentSessionCreateError(err, router), }); return ( {liveUrl.replace(/^https?:\/\//, "")} ) : ( "未发布" ) } note={detail.custom_domain ? null : "未绑自定义域名"} action={ detail.custom_domain ? null : ( ) } /> resume.mutate(deployment.deployment_id)} disabled={resume.isPending}> 恢复部署 ) : deployment != null ? ( ) : null } /> 0 ? `已归档 ${detail.archived_session_count} 个` : null} action={ } /> ); };