Skip to content

Let's use AI to Earn!

dulicanshu

I5bijibne3ade57db6fec
diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx
index a62e55e7..15efb41b 100644
--- a/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx
@@ -7,6 +7,7 @@ import KwaiParams from "@/components/PublishDialog/compoents/PlatParamsSetting/p
import FacebookParams from "@/components/PublishDialog/compoents/PlatParamsSetting/plats/FacebookParams";
import InstagramParams from "@/components/PublishDialog/compoents/PlatParamsSetting/plats/InstagramParams";
import YouTubeParams from "@/components/PublishDialog/compoents/PlatParamsSetting/plats/YouTubeParams";
+import WxGzhParams from "@/components/PublishDialog/compoents/PlatParamsSetting/plats/WxGzhParams";
import { useShallow } from "zustand/react/shallow";
import { PubItem } from "@/components/PublishDialog/publishDialog.type";
@@ -41,6 +42,8 @@ const PlatParamsSetting = memo(
return <KwaiParams pubItem={pubItem} />;
case PlatType.BILIBILI:
return <BilibParams pubItem={pubItem} />;
+ case PlatType.WxGzh:
+ return <WxGzhParams pubItem={pubItem} />;
case PlatType.Facebook:
return <FacebookParams pubItem={pubItem} />;
case PlatType.Instagram:
diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/WxGzhParams.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/WxGzhParams.tsx
new file mode 100644
index 00000000..96ea8150
--- /dev/null
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/WxGzhParams.tsx
@@ -0,0 +1,52 @@
+import { ForwardedRef, forwardRef, memo, useEffect } from "react";
+import { IPlatsParamsProps, IPlatsParamsRef } from "@/components/PublishDialog/compoents/PlatParamsSetting/plats/plats.type";
+import PubParmasTextarea from "@/components/PublishDialog/compoents/PubParmasTextarea";
+import usePlatParamsCommon from "@/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon";
+import styles from "../platParamsSetting.module.scss";
+import { Input } from "antd";
+import { useTransClient } from "@/app/i18n/client";
+
+/**
+ * 微信公众号平台参数
+ * - 独立参数:title(与通用 title 区分,使用 option.wxGzh.title 保存)
+ */
+const WxGzhParams = memo(
+ forwardRef(({ pubItem }: IPlatsParamsProps, ref: ForwardedRef<IPlatsParamsRef>) => {
+ const { t } = useTransClient("publish");
+ const { pubParmasTextareaCommonParams, setOnePubParams } = usePlatParamsCommon(pubItem);
+
+ // 初始化 wxGzh 参数对象
+ // useEffect(() => {
+ // const option = pubItem.params.option;
+ // if (!option.wxGzh) {
+ // option.wxGzh = {};
+ // setOnePubParams({ option }, pubItem.account.id);
+ // }
+ // // eslint-disable-next-line react-hooks/exhaustive-deps
+ // }, [pubItem.account.id]);
+
+ return (
+ <>
+ <PubParmasTextarea
+ {...pubParmasTextareaCommonParams}
+ extend={<>
+ <div className={styles.commonTitleInput} style={{ marginTop: "10px" }}>
+ <div className="platParamsSetting-label">{t("form.title")}</div>
+ <Input
+ value={pubItem.params.title}
+ placeholder={t("form.titlePlaceholder")}
+ onChange={(e) => {
+ setOnePubParams({ title: e.target.value }, pubItem.account.id);
+ }}
+ />
+ </div>
+ </>}
+ />
+ </>
+ );
+ })
+);
+
+export default WxGzhParams;
+
+
diff --git a/src/components/PublishDialog/hooks/usePubParamsVerify.tsx b/src/components/PublishDialog/hooks/usePubParamsVerify.tsx
index 25e81279..4c495ffd 100644
--- a/src/components/PublishDialog/hooks/usePubParamsVerify.tsx
+++ b/src/components/PublishDialog/hooks/usePubParamsVerify.tsx
@@ -137,6 +137,14 @@ export default function usePubParamsVerify(data: PubItem[]) {
}
}
+ // 微信公众号的强制校验
+ if (v.account.type === PlatType.WxGzh) {
+ // 强制需要标题
+ if (!v.params.title) {
+ return setErrorMsg(t("validation.titleRequired"));
+ }
+ }
+
// facebook的强制校验
if (v.account.type === PlatType.Facebook) {
switch (v.params.option.facebook?.content_category) {
diff --git a/src/components/PublishDialog/publishDialog.type.ts b/src/components/PublishDialog/publishDialog.type.ts
index 147933c8..5397a62e 100644
--- a/src/components/PublishDialog/publishDialog.type.ts
+++ b/src/components/PublishDialog/publishDialog.type.ts
@@ -45,6 +45,10 @@ export interface IPlatOption {
// 如果copyright为转载,则此字段表示转载来源
source?: string;
};
+ wxGzh?: {
+ // 平台独立标题,仅用于微信公众号
+ title?: string;
+ };
facebook?: {
// 页面ID,由获取Facebook页面信息接口得到
page_id?: string;