feat: 拆分发布中心内容和小程序标签页
This commit is contained in:
1 parent
3d0252d187
commit
ab1531d9b0
1 file changed
+41
-9
@@ -13,6 +13,7 @@ import {
|
||||
Space,
|
||||
Spin,
|
||||
Tag,
|
||||
Tabs,
|
||||
Typography,
|
||||
message,
|
||||
} from "antd";
|
||||
@@ -44,6 +45,7 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
const [settingsAppId, setSettingsAppId] = useState("");
|
||||
const [settingsArtifactPath, setSettingsArtifactPath] = useState("");
|
||||
const [settingsPrivateKey, setSettingsPrivateKey] = useState("");
|
||||
const [activeTab, setActiveTab] = useState("content");
|
||||
const brand = useQuery({
|
||||
queryKey: ["publication-brand"],
|
||||
queryFn: () => client.getAdminBrand(),
|
||||
@@ -157,7 +159,6 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
mutationFn: (values: { appId?: string; artifactPath?: string; privateKey?: string }) =>
|
||||
client.updateAdminMiniAppSettings(values),
|
||||
onSuccess: () => {
|
||||
setSettingsOpen(false);
|
||||
message.success("小程序上传配置已保存");
|
||||
void miniAppSettings.refetch();
|
||||
},
|
||||
@@ -185,9 +186,15 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
const loading = [brand, workspace, catalog, readiness, releases, miniAppReleases].some(
|
||||
(query) => query.isLoading,
|
||||
);
|
||||
const error = [brand, workspace, catalog, readiness, releases, miniAppReleases].find(
|
||||
(query) => query.isError,
|
||||
)?.error;
|
||||
const error = [
|
||||
brand,
|
||||
workspace,
|
||||
catalog,
|
||||
readiness,
|
||||
releases,
|
||||
miniAppReleases,
|
||||
miniAppSettings,
|
||||
].find((query) => query.isError)?.error;
|
||||
const retry = () => {
|
||||
void brand.refetch();
|
||||
void workspace.refetch();
|
||||
@@ -212,12 +219,13 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
? brand.data.config.visualTemplateKey
|
||||
: (visuals[0]?.key ?? null);
|
||||
const currentRelease = releases.data?.find((item) => item.status === "published");
|
||||
const settings = miniAppSettings.data;
|
||||
useEffect(() => {
|
||||
if (!miniAppSettings.data) return;
|
||||
setSettingsAppId(miniAppSettings.data.appId);
|
||||
setSettingsArtifactPath(miniAppSettings.data.artifactPath);
|
||||
setSettingsPrivateKey("");
|
||||
}, [miniAppSettings.data]);
|
||||
}, [settings]);
|
||||
const publishedHistory = (releases.data ?? []).filter(
|
||||
(item) => item.status === "published" || item.status === "superseded",
|
||||
);
|
||||
@@ -228,12 +236,24 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
isEnabled: boolean;
|
||||
}>;
|
||||
|
||||
const contentTab = <Space direction="vertical" size={24} style={{ width: "100%" }}></Space>;
|
||||
const miniAppTab = <Space direction="vertical" size={24} style={{ width: "100%" }}></Space>;
|
||||
|
||||
return (
|
||||
<QueryState loading={loading} error={error} onRetry={retry}>
|
||||
<AdminPageHeader
|
||||
title="配置与发布"
|
||||
description="编辑内容不会立即影响小程序;确认后统一发布当前品牌。"
|
||||
/>
|
||||
<Tabs
|
||||
activeKey={activeTab}
|
||||
onChange={setActiveTab}
|
||||
items={[
|
||||
{ key: "content", label: "内容发布", children: contentTab },
|
||||
{ key: "miniapp", label: "小程序发布", children: miniAppTab },
|
||||
]}
|
||||
/>
|
||||
{activeTab === "content" && (
|
||||
<Space direction="vertical" size={24} style={{ width: "100%" }}>
|
||||
<section>
|
||||
<Typography.Title level={4}>1. 选择表达方式</Typography.Title>
|
||||
@@ -305,9 +325,12 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
)}
|
||||
<MutationError error={importSample.error} />
|
||||
</section>
|
||||
|
||||
</Space>
|
||||
)}
|
||||
{activeTab === "miniapp" && (
|
||||
<Space direction="vertical" size={24} style={{ width: "100%" }}>
|
||||
<section>
|
||||
<Typography.Title level={4}>2. 核对草稿内容</Typography.Title>
|
||||
<Typography.Title level={4}>1. 核对草稿内容</Typography.Title>
|
||||
<Typography.Paragraph type="secondary">
|
||||
此处核对的是待发布内容,不是小程序视觉预览。
|
||||
</Typography.Paragraph>
|
||||
@@ -331,7 +354,11 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
</Space>
|
||||
</Space>
|
||||
</section>
|
||||
</Space>
|
||||
)}
|
||||
|
||||
{activeTab === "content" && (
|
||||
<Space direction="vertical" size={24} style={{ width: "100%" }}>
|
||||
<section>
|
||||
<Typography.Title level={4}>3. 检查并发布</Typography.Title>
|
||||
<Space wrap style={{ marginBottom: 12 }}>
|
||||
@@ -385,7 +412,9 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
{releases.data.map((item) => (
|
||||
<Space key={item.id} wrap>
|
||||
<Typography.Text>v{item.version}</Typography.Text>
|
||||
<Tag color={item.status === "published" ? "green" : "default"}>{item.status}</Tag>
|
||||
<Tag color={item.status === "published" ? "green" : "default"}>
|
||||
{item.status}
|
||||
</Tag>
|
||||
<Typography.Text type="secondary">
|
||||
{new Date(item.createdAt).toLocaleString("zh-CN")}
|
||||
</Typography.Text>
|
||||
@@ -501,7 +530,9 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
{task.status === "failed" && (
|
||||
<Button
|
||||
size="small"
|
||||
onClick={() => updateMiniAppStatus.mutate({ id: task.id, status: "built" })}
|
||||
onClick={() =>
|
||||
updateMiniAppStatus.mutate({ id: task.id, status: "built" })
|
||||
}
|
||||
>
|
||||
重置可上传
|
||||
</Button>
|
||||
@@ -515,6 +546,7 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
)}
|
||||
</section>
|
||||
</Space>
|
||||
)}
|
||||
<Modal
|
||||
title={confirmAction === "revoke" ? "确认撤回品牌" : "确认发布品牌"}
|
||||
open={confirmAction !== null}
|
||||
|
||||
Reference in new issue
Block a user