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