Skip to content

Let's use AI to Earn!

feat: 通用发布参数中的标题和定时发布根据选择的平台动态调整完成。

gaoSir1d108f807a2b
diff --git a/src/views/account/comment.ts b/src/views/account/comment.ts
index 64640b05..77f1bc43 100644
--- a/src/views/account/comment.ts
+++ b/src/views/account/comment.ts
@@ -23,6 +23,22 @@ export interface IAccountPlatInfo {
url: string;
// 支持的发布类型
pubTypes: Set<PubType>;
+ /**
+ * 通用发布参数配置,有两个地方用到
+ * 1. 在设置通用发布参数的时候会根据当前选择的账户中的最小参数为基准设置参数限制
+ * 2. 规定每个平台通用参数的限制
+ */
+ commonPubParamsConfig: {
+ // title限制字数,可以不填,不填表示该平台无标题参数
+ titleMax?: number;
+ // 定时发布,可以不填,不填表示该平台无定时发布参数
+ timingMax?: {
+ // 同 VideoPubSetModalCommon.maxDate
+ maxDate: number;
+ // 同 VideoPubSetModalCommon.timeOffset
+ timeOffset: number;
+ };
+ };
}
// 支持所有发布
@@ -36,6 +52,12 @@ export const AccountPlatInfoMap = new Map<AccountType, IAccountPlatInfo>([
icon: ksSvg,
url: 'https://cp.kuaishou.com/profile',
pubTypes: PubTypeAll,
+ commonPubParamsConfig: {
+ timingMax: {
+ maxDate: 13,
+ timeOffset: 60,
+ },
+ },
},
],
[
@@ -46,6 +68,13 @@ export const AccountPlatInfoMap = new Map<AccountType, IAccountPlatInfo>([
url: 'https://creator.xiaohongshu.com/login?source=official',
// url: 'https://www.xiaohongshu.com/explore',
pubTypes: PubTypeAll,
+ commonPubParamsConfig: {
+ timingMax: {
+ maxDate: 14,
+ timeOffset: 60,
+ },
+ titleMax: 20,
+ },
},
],
[
@@ -55,6 +84,13 @@ export const AccountPlatInfoMap = new Map<AccountType, IAccountPlatInfo>([
icon: douyinSvg,
url: 'https://creator.douyin.com/creator-micro/content/upload?enter_from=dou_web',
pubTypes: PubTypeAll,
+ commonPubParamsConfig: {
+ timingMax: {
+ maxDate: 14,
+ timeOffset: 120,
+ },
+ titleMax: 30,
+ },
},
],
[
@@ -64,6 +100,13 @@ export const AccountPlatInfoMap = new Map<AccountType, IAccountPlatInfo>([
icon: wxSphSvg,
url: 'https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/helper/hepler_merlin_mmdata?_rid=67b30b55-6e3ea588',
pubTypes: PubTypeAll,
+ commonPubParamsConfig: {
+ timingMax: {
+ maxDate: 30,
+ timeOffset: 60,
+ },
+ titleMax: 16,
+ },
},
],
]);
diff --git a/src/views/publish/children/videoPage/components/CommonPubSetting.tsx b/src/views/publish/children/videoPage/components/CommonPubSetting.tsx
index 39de02f5..178b7b5b 100644
--- a/src/views/publish/children/videoPage/components/CommonPubSetting.tsx
+++ b/src/views/publish/children/videoPage/components/CommonPubSetting.tsx
@@ -1,10 +1,22 @@
-import { ForwardedRef, forwardRef, memo, useState } from 'react';
+import React, {
+ ForwardedRef,
+ forwardRef,
+ memo,
+ useMemo,
+ useState,
+} from 'react';
import VideoCoverSeting from '@/views/publish/children/videoPage/components/VideoCoverSeting';
import { Input, Tooltip } from 'antd';
import { ExclamationCircleOutlined } from '@ant-design/icons';
import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPageStore';
import { useShallow } from 'zustand/react/shallow';
import { IImgFile } from '@/components/Choose/ImgChoose';
+import { ScheduledTimeSelect } from './VideoPubSetModal/components/VideoPubSetModalCommon';
+import {
+ AccountPlatInfoMap,
+ IAccountPlatInfo,
+} from '../../../../account/comment';
+import { AccountType } from '../../../../../../commont/AccountEnum';
const { TextArea } = Input;
@@ -27,6 +39,36 @@ const CommonPubSetting = memo(
// 当前选择的通用封面
const [cover, setCover] = useState<IImgFile>();
+ // 获取选择的账户的所有相关平台
+ const getChoosedAccountPlatList = useMemo(() => {
+ const platMap = new Map<AccountType, IAccountPlatInfo>();
+ videoListChoose.map((v) => {
+ if (v.account) {
+ platMap.set(
+ v.account.type,
+ AccountPlatInfoMap.get(v.account.type)!,
+ );
+ }
+ });
+ return Array.from(platMap.values());
+ }, [videoListChoose]);
+
+ // 所有平台通用发布参数的最大值获取,做为默认值
+ const getPlatCommonParamsMax = useMemo(() => {
+ const platList = Array.from(AccountPlatInfoMap.values());
+
+ const maxValue = (getValue: (v: any) => number) =>
+ Math.max(...platList.map((v) => getValue(v) || -Infinity));
+
+ return {
+ maxDate: maxValue((v) => v.commonPubParamsConfig.timingMax?.maxDate),
+ timeOffset: maxValue(
+ (v) => v.commonPubParamsConfig.timingMax?.timeOffset,
+ ),
+ titleMax: maxValue((v) => v.commonPubParamsConfig.titleMax),
+ };
+ }, [AccountPlatInfoMap]);
+
return (
<div className="commonPubSetting">
<h1>通用发布设置</h1>
@@ -55,15 +97,37 @@ const CommonPubSetting = memo(
<p className="commonPubSetting-tip">
支持常用图片格式上传,暂不支持 GIF,上传后图片将按平台要求自动裁剪
</p>
+
<h2>
标题
- <Tooltip title="更多详情中单独设置的话题和描述中带的话题都是有效的,发布时将合并去重处理">
+ <Tooltip
+ title={
+ <div>
+ {Array.from(AccountPlatInfoMap.values()).map((platInfo) => {
+ const titleMax = platInfo.commonPubParamsConfig.titleMax;
+ return (
+ <p key={platInfo.name}>
+ <b>{platInfo.name}</b>
+ {!titleMax
+ ? `没有标题参数`
+ : `标题字数限制${titleMax}字`}
+ </p>
+ );
+ })}
+ </div>
+ }
+ >
<ExclamationCircleOutlined />
</Tooltip>
</h2>
<Input
showCount
- maxLength={30}
+ maxLength={Math.min(
+ getPlatCommonParamsMax.titleMax,
+ ...getChoosedAccountPlatList.map(
+ (v) => v.commonPubParamsConfig.titleMax || 30,
+ ),
+ )}
placeholder="请输入视频标题"
variant="filled"
onChange={(e) => {
@@ -72,6 +136,7 @@ const CommonPubSetting = memo(
});
}}
/>
+
<h2>描述</h2>
<TextArea
placeholder="请输入视频描述"
@@ -95,6 +160,54 @@ const CommonPubSetting = memo(
</Tooltip>
将根据平台自动处理 如:这是一段文字描述#最美中国 #夏日穿搭
</p>
+
+ <h2>
+ 定时发布
+ <Tooltip
+ styles={{
+ root: {
+ maxWidth: 'none',
+ },
+ }}
+ title={
+ <div>
+ {Array.from(AccountPlatInfoMap.values()).map((platInfo) => {
+ const timingMax = platInfo.commonPubParamsConfig.timingMax;
+ return (
+ <p key={platInfo.name}>
+ <b>{platInfo.name}</b>
+ {!timingMax
+ ? `没有定时发布参数;`
+ : `支持${timingMax.timeOffset}分钟后及${timingMax.maxDate}天内的定时发布;`}
+ </p>
+ );
+ })}
+ </div>
+ }
+ >
+ <ExclamationCircleOutlined />
+ </Tooltip>
+ </h2>
+ <ScheduledTimeSelect
+ maxDate={Math.min(
+ getPlatCommonParamsMax.maxDate,
+ ...getChoosedAccountPlatList.map(
+ (v) => v.commonPubParamsConfig.timingMax?.maxDate || Infinity,
+ ),
+ )}
+ timeOffset={Math.min(
+ getPlatCommonParamsMax.timeOffset,
+ ...getChoosedAccountPlatList.map(
+ (v) =>
+ v.commonPubParamsConfig.timingMax?.timeOffset || Infinity,
+ ),
+ )}
+ onChange={(e) => {
+ setPubParams({
+ timingTime: e ? e.toDate() : undefined,
+ });
+ }}
+ />
</div>
);
},
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
index c3ceaf7c..3393f261 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
@@ -1,4 +1,4 @@
-import {
+import React, {
ForwardedRef,
forwardRef,
memo,
@@ -11,6 +11,7 @@ import {
Alert,
Avatar,
Button,
+ Input,
message,
Modal,
notification,
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx
index 36040a5b..d469f103 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx
@@ -39,6 +39,7 @@ import styles from '../components/videoPubSetModalCommon.module.scss';
import { describeNumber } from '@/utils';
import { onAccountLoginFinish } from '@/icp/receiveMsg';
import UserSelect from '../components/UserSelect';
+import { AccountPlatInfoMap } from '../../../../../../account/comment';
const { TextArea } = Input;
@@ -309,7 +310,10 @@ const VideoPubSetModal_KWAI = memo(
<Input
value={currChooseAccount.pubParams.title}
showCount
- maxLength={30}
+ maxLength={
+ AccountPlatInfoMap.get(currChooseAccount.account!.type)
+ ?.commonPubParamsConfig.titleMax
+ }
placeholder="好的标题可以获得更多浏览"
variant="filled"
onChange={(e) => {
@@ -362,11 +366,7 @@ const VideoPubSetModal_KWAI = memo(
<HotspotSelect {...props} />
- <ScheduledTimeSelect
- currChooseAccount={currChooseAccount}
- tips="支持2小时后及14天内的定时发布"
- timeOffset={120}
- />
+ <ScheduledTimeSelect currChooseAccount={currChooseAccount} />
<h1>自主声明</h1>
<Select
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx
index c3474088..5950d0f1 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx
@@ -87,10 +87,7 @@ const VideoPubSetModal_KWAI = memo(
value={currChooseAccount?.pubParams.visibleType}
/>
- <ScheduledTimeSelect
- currChooseAccount={currChooseAccount}
- maxDate={13}
- />
+ <ScheduledTimeSelect currChooseAccount={currChooseAccount} />
</>
);
},
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx
index 9a83190b..131bf77c 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx
@@ -18,6 +18,7 @@ import { getSphActivity } from '@/icp/publish';
import { ipcUpdateAccountStatus } from '@/icp/account';
import { WxSphEventList } from '../../../../../../../../electron/plat/shipinhao/wxShp.type';
import UserSelect from '../components/UserSelect';
+import { AccountPlatInfoMap } from '../../../../../../account/comment';
const { TextArea } = Input;
@@ -107,7 +108,10 @@ const VideoPubSetModal_KWAI = memo(
<Input
value={currChooseAccount.pubParams.title}
showCount
- maxLength={16}
+ maxLength={
+ AccountPlatInfoMap.get(currChooseAccount.account!.type)
+ ?.commonPubParamsConfig.titleMax
+ }
placeholder="概况视频的主要内容。字数建议6-16个字符"
variant="filled"
onChange={(e) => {
@@ -226,10 +230,7 @@ const VideoPubSetModal_KWAI = memo(
声明后,作品将展示原创标记,有机会获得广告收入
</Checkbox>
- <ScheduledTimeSelect
- currChooseAccount={currChooseAccount}
- maxDate={24}
- />
+ <ScheduledTimeSelect currChooseAccount={currChooseAccount} />
</>
);
},
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx
index 280a8767..8d2bcd32 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx
@@ -11,6 +11,7 @@ import TopicSelect from '@/views/publish/children/videoPage/components/VideoPubS
import LocationSelect from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect';
import { ScheduledTimeSelect } from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon';
import UserSelect from '../components/UserSelect';
+import { AccountPlatInfoMap } from '../../../../../../account/comment';
const { TextArea } = Input;
@@ -33,7 +34,10 @@ const VideoPubSetModal_KWAI = memo(
<Input
value={currChooseAccount.pubParams.title}
showCount
- maxLength={20}
+ maxLength={
+ AccountPlatInfoMap.get(currChooseAccount.account!.type)
+ ?.commonPubParamsConfig.titleMax
+ }
placeholder="填写标题,可能会有更多赞哦"
variant="filled"
onChange={(e) => {
@@ -95,11 +99,7 @@ const VideoPubSetModal_KWAI = memo(
}}
value={currChooseAccount?.pubParams.visibleType}
/>
- <ScheduledTimeSelect
- currChooseAccount={currChooseAccount}
- tips="定时发布仅支持指定1h-14天内"
- timeOffset={60}
- />
+ <ScheduledTimeSelect currChooseAccount={currChooseAccount} />
</>
);
},
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx
index a0bc8859..8d20be7b 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx
@@ -1,10 +1,11 @@
import { AccountStatus } from '@@/AccountEnum';
import { Button, DatePicker } from 'antd';
-import React from 'react';
+import React, { useEffect } from 'react';
import { IVideoChooseItem } from '@/views/publish/children/videoPage/videoPage';
import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPageStore';
import { useShallow } from 'zustand/react/shallow';
import dayjs from 'dayjs';
+import { AccountPlatInfoMap } from '../../../../../../account/comment';
export const VideoPubRestartLogin = ({
currChooseAccount,
@@ -40,16 +41,20 @@ export const VideoPubRestartLogin = ({
// 定时发布
export const ScheduledTimeSelect = ({
currChooseAccount,
- tips,
- timeOffset = 10,
+ timeOffset = 60,
maxDate = 14,
+ value,
+ onChange,
}: {
- currChooseAccount: IVideoChooseItem;
- tips?: string;
+ currChooseAccount?: IVideoChooseItem;
// 分钟、当前时间 + 这个分钟之后的时间才可以选择
timeOffset?: number;
// 天,昨天 ~ maxDate
maxDate?: number;
+ value?: dayjs.Dayjs | null | undefined;
+ onChange?:
+ | ((date: dayjs.Dayjs, dateString: string | string[]) => void)
+ | undefined;
}) => {
const { setOnePubParams } = useVideoPageStore(
useShallow((state) => ({
@@ -57,6 +62,17 @@ export const ScheduledTimeSelect = ({
})),
);
+ useEffect(() => {
+ if (currChooseAccount) {
+ const accountPlatInfo = AccountPlatInfoMap.get(
+ currChooseAccount.account!.type,
+ )!;
+ const timingMax = accountPlatInfo.commonPubParamsConfig.timingMax;
+ timeOffset = timingMax?.timeOffset || timeOffset;
+ maxDate = timingMax?.maxDate || maxDate;
+ }
+ }, []);
+
const range = (start: number, end: number) => {
const result = [];
for (let i = start; i < end; i++) {
@@ -93,27 +109,47 @@ export const ScheduledTimeSelect = ({
return (
<>
- <h1>定时发布</h1>
+ {!onChange && <h1>定时发布</h1>}
<DatePicker
format="YYYY-MM-DD HH:mm"
disabledDate={disabledDate}
disabledTime={disabledTime}
showTime={{ defaultValue: dayjs('00:00:00', 'HH:mm:ss') }}
value={
- currChooseAccount.pubParams.timingTime
- ? dayjs(currChooseAccount.pubParams.timingTime)
- : undefined
+ value
+ ? value
+ : currChooseAccount?.pubParams.timingTime
+ ? dayjs(currChooseAccount?.pubParams.timingTime)
+ : undefined
+ }
+ onChange={
+ onChange
+ ? onChange
+ : (e) => {
+ if (!currChooseAccount) return;
+ setOnePubParams(
+ {
+ timingTime: e ? e.toDate() : undefined,
+ },
+ currChooseAccount!.id,
+ );
+ }
}
- onChange={(e) => {
- setOnePubParams(
- {
- timingTime: e ? e.toDate() : undefined,
- },
- currChooseAccount!.id,
- );
- }}
/>
- {tips && <p className="videoPubSetModal_con-tips">{tips}</p>}
+ {!onChange ? (
+ <p className="videoPubSetModal_con-tips">
+ 支持{timeOffset}分钟后及{maxDate}天内的定时发布
+ </p>
+ ) : (
+ <p
+ style={{
+ color: 'rgb(178, 185, 185)',
+ fontSize: 'var(--fs-sm)',
+ }}
+ >
+ 请选择{timeOffset}分钟后及{maxDate}天内的时间
+ </p>
+ )}
</>
);
};
diff --git a/src/views/publish/children/videoPage/components/videoCoverSeting.module.scss b/src/views/publish/children/videoPage/components/videoCoverSeting.module.scss
index 9fd67e14..64afc623 100644
--- a/src/views/publish/children/videoPage/components/videoCoverSeting.module.scss
+++ b/src/views/publish/children/videoPage/components/videoCoverSeting.module.scss
@@ -70,4 +70,4 @@
#videoCoverSetingModal--cropper {
}
}
-}
\ No newline at end of file
+}
diff --git a/src/views/publish/children/videoPage/useVideoPageStore.ts b/src/views/publish/children/videoPage/useVideoPageStore.ts
index 58a42545..40e7e220 100644
--- a/src/views/publish/children/videoPage/useVideoPageStore.ts
+++ b/src/views/publish/children/videoPage/useVideoPageStore.ts
@@ -109,7 +109,7 @@ export const useVideoPageStore = create(
// 初始化发布参数
pubParamsInit(): IPubParams {
- return lodash.cloneDeep(store.commonPubParams);
+ return lodash.cloneDeep(get().commonPubParams);
},
/**
@@ -322,12 +322,12 @@ export const useVideoPageStore = create(
const commonPubParams = { ...get().commonPubParams };
videoListChoose.map((v) => {
- for (const key in pubParmas) {
- if (pubParmas[key as 'title']) {
+ Object.keys(pubParmas).map((key) => {
+ if (pubParmas.hasOwnProperty(key)) {
v.pubParams[key as 'title'] = pubParmas[key as 'title'];
commonPubParams[key as 'title'] = pubParmas[key as 'title'];
}
- }
+ });
});
set({
videoListChoose,
diff --git a/src/views/publish/children/videoPage/video.module.scss b/src/views/publish/children/videoPage/video.module.scss
index 02a3acdf..8afc633d 100644
--- a/src/views/publish/children/videoPage/video.module.scss
+++ b/src/views/publish/children/videoPage/video.module.scss
@@ -105,6 +105,7 @@
margin-left: 20px;
padding-left: 10px;
border-left: 1px solid rgb(232, 232, 232);
+ overflow: auto;
}
&-footer {
border-top: 1px solid #ccc;
diff --git a/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx b/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx
index 5ece1d95..5588bec6 100644
--- a/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx
+++ b/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx
@@ -149,6 +149,7 @@ const PlatChoose = memo(
};
useImperativeHandle(ref, () => ({
+ // 恢复到本次操作之前的状态
recover() {
if (!choosedAccounts || choosedAccounts.length === 0)
return setChoosedAcountMap(new Map());