Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat(发布弹框): 发布弹框对不支持上传 图片/视频 的平台做了限制
gaoSirfc83703ccb8f
diff --git a/.idea/workspace.xml b/.idea/workspace.xmlindex 49e55d5e..56364b7c 100644--- a/.idea/workspace.xml+++ b/.idea/workspace.xml@@ -4,17 +4,10 @@<option name="autoReloadType" value="SELECTIVE" /></component><component name="ChangeListManager">- <list default="true" id="8ce961ad-7c9e-494c-bc53-9ecde4358af8" name="更改" comment="feat(日历):日历在同一个单元格发布记录太多会自动隐藏,并且显示按钮让用户点击查看更多">- <change afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/AllPlatIcon.tsx" afterDir="false" />+ <list default="true" id="8ce961ad-7c9e-494c-bc53-9ecde4358af8" name="更改" comment="feat(发布弹框): 添加选择账户一系列逻辑: 1. 选择账户时,开启发布弹框会默认选择,右侧选择的账户。 2. 添加日历header选择用户展示的样式。"><change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />- <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/accountCore.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/accountCore.tsx" afterDir="false" />- <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx" afterDir="false" />- <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.module.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.module.scss" afterDir="false" />- <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/index.tsx" afterDir="false" />- <change beforePath="$PROJECT_DIR$/src/components/AvatarPlat/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/AvatarPlat/index.tsx" afterDir="false" />- <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/index.tsx" afterDir="false" />- <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/usePublishDialog.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/usePublishDialog.ts" afterDir="false" />- <change beforePath="$PROJECT_DIR$/src/store/account.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/store/account.ts" afterDir="false" />+ <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx" afterDir="false" />+ <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx" afterDir="false" /></list><option name="SHOW_DIALOG" value="false" /><option name="HIGHLIGHT_CONFLICTS" value="true" />@@ -100,7 +93,7 @@<workItem from="1752118620733" duration="566000" /><workItem from="1752130881346" duration="11774000" /><workItem from="1752200550278" duration="253000" />- <workItem from="1752200816463" duration="15533000" />+ <workItem from="1752200816463" duration="16253000" /></task><task id="LOCAL-00001" summary="feat(CalendarTiming): 优化发布记录列表展示 - 调整日历记录项的样式和布局 - 优化 RecordCore组件,添加平台图标和时间显示 - 修改 CalendarTimingItem 组件,移除不必要的 Fragment -调整 index.tsx 中的日期格式化逻辑"><option name="closed" value="true" />@@ -214,7 +207,15 @@<option name="project" value="LOCAL" /><updated>1752236562804</updated></task>- <option name="localTasksCounter" value="15" />+ <task id="LOCAL-00015" summary="feat(发布弹框): 添加选择账户一系列逻辑: 1. 选择账户时,开启发布弹框会默认选择,右侧选择的账户。 2. 添加日历header选择用户展示的样式。">+ <option name="closed" value="true" />+ <created>1752239323126</created>+ <option name="number" value="00015" />+ <option name="presentableId" value="LOCAL-00015" />+ <option name="project" value="LOCAL" />+ <updated>1752239323126</updated>+ </task>+ <option name="localTasksCounter" value="16" /><servers /></component><component name="TypeScriptGeneratedFilesManager">@@ -248,6 +249,7 @@<MESSAGE value="fix(发布): 默认返回快手参数" /><MESSAGE value="feat(日历):细节调整,1. 发布记录查看,添加图片、视频分别处理。 2. 发布API添加图片处理" /><MESSAGE value="feat(日历):日历在同一个单元格发布记录太多会自动隐藏,并且显示按钮让用户点击查看更多" />- <option name="LAST_COMMIT_MESSAGE" value="feat(日历):日历在同一个单元格发布记录太多会自动隐藏,并且显示按钮让用户点击查看更多" />+ <MESSAGE value="feat(发布弹框): 添加选择账户一系列逻辑: 1. 选择账户时,开启发布弹框会默认选择,右侧选择的账户。 2. 添加日历header选择用户展示的样式。" />+ <option name="LAST_COMMIT_MESSAGE" value="feat(发布弹框): 添加选择账户一系列逻辑: 1. 选择账户时,开启发布弹框会默认选择,右侧选择的账户。 2. 添加日历header选择用户展示的样式。" /></component></project>\ No newline at end of filediff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsxindex 4cc48fd7..002109f5 100644--- a/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx@@ -39,6 +39,7 @@ export default function usePlatParamsCommon(pubItem: PubItem) {const pubParmasTextareaCommonParams = useMemo(() => {const props: IPubParmasTextareaProps = {+ platType: pubItem.account.type,onChange,desValue: pubItem.params.des,imageFileListValue: pubItem.params.images,diff --git a/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx b/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsxindex c13171d0..19a17e1d 100644--- a/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx+++ b/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx@@ -23,6 +23,8 @@ import {import VideoCoverSeting from "@/components/PublishDialog/compoents/PubParmasTextarea/VideoCoverSeting";import PubParmasTextareaUpload from "@/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload";+import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";+import { PubType } from "@/app/config/publishConfig";const { TextArea } = Input;const { Dragger } = Upload;@@ -40,12 +42,12 @@ export interface IPubParmasTextareaProps {rows?: number;// 视频数量限制videoMax?: number;- // 图片数量限制- imageMax?: number;// 扩展内容extend?: React.ReactNode;// 在前面的扩展元素beforeExtend?: React.ReactNode;+ // 平台类型+ platType: PlatType;style?: CSSProperties;imageFileListValue?: IImgFile[];videoFileValue?: IVideoFile;@@ -60,12 +62,12 @@ const PubParmasTextarea = memo(onChange,rows = 12,videoMax = 1,- imageMax = 20,extend,imageFileListValue = [],videoFileValue,desValue = "",beforeExtend,+ platType,}: IPubParmasTextareaProps,ref: ForwardedRef<IPubParmasTextareaRef>,) => {@@ -114,14 +116,27 @@ const PubParmasTextarea = memo(setVideoFile(videoFileValue);}, [videoFileValue]);+ const platConfig = useMemo(() => {+ return AccountPlatInfoMap.get(platType)! || {};+ }, [platType]);+ const imageMax = useMemo(() => {+ return platConfig.commonPubParamsConfig.imgTextConfig?.imagesMax || 10;+ }, [platConfig]);+// 动态accept类型const uploadAccept = useMemo(() => {const hasImage = imageFileList.length !== 0;const hasVideo = !!videoFile;- if (hasImage && !hasVideo) return "image/*";- if (!hasImage && hasVideo) return "video/*";- return "image/*,video/*";- }, [imageFileList, videoFile]);+ if (hasImage && !hasVideo && platConfig.pubTypes.has(PubType.ImageText))+ return "image/*";+ if (!hasImage && hasVideo && platConfig.pubTypes.has(PubType.VIDEO))+ return "video/*";++ if (platConfig.pubTypes.has(PubType.ImageText)) return "image/*";+ if (platConfig.pubTypes.has(PubType.VIDEO)) return "video/*";++ return "video/*,image/*";+ }, [imageFileList, videoFile, platConfig]);// 是否可见Draggerconst canShowDragger = useMemo(() => {@@ -163,6 +178,15 @@ const PubParmasTextarea = memo(});};+ if (uploadHasImage && !platConfig.pubTypes.has(PubType.ImageText)) {+ messageOpen("该平台不支持上传图片");+ return false;+ }+ if (uploadHasVideo && !platConfig.pubTypes.has(PubType.VIDEO)) {+ messageOpen("该平台不支持上传视频");+ return false;+ }+// 已有图片,只能传图片if (hasImageInList && !hasVideoInList && uploadHasVideo) {messageOpen("已有图片,仅可继续上传图片,不能上传视频!");@@ -209,7 +233,7 @@ const PubParmasTextarea = memo(}return true;},- [imageFileList, videoMax, imageMax, videoFile],+ [imageFileList, videoMax, imageMax, videoFile, platConfig],);return (