Skip to content

Let's use AI to Earn!

feat: 添加了等待视频发布快手作品审核的逻辑(为了查看链接,因为快手只有审核完成后才会给作品id,根据作品id才能拼接查看链接)。

gaoSir2acf4cb98264
diff --git a/commont/UtilsEnum.ts b/commont/UtilsEnum.ts
index 5fbe6432..18172567 100644
--- a/commont/UtilsEnum.ts
+++ b/commont/UtilsEnum.ts
@@ -19,4 +19,6 @@ export enum SendChannelEnum {
CommentRelyProgress = 'CommentRelyProgress',
// 评论互动进度
InteractionProgress = 'InteractionProgress',
+ // 视频发布完成后待审核变成审核的事件
+ VideoAuditFinish = 'VideoAuditFinish',
}
diff --git a/commont/utils.ts b/commont/utils.ts
index 393ac65e..ec94a6cd 100644
--- a/commont/utils.ts
+++ b/commont/utils.ts
@@ -11,4 +11,9 @@ export function getFilePathNameCommon(path: string) {
filename,
suffix: filename.split('.')[filename.split('.').length - 1],
};
-}
\ No newline at end of file
+}
+
+// 等待n毫秒
+export function sleep(ms: number) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+}
diff --git a/electron/db/models/pubRecord.ts b/electron/db/models/pubRecord.ts
index 06c88fe6..a4eac5ae 100644
--- a/electron/db/models/pubRecord.ts
+++ b/electron/db/models/pubRecord.ts
@@ -14,6 +14,7 @@ export enum PubStatus {
RELEASED = 1, // 已发布
FAIL = 2, // 发布失败
PartSuccess = 3, // 部分成功
+ Audit = 4, // 审核中
}
@Entity({ name: 'pubRecord' })
export class PubRecordModel extends TempModel {
diff --git a/electron/db/models/workData.ts b/electron/db/models/workData.ts
index 98ca4656..da54b7b0 100644
--- a/electron/db/models/workData.ts
+++ b/electron/db/models/workData.ts
@@ -107,7 +107,7 @@ export class WorkData extends TempModel {
@Column({
type: 'tinyint',
nullable: false,
- comment: '状态 0 未发布/草稿 1 已发布 2=发布失败 3=部分成功',
+ comment: '状态 0 未发布/草稿 1 已发布 2=发布失败 3=部分成功 4=审核中',
default: PubStatus.UNPUBLISH,
})
status!: PubStatus;
diff --git a/electron/global/event.ts b/electron/global/event.ts
index 7cb6358a..e35cb174 100644
--- a/electron/global/event.ts
+++ b/electron/global/event.ts
@@ -6,4 +6,5 @@
* @Description: 全局事件
*/
import { EventEmitter } from 'events';
+
export const EtEvent = new EventEmitter();
diff --git a/electron/main/account/controller.ts b/electron/main/account/controller.ts
index a0df017f..087bbe96 100644
--- a/electron/main/account/controller.ts
+++ b/electron/main/account/controller.ts
@@ -141,11 +141,24 @@ export class AccountController {
// 获取账户列表(ids)
@Icp('ICP_ACCOUNT_GET_LIST_BY_IDS')
- async getAccountListByIds(
+ async getAccountListByIdsTcp(
event: Electron.IpcMainInvokeEvent,
ids: number[],
): Promise<any> {
+ return this.getAccountListByIds(ids);
+ }
+ // 获取账户列表(ids)
+ @Et('ET_ACCOUNT_GET_LIST_BY_IDS')
+ async getAccountListByIdsEt(
+ ids: number[],
+ callback: (p: AccountModel[]) => void,
+ ): Promise<any> {
+ const accounts = await this.getAccountListByIds(ids);
+ callback(accounts);
+ }
+ async getAccountListByIds(ids: number[]) {
const userInfo = getUserInfo();
+ if (!userInfo?.id) return [];
return this.accountService.getAccountListByIds(userInfo.id, ids);
}
diff --git a/electron/main/index.ts b/electron/main/index.ts
index f156c625..2b39f8d9 100644
--- a/electron/main/index.ts
+++ b/electron/main/index.ts
@@ -11,6 +11,7 @@ import windowOperate from '../util/windowOperate';
import { logger } from '../global/log';
import { SplashWindow } from './splash';
import dotenv from 'dotenv';
+import KwaiPubListener from "./plat/platforms/Kwai/KwaiPubListener";
const platform = process.platform;
dotenv.config();
@@ -95,6 +96,7 @@ async function createWindow() {
}
// 延长启动窗口显示时间
+ KwaiPubListener.start();
setTimeout(() => {
if (splashWindow) {
win?.show();
diff --git a/electron/main/plat/module.ts b/electron/main/plat/module.ts
index 13f9a84c..1214ed24 100644
--- a/electron/main/plat/module.ts
+++ b/electron/main/plat/module.ts
@@ -6,6 +6,7 @@
* @Description:
*/
import { AccountType } from '../../../commont/AccountEnum';
+import { PubStatus } from '../../db/models/pubRecord';
interface IProperty {
code: number;
@@ -31,6 +32,8 @@ export class PublishVideoResult {
dataId?: string;
// 预览视频地址
previewVideoLink?: string;
+ // 发布状态,可选值
+ pubStatus?: PubStatus;
constructor(
{ code, msg, dataId, previewVideoLink }: IProperty = {
diff --git a/electron/main/plat/platforms/Kwai/KwaiPubListener.ts b/electron/main/plat/platforms/Kwai/KwaiPubListener.ts
new file mode 100644
index 00000000..00611483
--- /dev/null
+++ b/electron/main/plat/platforms/Kwai/KwaiPubListener.ts
@@ -0,0 +1,123 @@
+import { kwaiPub } from '../../../../plat/Kwai';
+import { EtEvent } from '../../../../global/event';
+import windowOperate from '../../../../util/windowOperate';
+import { SendChannelEnum } from '../../../../../commont/UtilsEnum';
+import { sleep } from '../../../../../commont/utils';
+import { PubStatus } from '../../../../db/models/pubRecord';
+import { VideoModel } from '../../../../db/models/video';
+import { AccountModel } from '../../../../db/models/account';
+
+/**
+ * 快手发布监听器
+ * 快手发布视频后会调用这个静态类的方法监听该条发布的视频是否完成,如果完成那么不会再监听
+ */
+export default class KwaiPubListener {
+ private constructor() {}
+
+ // 是否已经开始启动,防止重复启动
+ static started = false;
+ // key=cookie,val=侦听的id
+ static listenMap: Map<string, number[]> = new Map();
+
+ // 处理逻辑
+ static async handle(cookie: string) {
+ const ids = KwaiPubListener.listenMap.get(cookie)!;
+ const works = await kwaiPub.refreshWorks(JSON.parse(cookie), ids);
+ works.data.data.list.find((v) => {
+ if (v.workId) {
+ const previewVideoLink = `https://www.kuaishou.com/short-video/${v.workId}`;
+ EtEvent.emit('ET_PUBLISH_UPDATE_VIDEO_PUL_BY_DATAID', {
+ previewVideoLink,
+ status: PubStatus.RELEASED,
+ dataId: `${v.id}`,
+ });
+ windowOperate.sendRenderMsg(SendChannelEnum.VideoAuditFinish, {
+ previewVideoLink,
+ dataId: v.id,
+ });
+ const newIds = ids.filter((id) => id != v.id);
+ if (newIds.length === 0) {
+ KwaiPubListener.listenMap.delete(cookie);
+ } else {
+ KwaiPubListener.listenMap.set(cookie, newIds);
+ }
+ }
+ });
+ }
+
+ static async getVideoRecord() {
+ return new Promise<VideoModel[]>((resolve) => {
+ EtEvent.emit('ET_PUBLISH_VIDEO_AUDIT_LIST', (list: VideoModel[]) => {
+ resolve(list);
+ });
+ });
+ }
+
+ static async getAccountById(ids: number[]) {
+ return new Promise<AccountModel[]>((resolve) => {
+ EtEvent.emit(
+ 'ET_ACCOUNT_GET_LIST_BY_IDS',
+ ids,
+ (list: AccountModel[]) => {
+ resolve(list);
+ },
+ );
+ });
+ }
+
+ /**
+ * 开始监听
+ */
+ static async start(cookie?: string, id?: number) {
+ if (cookie) {
+ if (!KwaiPubListener.listenMap.has(cookie)) {
+ KwaiPubListener.listenMap.set(cookie, []);
+ }
+ KwaiPubListener.listenMap.get(cookie)?.push(id!);
+ } else {
+ const videoModels: VideoModel[] = await KwaiPubListener.getVideoRecord();
+ if (videoModels && videoModels.length === 0) return;
+ const accountIds = videoModels.map((v) => {
+ return v.accountId;
+ });
+ if (accountIds.length === 0) return;
+ const accounts: AccountModel[] =
+ await KwaiPubListener.getAccountById(accountIds);
+ if (accounts.length === 0) return;
+
+ accounts.map((v) => {
+ const cookie = v.loginCookie;
+ if (!KwaiPubListener.listenMap.has(cookie)) {
+ KwaiPubListener.listenMap.set(
+ cookie,
+ videoModels
+ .filter((k) => k.accountId === v.id)
+ .map((v) => {
+ return parseInt(<string>v.dataId);
+ }),
+ );
+ }
+ });
+ }
+ if (KwaiPubListener.started) return;
+
+ KwaiPubListener.started = true;
+ while (true) {
+ if (KwaiPubListener.listenMap.size === 0) {
+ break;
+ }
+ try {
+ const tasks: Promise<void>[] = [];
+ for (const [cookie] of KwaiPubListener.listenMap) {
+ tasks.push(this.handle(cookie));
+ }
+ await Promise.all(tasks);
+ } catch (e) {
+ console.error('快手审核作品查询错误:', e);
+ break;
+ }
+ await sleep(3000);
+ }
+ KwaiPubListener.started = false;
+ }
+}
diff --git a/electron/main/plat/platforms/Kwai/index.ts b/electron/main/plat/platforms/Kwai/index.ts
index aa0fc069..d582989d 100644
--- a/electron/main/plat/platforms/Kwai/index.ts
+++ b/electron/main/plat/platforms/Kwai/index.ts
@@ -28,6 +28,8 @@ import { AccountModel } from '../../../../db/models/account';
import dayjs from 'dayjs';
import { VideoModel } from '../../../../db/models/video';
import { VisibleTypeEnum } from '../../../../../commont/publish/PublishEnum';
+import { PubStatus } from '../../../../db/models/pubRecord';
+import KwaiPubListener from './KwaiPubListener';
export class Kwai extends PlatformBase {
constructor() {
@@ -119,11 +121,13 @@ export class Kwai extends PlatformBase {
msg: '网络繁忙,请稍后重试',
});
+ KwaiPubListener.start(JSON.stringify(params.cookies), +result.publishId);
return resolve({
code: 1,
msg: '发布成功',
dataId: result.publishId,
previewVideoLink: result.shareLink,
+ pubStatus: PubStatus.Audit,
});
});
}
diff --git a/electron/main/plat/pub/PubItemVideo.ts b/electron/main/plat/pub/PubItemVideo.ts
index c7ea3ac3..529706e0 100644
--- a/electron/main/plat/pub/PubItemVideo.ts
+++ b/electron/main/plat/pub/PubItemVideo.ts
@@ -67,7 +67,11 @@ export class PubItemVideo extends PubItemBase {
});
} else {
// 发布成功
- this.videoModel.status = PubStatus.RELEASED;
+ if (typeof publishVideoResult.pubStatus === 'number') {
+ this.videoModel.status = publishVideoResult.pubStatus;
+ } else {
+ this.videoModel.status = PubStatus.RELEASED;
+ }
this.videoModel.dataId = publishVideoResult.dataId;
this.videoModel.previewVideoLink = publishVideoResult.previewVideoLink;
windowOperate.sendRenderMsg(SendChannelEnum.VideoPublishProgress, {
diff --git a/electron/main/publish/video/controller.ts b/electron/main/publish/video/controller.ts
index ec1a9683..e24f9a5d 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 lodash from 'lodash';
@Controller()
export class VideoPubController {
@@ -153,6 +154,31 @@ export class VideoPubController {
return await this.videoPubService.getVideoPulTypeCount(userInfo.id, type);
}
+ // 获取状态为审核中的视频列表
+ @Et('ET_PUBLISH_VIDEO_AUDIT_LIST')
+ async getAuditVideoList(callback: (_: VideoModel[]) => void): Promise<any> {
+ console.log(callback);
+ const userInfo = getUserInfo();
+ if (!userInfo?.id) return [];
+ const res = await this.videoPubService.getVideoPulList(
+ userInfo.id,
+ {
+ page_size: 20,
+ page_no: 1,
+ },
+ {
+ status: PubStatus.Audit,
+ },
+ );
+ callback(res.list);
+ }
+
+ // 根据dataid更新数据
+ @Et('ET_PUBLISH_UPDATE_VIDEO_PUL_BY_DATAID')
+ async updateVideoPubByDataid(videoModel: Partial<VideoModel>): Promise<any> {
+ return await this.videoPubService.updateVideoPulByDataId(videoModel);
+ }
+
// 更新视频发布数据
@Et('ET_PUBLISH_UPDATE_VIDEO_PUL')
async updateVideoPul(videoModel: VideoModel): Promise<any> {
diff --git a/electron/main/publish/video/service.ts b/electron/main/publish/video/service.ts
index 058f61b1..3a5ea12b 100644
--- a/electron/main/publish/video/service.ts
+++ b/electron/main/publish/video/service.ts
@@ -31,6 +31,14 @@ export class VideoPubService {
return await this.videoRepository.update(videoModel.id!, videoModel);
}
+ // 根据dataid更新数据
+ async updateVideoPulByDataId(videoModel: Partial<VideoModel>) {
+ return await this.videoRepository.update(
+ { dataId: videoModel.dataId },
+ videoModel,
+ );
+ }
+
// 获取视频发布信息
async getVideoPulInfo(id: number) {
return await this.videoRepository.findOne({ where: { id } });
diff --git a/electron/main/views.ts b/electron/main/views.ts
index b6b7ec0b..7c5cd786 100644
--- a/electron/main/views.ts
+++ b/electron/main/views.ts
@@ -13,6 +13,7 @@ import requestNet from '../plat/requestNet';
// @ts-ignore
import coordtransform from 'coordtransform';
import { logger } from '../global/log';
+import KwaiPubListener from './plat/platforms/Kwai/KwaiPubListener';
export interface ISaveFileParams {
// 要保存的路由
@@ -24,6 +25,11 @@ export interface ISaveFileParams {
}
export function views(win: Electron.BrowserWindow) {
+ // 开始监听快手审核发布
+ ipcMain.handle('start-kwai-listen', function () {
+ KwaiPubListener.start();
+ });
+
// 窗口最小化
ipcMain.handle('window-minimize', function () {
win.minimize();
diff --git a/electron/plat/Kwai/index.ts b/electron/plat/Kwai/index.ts
index 55b7b003..6730bec3 100644
--- a/electron/plat/Kwai/index.ts
+++ b/electron/plat/Kwai/index.ts
@@ -4,6 +4,7 @@ import {
GetCommentListResponse,
GetPhotoListResponse,
GetSubCommentListResponse,
+ GetWorksListResponse,
IGetHomeInfoResponse,
IGetHomeOverview,
IKwaiGetLocationsResponse,
@@ -13,6 +14,7 @@ import {
IKwaiUserInfoResponse,
ILoginResponse,
KwaiSubmitResponse,
+ RefreshWorksResponse,
UploadFinishResponse,
UploadPpreResponse,
} from './kwai.type';
@@ -198,13 +200,23 @@ class KwaiPub {
if (submitRes.data.result !== 1) {
return reject(submitRes.data.message);
}
+ callback(95, `正在查询发布结果...`);
+ const worksList = await this.getWorks(params.cookies, {
+ queryType: '2',
+ });
+ console.log(worksList);
+ const work = worksList.data.data.list.find(
+ (v) => v.unPublishCoverKey === coverRes.data.data.coverKey,
+ );
+ if (!work) throw '作品查询失败!';
console.log('发布成功!');
resolve({
shareLink: ``,
- publishId: '1',
+ publishId: `${work?.publishId}`,
});
} catch (e: any) {
reject(`发布失败,失败原因:${e.message}`);
+ console.error(e);
}
});
}
@@ -405,6 +417,43 @@ class KwaiPub {
});
}
+ // 刷新作品
+ async refreshWorks(cookies: Electron.Cookie[], ids: number[]) {
+ return await this.requestApi<RefreshWorksResponse>({
+ cookie: cookies,
+ url: `/rest/cp/works/v2/video/pc/publish/refresh`,
+ method: 'POST',
+ body: {
+ ids,
+ },
+ });
+ }
+
+ // 获取作品-开发者后台
+ async getWorks(
+ cookies: Electron.Cookie[],
+ params: {
+ // 0=全部作品,1=已发布,2=待发布,3=未通过
+ queryType: '0' | '1' | '2' | '3';
+ limit?: number;
+ },
+ ) {
+ return await this.requestApi<GetWorksListResponse>({
+ cookie: cookies,
+ url: `/rest/cp/works/v2/video/pc/photo/list`,
+ method: 'POST',
+ body: {
+ cursor: Date.now(),
+ queryType: params.queryType,
+ limit: params.limit || 100,
+ timeRangeType: 5,
+ keyword: '',
+ startTime: Date.now() - 1000 * 60 * 60 * 24 * 30,
+ endTime: Date.now(),
+ },
+ });
+ }
+
/**
* 获取作品列表
* @param cookies
@@ -507,7 +556,6 @@ class KwaiPub {
/**
* 添加评论和回复评论
* @param cookie
- * @param photoId
* @param content
* @param reply
* @returns
@@ -537,9 +585,8 @@ class KwaiPub {
/**
* 点赞
* @param cookie
- * @param photoId
- * @param content
- * @param reply
+ * @param dataId
+ * @param option
* @returns
*/
async dianzanDyOther(cookie: Electron.Cookie[], dataId: string, option: any) {
@@ -569,10 +616,10 @@ class KwaiPub {
/**
* 视频评论
- * @param cookieu
- * @param photoId
+ * @param cookie
+ * @param dataId
* @param content
- * @param reply
+ * @param authorId
* @returns
*/
async videoCommentByOther(
@@ -609,9 +656,8 @@ class KwaiPub {
/**
* 获取视频评论列表
* @param cookie
- * @param photoId
- * @param content
- * @param reply
+ * @param dataId
+ * @param pcursor
* @returns
*/
async getVideoCommentList(
@@ -645,12 +691,10 @@ class KwaiPub {
/**
* 回复二级评论
* @param cookie
- * @param commentId
* @param content
* @param option
* @returns
*/
-
async replyCommentByOther(
cookie: Electron.Cookie[],
content: string,
diff --git a/electron/plat/Kwai/kwai.type.ts b/electron/plat/Kwai/kwai.type.ts
index e8506658..73d1599b 100644
--- a/electron/plat/Kwai/kwai.type.ts
+++ b/electron/plat/Kwai/kwai.type.ts
@@ -175,6 +175,53 @@ export interface ILoginResponse {
userInfo: IRequestNetResult<IKwaiUserInfoResponse>;
}
+// 刷新作品
+export type RefreshWorksResponse = IKwaiUserCommonResponse<{
+ list: {
+ id: number;
+ likeCount: number;
+ operations: number[];
+ playCount: number;
+ publishStatus: number;
+ // 如果已经发布这个值会存在
+ workId?: string;
+ }[];
+}>;
+
+// 获取作品,开发者后台
+export type GetWorksListResponse = IKwaiUserCommonResponse<{
+ list: {
+ publishId: number;
+ workId: string;
+ title: string;
+ publishCoverUrl: string;
+ unPublishCoverKey: string | null;
+ userId: number;
+ userIdStr: string;
+ userName: string;
+ userHead: string;
+ playCount: number;
+ likeCount: number;
+ commentCount: number;
+ uploadTime: number;
+ durationSecond: number;
+ judgementTitle: string;
+ judgementStatus: number;
+ publishStatus: number;
+ operations: string[];
+ publishType: number;
+ photoStatus: number;
+ photoTop: boolean;
+ collectionTitle: string;
+ collectionId: number;
+ awdId: number;
+ hotspotActivity: null;
+ hotspot: null;
+ showAtlasIcon: boolean;
+ showDuration: boolean;
+ }[];
+}>;
+
// 获取作品列表
export interface GetPhotoListResponse {
result: number; // 1;
diff --git a/src/icp/receiveMsg.ts b/src/icp/receiveMsg.ts
index 34c4056e..1928b343 100644
--- a/src/icp/receiveMsg.ts
+++ b/src/icp/receiveMsg.ts
@@ -46,6 +46,16 @@ export const onAccountLoginFinish = (
);
};
+// 视频审核完成
+export const onVideoAuditFinish = (
+ callback: (_: { previewVideoLink: string; dataId: string }) => void,
+) => {
+ return bindEventCore(SendChannelEnum.VideoAuditFinish, (_, ...args) => {
+ // @ts-ignore
+ callback(...args);
+ });
+};
+
// 视频发布进度
export const onVideoPublishProgress = (
callback: (progressData: PublishProgressRes) => void,
diff --git a/src/router/index.tsx b/src/router/index.tsx
index 77cb963b..ad7c8e22 100644
--- a/src/router/index.tsx
+++ b/src/router/index.tsx
@@ -20,6 +20,7 @@ import {
MessageOutlined,
AuditOutlined,
MoneyCollectOutlined,
+ OpenAIOutlined,
} from '@ant-design/icons';
// 组件
@@ -35,18 +36,13 @@ import ImagePage from '@/views/publish/children/imagePage/page';
import PubRecord from '@/views/publish/children/pubRecord/page';
import Statistics from '@/views/statistics/statistics';
import Task from '@/views/task/task';
-// import HotTopic from '@/views/trending/hotTopic';
-// import CarTask from '@/views/task/carTask';
-// import PopTask from '@/views/task/popTask';
-// import VideoTask from '@/views/task/videoTask';
-// import MineTask from '@/views/task/mineTask';
import UserWalletAccount from '@/views/finance/userWalletAccount';
import Finance from '@/views/finance/finance';
import UserWalletRecord from '@/views/finance/userWalletRecord';
import Reply from '@/views/reply';
import Replyother from '@/views/replyother/replyother';
import ErrorBoundary from '../components/ErrorBoundary/ErrorBoundary';
-import Test from '@/views/test';
+import AiTool from '@/views/aiTool/index';
interface IRouterMeta {
// 路由名称
@@ -117,6 +113,11 @@ export const router: CustomRouteObject[] = [
{ path: 'pubRecord', element: <PubRecord /> },
],
},
+ {
+ path: '/aiTool',
+ element: <AiTool />,
+ meta: { name: 'Ai工具', icon: OpenAIOutlined },
+ },
{
path: '/reply',
element: <Reply />,
diff --git a/src/views/account/index.tsx b/src/views/account/index.tsx
index 2bbed37a..38a3960f 100644
--- a/src/views/account/index.tsx
+++ b/src/views/account/index.tsx
@@ -6,7 +6,7 @@
* @Description: 账户
*/
-import React, { useCallback, useState } from 'react';
+import React, { useCallback, useEffect, useState } from 'react';
import styles from './account.module.scss';
import AccountSidebar from './components/AccountSidebar/AccountSidebar';
@@ -17,6 +17,10 @@ const Account: React.FC = () => {
const [activeAccountId, setActiveAccountId] = useState(-1);
const [accountInfo, setAccountInfo] = useState<AccountInfo>();
+ useEffect(() => {
+ window.ipcRenderer.invoke('start-kwai-listen');
+ }, []);
+
return (
<div className={styles.account}>
<AccountSidebar
diff --git a/src/views/aiTool/index.tsx b/src/views/aiTool/index.tsx
new file mode 100644
index 00000000..7368ccd0
--- /dev/null
+++ b/src/views/aiTool/index.tsx
@@ -0,0 +1,3 @@
+export default function Page() {
+ return <>Ai工具</>;
+}
diff --git a/src/views/publish/children/pubRecord/components/PubRecordDetails.tsx b/src/views/publish/children/pubRecord/components/PubRecordDetails.tsx
index f6131f26..616ba34d 100644
--- a/src/views/publish/children/pubRecord/components/PubRecordDetails.tsx
+++ b/src/views/publish/children/pubRecord/components/PubRecordDetails.tsx
@@ -104,24 +104,37 @@ const PubRecordDetails = memo(
{pubRecordList?.map((v) => {
const account = accountMap.get(v.accountId);
const plat = AccountPlatInfoMap.get(v.type);
+ let statusText = '';
+ let className = '';
+ let tooltipText = '';
+ if (v.status === 1) {
+ statusText = '发布成功';
+ className = 'pubRecord-record-item--success';
+ } else if (v.status === 0) {
+ statusText = '发布中';
+ className = 'pubRecord-record-item--processing';
+ } else if (v.status === 2) {
+ statusText = '发布失败';
+ className = 'pubRecord-record-item--fail';
+ } else if (v.status === 4) {
+ statusText = '审核中';
+ tooltipText =
+ '快手需要几十秒时间审核,等待几十秒后刷新数据即可';
+ className = 'pubRecord-record-item--processing';
+ }
+
return (
<li className="pubRecord-record-item" key={v.id}>
- <div
- className={[
- 'pubRecord-record-item-status',
- v.status === 1
- ? 'pubRecord-record-item--success'
- : v.status === 0
- ? 'pubRecord-record-item--processing'
- : 'pubRecord-record-item--fail',
- ].join(' ')}
- >
- {v.status === 1
- ? '发布成功'
- : v.status === 0
- ? '发布中'
- : '发布失败'}
- </div>
+ <Tooltip title={tooltipText || undefined}>
+ <div
+ className={[
+ 'pubRecord-record-item-status',
+ className,
+ ].join(' ')}
+ >
+ {statusText}
+ </div>
+ </Tooltip>
<div className="pubRecord-record-item-con">
<div className="pubRecord-record-item-con-avatar">
<Avatar size="large" src={account?.avatar} />
@@ -143,61 +156,61 @@ const PubRecordDetails = memo(
</div>
</div>
<div className="pubRecord-record-item-btns">
- {v.status !== 0 &&
- (v.status !== 1 ? (
- <Button
- type="link"
- onClick={async () => {
- if (
- currPubRecordModel?.type === PubType.VIDEO
- ) {
- setRecordLoaidng(true);
- const prl = pubRecordList.filter(
- (v) => v.status === 2,
- );
- await restartPub(
- prl as VideoModel[],
- prl.map(
- (k) => accountMap.get(k.accountId)!,
- ),
- currPubRecordModel,
- );
- setRecordLoaidng(false);
- navigate('/publish/video');
- } else if (
- currPubRecordModel?.type ===
- PubType.ImageText
- ) {
- }
- }}
- >
- 重新发布
- </Button>
- ) : (
- <Button
- type="link"
- onClick={async () => {
- if (!v.dataId) return;
- const newState: IExamineVideo = {
- jsCode: '',
- open: true,
- url: '',
- account,
- };
- if (account?.type === AccountType.WxSph) {
- const videoFile = await getVideoFile(
- (v as VideoModel).videoPath!,
- );
- newState['videoSrc'] = videoFile.videoUrl;
- } else {
- newState['url'] = v.previewVideoLink || '';
- }
- onExamineVideoClick(newState);
- }}
- >
- 查看
- </Button>
- ))}
+ {v.status === 2 && (
+ <Button
+ type="link"
+ onClick={async () => {
+ if (
+ currPubRecordModel?.type === PubType.VIDEO
+ ) {
+ setRecordLoaidng(true);
+ const prl = pubRecordList.filter(
+ (v) => v.status === 2,
+ );
+ await restartPub(
+ prl as VideoModel[],
+ prl.map(
+ (k) => accountMap.get(k.accountId)!,
+ ),
+ currPubRecordModel,
+ );
+ setRecordLoaidng(false);
+ navigate('/publish/video');
+ } else if (
+ currPubRecordModel?.type === PubType.ImageText
+ ) {
+ }
+ }}
+ >
+ 重新发布
+ </Button>
+ )}
+
+ {v.status === 1 && (
+ <Button
+ type="link"
+ onClick={async () => {
+ if (!v.dataId) return;
+ const newState: IExamineVideo = {
+ jsCode: '',
+ open: true,
+ url: '',
+ account,
+ };
+ if (account?.type === AccountType.WxSph) {
+ const videoFile = await getVideoFile(
+ (v as VideoModel).videoPath!,
+ );
+ newState['videoSrc'] = videoFile.videoUrl;
+ } else {
+ newState['url'] = v.previewVideoLink || '';
+ }
+ onExamineVideoClick(newState);
+ }}
+ >
+ 查看
+ </Button>
+ )}
</div>
</li>
);
diff --git a/src/views/publish/children/pubRecord/page.tsx b/src/views/publish/children/pubRecord/page.tsx
index f9a75648..25014493 100644
--- a/src/views/publish/children/pubRecord/page.tsx
+++ b/src/views/publish/children/pubRecord/page.tsx
@@ -11,6 +11,7 @@ import { PubType } from '../../../../../commont/publish/PublishEnum';
import PubRecordDetails, {
IPubRecordDetailsRef,
} from './components/PubRecordDetails';
+import { onVideoAuditFinish } from '../../../../icp/receiveMsg';
export const ImageView = ({
prm,
@@ -168,6 +169,10 @@ export default function Page({
useEffect(() => {
GetPubList();
+
+ return onVideoAuditFinish((params) => {
+ console.log('视频审核完成', params);
+ });
}, [pubType]);
async function GetPubList() {