Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
daoyian03bb15a3ca05
diff --git a/src/app/i18n/locales/en/publish.json b/src/app/i18n/locales/en/publish.jsonindex 10f702a2..59b581d4 100644--- a/src/app/i18n/locales/en/publish.json+++ b/src/app/i18n/locales/en/publish.json@@ -41,7 +41,9 @@"regionPlaceholder": "Select region","category": "Category","categoryPlaceholder": "Select category",- "categoryPlaceholderDisabled": "Select region first"+ "categoryPlaceholderDisabled": "Select region first",+ "board": "Board",+ "boardPlaceholder": "Select Board"},"upload": {"finishingUp": "Finishing up...",@@ -66,6 +68,7 @@"partitionRequired": "You must select a partition!","sourceRequired": "Source must be filled when reprinting!","pageRequired": "You must select a page!",+ "boardRequired": "You must select a Board!","coverSizeError": "Cover minimum size 400*400!"},"preview": {diff --git a/src/app/i18n/locales/zh-CN/publish.json b/src/app/i18n/locales/zh-CN/publish.jsonindex 040ef38b..eb063e8e 100644--- a/src/app/i18n/locales/zh-CN/publish.json+++ b/src/app/i18n/locales/zh-CN/publish.json@@ -41,7 +41,9 @@"regionPlaceholder": "请选择国区","category": "视频分类","categoryPlaceholder": "请选择视频分类",- "categoryPlaceholderDisabled": "请先选择国区"+ "categoryPlaceholderDisabled": "请先选择国区",+ "board": "Board",+ "boardPlaceholder": "请选择Board"},"upload": {"finishingUp": "正在完成...",@@ -66,6 +68,7 @@"partitionRequired": "您必须选择分区!","sourceRequired": "转载时必须填写转载来源!","pageRequired": "您必须选择页面!",+ "boardRequired": "您必须选择Board!","coverSizeError": "封面最小尺寸400*400!"},"preview": {diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsxindex 15efb41b..e2a66ea1 100644--- a/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx@@ -8,6 +8,7 @@ import FacebookParams from "@/components/PublishDialog/compoents/PlatParamsSettiimport 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 PinterestParams from "@/components/PublishDialog/compoents/PlatParamsSetting/plats/PinterestParams";import { useShallow } from "zustand/react/shallow";import { PubItem } from "@/components/PublishDialog/publishDialog.type";@@ -50,6 +51,8 @@ const PlatParamsSetting = memo(return <InstagramParams pubItem={pubItem} />;case PlatType.YouTube:return <YouTubeParams pubItem={pubItem} />;+ case PlatType.Pinterest:+ return <PinterestParams pubItem={pubItem} />;default:return <KwaiParams pubItem={pubItem} />;}diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/PinterestParams.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/PinterestParams.tsxnew file mode 100644index 00000000..403c009f--- /dev/null+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/PinterestParams.tsx@@ -0,0 +1,90 @@+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 CommonTitleInput from "@/components/PublishDialog/compoents/PlatParamsSetting/common/CommonTitleInput";+import { usePublishDialogData } from "@/components/PublishDialog/usePublishDialogData";+import { useShallow } from "zustand/react/shallow";+import styles from "../platParamsSetting.module.scss";+import { Select } from "antd";+import { useTransClient } from "@/app/i18n/client";++const PinterestParams = memo(+ forwardRef(+ ({ pubItem }: IPlatsParamsProps, ref: ForwardedRef<IPlatsParamsRef>) => {+ const { t } = useTransClient("publish");+ const { pubParmasTextareaCommonParams, setOnePubParams } =+ usePlatParamsCommon(pubItem);+ const { getPinterestBoards, pinterestBoards } =+ usePublishDialogData(+ useShallow((state) => ({+ getPinterestBoards: state.getPinterestBoards,+ pinterestBoards: state.pinterestBoards,+ })),+ );++ useEffect(() => {+ getPinterestBoards();+ }, [getPinterestBoards]);++ // 初始化Pinterest参数+ useEffect(() => {+ const option = pubItem.params.option;+ if (!option.pinterest) {+ option.pinterest = {};+ }+ setOnePubParams(+ {+ option,+ },+ pubItem.account.id,+ );+ }, [pubItem.account.id]);++ return (+ <>+ <PubParmasTextarea+ {...pubParmasTextareaCommonParams}+ extend={+ <>+ <CommonTitleInput pubItem={pubItem} />+ <div+ className={styles.commonTitleInput}+ style={{ marginTop: "10px" }}+ >+ <div className="platParamsSetting-label">{t("form.board")}</div>+ <Select+ style={{ width: "100%" }}+ options={pinterestBoards}+ value={pubItem.params.option.pinterest?.boardId}+ onChange={(value) => {+ const option = pubItem.params.option;+ option.pinterest!.boardId = value;+ setOnePubParams(+ {+ option,+ },+ pubItem.account.id,+ );+ }}+ showSearch={true}+ placeholder={t("form.boardPlaceholder")}+ fieldNames={{+ label: "name",+ value: "id",+ }}+ />+ </div>+ </>+ }+ />+ </>+ );+ },+ ),+);++export default PinterestParams;diff --git a/src/components/PublishDialog/hooks/usePubParamsVerify.tsx b/src/components/PublishDialog/hooks/usePubParamsVerify.tsxindex 4c495ffd..3474a1b6 100644--- a/src/components/PublishDialog/hooks/usePubParamsVerify.tsx+++ b/src/components/PublishDialog/hooks/usePubParamsVerify.tsx@@ -186,6 +186,14 @@ export default function usePubParamsVerify(data: PubItem[]) {break;}}++ // Pinterest的强制校验+ if (v.account.type === PlatType.Pinterest) {+ // 强制需要选择Board+ if (!v.params.option.pinterest?.boardId) {+ return setErrorMsg(t("validation.boardRequired"));+ }+ }})();}return errParamsMapTemp;diff --git a/src/components/PublishDialog/publishDialog.type.ts b/src/components/PublishDialog/publishDialog.type.tsindex 5397a62e..05bad13b 100644--- a/src/components/PublishDialog/publishDialog.type.ts+++ b/src/components/PublishDialog/publishDialog.type.ts@@ -67,6 +67,10 @@ export interface IPlatOption {// 视频分类IDcategoryId?: string;};+ pinterest?: {+ // Board ID,由获取Pinterest Board信息接口得到+ boardId?: string;+ };}// 发布参数diff --git a/src/components/PublishDialog/usePublishDialogData.ts b/src/components/PublishDialog/usePublishDialogData.tsindex 177e4137..74ba29c7 100644--- a/src/components/PublishDialog/usePublishDialogData.ts+++ b/src/components/PublishDialog/usePublishDialogData.ts@@ -5,6 +5,7 @@ import { BiblPartItem, YouTubeCategoryItem } from "@/components/PublishDialog/puimport { apiGetBilibiliPartitions } from "@/api/plat/bilibili";import { apiGetFacebookPages, FacebookPageItem } from "@/api/plat/facebook";import { apiGetYouTubeCategories, apiGetYouTubeRegions } from "@/api/plat/youtube";+import { getPinterestBoardListApi } from "@/api/pinterest";import { useAccountStore } from "@/store/account";import { PlatType } from "@/app/config/platConfig";@@ -17,6 +18,12 @@ export interface IPublishDialogDataStore {youTubeCategories: YouTubeCategoryItem[];// YouTube国区列表youTubeRegions: string[];+ // Pinterest Board列表+ pinterestBoards: Array<{+ id: string;+ name: string;+ description?: string;+ }>;}const store: IPublishDialogDataStore = {@@ -24,6 +31,7 @@ const store: IPublishDialogDataStore = {facebookPages: [],youTubeCategories: [],youTubeRegions: [],+ pinterestBoards: [],};const getStore = () => {@@ -112,6 +120,24 @@ export const usePublishDialogData = create(});return res?.data;},+ // 获取Pinterest Board列表+ async getPinterestBoards() {+ if (get().pinterestBoards.length !== 0) return;+ const pinterestAccount = useAccountStore+ .getState()+ .accountList.find((v) => v.type === PlatType.Pinterest);++ if (!pinterestAccount) {+ console.warn('没有找到Pinterest账户');+ return;+ }++ const res:any = await getPinterestBoardListApi({ page: 1, size: 100 }, pinterestAccount.account);+ set({+ pinterestBoards: res?.data?.list || [],+ });+ return res?.data?.list;+ },};return methods;