Skip to content

Let's use AI to Earn!

feat: 【发布弹框】精细化参数处理

gaoSir45ed683c5a3e
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index d06b9662..8c7a325b 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,14 +4,12 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
- <list default="true" id="90ed3383-49aa-4e32-95a2-9f070c0da49b" name="更改" comment="feat: 发布弹框:上传图片/视频完成、裁剪图片,描述写入,完成。">
+ <list default="true" id="90ed3383-49aa-4e32-95a2-9f070c0da49b" name="更改" comment="feat: 发布弹框整体设计">
+ <change afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/useImagePageStore.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/publish/imagePage/useImagePageStore.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/plats/KwaiParams.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/plats/KwaiParams.tsx" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/plats/plats.type.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/plats/plats.type.ts" 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" />
<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/publishDialog.module.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/publishDialog.module.scss" afterDir="false" />
@@ -27,6 +25,7 @@
<list>
<option value="TypeScript JSX File" />
<option value="tsx组件模板" />
+ <option value="TypeScript File" />
</list>
</option>
</component>
@@ -88,8 +87,8 @@
<recent name="E:\project-dev\web\艺咖\aitoearn-web\src\components\PublishDialog\plats" />
</key>
<key name="MoveFile.RECENT_KEYS">
- <recent name="E:\project-dev\web\艺咖\aitoearn-web\src\components\PublishDialog\compoents\PubParmasTextarea" />
<recent name="E:\project-dev\web\艺咖\aitoearn-web\src\components\PublishDialog\compoents\PlatParamsSetting" />
+ <recent name="E:\project-dev\web\艺咖\aitoearn-web\src\components\PublishDialog\compoents\PubParmasTextarea" />
<recent name="E:\project-dev\web\艺咖\aitoearn-web\src\assets\svgs\plat" />
</key>
</component>
@@ -109,7 +108,7 @@
<workItem from="1750763285511" duration="48000" />
<workItem from="1750763342070" duration="32000" />
<workItem from="1750763376065" duration="41000" />
- <workItem from="1750763426455" duration="30631000" />
+ <workItem from="1750763426455" duration="35733000" />
</task>
<task id="LOCAL-00001" summary="feat: 日历完善">
<option name="closed" value="true" />
@@ -191,7 +190,15 @@
<option name="project" value="LOCAL" />
<updated>1750851652194</updated>
</task>
- <option name="localTasksCounter" value="11" />
+ <task id="LOCAL-00011" summary="feat: 发布弹框整体设计">
+ <option name="closed" value="true" />
+ <created>1750859702156</created>
+ <option name="number" value="00011" />
+ <option name="presentableId" value="LOCAL-00011" />
+ <option name="project" value="LOCAL" />
+ <updated>1750859702156</updated>
+ </task>
+ <option name="localTasksCounter" value="12" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -221,6 +228,7 @@
<MESSAGE value="feat: 发布弹框开发中..." />
<MESSAGE value="feat: 发布逻辑初步实现" />
<MESSAGE value="feat: 发布弹框:上传图片/视频完成、裁剪图片,描述写入,完成。" />
- <option name="LAST_COMMIT_MESSAGE" value="feat: 发布弹框:上传图片/视频完成、裁剪图片,描述写入,完成。" />
+ <MESSAGE value="feat: 发布弹框整体设计" />
+ <option name="LAST_COMMIT_MESSAGE" value="feat: 发布弹框整体设计" />
</component>
</project>
\ No newline at end of file
diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.ts b/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.ts
new file mode 100644
index 00000000..d5aa6ae3
--- /dev/null
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.ts
@@ -0,0 +1,45 @@
+import {
+ PubItem,
+ usePublishDialog,
+} from "@/components/PublishDialog/usePublishDialog";
+import { useShallow } from "zustand/react/shallow";
+import { useCallback, useMemo } from "react";
+import {
+ IChangeParams,
+ IPubParmasTextareaProps,
+} from "@/components/PublishDialog/compoents/PubParmasTextarea";
+
+export default function usePlatParamsCommon(pubItem: PubItem) {
+ const { setOnePubParams } = usePublishDialog(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ step: state.step,
+ })),
+ );
+
+ const onChange = useCallback(
+ (values: IChangeParams) => {
+ setOnePubParams(
+ {
+ images: values.imgs,
+ des: values.value,
+ video: values.video,
+ },
+ pubItem.account.id,
+ );
+ },
+ [setOnePubParams],
+ );
+
+ const pubParmasTextareaCommonParams = useMemo(() => {
+ const props: IPubParmasTextareaProps = {
+ onChange,
+ desValue: pubItem.params.des,
+ imageFileListValue: pubItem.params.images,
+ videoFileValue: pubItem.params.video,
+ };
+ return props;
+ }, [pubItem]);
+
+ return { pubParmasTextareaCommonParams };
+}
diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx
index ab5a8020..e918900d 100644
--- a/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx
@@ -21,12 +21,6 @@ const PlatParamsSetting = memo(
{ pubItem }: IPlatParamsSettingProps,
ref: ForwardedRef<IPlatParamsSettingRef>,
) => {
- const { step } = usePublishDialog(
- useShallow((state) => ({
- step: state.step,
- })),
- );
-
const platConfig = useMemo(() => {
return AccountPlatInfoMap.get(pubItem.account.type)!;
}, [pubItem]);
diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams.tsx
index 81295012..30ffdbac 100644
--- a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams.tsx
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams.tsx
@@ -4,20 +4,16 @@ import {
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";
const BilibParams = memo(
forwardRef(
({ pubItem }: IPlatsParamsProps, ref: ForwardedRef<IPlatsParamsRef>) => {
+ const { pubParmasTextareaCommonParams } = usePlatParamsCommon(pubItem);
+
return (
<>
- <PubParmasTextarea
- desValue={pubItem.params.des}
- imageFileListValue={pubItem.params.images}
- videoFileValue={pubItem.params.video}
- onChange={(v) => {
- console.log(v);
- }}
- />
+ <PubParmasTextarea {...pubParmasTextareaCommonParams} />
</>
);
},
diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/KwaiParams.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/KwaiParams.tsx
index 8d4e635a..09d87265 100644
--- a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/KwaiParams.tsx
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/KwaiParams.tsx
@@ -4,20 +4,16 @@ import {
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";
const KwaiParams = memo(
forwardRef(
({ pubItem }: IPlatsParamsProps, ref: ForwardedRef<IPlatsParamsRef>) => {
+ const { pubParmasTextareaCommonParams } = usePlatParamsCommon(pubItem);
+
return (
<>
- <PubParmasTextarea
- desValue={pubItem.params.des}
- imageFileListValue={pubItem.params.images}
- videoFileValue={pubItem.params.video}
- onChange={(v) => {
- console.log(v);
- }}
- />
+ <PubParmasTextarea {...pubParmasTextareaCommonParams} />
</>
);
},
diff --git a/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx b/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
index af2ff0fa..b9a1bd52 100644
--- a/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
+++ b/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
@@ -29,12 +29,14 @@ const { Dragger } = Upload;
export interface IPubParmasTextareaRef {}
+export interface IChangeParams {
+ imgs?: IImgFile[];
+ video?: IVideoFile;
+ value: string;
+}
+
export interface IPubParmasTextareaProps {
- onChange: (values: {
- imgs?: IImgFile[];
- video?: IVideoFile;
- value: string;
- }) => void;
+ onChange?: (values: IChangeParams) => void;
rows?: number;
// 视频数量限制
videoMax?: number;
@@ -84,7 +86,7 @@ const PubParmasTextarea = memo(
video: videoFile,
value,
};
- onChange(values);
+ if (onChange) onChange(values);
}, [imageFileList, videoFile, value]);
useEffect(() => {
diff --git a/src/components/PublishDialog/index.tsx b/src/components/PublishDialog/index.tsx
index f994ac76..d048446b 100644
--- a/src/components/PublishDialog/index.tsx
+++ b/src/components/PublishDialog/index.tsx
@@ -104,6 +104,7 @@ const PublishDialog = memo(
open={open}
onCancel={closeDialog}
footer={null}
+ styles={{ wrapper: { textAlign: "center" } }}
>
<CSSTransition
in={openLeft}
@@ -153,6 +154,28 @@ const PublishDialog = memo(
} else {
newPubListChoosed.push(pubItem);
}
+ if (newPubListChoosed.length === 0 && step === 1) {
+ const isBack = newPubListChoosed.every(
+ (v) =>
+ !v.params.des &&
+ !v.params.video &&
+ !v.params.images?.length,
+ );
+ if (isBack) {
+ setStep(0);
+ }
+ }
+ if (step === 0) {
+ const isFront = newPubListChoosed.every(
+ (v) =>
+ v.params.des ||
+ v.params.video ||
+ v.params.images?.length,
+ );
+ if (isFront) {
+ setStep(1);
+ }
+ }
setPubListChoosed(newPubListChoosed);
}}
>
@@ -171,9 +194,6 @@ const PublishDialog = memo(
<>
{pubListChoosed.length == 1 && (
<PlatParamsSetting pubItem={pubListChoosed[0]} />
- // <div style={{ height: "500px" }}>
- // {accountChoosed[0].type}
- // </div>
)}
{pubListChoosed.length >= 2 && (
<PubParmasTextarea
@@ -183,15 +203,23 @@ const PublishDialog = memo(
imageFileListValue={commonPubParams.images}
onChange={(values) => {
setAccountAllParams({
- ...values,
+ des: values.value,
+ images: values.imgs,
+ video: values.video,
});
}}
/>
- // <div style={{ height: "500px" }}>通用参数</div>
)}
</>
) : (
- <>第二部</>
+ <>
+ {pubListChoosed.map((v) => {
+ console.log(v);
+ return (
+ <PlatParamsSetting pubItem={v} key={v.account.id} />
+ );
+ })}
+ </>
)}
{pubListChoosed.length === 0 && (
diff --git a/src/components/PublishDialog/publishDialog.module.scss b/src/components/PublishDialog/publishDialog.module.scss
index 0304df9e..8d7e006c 100644
--- a/src/components/PublishDialog/publishDialog.module.scss
+++ b/src/components/PublishDialog/publishDialog.module.scss
@@ -2,6 +2,8 @@ $assistantWidth: 300px;
.publishDialog {
width: auto !important;
+ margin: 0 auto;
+ display: inline-block;
:global {
.ant-modal-content {
padding: 0 !important;
diff --git a/src/components/PublishDialog/usePublishDialog.ts b/src/components/PublishDialog/usePublishDialog.ts
index 6f55861c..0658c6f2 100644
--- a/src/components/PublishDialog/usePublishDialog.ts
+++ b/src/components/PublishDialog/usePublishDialog.ts
@@ -25,6 +25,8 @@ export interface IPublishDialogStore {
commonPubParams: IPubParams;
// 当前步骤,0=所有账号没有参数,要设置参数。 1=所有账号有参数,详细设置参数
step: number;
+ // 第二部时需要,展开的账户参数
+ expandedPubItem?: PubItem;
}
const store: IPublishDialogStore = {
@@ -36,6 +38,7 @@ const store: IPublishDialogStore = {
video: undefined,
images: [],
},
+ expandedPubItem: undefined,
};
const getStore = () => {
@@ -102,6 +105,23 @@ export const usePublishDialog = create(
});
},
+ // 设置单个账号的参数
+ setOnePubParams(pubParmas: Partial<IPubParams>, accountId: string) {
+ const pubList = [...get().pubList];
+ const findedData = pubList.find((v) => v.account.id === accountId);
+ if (!findedData) return;
+
+ for (const key in pubParmas) {
+ if (pubParmas.hasOwnProperty(key)) {
+ findedData.params[key as "des"] = pubParmas[key as "des"]!;
+ }
+ }
+
+ set({
+ pubList,
+ });
+ },
+
setPubListChoosed(pubListChoosed: PubItem[]) {
set({
pubListChoosed,