Skip to content

Let's use AI to Earn!

feat: 图文发布参数校验添加

gaoSir2d2c78e0b671
diff --git a/electron/db/models/pubRecord.ts b/electron/db/models/pubRecord.ts
index 930af1b3..8503dd58 100644
--- a/electron/db/models/pubRecord.ts
+++ b/electron/db/models/pubRecord.ts
@@ -48,12 +48,16 @@ export class PubRecordModel extends TempModel {
timingTime?: Date;
// 封面路径
- @Column({ type: 'varchar', nullable: false, comment: '封面路径,展示给前台用' })
+ @Column({
+ type: 'varchar',
+ nullable: false,
+ comment: '封面路径,展示给前台用',
+ })
coverPath!: string;
// 通用封面路径
- @Column({ type: 'varchar', nullable: false, comment: '通用封面路径' })
- commonCoverPath!: string;
+ @Column({ type: 'varchar', nullable: true, comment: '通用封面路径' })
+ commonCoverPath?: string;
// 发布时间
@Column({ type: 'datetime', nullable: false, comment: '发布时间' })
diff --git a/electron/main/publish/imgText/controller.ts b/electron/main/publish/imgText/controller.ts
index bca7840f..3eb94003 100644
--- a/electron/main/publish/imgText/controller.ts
+++ b/electron/main/publish/imgText/controller.ts
@@ -1,14 +1,16 @@
-import { Controller, Et, Inject } from '../../core/decorators';
+import { Controller, Et, Icp, Inject } from '../../core/decorators';
import { VideoPubService } from '../video/service';
import { PublishService } from '../service';
import { AccountService } from '../../account/service';
import { ImgTextPubService } from './service';
import { ImgTextModel } from '../../../db/models/imgText';
+import { PubStatus } from '../../../db/models/pubRecord';
+import platController from '../../plat';
@Controller()
export class ImgTextPubController {
@Inject(VideoPubService)
- private readonly imgTextRepository!: ImgTextPubService;
+ private readonly imgTextService!: ImgTextPubService;
@Inject(PublishService)
private readonly publishService!: PublishService;
@@ -19,6 +21,46 @@ export class ImgTextPubController {
// 更新视频发布数据
@Et('ET_PUBLISH_UPDATE_IMG_TEXT_PUL')
async updateImgTextPul(imgTextModel: ImgTextModel): Promise<any> {
- await this.imgTextRepository.updateImgTextPul(imgTextModel);
+ await this.imgTextService.updateImgTextPul(imgTextModel);
+ }
+
+ // 发布图文
+ @Icp('ICP_PUBLISH_IMG_TEXT')
+ async pubImgText(event: Electron.IpcMainInvokeEvent, pubRecordId: number) {
+ const pubRecordInfo =
+ await this.publishService.getPubRecordInfo(pubRecordId);
+
+ if (pubRecordInfo?.status === PubStatus.RELEASED) {
+ console.error('发布记录已发布');
+ }
+
+ // 获取图文发布记录列表
+ const imgTextModels =
+ await this.imgTextService.getImgTextPulListByPubRecordId(pubRecordId);
+ // 获取用到的账户信息
+ const accountList = await this.accountService.getAccountsByIds(
+ imgTextModels.map((v) => v.accountId),
+ );
+
+ // 发布
+ const pubRes = await platController.imgTextPublish(
+ imgTextModels,
+ accountList,
+ );
+
+ let successCount = 0;
+ pubRes.map((v) => {
+ if (v.code === 1) successCount++;
+ });
+ // 更改记录状态
+ await this.publishService.updatePubRecordStatus(
+ pubRecordId,
+ successCount === 0
+ ? PubStatus.FAIL
+ : successCount === pubRes.length
+ ? PubStatus.RELEASED
+ : PubStatus.PartSuccess,
+ );
+ return pubRes;
}
}
diff --git a/electron/main/publish/imgText/service.ts b/electron/main/publish/imgText/service.ts
index c3f89639..c4503a9a 100644
--- a/electron/main/publish/imgText/service.ts
+++ b/electron/main/publish/imgText/service.ts
@@ -12,7 +12,15 @@ export class ImgTextPubService {
this.imgTextRepository = AppDataSource.getRepository(VideoModel);
}
+ // 更新数据
async updateImgTextPul(imgTextModel: ImgTextModel) {
return await this.imgTextRepository.update(imgTextModel.id!, imgTextModel);
}
+
+ // 根据发布记录ID获取图文记录列表
+ async getImgTextPulListByPubRecordId(pubRecordId: number) {
+ return await this.imgTextRepository.find({
+ where: { pubRecordId },
+ });
+ }
}
diff --git a/electron/main/publish/service.ts b/electron/main/publish/service.ts
index fe81ad77..cbaf9ab2 100644
--- a/electron/main/publish/service.ts
+++ b/electron/main/publish/service.ts
@@ -10,6 +10,7 @@ import { FindManyOptions, FindOptionsWhere, Repository } from 'typeorm';
import { CorrectQuery, backPageData } from '../../global/table';
import { PubRecordModel, PubStatus } from '../../db/models/pubRecord';
import { EtEvent } from '../../global/event';
+import { getUserInfo } from '../user/comment';
@Injectable()
export class PublishService {
private pubRecordRepository: Repository<PubRecordModel>;
@@ -41,7 +42,14 @@ export class PublishService {
// 获取发布记录信息
async getPubRecordInfo(id: number) {
- return await this.pubRecordRepository.findOne({ where: { id } });
+ const userInfo = getUserInfo();
+ const pubRecordInfo = await this.pubRecordRepository.findOne({
+ where: { id },
+ });
+ if (!pubRecordInfo || pubRecordInfo.userId !== userInfo.id) {
+ console.error('发布记录不存在');
+ }
+ return pubRecordInfo;
}
// 更新发布记录的状态
diff --git a/electron/main/publish/video/controller.ts b/electron/main/publish/video/controller.ts
index bf056b1f..22c941f8 100644
--- a/electron/main/publish/video/controller.ts
+++ b/electron/main/publish/video/controller.ts
@@ -18,6 +18,7 @@ import { PublishService } from '../service';
import platController from '../../plat';
import { AccountService } from '../../account/service';
import { AccountType } from '../../../../commont/AccountEnum';
+import { PublishVideoResult } from '../../plat/module';
@Controller()
export class VideoPubController {
@@ -57,23 +58,12 @@ export class VideoPubController {
async pubVideo(
event: Electron.IpcMainInvokeEvent,
pubRecordId: number,
- ): Promise<any> {
- const res = {
- code: 0,
- msg: '发布失败',
- };
-
- const userInfo = getUserInfo();
+ ): Promise<PublishVideoResult[]> {
const pubRecordInfo =
await this.publishService.getPubRecordInfo(pubRecordId);
- if (!pubRecordInfo || pubRecordInfo.userId !== userInfo.id) {
- res.msg = '发布记录不存在';
- return res;
- }
- if (pubRecordInfo.status === PubStatus.RELEASED) {
- res.msg = '发布记录已发布';
- return res;
+ if (pubRecordInfo?.status === PubStatus.RELEASED) {
+ console.error('发布记录已发布');
}
// 获取视频发布记录列表
diff --git a/src/icp/publish.ts b/src/icp/publish.ts
index 513a5ebd..01662e90 100644
--- a/src/icp/publish.ts
+++ b/src/icp/publish.ts
@@ -30,6 +30,7 @@ import {
import { IRequestNetResult } from '../../electron/plat/requestNet';
import { WeChatVideoApiResponse } from '../../electron/plat/shipinhao/wxShp.type';
import { parseTopicString } from '../utils';
+import { PublishVideoResult } from '../../electron/main/plat/module';
// 创建发布记录
export async function icpCreatePubRecord(pubRecord: Partial<PubRecordModel>) {
@@ -68,12 +69,19 @@ export async function icpGetPubVideoRecord(pubRecordId: number) {
// 发布视频
export async function icpPubVideo(pubRecordId: number) {
- const res: {
- // 0=失败 1=成功
- code: number;
- msg: string;
- dataId: string;
- }[] = await window.ipcRenderer.invoke('ICP_PUB_VIDEO', pubRecordId);
+ const res: PublishVideoResult[] = await window.ipcRenderer.invoke(
+ 'ICP_PUB_VIDEO',
+ pubRecordId,
+ );
+ return res;
+}
+
+// 发布图文
+export async function icpPubImgText(pubRecordId: number) {
+ const res: PublishVideoResult[] = await window.ipcRenderer.invoke(
+ 'ICP_PUBLISH_IMG_TEXT',
+ pubRecordId,
+ );
return res;
}
diff --git a/src/views/publish/children/imagePage/components/ImageLeftSetting/ImgTextImagesView.tsx b/src/views/publish/children/imagePage/components/ImageLeftSetting/ImgTextImagesView.tsx
index 88ad72b1..0c0c0093 100644
--- a/src/views/publish/children/imagePage/components/ImageLeftSetting/ImgTextImagesView.tsx
+++ b/src/views/publish/children/imagePage/components/ImageLeftSetting/ImgTextImagesView.tsx
@@ -72,7 +72,6 @@ const ImgTextImagesView = memo(
<div
className="imgTextImagesView_content-item-close"
onClick={() => {
- console.log(i);
const newImages = [...images];
newImages.splice(i, 1);
setImages(newImages);
diff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx
index d781bb9e..9305bc93 100644
--- a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx
+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx
@@ -5,8 +5,10 @@ import styles from './imageParamsSet.module.scss';
import { AccountType } from '../../../../../../../../commont/AccountEnum';
import { IImageAccountItem } from '../../../imagePage.type';
import { AccountPlatInfoMap } from '../../../../../../account/comment';
-import { CloseOutlined } from '@ant-design/icons';
+import { CloseOutlined, InfoOutlined } from '@ant-design/icons';
import ParamsSettingDetails from './ParamsSettingDetails';
+import { ErrPubParamsItem } from '../../../../../hooks/usePubParamsVerify';
+import { Tooltip } from 'antd';
export interface IImageParamsSetRef {}
@@ -28,6 +30,7 @@ const ImageParamsSet = memo(
setPlatActiveAccountMap,
platActiveAccountMap,
delAccountByPalt,
+ errParamsMap,
} = useImagePageStore(
useShallow((state) => ({
imageAccounts: state.imageAccounts,
@@ -36,6 +39,7 @@ const ImageParamsSet = memo(
setPlatActiveAccountMap: state.setPlatActiveAccountMap,
platActiveAccountMap: state.platActiveAccountMap,
delAccountByPalt: state.delAccountByPalt,
+ errParamsMap: state.errParamsMap,
})),
);
@@ -98,6 +102,18 @@ const ImageParamsSet = memo(
setPlatActiveAccountMap(newPlatActiveAccountMap);
}, [platAccountImagesMap]);
+ // key=平台,val==错误消息
+ const errParamsPlatMap = useMemo(() => {
+ if (!errParamsMap) return undefined;
+ const errParamsMapTemp = new Map<AccountType, ErrPubParamsItem>();
+ for (const [_, errParamsItem] of errParamsMap) {
+ if (!errParamsMapTemp.has(errParamsItem.plat!)) {
+ errParamsMapTemp.set(errParamsItem.plat!, errParamsItem);
+ }
+ }
+ return errParamsMapTemp;
+ }, [errParamsMap]);
+
return (
<div className={styles.imageParamsSet}>
<div className="imageParamsSet_plats">
@@ -126,6 +142,15 @@ const ImageParamsSet = memo(
>
<CloseOutlined />
</div>
+ {errParamsPlatMap?.get(accountType) && (
+ <Tooltip
+ title={errParamsPlatMap?.get(accountType)?.parErrMsg}
+ >
+ <div className="imageParamsSet_plats-item-err">
+ <InfoOutlined />
+ </div>
+ </Tooltip>
+ )}
</div>
<span>{platInfo.name}</span>
</div>
diff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx
index 64c756b3..353abdea 100644
--- a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx
+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx
@@ -1,13 +1,17 @@
import { ForwardedRef, forwardRef, memo, useMemo } from 'react';
import styles from './imageParamsSet.module.scss';
import { CloseOutlined, PlusOutlined } from '@ant-design/icons';
-import { Avatar, Tooltip } from 'antd';
-import { AccountType } from '../../../../../../../../commont/AccountEnum';
+import { Alert, Avatar, Tooltip } from 'antd';
+import {
+ AccountStatus,
+ AccountType,
+} from '../../../../../../../../commont/AccountEnum';
import ImageParamsSet_Douyin from './children/ImageParamsSet_Douyin';
import ImageParamsSet_XHS from './children/ImageParamsSet_XHS';
import { IImageAccountItem } from '../../../imagePage.type';
import { useImagePageStore } from '../../../useImagePageStore';
import { useShallow } from 'zustand/react/shallow';
+import { PubParamsErrStatusEnum } from '../../../../../hooks/usePubParamsVerify';
export interface IParamsSettingDetailsRef {}
@@ -28,12 +32,16 @@ const ParamsSettingDetails = memo(
platActiveAccountMap,
delAccountById,
setPlatActiveAccountMap,
+ accountRestart,
+ errParamsMap,
} = useImagePageStore(
useShallow((state) => ({
activePlat: state.activePlat,
platActiveAccountMap: state.platActiveAccountMap,
setPlatActiveAccountMap: state.setPlatActiveAccountMap,
delAccountById: state.delAccountById,
+ accountRestart: state.accountRestart,
+ errParamsMap: state.errParamsMap,
})),
);
@@ -42,6 +50,11 @@ const ParamsSettingDetails = memo(
return platActiveAccountMap.get(activePlat);
}, [platActiveAccountMap, activePlat]);
+ const currErrParams = useMemo(() => {
+ if (!currAccountItem?.account.id || !errParamsMap) return undefined;
+ return errParamsMap.get(+currAccountItem.account.id);
+ }, [errParamsMap, currAccountItem]);
+
return (
<div className={styles.paramsSettingItem}>
<h1 style={{ marginTop: '10px' }}>
@@ -88,16 +101,61 @@ const ParamsSettingDetails = memo(
</div>
<Avatar src={v.account.avatar} size="large" />
</div>
- <Tooltip title={v.account.nickname}>
- <p className="paramsSettingItem-users-item-name">
- {v.account.nickname}
- </p>
- </Tooltip>
+ {v.account.status === AccountStatus.DISABLE ? (
+ <Tooltip
+ title={
+ <>
+ 账号已失效,请
+ <a
+ onClick={() => {
+ accountRestart(v.account.type);
+ }}
+ >
+ 重新登录
+ </a>
+ 。
+ </>
+ }
+ >
+ <Alert message="登录失效" type="error" />
+ </Tooltip>
+ ) : (
+ <Tooltip title={v.account.nickname}>
+ <p className="paramsSettingItem-users-item-name">
+ {v.account.nickname}
+ </p>
+ </Tooltip>
+ )}
</div>
);
})}
</div>
+ {currErrParams && (
+ <Alert
+ type="error"
+ showIcon
+ message={
+ currErrParams.errType === PubParamsErrStatusEnum.LOGIN ? (
+ <>
+ 登录失效,请
+ <a
+ style={{ fontSize: '13px' }}
+ onClick={() => {
+ accountRestart(activePlat!);
+ }}
+ >
+ 重新登录
+ </a>
+ </>
+ ) : (
+ currErrParams.parErrMsg
+ )
+ }
+ style={{ marginTop: '20px' }}
+ />
+ )}
+
{(() => {
switch (activePlat) {
case AccountType.Douyin:
diff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/components/imageParamsSet.module.scss b/src/views/publish/children/imagePage/components/ImageRightSetting/components/imageParamsSet.module.scss
index 929189a1..ecda7d85 100644
--- a/src/views/publish/children/imagePage/components/ImageRightSetting/components/imageParamsSet.module.scss
+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/components/imageParamsSet.module.scss
@@ -21,6 +21,18 @@
display: flex !important;
}
}
+ &-err {
+ position: absolute;
+ bottom: 2px;
+ right: -5px;
+ color: #fff;
+ background: red;
+ width: 12px;
+ height: 12px;
+ line-height: 10px;
+ text-align: center;
+ border-radius: 50%;
+ }
&-img {
position: relative;
img {
@@ -85,6 +97,14 @@
flex-direction: column;
align-items: center;
margin-right: 5px;
+ .ant-alert {
+ padding: 2px 4px;
+ font-size: var(--fs-xs);
+ font-weight: 900;
+ margin-top: 4px;
+ border-radius: 6px;
+ color: var(--errerColor);
+ }
&--active {
.paramsSettingItem-users-item-img {
border-color: var(--colorPrimary6);
@@ -109,7 +129,7 @@
}
&-name {
width: 100%;
- margin-top: 4px;
+ margin-top: 6px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
diff --git a/src/views/publish/children/imagePage/page.tsx b/src/views/publish/children/imagePage/page.tsx
index 782d67d0..fee8033f 100644
--- a/src/views/publish/children/imagePage/page.tsx
+++ b/src/views/publish/children/imagePage/page.tsx
@@ -3,21 +3,45 @@ import { useShallow } from 'zustand/react/shallow';
import { useImagePageStore } from './useImagePageStore';
import ImageLeftSetting from './components/ImageLeftSetting/ImageLeftSetting';
import ImageRightSetting from './components/ImageRightSetting/ImageRightSetting';
-import { Button, Popconfirm } from 'antd';
+import { Button, message, Popconfirm } from 'antd';
import { useEffect } from 'react';
+import usePubParamsVerify from '../../hooks/usePubParamsVerify';
export default function Page() {
- const { clear, images, imageAccounts } = useImagePageStore(
+ const {
+ clear,
+ images,
+ imageAccounts,
+ setActivePlat,
+ setPlatActiveAccountMap,
+ setErrParamsMap,
+ } = useImagePageStore(
useShallow((state) => ({
clear: state.clear,
images: state.images,
imageAccounts: state.imageAccounts,
+ setPlatActiveAccountMap: state.setPlatActiveAccountMap,
+ setActivePlat: state.setActivePlat,
+ setErrParamsMap: state.setErrParamsMap,
})),
);
+ const { errParamsMap } = usePubParamsVerify(
+ imageAccounts.map((v) => {
+ return {
+ id: v.account.id,
+ account: v.account,
+ pubParams: v.pubParams,
+ };
+ }),
+ );
+
+ useEffect(() => {
+ setErrParamsMap(errParamsMap);
+ }, [errParamsMap]);
useEffect(() => {
return () => {
- clear();
+ // clear();
};
}, []);
@@ -43,6 +67,23 @@ export default function Page() {
type="primary"
disabled={imageAccounts.length === 0 || images.length === 0}
onClick={() => {
+ for (const [key, errVideoItem] of errParamsMap) {
+ if (errVideoItem) {
+ const imageAccount = imageAccounts.find(
+ (v) => v.account.id === +key,
+ )!;
+ const platType = imageAccount!.account.type;
+ const platActiveAccountMap = new Map(
+ useImagePageStore.getState().platActiveAccountMap,
+ );
+ setActivePlat(platType);
+ platActiveAccountMap.set(platType, imageAccount);
+ setPlatActiveAccountMap(platActiveAccountMap);
+ message.warning(errVideoItem.parErrMsg);
+ return;
+ }
+ }
+ console.log(errParamsMap);
console.log('images:', images);
console.log('imageAccounts:', imageAccounts);
}}
diff --git a/src/views/publish/children/imagePage/useImagePageStore.ts b/src/views/publish/children/imagePage/useImagePageStore.ts
index 3163862f..0a8bc635 100644
--- a/src/views/publish/children/imagePage/useImagePageStore.ts
+++ b/src/views/publish/children/imagePage/useImagePageStore.ts
@@ -8,6 +8,8 @@ import { useVideoPageStore } from '../videoPage/useVideoPageStore';
import { AccountType } from '../../../../../commont/AccountEnum';
import { IPubParams } from '../videoPage/videoPage';
import { message } from 'antd';
+import { accountLogin } from '../../../../icp/account';
+import { ErrPubParamsMapType } from '../../hooks/usePubParamsVerify';
interface IImagePageStore {
// 账户数据和对应参数
@@ -22,6 +24,11 @@ interface IImagePageStore {
commonPubParams: IPubParams;
// 图片上传上限
imgUploadLimit: number;
+ /**
+ * 这个属性在 imagePage/page.tsx 中进行计算,然后实时的放到这里
+ * 因为别的组件需要这个属性,为了使其只计算一次,特此放到store引用
+ */
+ errParamsMap?: ErrPubParamsMapType;
}
const store: IImagePageStore = {
@@ -31,6 +38,7 @@ const store: IImagePageStore = {
platActiveAccountMap: new Map<AccountType, IImageAccountItem>(),
activePlat: undefined,
commonPubParams: useVideoPageStore.getState().pubParamsInit(),
+ errParamsMap: undefined,
};
const getStore = () => {
@@ -52,13 +60,28 @@ export const useImagePageStore = create(
platActiveAccountMap,
});
},
-
+ setErrParamsMap(errParamsMap: ErrPubParamsMapType) {
+ set({
+ errParamsMap,
+ });
+ },
setActivePlat(activePlat: AccountType) {
set({
activePlat,
});
},
+ /**
+ * 账户重新登录。登录成功后会自动更新该条账户数据
+ */
+ async accountRestart(pType: AccountType) {
+ const res = await accountLogin(pType);
+ if (!res) return;
+ message.success('登录成功!');
+ // 更新此条账户数据
+ methods.updateAccounts([res]);
+ },
+
// 设置图片
setImages(images: IImgFile[]) {
set({
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
index ee49632e..d5ccac1c 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
@@ -123,7 +123,7 @@ const VideoPubSetModal = memo(
>(new Map());
const [pubProgressModuleOpen, setPubProgressModuleOpen] = useState(false);
const videoPubSetModalVideoRef = useRef<IVideoPubSetModalVideoRef>(null);
- const { errVideoMap } = usePubParamsVerify(
+ const { errParamsMap } = usePubParamsVerify(
videoListChoose.map((v) => {
return {
id: v.id,
@@ -246,7 +246,7 @@ const VideoPubSetModal = memo(
const handleOk = async () => {
// 数据校验
- for (const [key, errVideoItem] of errVideoMap) {
+ for (const [key, errVideoItem] of errParamsMap) {
if (errVideoItem) {
setCurrChooseAccountId(`${key}`);
message.warning(errVideoItem.parErrMsg);
@@ -326,7 +326,7 @@ const VideoPubSetModal = memo(
items={videoListChoose
.map((v) => {
const account = v.account!;
- const errItem = errVideoMap.get(v.id);
+ const errItem = errParamsMap.get(v.id);
if (!account || !v.video) return undefined;
return {
@@ -366,7 +366,7 @@ const VideoPubSetModal = memo(
>
<div className="videoPubSetModal_con-left">
{(() => {
- const errItem = errVideoMap.get(
+ const errItem = errParamsMap.get(
currChooseAccount?.id || '',
);
if (!errItem) return;
diff --git a/src/views/publish/children/videoPage/useVideoPageStore.ts b/src/views/publish/children/videoPage/useVideoPageStore.ts
index 92ef2249..5e85cd8d 100644
--- a/src/views/publish/children/videoPage/useVideoPageStore.ts
+++ b/src/views/publish/children/videoPage/useVideoPageStore.ts
@@ -385,11 +385,13 @@ export const useVideoPageStore = create(
try {
methods.setOperateId();
- const cover = await getImgFile(pubRecord.commonCoverPath);
- commonPubParams = {
- ...pubRecord,
- cover,
- };
+ if (pubRecord.commonCoverPath) {
+ const cover = await getImgFile(pubRecord.commonCoverPath);
+ commonPubParams = {
+ ...pubRecord,
+ cover,
+ };
+ }
// key=视频路径 val=视频文件,防止多个相同视频重复取视频文件
const videoFileMap = new Map<string, IVideoFile>();
diff --git a/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx b/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx
index 17a6a7b3..ee665478 100644
--- a/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx
+++ b/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx
@@ -25,6 +25,7 @@ import { PubType } from '../../../../../../commont/publish/PublishEnum';
import { CheckOutlined } from '@ant-design/icons';
import { useAccountStore } from '../../../../../store/account';
import { useShallow } from 'zustand/react/shallow';
+import { Link } from 'react-router-dom';
export interface IPlatChooseRef {
/**
@@ -193,7 +194,13 @@ const PlatChoose = memo(
<div className={styles.platChoose}>
{getAllAccountList.length === 0 ? (
<div className="platChoose-empty">
- <Empty description="无账户数据,请添加账户" />
+ <Empty
+ description={
+ <>
+ 无账户数据,请前往 <Link to="/">账户</Link>添加数据
+ </>
+ }
+ />
</div>
) : (
<>
diff --git a/src/views/publish/hooks/usePubParamsVerify.tsx b/src/views/publish/hooks/usePubParamsVerify.tsx
index 069acde1..97cf7977 100644
--- a/src/views/publish/hooks/usePubParamsVerify.tsx
+++ b/src/views/publish/hooks/usePubParamsVerify.tsx
@@ -12,6 +12,18 @@ export enum PubParamsErrStatusEnum {
PARAMS = 2,
}
+export interface ErrPubParamsItem {
+ message: string;
+ // 同 AlertProps.type
+ type: 'warning' | 'error';
+ errType: PubParamsErrStatusEnum;
+ // 参数错误提示消息
+ parErrMsg?: string;
+ plat?: AccountType;
+}
+
+export type ErrPubParamsMapType = Map<string | number, ErrPubParamsItem>;
+
/**
* 发布参数校验是否复合平台规范
* @param data
@@ -23,19 +35,10 @@ export default function (
pubParams: IPubParams;
}[],
) {
- const errVideoMap = useMemo(() => {
- const errVideoMapTemp: Map<
- string | number,
- {
- message: string;
- // 同 AlertProps.type
- type: 'warning' | 'error';
- errType: PubParamsErrStatusEnum;
- // 参数错误提示消息
- parErrMsg?: string;
- }
- > = new Map();
+ const errParamsMap = useMemo(() => {
+ const errParamsMapTemp: ErrPubParamsMapType = new Map();
for (const v of data) {
+ if (!v.account) continue;
const platInfo = AccountPlatInfoMap.get(v.account!.type)!;
const { topics } = parseTopicString(v.pubParams.describe || '');
const topicsAll = [...new Set(v.pubParams.topics?.concat(topics))];
@@ -43,7 +46,7 @@ export default function (
if (v.account && v.account.status === AccountStatus.DISABLE) {
// 登录状态校验
- errVideoMapTemp.set(v.id, {
+ errParamsMapTemp.set(v.id, {
message: '登录失效',
type: 'warning',
errType: PubParamsErrStatusEnum.LOGIN,
@@ -55,7 +58,7 @@ export default function (
(v.pubParams.cover.width < 400 || v.pubParams.cover.height < 400)
) {
// 快手要求封面必须大于 400x400
- errVideoMapTemp.set(v.id, {
+ errParamsMapTemp.set(v.id, {
message: '参数错误',
type: 'error',
errType: PubParamsErrStatusEnum.PARAMS,
@@ -63,7 +66,7 @@ export default function (
});
} else if (topicsAll.length > topicMax) {
// 话题校验
- errVideoMapTemp.set(v.id, {
+ errParamsMapTemp.set(v.id, {
message: '参数错误',
type: 'error',
errType: PubParamsErrStatusEnum.PARAMS,
@@ -79,18 +82,25 @@ export default function (
* 抖音的话题和活动奖励校验
* 抖音规定活动奖励 + 话题不能超过5个
*/
- errVideoMapTemp.set(v.id, {
+ errParamsMapTemp.set(v.id, {
message: '参数错误',
type: 'error',
errType: PubParamsErrStatusEnum.PARAMS,
parErrMsg: `话题 + 活动奖励不能超过${topicMax}个`,
});
}
+ // 通用参数
+ if (errParamsMapTemp.has(v.id)) {
+ errParamsMapTemp.set(v.id, {
+ ...errParamsMapTemp.get(v.id)!,
+ plat: v.account.type,
+ });
+ }
}
- return errVideoMapTemp;
+ return errParamsMapTemp;
}, [data]);
return {
- errVideoMap,
+ errParamsMap,
};
}