feat: 增加模板版本独立预览入口
This commit is contained in:
1 parent
413413efda
commit
6edde5a8d6
15 files changed
+781
-14
No files matched your search
@@ -1,13 +1,14 @@
|
||||
import { useRef, useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { Alert, Button, List, Modal, Table, Tag, Typography, message } from "antd";
|
||||
import { ReloadOutlined, UploadOutlined } from "@ant-design/icons";
|
||||
import { EyeOutlined, ReloadOutlined, UploadOutlined } from "@ant-design/icons";
|
||||
import type { TemplatePackageVersion } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { AdminSection } from "../../components/AdminSection.js";
|
||||
import { EmptyState } from "../../components/EmptyState.js";
|
||||
import { ErrorNote, QueryState } from "../../components/QueryState.js";
|
||||
import { TemplatePackagePreviewModal } from "./TemplatePackagePreviewModal.js";
|
||||
|
||||
const client = createApiClient();
|
||||
|
||||
@@ -23,6 +24,7 @@ export function TemplateManagementPage() {
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
const [auditId, setAuditId] = useState<string | null>(null);
|
||||
const [previewVersion, setPreviewVersion] = useState<TemplatePackageVersion | null>(null);
|
||||
const queryClient = useQueryClient();
|
||||
const packages = useQuery({
|
||||
queryKey: ["admin-template-packages", page, pageSize],
|
||||
@@ -167,7 +169,7 @@ export function TemplateManagementPage() {
|
||||
key: "report",
|
||||
render: (_, item) => {
|
||||
const report = item.validationReport;
|
||||
return `${String(report.fileCount ?? "-")} 个,${formatBytes(report.extractedBytes)}`;
|
||||
return `${typeof report.fileCount === "number" ? report.fileCount : "-"} 个,${formatBytes(report.extractedBytes)}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -188,6 +190,14 @@ export function TemplateManagementPage() {
|
||||
key: "actions",
|
||||
render: (_, item) => (
|
||||
<span>
|
||||
<Button
|
||||
type="link"
|
||||
icon={<EyeOutlined />}
|
||||
onClick={() => setPreviewVersion(item)}
|
||||
disabled={!item.manifestSummary?.supportedIndustryTemplates?.length}
|
||||
>
|
||||
预览
|
||||
</Button>
|
||||
<Button
|
||||
type="link"
|
||||
loading={lifecycle.isPending && lifecycle.variables?.id === item.id}
|
||||
@@ -247,6 +257,12 @@ export function TemplateManagementPage() {
|
||||
/>
|
||||
</QueryState>
|
||||
</Modal>
|
||||
{previewVersion ? (
|
||||
<TemplatePackagePreviewModal
|
||||
version={previewVersion}
|
||||
onClose={() => setPreviewVersion(null)}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user