Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat: 图文发布前端,设置参数初版完成。
gaoSirc998007e78ef
diff --git a/electron/plat/requestNet.ts b/electron/plat/requestNet.tsindex d8869d26..8c3cc04a 100644--- a/electron/plat/requestNet.ts+++ b/electron/plat/requestNet.ts@@ -7,7 +7,7 @@ export interface IRequestNetResult<T> {}export interface IRequestNetParams {- headers?: any;+ headers: Record<string, string | string[]>;url: string;body?: any;method?: 'GET' | 'POST' | 'PUT' | 'DELETE';diff --git a/src/views/publish/children/imagePage/components/ImageLeftSetting/ImageLeftSetting.tsx b/src/views/publish/children/imagePage/components/ImageLeftSetting/ImageLeftSetting.tsxindex a351b572..f9c28590 100644--- a/src/views/publish/children/imagePage/components/ImageLeftSetting/ImageLeftSetting.tsx+++ b/src/views/publish/children/imagePage/components/ImageLeftSetting/ImageLeftSetting.tsx@@ -5,6 +5,8 @@ import localUpload from '../../../videoPage/images/localUpload.png';import ImgChoose from '../../../../../../components/Choose/ImgChoose';import { Button, Input } from 'antd';import { ArrowRightOutlined } from '@ant-design/icons';+import { useShallow } from 'zustand/react/shallow';+import { useImagePageStore } from '../../useImagePageStore';const { TextArea } = Input;@@ -15,6 +17,15 @@ export interface IImageLeftSettingProps {}const ImageLeftSetting = memo(forwardRef(({}: IImageLeftSettingProps, ref: ForwardedRef<IImageLeftSettingRef>) => {+ const { setAllPubParams, commonPubParams, setCommonPubParams } =+ useImagePageStore(+ useShallow((state) => ({+ setAllPubParams: state.setAllPubParams,+ commonPubParams: state.commonPubParams,+ setCommonPubParams: state.setCommonPubParams,+ })),+ );+return (<div className={styles.imageLeftSetting}><div className="imageLeftSetting-upload">@@ -37,18 +48,31 @@ const ImageLeftSetting = memo(<div className="imageLeftSetting-commonPar-titles"><label>通用发布设置</label><div className="imageLeftSetting-commonPar-titles-operate">- <Button icon={<ArrowRightOutlined />}>同步至右侧</Button>+ <Button+ icon={<ArrowRightOutlined />}+ onClick={() => {+ setAllPubParams({+ title: commonPubParams.title,+ describe: commonPubParams.describe,+ });+ }}+ >+ 同步至右侧+ </Button></div></div><div className="imageLeftSetting-commonPar-item"><label>一键设置标题:</label><Input+ value={commonPubParams.title}placeholder="请输入标题"showCountvariant="filled"onChange={(e) => {- console.log(e.target.value);+ setCommonPubParams({+ title: e.target.value,+ });}}/></div>@@ -59,12 +83,15 @@ const ImageLeftSetting = memo(><label>一键设置简介:</label><TextArea+ value={commonPubParams.describe}maxLength={1000}placeholder="请输入简介"showCountvariant="filled"onChange={(e) => {- console.log(e.target.value);+ setCommonPubParams({+ describe: e.target.value,+ });}}/></div>diff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsxindex 01d09878..8da6e601 100644--- a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx@@ -12,6 +12,7 @@ export interface IImageParamsSetRef {}export interface IImageParamsSetProps {}+// 图片发布右侧参数设置const ImageParamsSet = memo(forwardRef(({}: IImageParamsSetProps, ref: ForwardedRef<IImageParamsSetRef>) => {diff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageRightSettingCommon.tsx b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageRightSettingCommon.tsxindex e69de29b..15020ef6 100644--- a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageRightSettingCommon.tsx+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageRightSettingCommon.tsx@@ -0,0 +1,269 @@+// 话题选择器+import {+ ILocationDataItem,+ IUsersItem,+} from '../../../../../../../../electron/main/plat/plat.type';+import { useShallow } from 'zustand/react/shallow';+import CommonLocationSelect from '../../../../../components/CommonComponents/CommonLocationSelect';+import React from 'react';+import { Input, SelectProps, Tooltip } from 'antd';+import { useImagePageStore } from '../../../useImagePageStore';+import { useImagePlatParams } from './children/hooks/useImagePlatParams';+import CommonTopicSelect, {+ CommonTopicSelectProps,+ CommonTopicSelectValueType,+} from '../../../../../components/CommonComponents/CommonTopicSelect';+import CommonUserSelect, {+ CommonUserSelectProps,+} from '../../../../../components/CommonComponents/CommonUserSelect';+import { QuestionCircleOutlined } from '@ant-design/icons';+import CommonScheduledTimeSelect, {+ ICommonScheduledTimeSelectProps,+} from '../../../../../components/CommonComponents/CommonScheduledTimeSelect';+import dayjs from 'dayjs';++interface DebounceSelectProps<ValueType = any>+ extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {}++const { TextArea } = Input;++// 位置选择器+export const ImgTextLocationSelect = ({+ ...props+}: DebounceSelectProps<ILocationDataItem>) => {+ const { imageAccountItem } = useImagePlatParams();+ const { setOnePubParams, updateAccounts } = useImagePageStore(+ useShallow((state) => ({+ setOnePubParams: state.setOnePubParams,+ updateAccounts: state.updateAccounts,+ })),+ );++ return (+ <CommonLocationSelect+ {...props}+ account={imageAccountItem.account}+ value={imageAccountItem.pubParams!.location}+ onAccountChange={(account) => {+ updateAccounts([account]);+ }}+ onChange={(_, value) => {+ setOnePubParams(+ {+ location: (value as ILocationDataItem) || null,+ },+ imageAccountItem.account.id,+ );+ }}+ />+ );+};++// 话题选择器+export const ImgTextTopicSelect = ({ ...props }: CommonTopicSelectProps) => {+ const { imageAccountItem } = useImagePlatParams();+ const { setOnePubParams, updateAccounts } = useImagePageStore(+ useShallow((state) => ({+ setOnePubParams: state.setOnePubParams,+ updateAccounts: state.updateAccounts,+ })),+ );++ return (+ <CommonTopicSelect+ {...props}+ account={imageAccountItem.account}+ value={imageAccountItem.pubParams!.topics!.map((v) => {+ return {+ value: v,+ label: v,+ };+ })}+ onAccountChange={(account) => {+ updateAccounts([account]);+ }}+ onChange={(newValue) => {+ setOnePubParams(+ {+ topics: (newValue as CommonTopicSelectValueType[]).map(+ (v) => v.label,+ ),+ diffParams: {+ ...imageAccountItem.pubParams.diffParams,+ },+ },+ imageAccountItem.account.id,+ );+ }}+ ></CommonTopicSelect>+ );+};++// 用户选择器+export const ImgTextUserSelect = ({+ ...props+}: CommonUserSelectProps<IUsersItem>) => {+ const { imageAccountItem } = useImagePlatParams();+ const { setOnePubParams, updateAccounts } = useImagePageStore(+ useShallow((state) => ({+ setOnePubParams: state.setOnePubParams,+ updateAccounts: state.updateAccounts,+ })),+ );++ return (+ <CommonUserSelect+ {...props}+ account={imageAccountItem.account!}+ onAccountChange={(account) => {+ updateAccounts([account]);+ }}+ value={+ imageAccountItem.pubParams!.mentionedUserInfo?.map((v) => {+ return {+ ...v,+ id: v.value,+ name: v.label,+ };+ }) as any+ }+ onChange={(_, value) => {+ setOnePubParams(+ {+ mentionedUserInfo: value+ ? (value as IUsersItem[]).map((v) => {+ return {+ value: v.id,+ label: v.name,+ };+ })+ : undefined,+ },+ imageAccountItem.account.id,+ );+ }}+ />+ );+};++// 标题+export const ImgTextTitleInput = ({+ placeholder,+ tips,+ title = '标题',+ maxLength = 20,+}: {+ placeholder: string;+ tips?: string;+ title?: string;+ maxLength?: number;+}) => {+ const { imageAccountItem } = useImagePlatParams();+ const { setOnePubParams } = useImagePageStore(+ useShallow((state) => ({+ setOnePubParams: state.setOnePubParams,+ })),+ );++ return (+ <>+ <h1>+ {title}+ {tips && (+ <Tooltip title={tips}>+ <QuestionCircleOutlined style={{ marginLeft: '2px' }} />+ </Tooltip>+ )}+ </h1>+ <Input+ value={imageAccountItem.pubParams.title}+ maxLength={maxLength}+ placeholder={placeholder}+ showCount+ variant="filled"+ onChange={(e) => {+ setOnePubParams(+ {+ title: e.target.value,+ },+ imageAccountItem.account.id,+ );+ }}+ />+ </>+ );+};++// 描述+export const ImgTextDescTextArea = ({+ placeholder,+ title = '描述',+ maxLength = 1000,+}: {+ placeholder: string;+ tips?: string;+ title?: string;+ maxLength?: number;+}) => {+ const { imageAccountItem } = useImagePlatParams();+ const { setOnePubParams } = useImagePageStore(+ useShallow((state) => ({+ setOnePubParams: state.setOnePubParams,+ })),+ );++ return (+ <>+ <h1>{title}</h1>+ <TextArea+ value={imageAccountItem?.pubParams.describe}+ placeholder={placeholder}+ variant="filled"+ showCount+ maxLength={maxLength}+ autoSize={{ minRows: 6, maxRows: 6 }}+ onChange={(e) => {+ setOnePubParams(+ {+ describe: e.target.value,+ },+ imageAccountItem.account!.id,+ );+ }}+ />+ </>+ );+};++// 定时发布+export const ImgTextScheduledTimeSelect = ({+ ...props+}: ICommonScheduledTimeSelectProps) => {+ const { imageAccountItem } = useImagePlatParams();+ const { setOnePubParams } = useImagePageStore(+ useShallow((state) => ({+ setOnePubParams: state.setOnePubParams,+ })),+ );++ return (+ <CommonScheduledTimeSelect+ {...props}+ platType={imageAccountItem?.account?.type}+ value={+ imageAccountItem?.pubParams.timingTime+ ? dayjs(imageAccountItem?.pubParams.timingTime)+ : undefined+ }+ onChange={(e) => {+ if (!imageAccountItem) return;+ setOnePubParams(+ {+ timingTime: e ? e.toDate() : undefined,+ },+ imageAccountItem.account.id,+ );+ }}+ />+ );+};diff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsxindex 4f2ec333..5f27c9dd 100644--- a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx@@ -15,6 +15,7 @@ export interface IParamsSettingDetailsProps {imageAccountList: IImageAccountItem[];}+// 图文发布右侧参数设置的具体参数设置,为了防止代码冗余拆分const ParamsSettingDetails = memo(forwardRef((@@ -42,10 +43,10 @@ const ParamsSettingDetails = memo(return (<div className={styles.paramsSettingItem}>- <h2>+ <h1 style={{ marginTop: '10px' }}><span>发布账号</span><i>*</i>- </h2>+ </h1><div className="paramsSettingItem-users">{imageAccountList.map((v) => {return (diff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_Douyin.tsx b/src/views/publish/children/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_Douyin.tsxindex 6d15e329..eda8ea63 100644--- a/src/views/publish/children/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_Douyin.tsx+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_Douyin.tsx@@ -1,9 +1,31 @@import { forwardRef, memo } from 'react';import { ImageRightSettingChildProps } from '../ImageParamsSet.type';+import {+ ImgTextDescTextArea,+ ImgTextLocationSelect,+ ImgTextScheduledTimeSelect,+ ImgTextTitleInput,+ ImgTextTopicSelect,+ ImgTextUserSelect,+} from '../ImageRightSettingCommon';const ImageParamsSet_Douyin = memo(- forwardRef(({}: ImageRightSettingChildProps) => {- return <></>;+ forwardRef(({}: ImageRightSettingChildProps, _) => {+ return (+ <>+ <ImgTextTitleInput placeholder="添加作品标题" />++ <ImgTextDescTextArea placeholder="添加作品简介" />++ <ImgTextTopicSelect tips="最多可添加5个话题(包含活动奖励)" />++ <ImgTextUserSelect />++ <ImgTextLocationSelect />++ <ImgTextScheduledTimeSelect />+ </>+ );}),);ImageParamsSet_Douyin.displayName = 'ImageParamsSet_Douyin';diff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_XHS.tsx b/src/views/publish/children/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_XHS.tsxindex e5600ff6..8bfbeedc 100644--- a/src/views/publish/children/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_XHS.tsx+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_XHS.tsx@@ -1,9 +1,30 @@import { forwardRef, memo } from 'react';import { ImageRightSettingChildProps } from '../ImageParamsSet.type';+import {+ ImgTextDescTextArea,+ ImgTextLocationSelect, ImgTextScheduledTimeSelect,+ ImgTextTitleInput,+ ImgTextTopicSelect,+ ImgTextUserSelect+} from "../ImageRightSettingCommon";const ImageParamsSet_XHS = memo(- forwardRef(({}: ImageRightSettingChildProps) => {- return <></>;+ forwardRef(({}: ImageRightSettingChildProps, _) => {+ return (+ <>+ <ImgTextTitleInput placeholder="填写标题,可能会有更多赞哦" />++ <ImgTextDescTextArea placeholder="填写更全面的描述信息,让更多人看到你吧!" />++ <ImgTextTopicSelect maxLength={20} tips="您可以添加20个话题" />++ <ImgTextUserSelect />++ <ImgTextLocationSelect />++ <ImgTextScheduledTimeSelect />+ </>+ );}),);ImageParamsSet_XHS.displayName = 'ImageParamsSet_XHS';diff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/components/children/hooks/useImagePlatParams.ts b/src/views/publish/children/imagePage/components/ImageRightSetting/components/children/hooks/useImagePlatParams.tsnew file mode 100644index 00000000..8fed5f11--- /dev/null+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/components/children/hooks/useImagePlatParams.ts@@ -0,0 +1,20 @@+import { useImagePageStore } from '../../../../../useImagePageStore';+import { useShallow } from 'zustand/react/shallow';+import { useMemo } from 'react';++export function useImagePlatParams() {+ const { activePlat, platActiveAccountMap } = useImagePageStore(+ useShallow((state) => ({+ activePlat: state.activePlat,+ platActiveAccountMap: state.platActiveAccountMap,+ })),+ );++ const imageAccountItem = useMemo(() => {+ return platActiveAccountMap.get(activePlat!)!;+ }, [activePlat, platActiveAccountMap]);++ return {+ imageAccountItem,+ };+}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.scssindex 672c3bf4..a0542fd5 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@@ -56,14 +56,15 @@.paramsSettingItem {width: 100%;+ text-align: left;:global {- h2 {+ h1 {font-size: var(--fs-md);font-weight: 400;display: flex;align-items: center;color: var(--darkGreyColor);- margin-bottom: 10px;+ margin: 30px 0 10px 0;span {margin-right: 5px;}diff --git a/src/views/publish/children/imagePage/useImagePageStore.ts b/src/views/publish/children/imagePage/useImagePageStore.tsindex 70096cf7..ca0f6610 100644--- a/src/views/publish/children/imagePage/useImagePageStore.ts+++ b/src/views/publish/children/imagePage/useImagePageStore.ts@@ -6,6 +6,7 @@ import lodash from 'lodash';import { AccountInfo } from '../../../account/comment';import { useVideoPageStore } from '../videoPage/useVideoPageStore';import { AccountType } from '../../../../../commont/AccountEnum';+import { IPubParams } from '../videoPage/videoPage';interface IImagePageStore {// 账户数据和对应参数@@ -16,6 +17,7 @@ interface IImagePageStore {platActiveAccountMap: Map<AccountType, IImageAccountItem>;// 当前选择的平台activePlat?: AccountType;+ commonPubParams: IPubParams;}const store: IImagePageStore = {@@ -23,6 +25,7 @@ const store: IImagePageStore = {imageAccounts: [],platActiveAccountMap: new Map<AccountType, IImageAccountItem>(),activePlat: undefined,+ commonPubParams: useVideoPageStore.getState().pubParamsInit(),};const getStore = () => {@@ -51,6 +54,36 @@ export const useImagePageStore = create(});},+ // 设置所有参数+ setAllPubParams(pubParmas: IPubParams) {+ const imageAccounts = [...get().imageAccounts];++ imageAccounts.map((v) => {+ // 替换+ Object.keys(pubParmas).map((key) => {+ if (pubParmas.hasOwnProperty(key)) {+ v.pubParams[key as 'topics'] = pubParmas[key as 'topics'];+ }+ });+ });+ set({+ imageAccounts,+ });+ },++ // 设置通用发布参数+ setCommonPubParams(pubParmas: IPubParams) {+ const commonPubParams = { ...get().commonPubParams };+ for (const key in commonPubParams) {+ if (pubParmas.hasOwnProperty(key)) {+ commonPubParams[key as 'topics'] = pubParmas[key as 'topics'];+ }+ }+ set({+ commonPubParams,+ });+ },+// 按照账号id删除delAccountById(accountId: number) {const imageAccounts = get().imageAccounts.filter(@@ -60,6 +93,7 @@ export const useImagePageStore = create(imageAccounts,});},+// 按平台删除delAccountByPalt(accountType: AccountType) {const imageAccounts = get().imageAccounts.filter(@@ -108,6 +142,38 @@ export const useImagePageStore = create(});},+ // 设置单条数据的参数+ setOnePubParams(pubParmas: IPubParams, id: number) {+ const imageAccounts = [...get().imageAccounts];+ const findedData = imageAccounts.find((v) => v.account.id === id);+ if (!findedData) return;++ for (const key in pubParmas) {+ if (pubParmas.hasOwnProperty(key)) {+ findedData.pubParams[key as 'title'] = pubParmas[key as 'title'];+ }+ }++ set({ imageAccounts });+ },++ // 更新用户数据+ updateAccounts(accounts: AccountInfo[]) {+ const imageAccounts = [...get().imageAccounts];+ const imageTextMap = new Map<number, IImageAccountItem>();++ imageAccounts.map((v) => {+ imageTextMap.set(v.account.id || 0, v);+ });++ accounts.map((v) => {+ imageTextMap.get(v.id)!.account = v;+ });++ set({ imageAccounts });+ },++ // 清除本store所有数据clear() {set({...getStore(),diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsxindex 3f618e0f..75f579c9 100644--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx@@ -2,17 +2,17 @@ import React from 'react';import { SelectProps } from 'antd';import { ILocationDataItem } from '../../../../../../../../electron/main/plat/plat.type';import { IVideoChooseItem } from '@/views/publish/children/videoPage/videoPage';-// @ts-ignoreimport CommonLocationSelect from '../../../../../components/CommonComponents/CommonLocationSelect';import { useVideoPageStore } from '../../../useVideoPageStore';import { useShallow } from 'zustand/react/shallow';+import { VideoPubRestartLogin } from './VideoPubSetModalCommon';interface DebounceSelectProps<ValueType = any>extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {currChooseAccount: IVideoChooseItem;}-// 话题选择器+// 位置选择器export default function LocationSelect({currChooseAccount,...props@@ -28,18 +28,20 @@ export default function LocationSelect({<CommonLocationSelect{...props}account={currChooseAccount.account}- value={currChooseAccount.pubParams!.location as any}+ value={currChooseAccount.pubParams!.location}onAccountChange={(account) => {updateAccounts({ accounts: [account] });}}onChange={(_, value) => {setOnePubParams({- location: (value as ILocationDataItem) || null,+ location: value as ILocationDataItem,},currChooseAccount.id,);}}- />+ >+ <VideoPubRestartLogin currChooseAccount={currChooseAccount} />+ </CommonLocationSelect>);}diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsxindex 2e7b15fe..27fd52b3 100644--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx@@ -1,6 +1,6 @@import { AccountStatus } from '@@/AccountEnum';-import { Button, DatePicker, Input, Tooltip } from 'antd';-import React, { useEffect } from 'react';+import { Button, Input, Tooltip } from 'antd';+import React from 'react';import { IVideoChooseItem } from '@/views/publish/children/videoPage/videoPage';import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPageStore';import { useShallow } from 'zustand/react/shallow';@@ -9,6 +9,9 @@ import { AccountPlatInfoMap } from '../../../../../../account/comment';import { QuestionCircleOutlined } from '@ant-design/icons';import { AiCreateType } from '../../../../../../../api/types/tools';import AICreateTitle from '../../../../../components/AICreateTitle/AICreateTitle';+import CommonScheduledTimeSelect, {+ ICommonScheduledTimeSelectProps,+} from '../../../../../components/CommonComponents/CommonScheduledTimeSelect';const { TextArea } = Input;@@ -46,116 +49,43 @@ export const VideoPubRestartLogin = ({// 定时发布export const ScheduledTimeSelect = ({currChooseAccount,- timeOffset = 60,- maxDate = 14,- value,- onChange,-}: {- currChooseAccount?: IVideoChooseItem;- // 分钟、当前时间 + 这个分钟之后的时间才可以选择- timeOffset?: number;- // 天,昨天 ~ maxDate- maxDate?: number;- value?: dayjs.Dayjs | null | undefined;- onChange?:- | ((date: dayjs.Dayjs, dateString: string | string[]) => void)- | undefined;+ ...props+}: ICommonScheduledTimeSelectProps & {+ currChooseAccount: IVideoChooseItem;}) => {+ const { value, onChange } = props;const { setOnePubParams } = useVideoPageStore(useShallow((state) => ({setOnePubParams: state.setOnePubParams,})),);- 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++) {- result.push(i);- }- return result;- };-- const disabledDate = (current: dayjs.Dayjs) => {- const yesterday = dayjs().subtract(0, 'day').startOf('day');- const futureDate = dayjs().add(maxDate, 'day').endOf('day');- return (- current &&- (current.isBefore(yesterday, 'day') || current.isAfter(futureDate, 'day'))- );- };-- const disabledTime = (current: dayjs.Dayjs | null) => {- const now = dayjs();- const minutesOffset = now.add(timeOffset, 'minute');- if (current && current.isBefore(minutesOffset)) {- const hours = minutesOffset.hour();- const minutes = minutesOffset.minute();- return {- disabledHours: () => range(0, hours),- disabledMinutes: () => range(0, minutes),- };- }- return {- disabledHours: () => [],- disabledMinutes: () => [],- };- };-return (- <>- {!onChange && <h1>定时发布</h1>}- <DatePicker- format="YYYY-MM-DD HH:mm"- disabledDate={disabledDate}- disabledTime={disabledTime}- showTime={{ defaultValue: dayjs('00:00:00', 'HH:mm:ss') }}- value={- 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 ? (- <p className="videoPubSetModal_con-tips">- 支持{timeOffset}分钟后及{maxDate}天内的定时发布- </p>- ) : (- <p- style={{- color: 'rgb(178, 185, 185)',- fontSize: 'var(--fs-sm)',- }}- >- 请选择{timeOffset}分钟后及{maxDate}天内的时间- </p>- )}- </>+ <CommonScheduledTimeSelect+ {...props}+ platType={currChooseAccount?.account?.type}+ value={+ value+ ? value+ : currChooseAccount?.pubParams.timingTime+ ? dayjs(currChooseAccount?.pubParams.timingTime)+ : undefined+ }+ isTitle={!onChange}+ onChange={+ onChange+ ? onChange+ : (e) => {+ if (!currChooseAccount) return;+ setOnePubParams(+ {+ timingTime: e ? e.toDate() : undefined,+ },+ currChooseAccount!.id,+ );+ }+ }+ />);};diff --git a/src/views/publish/components/CommonComponents/CommonScheduledTimeSelect.tsx b/src/views/publish/components/CommonComponents/CommonScheduledTimeSelect.tsxnew file mode 100644index 00000000..7fae40cf--- /dev/null+++ b/src/views/publish/components/CommonComponents/CommonScheduledTimeSelect.tsx@@ -0,0 +1,106 @@+import React, { ForwardedRef, forwardRef, memo, useMemo } from 'react';+import dayjs from 'dayjs';+import { AccountPlatInfoMap } from '../../../account/comment';+import { DatePicker } from 'antd';+import styles from './commonComponents.module.scss';+import { AccountType } from '../../../../../commont/AccountEnum';++export interface ICommonScheduledTimeSelectRef {}++export interface ICommonScheduledTimeSelectProps {+ // 分钟、当前时间 + 这个分钟之后的时间才可以选择+ timeOffset?: number;+ // 天,昨天 ~ maxDate+ maxDate?: number;+ value?: dayjs.Dayjs | null | undefined;+ onChange?:+ | ((date: dayjs.Dayjs, dateString: string | string[]) => void)+ | undefined;+ platType?: AccountType;+ isTitle?: boolean;+}++// 通用定时发布+const CommonScheduledTimeSelect = memo(+ forwardRef(+ (+ {+ timeOffset,+ maxDate,+ value,+ onChange,+ platType,+ isTitle = true,+ }: ICommonScheduledTimeSelectProps,+ ref: ForwardedRef<ICommonScheduledTimeSelectRef>,+ ) => {+ const getMaxTimes = useMemo(() => {+ const accountPlatInfo = AccountPlatInfoMap.get(+ platType || AccountType.Douyin,+ )!;+ const timingMax = accountPlatInfo.commonPubParamsConfig.timingMax;++ return {+ timeOffset: timeOffset || timingMax!.timeOffset,+ maxDate: maxDate || timingMax!.maxDate,+ };+ }, [platType]);++ const range = (start: number, end: number) => {+ const result = [];+ for (let i = start; i < end; i++) {+ result.push(i);+ }+ return result;+ };++ const disabledDate = (current: dayjs.Dayjs) => {+ const yesterday = dayjs().subtract(0, 'day').startOf('day');+ const futureDate = dayjs().add(getMaxTimes.maxDate, 'day').endOf('day');+ return (+ current &&+ (current.isBefore(yesterday, 'day') ||+ current.isAfter(futureDate, 'day'))+ );+ };++ const disabledTime = (current: dayjs.Dayjs | null) => {+ const now = dayjs();+ const minutesOffset = now.add(getMaxTimes.timeOffset, 'minute');+ if (current && current.isBefore(minutesOffset)) {+ const hours = minutesOffset.hour();+ const minutes = minutesOffset.minute();+ return {+ disabledHours: () => range(0, hours),+ disabledMinutes: () => range(0, minutes),+ };+ }+ return {+ disabledHours: () => [],+ disabledMinutes: () => [],+ };+ };++ return (+ <>+ {isTitle && <h1>定时发布</h1>}+ <DatePicker+ format="YYYY-MM-DD HH:mm"+ disabledDate={disabledDate}+ disabledTime={disabledTime}+ showTime={{ defaultValue: dayjs('00:00:00', 'HH:mm:ss') }}+ value={value}+ onChange={onChange}+ />+ <p className={styles.tips}>+ 支持{getMaxTimes.timeOffset}分钟后及{getMaxTimes.maxDate}+ 天内的定时发布+ </p>+ </>+ );+ },+ ),+);+CommonScheduledTimeSelect.displayName = 'CommonScheduledTimeSelect';++export default CommonScheduledTimeSelect;diff --git a/src/views/publish/components/CommonComponents/CommonTopicSelect.tsx b/src/views/publish/components/CommonComponents/CommonTopicSelect.tsxindex 37af3693..14503f8e 100644--- a/src/views/publish/components/CommonComponents/CommonTopicSelect.tsx+++ b/src/views/publish/components/CommonComponents/CommonTopicSelect.tsx@@ -6,6 +6,7 @@ import { AccountStatus } from '@@/AccountEnum';import { ipcUpdateAccountStatus } from '@/icp/account';import useDebounceFetcher from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher';import { AccountInfo } from '../../../account/comment';+import styles from './commonComponents.module.scss';export interface CommonTopicSelectProps<ValueType = any>extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {@@ -67,7 +68,7 @@ export default function CommonTopicSelect({options={options}/>{children}- <p className="videoPubSetModal_con-tips">{tips}</p>+ <p className={styles.tips}>{tips}</p></>);}diff --git a/src/views/publish/components/CommonComponents/CommonUserSelect.tsx b/src/views/publish/components/CommonComponents/CommonUserSelect.tsxindex 0f54d636..f308321f 100644--- a/src/views/publish/components/CommonComponents/CommonUserSelect.tsx+++ b/src/views/publish/components/CommonComponents/CommonUserSelect.tsx@@ -14,7 +14,7 @@ export interface CommonUserSelectProps<ValueType = any>extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {account?: AccountInfo;tips?: string;- title: string;+ title?: string;children?: React.ReactNode;onAccountChange?: (account: AccountInfo) => void;}@@ -66,7 +66,7 @@ export default function CommonUserSelect({return (<>- <h1>{props.title}</h1>+ <h1>{props.title || '用户选择'}</h1><Select{...props}showSearch={diff --git a/src/views/publish/components/CommonComponents/commonComponents.module.scss b/src/views/publish/components/CommonComponents/commonComponents.module.scssindex bca35d20..7f609daf 100644--- a/src/views/publish/components/CommonComponents/commonComponents.module.scss+++ b/src/views/publish/components/CommonComponents/commonComponents.module.scss@@ -211,3 +211,9 @@}}}++.tips {+ color: rgb(178, 185, 185);+ text-align: left;+ font-size: var(--fs-sm);+}