Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat: 【发布弹框】参数校验完成
gaoSire24a50d8e010
diff --git a/.idea/workspace.xml b/.idea/workspace.xmlindex d4d1183c..dd069e27 100644--- a/.idea/workspace.xml+++ b/.idea/workspace.xml@@ -4,11 +4,15 @@<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/hooks/usePubParamsVerify.tsx" afterDir="false" />+ <change afterPath="$PROJECT_DIR$/src/components/PublishDialog/publishDialog.type.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/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx" 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/PubParmasTextarea/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx" afterDir="false" />+ <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PubParmasTextarea/pubCommonComps.module.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PubParmasTextarea/pubCommonComps.module.scss" 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" /></list>@@ -45,27 +49,27 @@<option name="hideEmptyMiddlePackages" value="true" /><option name="showLibraryContents" value="true" /></component>- <component name="PropertiesComponent">{- "keyToString": {- "ASKED_ADD_EXTERNAL_FILES": "true",- "ASKED_MARK_IGNORED_FILES_AS_EXCLUDED": "true",- "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",- "RunOnceActivity.ShowReadmeOnStart": "true",- "SHARE_PROJECT_CONFIGURATION_FILES": "true",- "git-widget-placeholder": "master",- "ignore.virus.scanning.warn.message": "true",- "last_opened_file_path": "E:/project-dev/web/艺咖/aitoearn-web/src/components/PublishDialog/compoents/PubParmasTextarea/components",- "node.js.detected.package.eslint": "true",- "node.js.detected.package.tslint": "true",- "node.js.selected.package.eslint": "(autodetect)",- "node.js.selected.package.tslint": "(autodetect)",- "nodejs_package_manager_path": "npm",- "run.code.analysis.last.selected.profile": "pProject Default",- "settings.editor.selected.configurable": "editor.reader.mode",- "ts.external.directory.path": "E:\\project-dev\\web\\艺咖\\aitoearn-web\\node_modules\\typescript\\lib",- "vue.rearranger.settings.migration": "true"+ <component name="PropertiesComponent"><![CDATA[{+ "keyToString": {+ "ASKED_ADD_EXTERNAL_FILES": "true",+ "ASKED_MARK_IGNORED_FILES_AS_EXCLUDED": "true",+ "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",+ "RunOnceActivity.ShowReadmeOnStart": "true",+ "SHARE_PROJECT_CONFIGURATION_FILES": "true",+ "git-widget-placeholder": "master",+ "ignore.virus.scanning.warn.message": "true",+ "last_opened_file_path": "E:/project-dev/web/艺咖/aitoearn-web/src/components/PublishDialog/hooks",+ "node.js.detected.package.eslint": "true",+ "node.js.detected.package.tslint": "true",+ "node.js.selected.package.eslint": "(autodetect)",+ "node.js.selected.package.tslint": "(autodetect)",+ "nodejs_package_manager_path": "npm",+ "run.code.analysis.last.selected.profile": "pProject Default",+ "settings.editor.selected.configurable": "editor.reader.mode",+ "ts.external.directory.path": "E:\\project-dev\\web\\艺咖\\aitoearn-web\\node_modules\\typescript\\lib",+ "vue.rearranger.settings.migration": "true"}-}</component>+}]]></component><component name="ReactBuddySettings"><option name="extensionsIgnore" value="true" /></component>@@ -80,6 +84,7 @@</component><component name="RecentsManager"><key name="CopyFile.RECENT_KEYS">+ <recent name="E:\project-dev\web\艺咖\aitoearn-web\src\components\PublishDialog\hooks" /><recent name="E:\project-dev\web\艺咖\aitoearn-web\src\components\PublishDialog\compoents\PubParmasTextarea\components" /><recent name="E:\project-dev\web\艺咖\aitoearn-web\src\components\PublishDialog\plats" /></key>@@ -106,7 +111,7 @@<workItem from="1750763342070" duration="32000" /><workItem from="1750763376065" duration="41000" /><workItem from="1750763426455" duration="38708000" />- <workItem from="1750932869295" duration="6465000" />+ <workItem from="1750932869295" duration="11532000" /></task><task id="LOCAL-00001" summary="feat: 日历完善"><option name="closed" value="true" />@@ -204,7 +209,15 @@<option name="project" value="LOCAL" /><updated>1750907902596</updated></task>- <option name="localTasksCounter" value="13" />+ <task id="LOCAL-00013" summary="feat: 【发布弹框】展开和隐藏、光标自动聚焦和自动到最后一位">+ <option name="closed" value="true" />+ <created>1750940945665</created>+ <option name="number" value="00013" />+ <option name="presentableId" value="LOCAL-00013" />+ <option name="project" value="LOCAL" />+ <updated>1750940945665</updated>+ </task>+ <option name="localTasksCounter" value="14" /><servers /></component><component name="TypeScriptGeneratedFilesManager">@@ -236,6 +249,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 filediff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.ts b/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsxsimilarity index 55%rename from src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsrename to src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsxindex d5aa6ae3..4cc48fd7 100644--- a/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.ts+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx@@ -1,22 +1,28 @@-import {- PubItem,- usePublishDialog,-} from "@/components/PublishDialog/usePublishDialog";+import { usePublishDialog } from "@/components/PublishDialog/usePublishDialog";import { useShallow } from "zustand/react/shallow";import { useCallback, useMemo } from "react";import {IChangeParams,IPubParmasTextareaProps,} from "@/components/PublishDialog/compoents/PubParmasTextarea";+import { PubItem } from "@/components/PublishDialog/publishDialog.type";+import { PubParamsVerifyInfo } from "@/components/PublishDialog/hooks/usePubParamsVerify";export default function usePlatParamsCommon(pubItem: PubItem) {- const { setOnePubParams } = usePublishDialog(+ const { setOnePubParams, errParamsMap, pubListChoosed } = usePublishDialog(useShallow((state) => ({setOnePubParams: state.setOnePubParams,step: state.step,+ errParamsMap: state.errParamsMap,+ pubListChoosed: state.pubListChoosed,})),);+ // 当前组件的错误消息+ const currErrItem = useMemo(() => {+ return errParamsMap?.get(pubItem.account.id);+ }, [errParamsMap, pubItem, pubListChoosed]);+const onChange = useCallback((values: IChangeParams) => {setOnePubParams(@@ -28,7 +34,7 @@ export default function usePlatParamsCommon(pubItem: PubItem) {pubItem.account.id,);},- [setOnePubParams],+ [pubItem, setOnePubParams],);const pubParmasTextareaCommonParams = useMemo(() => {@@ -37,9 +43,14 @@ export default function usePlatParamsCommon(pubItem: PubItem) {desValue: pubItem.params.des,imageFileListValue: pubItem.params.images,videoFileValue: pubItem.params.video,+ beforeExtend: (+ <>+ <PubParamsVerifyInfo errItem={currErrItem} />+ </>+ ),};return props;- }, [pubItem]);+ }, [currErrItem, onChange, pubItem]);return { pubParmasTextareaCommonParams };}diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsxindex 44198885..1b2c0536 100644--- a/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx@@ -1,13 +1,11 @@import { CSSProperties, ForwardedRef, forwardRef, memo, useMemo } from "react";import styles from "./platParamsSetting.module.scss";-import {- PubItem,- usePublishDialog,-} from "@/components/PublishDialog/usePublishDialog";+import { usePublishDialog } from "@/components/PublishDialog/usePublishDialog";import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";import BilibParams from "@/components/PublishDialog/compoents/PlatParamsSetting/plats/BilibParams";import KwaiParams from "@/components/PublishDialog/compoents/PlatParamsSetting/plats/KwaiParams";import { useShallow } from "zustand/react/shallow";+import { PubItem } from "@/components/PublishDialog/publishDialog.type";export interface IPlatParamsSettingRef {}@@ -55,23 +53,26 @@ const PlatParamsSetting = memo(styles.platParamsSetting,!isExpand ? styles.platParamsSetting_expand : "",].join(" ")}+ onClick={(e) => e.stopPropagation()}style={style}>- <div className="platParamsSetting-icon">- <img src={platConfig.icon} style={{ borderRadius: "50%" }} />- </div>- {isExpand ? (- PlatItemComp- ) : (- <div- className="platParamsSetting-des"- onClick={() => {- setExpandedPubItem(pubItem);- }}- >- {pubItem.params.des}+ <div className="platParamsSetting-wrapper">+ <div className="platParamsSetting-icon">+ <img src={platConfig.icon} style={{ borderRadius: "50%" }} /></div>- )}+ {isExpand ? (+ PlatItemComp+ ) : (+ <div+ className="platParamsSetting-des"+ onClick={() => {+ setExpandedPubItem(pubItem);+ }}+ >+ {pubItem.params.des}+ </div>+ )}+ </div></div>);},diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss b/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scssindex 1f427809..8370249b 100644--- a/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss@@ -1,8 +1,11 @@.platParamsSetting {- display: flex;:global {+ .platParamsSetting-wrapper {+ display: flex;+ width: 100%;+ }.platParamsSetting-icon {- margin-right: 10px;+ margin: 5px 10px 0 0;img {width: 25px;height: 25px;diff --git a/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx b/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsxindex b6ae4711..884e25a8 100644--- a/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx+++ b/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx@@ -46,6 +46,8 @@ export interface IPubParmasTextareaProps {imageMax?: number;// 扩展内容extend?: React.ReactNode;+ // 在前面的扩展元素+ beforeExtend?: React.ReactNode;style?: CSSProperties;imageFileListValue?: IImgFile[];videoFileValue?: IVideoFile;@@ -65,6 +67,7 @@ const PubParmasTextarea = memo(imageFileListValue = [],videoFileValue,desValue = "",+ beforeExtend}: IPubParmasTextareaProps,ref: ForwardedRef<IPubParmasTextareaRef>,) => {@@ -245,6 +248,7 @@ const PubParmasTextarea = memo(<div className={styles.pubParmasTextarea} style={style}><div className="pubParmasTextarea-input">+ {beforeExtend}<TextArearef={textareaRef}placeholder="开始写"diff --git a/src/components/PublishDialog/compoents/PubParmasTextarea/pubCommonComps.module.scss b/src/components/PublishDialog/compoents/PubParmasTextarea/pubCommonComps.module.scssindex 9ce38a35..8bfc55de 100644--- a/src/components/PublishDialog/compoents/PubParmasTextarea/pubCommonComps.module.scss+++ b/src/components/PublishDialog/compoents/PubParmasTextarea/pubCommonComps.module.scss@@ -1,7 +1,8 @@.pubParmasTextarea {border: 1px solid var(--grayColor4);border-radius: 6px;-+ flex: 1;+ text-align: left;:global {.pubParmasTextarea-input {padding: 15px;diff --git a/src/components/PublishDialog/hooks/usePubParamsVerify.tsx b/src/components/PublishDialog/hooks/usePubParamsVerify.tsxnew file mode 100644index 00000000..285fe392--- /dev/null+++ b/src/components/PublishDialog/hooks/usePubParamsVerify.tsx@@ -0,0 +1,92 @@+import { memo, useMemo } from "react";+import { parseTopicString } from "@/utils";+import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";+import { PubItem } from "@/components/PublishDialog/publishDialog.type";+import { Alert } from "antd";++export interface ErrPubParamsItem {+ // 参数错误提示消息+ parErrMsg?: string;+}++export type ErrPubParamsMapType = Map<string | number, ErrPubParamsItem>;++/**+ * 发布参数校验是否复合平台规范+ * @param data+ */+export default function usePubParamsVerify(data: PubItem[]) {+ // 用于判断描述中的话题是否符合规范+ const descTopicRegex = /#\S+#\S+/;++ // 错误参数,发布之前会检测错误参数,防止平台无法发布+ const errParamsMap = useMemo(() => {+ const errParamsMapTemp: ErrPubParamsMapType = new Map();+ for (const v of data) {+ const platInfo = AccountPlatInfoMap.get(v.account!.type)!;+ const { topics } = parseTopicString(v.params.des || "");+ const topicsAll = [...new Set(v.params.topics?.concat(topics))];+ const { topicMax } = platInfo.commonPubParamsConfig;++ (() => {+ // 图片或者视频校验,视频和图片必须要上传一个+ if (v.params.images?.length === 0 && !v.params.video) {+ return errParamsMapTemp.set(v.account.id, {+ parErrMsg: "请上传图片或视频",+ });+ }++ // 快手要求封面必须大于 400x400+ if (+ v.account?.type === PlatType.KWAI &&+ v.params.video?.cover &&+ (v.params.video.cover.width < 400 ||+ v.params.video.cover.height < 400)+ ) {+ return errParamsMapTemp.set(v.account.id, {+ parErrMsg: "封面最小尺寸400*400",+ });+ }+ // 话题校验+ if (topicsAll.length > topicMax) {+ return errParamsMapTemp.set(v.account.id, {+ parErrMsg: `${platInfo.name}话题最多不能超过${topicMax}个`,+ });+ }+ // 判断描述中的话题中间是否用空格分割,如:#话题1#话题2#话题3 这种格式错误+ if (descTopicRegex.test(v.params.des || "")) {+ return errParamsMapTemp.set(v.account.id, {+ parErrMsg: `描述中的话题必须使用空格分割,如:“#话题1 #话题2”`,+ });+ }+ })();+ }+ return errParamsMapTemp;+ }, [data]);++ return {+ errParamsMap,+ };+}++// 用于展示校验的结果+export const PubParamsVerifyInfo = memo(+ ({ errItem }: { errItem?: ErrPubParamsItem }) => {+ return (+ <>+ {errItem && (+ <Alert+ type="warning"+ showIcon+ message={<p style={{ textAlign: "left" }}>{errItem.parErrMsg}</p>}+ style={{+ marginBottom: "15px",+ padding: "6px 10px",+ fontSize: "12px",+ }}+ />+ )}+ </>+ );+ },+);diff --git a/src/components/PublishDialog/index.tsx b/src/components/PublishDialog/index.tsxindex f6e27664..5e7dd569 100644--- a/src/components/PublishDialog/index.tsx+++ b/src/components/PublishDialog/index.tsx@@ -8,7 +8,7 @@ import {useState,} from "react";import styles from "./publishDialog.module.scss";-import { Button, Modal } from "antd";+import { Button, message, Modal } from "antd";import { ArrowRightOutlined, ExclamationCircleFilled } from "@ant-design/icons";import PublishDialogAi from "@/components/PublishDialog/compoents/PublishDialogAi";import PublishDialogPreview from "@/components/PublishDialog/compoents/PublishDialogPreview";@@ -20,6 +20,7 @@ import { usePublishDialog } from "@/components/PublishDialog/usePublishDialog";import { useShallow } from "zustand/react/shallow";import PlatParamsSetting from "@/components/PublishDialog/compoents/PlatParamsSetting";import PubParmasTextarea from "@/components/PublishDialog/compoents/PubParmasTextarea";+import usePubParamsVerify from "@/components/PublishDialog/hooks/usePubParamsVerify";export interface IPublishDialogRef {}@@ -49,6 +50,9 @@ const PublishDialog = memo(step,setAccountAllParams,commonPubParams,+ setExpandedPubItem,+ expandedPubItem,+ setErrParamsMap,} = usePublishDialog(useShallow((state) => ({pubListChoosed: state.pubListChoosed,@@ -60,8 +64,12 @@ const PublishDialog = memo(step: state.step,setAccountAllParams: state.setAccountAllParams,commonPubParams: state.commonPubParams,+ setExpandedPubItem: state.setExpandedPubItem,+ expandedPubItem: state.expandedPubItem,+ setErrParamsMap: state.setErrParamsMap,})),);+ const { errParamsMap } = usePubParamsVerify(pubListChoosed);useEffect(() => {if (open) {@@ -94,7 +102,19 @@ const PublishDialog = memo(// 是否打开右侧预览const openRight = useMemo(() => {- return pubListChoosed.length !== 0;+ if (step === 0) {+ return pubListChoosed.length !== 0;+ } else {+ return expandedPubItem !== undefined;+ }+ }, [pubListChoosed, expandedPubItem, step]);++ useEffect(() => {+ setErrParamsMap(errParamsMap);+ }, [errParamsMap]);++ const pubClick = useCallback(() => {+ console.log("发布:", pubListChoosed);}, [pubListChoosed]);return (@@ -116,7 +136,12 @@ const PublishDialog = memo(<PublishDialogAi /></CSSTransition>- <div className="publishDialog-wrapper">+ <div+ className="publishDialog-wrapper"+ onClick={() => {+ setExpandedPubItem(undefined);+ }}+ ><div className="publishDialog-con"><div className="publishDialog-con-head"><span className="publishDialog-con-head-title">发布作品</span>@@ -144,7 +169,8 @@ const PublishDialog = memo(: "transparent",}}key={pubItem.account.id}- onClick={() => {+ onClick={(e) => {+ e.stopPropagation();const newPubListChoosed = [...pubListChoosed];// 查找当前账户是否已被选择const index = newPubListChoosed.findIndex(@@ -233,7 +259,10 @@ const PublishDialog = memo()}</div></div>- <div className="publishDialog-footer">+ <div+ className="publishDialog-footer"+ onClick={(e) => e.stopPropagation()}+ >time<div className="publishDialog-footer-btns">{step === 0 && pubListChoosed.length >= 2 ? (@@ -251,7 +280,25 @@ const PublishDialog = memo(<Button size="large" onClick={closeDialog}>取消发布</Button>- <Button size="large" type="primary">+ <Button+ size="large"+ type="primary"+ onClick={() => {+ for (const [key, errVideoItem] of errParamsMap) {+ if (errVideoItem) {+ const pubItem = pubListChoosed.find(+ (v) => v.account.id === key,+ )!;+ if (step === 1) {+ setExpandedPubItem(pubItem);+ }+ message.warning(errVideoItem.parErrMsg);+ return;+ }+ }+ pubClick();+ }}+ >计划发布</Button></>diff --git a/src/components/PublishDialog/publishDialog.type.ts b/src/components/PublishDialog/publishDialog.type.tsnew file mode 100644index 00000000..4b5cde5b--- /dev/null+++ b/src/components/PublishDialog/publishDialog.type.ts@@ -0,0 +1,19 @@+import { IImgFile } from "@/app/[lng]/publish/components/Choose/ImgChoose";+import { IVideoFile } from "@/app/[lng]/publish/components/Choose/VideoChoose";+import { SocialAccount } from "@/api/types/account.type";++export interface IPubParams {+ des: string;+ // 视频和图片不能同时存在,存在图片本次发布则为图文,存在视频则本次发布为视频发布 --------------+ // 图片+ images?: IImgFile[];+ // 视频+ video?: IVideoFile;+ // 话题+ topics?: string[];+}++export interface PubItem {+ account: SocialAccount;+ params: IPubParams;+}diff --git a/src/components/PublishDialog/usePublishDialog.ts b/src/components/PublishDialog/usePublishDialog.tsindex 3baf8d86..23785ae4 100644--- a/src/components/PublishDialog/usePublishDialog.ts+++ b/src/components/PublishDialog/usePublishDialog.ts@@ -2,19 +2,11 @@ import { create } from "zustand";import { combine } from "zustand/middleware";import lodash from "lodash";import { SocialAccount } from "@/api/types/account.type";-import { IImgFile } from "@/app/[lng]/publish/components/Choose/ImgChoose";-import { IVideoFile } from "@/app/[lng]/publish/components/Choose/VideoChoose";--interface IPubParams {- des: string;- images?: IImgFile[];- video?: IVideoFile;-}--export interface PubItem {- account: SocialAccount;- params: IPubParams;-}+import {+ IPubParams,+ PubItem,+} from "@/components/PublishDialog/publishDialog.type";+import { ErrPubParamsMapType } from "@/components/PublishDialog/hooks/usePubParamsVerify";export interface IPublishDialogStore {// 选择的发布列表@@ -27,6 +19,8 @@ export interface IPublishDialogStore {step: number;// 第二部时需要,展开的账户参数expandedPubItem?: PubItem;+ // 错误提示+ errParamsMap?: ErrPubParamsMapType;}const store: IPublishDialogStore = {@@ -39,6 +33,7 @@ const store: IPublishDialogStore = {images: [],},expandedPubItem: undefined,+ errParamsMap: undefined,};const getStore = () => {@@ -52,16 +47,32 @@ export const usePublishDialog = create(},(set, get, storeApi) => {const methods = {- // 清空所有数据- clear() {+ setPubListChoosed(pubListChoosed: PubItem[]) {set({- ...getStore(),+ pubListChoosed,+ });+ },+ setExpandedPubItem(expandedPubItem: PubItem | undefined) {+ set({+ expandedPubItem,+ });+ },+ setErrParamsMap(errParamsMap: ErrPubParamsMapType) {+ set({+ errParamsMap,});},setStep(step: number) {set({ step });},+ // 清空所有数据+ clear() {+ set({+ ...getStore(),+ });+ },+// 初始化发布参数pubParamsInit(): IPubParams {return lodash.cloneDeep(get().commonPubParams);@@ -108,6 +119,7 @@ export const usePublishDialog = create(// 设置单个账号的参数setOnePubParams(pubParmas: Partial<IPubParams>, accountId: string) {const pubList = [...get().pubList];+ let pubListChoosed = [...get().pubListChoosed];const findedData = pubList.find((v) => v.account.id === accountId);if (!findedData) return;@@ -117,21 +129,17 @@ export const usePublishDialog = create(}}- set({- pubList,+ pubListChoosed = pubListChoosed.map((v) => {+ const findData = pubList.find((k) => k.account.id === v.account.id);+ if (findData) return findData;+ return v;});- },- setPubListChoosed(pubListChoosed: PubItem[]) {set({+ pubList,pubListChoosed,});},- setExpandedPubItem(expandedPubItem: PubItem | undefined) {- set({- expandedPubItem,- });- },};return methods;},