Skip to content

Let's use AI to Earn!

feat: 将视频发布的话题、用户、热点、活动、位置等参数改为通用组件

gaoSirb0f5776f70e3
diff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/ImageRightSetting.tsx b/src/views/publish/children/imagePage/components/ImageRightSetting/ImageRightSetting.tsx
index da3a2ec9..4038b84e 100644
--- a/src/views/publish/children/imagePage/components/ImageRightSetting/ImageRightSetting.tsx
+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/ImageRightSetting.tsx
@@ -7,6 +7,7 @@ import { Steps } from 'antd';
import ChooseAccountModule from '../../../../components/ChooseAccountModule/ChooseAccountModule';
import { useShallow } from 'zustand/react/shallow';
import { useImagePageStore } from '../../useImagePageStore';
+import ImageParamsSet from './components/ImageParamsSet';
export interface IImageRightSettingRef {}
@@ -16,20 +17,20 @@ const ImageRightSetting = memo(
forwardRef(
({}: IImageRightSettingProps, ref: ForwardedRef<IImageRightSettingRef>) => {
const [chooseAccountOpen, setChooseAccountOpen] = useState(false);
- const { imageTextData, addAccount } = useImagePageStore(
+ const { imageAccounts, addAccount } = useImagePageStore(
useShallow((state) => ({
- imageTextData: state.imageTextData,
+ imageAccounts: state.imageAccounts,
addAccount: state.addAccount,
})),
);
return (
- <div className={styles.imageRightSetting}>
+ <>
<ChooseAccountModule
open={chooseAccountOpen}
onClose={setChooseAccountOpen}
platChooseProps={{
- choosedAccounts: imageTextData.imageAccounts
+ choosedAccounts: imageAccounts
.map((v) => v.account)
.filter((v) => v !== undefined),
pubType: PubType.ImageText,
@@ -38,35 +39,40 @@ const ImageRightSetting = memo(
addAccount(aList);
}}
/>
+ {imageAccounts.length === 0 ? (
+ <div className={styles.imageRightSetting}>
+ <SupportPlat
+ pubType={PubType.ImageText}
+ style={{ marginTop: '15px' }}
+ />
- <SupportPlat
- pubType={PubType.ImageText}
- style={{ marginTop: '15px' }}
- />
+ <h2 className="imageRightSetting-title">发布账户</h2>
+ <ChooseAccountChunk
+ onClick={() => {
+ setChooseAccountOpen(true);
+ }}
+ />
- <h2 className="imageRightSetting-title">发布账户</h2>
- <ChooseAccountChunk
- onClick={() => {
- setChooseAccountOpen(true);
- }}
- />
-
- <Steps
- direction="vertical"
- size="small"
- items={[
- {
- title: '选择发布账号',
- description: '选择将要推文的账号',
- },
- {
- title: '调整发文规则',
- description:
- '完成账号选择后,撰写推文,按需调整各个平台发文规则',
- },
- ]}
- />
- </div>
+ <Steps
+ direction="vertical"
+ size="small"
+ items={[
+ {
+ title: '选择发布账号',
+ description: '选择将要推文的账号',
+ },
+ {
+ title: '调整发文规则',
+ description:
+ '完成账号选择后,撰写推文,按需调整各个平台发文规则',
+ },
+ ]}
+ />
+ </div>
+ ) : (
+ <ImageParamsSet />
+ )}
+ </>
);
},
),
diff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx
new file mode 100644
index 00000000..78dcf7a2
--- /dev/null
+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx
@@ -0,0 +1,88 @@
+import { ForwardedRef, forwardRef, memo, useMemo, useState } from 'react';
+import { useImagePageStore } from '../../../useImagePageStore';
+import { useShallow } from 'zustand/react/shallow';
+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';
+
+export interface IImageParamsSetRef {}
+
+export interface IImageParamsSetProps {}
+
+const ImageParamsSet = memo(
+ forwardRef(
+ ({}: IImageParamsSetProps, ref: ForwardedRef<IImageParamsSetRef>) => {
+ const { imageAccounts } = useImagePageStore(
+ useShallow((state) => ({
+ imageAccounts: state.imageAccounts,
+ })),
+ );
+ // 当前选择的平台
+ const [activePlat, setActivePlat] = useState<AccountType>();
+
+ const platAccountImagesMap = useMemo(() => {
+ const platAccountMap = new Map<AccountType, IImageAccountItem[]>([]);
+ for (const imageAccount of imageAccounts) {
+ if (!platAccountMap.has(imageAccount.account.type)) {
+ platAccountMap.set(imageAccount.account.type, []);
+ }
+ platAccountMap.get(imageAccount.account.type)?.push(imageAccount);
+ }
+
+ if (!activePlat || !platAccountMap.has(activePlat)) {
+ setActivePlat(Array.from(platAccountMap)[0][0]);
+ }
+
+ return platAccountMap;
+ }, [imageAccounts]);
+
+ return (
+ <div className={styles.imageParamsSet}>
+ <div className="imageParamsSet_plats">
+ {Array.from(platAccountImagesMap).map(([accountType]) => {
+ const platInfo = AccountPlatInfoMap.get(accountType)!;
+ return (
+ <div
+ className={[
+ 'imageParamsSet_plats-item',
+ accountType === activePlat &&
+ 'imageParamsSet_plats-item--active',
+ ].join(' ')}
+ key={accountType}
+ onClick={() => {
+ setActivePlat(accountType);
+ }}
+ >
+ <div className="imageParamsSet_plats-item-img">
+ <img src={platInfo.icon} />
+ <div
+ className="imageParamsSet_plats-item-close"
+ onClick={(e) => {
+ e.stopPropagation();
+ console.log('close');
+ }}
+ >
+ <CloseOutlined />
+ </div>
+ </div>
+ <span>{platInfo.name}</span>
+ </div>
+ );
+ })}
+ </div>
+ <div className="imageParamsSet_paramsSet">
+ <h2>
+ <span>发布账号</span>
+ <i>*</i>
+ </h2>
+ </div>
+ </div>
+ );
+ },
+ ),
+);
+ImageParamsSet.displayName = 'ImageParamsSet';
+
+export default ImageParamsSet;
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
new file mode 100644
index 00000000..2b3f444c
--- /dev/null
+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/components/imageParamsSet.module.scss
@@ -0,0 +1,63 @@
+.imageParamsSet {
+ display: flex;
+ :global {
+ h2 {
+ font-size: var(--fs-md);
+ font-weight: 400;
+ display: flex;
+ align-items: center;
+ color: var(--darkGreyColor);
+ span {
+ margin-right: 5px;
+ }
+ i {
+ color: red;
+ }
+ }
+
+ .imageParamsSet_plats {
+ padding: 15px 10px;
+ border-right: 1px solid var(--superLightGreyColor);
+ margin-right: 15px;
+ &-item {
+ display: flex;
+ flex-direction: column;
+ font-size: var(--fs-xs);
+ color: var(--darkGreyColor);
+ cursor: pointer;
+ padding: 20px 15px 15px;
+ border-radius: 6px;
+ &:hover {
+ .imageParamsSet_plats-item-close {
+ display: flex !important;
+ }
+ }
+ &-img {
+ position: relative;
+ img {
+ width: 35px;
+ margin-bottom: 4px;
+ }
+ }
+ &-close {
+ position: absolute;
+ background: red;
+ color: #fff;
+ border-radius: 50%;
+ justify-content: center;
+ align-items: center;
+ width: 14px;
+ height: 14px;
+ font-size: 9px;
+ top: -7px;
+ right: -7px;
+ display: none;
+ }
+
+ &--active {
+ background: var(--colorPrimary1);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/views/publish/children/imagePage/image.module.scss b/src/views/publish/children/imagePage/image.module.scss
index 3707f0b1..934996c8 100644
--- a/src/views/publish/children/imagePage/image.module.scss
+++ b/src/views/publish/children/imagePage/image.module.scss
@@ -28,7 +28,6 @@
min-height: 0;
box-sizing: border-box;
padding: 25px 20px 0 0;
- margin-right: 20px;
border-right: 1px solid var(--superLightGreyColor);
:global {
.imageLeftSetting-upload {
@@ -63,6 +62,7 @@
}
.imageRightSetting {
+ margin-left: 20px;
:global {
.imageRightSetting-title {
text-align: left;
diff --git a/src/views/publish/children/imagePage/imagePage.type.ts b/src/views/publish/children/imagePage/imagePage.type.ts
index b12f71da..3dec2de8 100644
--- a/src/views/publish/children/imagePage/imagePage.type.ts
+++ b/src/views/publish/children/imagePage/imagePage.type.ts
@@ -2,6 +2,6 @@ import { AccountInfo } from '../../../account/comment';
import { IPubParams } from '../videoPage/videoPage';
export interface IImageAccountItem {
- account?: AccountInfo;
+ account: AccountInfo;
pubParams: IPubParams;
}
diff --git a/src/views/publish/children/imagePage/useImagePageStore.ts b/src/views/publish/children/imagePage/useImagePageStore.ts
index 5db95934..73bd332d 100644
--- a/src/views/publish/children/imagePage/useImagePageStore.ts
+++ b/src/views/publish/children/imagePage/useImagePageStore.ts
@@ -7,17 +7,13 @@ import { AccountInfo } from '../../../account/comment';
import { useVideoPageStore } from '../videoPage/useVideoPageStore';
interface IImagePageStore {
- imageTextData: {
- image: IImgFile[];
- imageAccounts: IImageAccountItem[];
- };
+ imageAccounts: IImageAccountItem[];
+ images: IImgFile[];
}
const store: IImagePageStore = {
- imageTextData: {
- image: [],
- imageAccounts: [],
- },
+ images: [],
+ imageAccounts: [],
};
const getStore = () => {
@@ -34,19 +30,39 @@ export const useImagePageStore = create(
const methods = {
// 添加账户
addAccount(accounts: AccountInfo[]) {
- const imageTextData = {
- ...get().imageTextData,
- };
+ let imageAccounts = [...get().imageAccounts];
+ // 新增账户
+ const accountSet = new Set<number>(accounts.map((v) => v.id));
+ // 已有账户
+ const existAccountSet = new Set<number>(
+ imageAccounts.map((v) => v.account.id),
+ );
+ // 要添加到数据的账户
+ const notAddAccount: AccountInfo[] = [];
+ // 过滤掉新增账户中的 已有账户
for (const account of accounts) {
- imageTextData.imageAccounts.push({
+ if (!existAccountSet.has(account.id)) notAddAccount.push(account);
+ }
+
+ /**
+ * 新增账户没有的账户
+ * 但是已有账户有,那么过滤
+ */
+ imageAccounts = imageAccounts.filter((v) =>
+ accountSet.has(v.account.id),
+ );
+
+ // 根据账户添加数据
+ for (const account of notAddAccount) {
+ imageAccounts.push({
account,
pubParams: useVideoPageStore.getState().pubParamsInit(),
});
}
set({
- imageTextData,
+ imageAccounts,
});
},
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 574fc2ae..3b9e7254 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
@@ -1,50 +1,28 @@
-import React, {
- ForwardedRef,
- forwardRef,
- memo,
- useEffect,
- useRef,
- useState,
-} from 'react';
+import React, { ForwardedRef, forwardRef, memo } from 'react';
import {
IVideoPubSetModalChildProps,
IVideoPubSetModalChildRef,
} from '@/views/publish/children/videoPage/components/VideoPubSetModal/videoPubSetModal.type';
-import { Button, Input, Modal, Radio, Select, Spin, Tooltip } from 'antd';
+import { Radio, Select } from 'antd';
import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPageStore';
import { useShallow } from 'zustand/react/shallow';
import { VisibleTypeEnum } from '@@/publish/PublishEnum';
import TopicSelect from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/TopicSelect';
import LocationSelect from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect';
import { AccountType } from '@@/AccountEnum';
-import useDebounceFetcher from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher';
-import {
- getDouyinActivityDetails,
- icpGetActivityTags,
- icpGetDouyinActivity,
- icpGetDoytinHot,
- icpGetDoytinHotAll,
-} from '@/icp/publish';
import {
DescTextArea,
ScheduledTimeSelect,
TitleInput,
VideoPubRestartLogin,
} from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon';
-import {
- DouyinActivity,
- DouyinActivityDetailResponse,
- DouyinHotSentence,
- DouyinQueryTags,
-} from '../../../../../../../../electron/plat/douyin/douyin.type';
-import styles from '../components/videoPubSetModalCommon.module.scss';
-import { describeNumber } from '@/utils';
-import { onAccountLoginFinish } from '@/icp/receiveMsg';
import UserSelect from '../components/UserSelect';
import { DeclarationDouyin } from '../../../../../../../../electron/plat/douyin/common.douyin';
-import { QuestionCircleOutlined } from '@ant-design/icons';
-
-const { TextArea } = Input;
+import {
+ CommonActivitySelect,
+ CommonHotspotSelect,
+} from '../../../../../components/CommonComponents/DouyinCommonComponents';
+import { ILableValue } from '../../../../../../../../electron/db/models/video';
const HotspotSelect = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
const { setOnePubParams } = useVideoPageStore(
@@ -52,262 +30,55 @@ const HotspotSelect = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
setOnePubParams: state.setOnePubParams,
})),
);
- const [doytinHotAll, setDoytinHotAll] = useState<DouyinHotSentence[]>([]);
- const [keywords, setKeywords] = useState('');
-
- const { fetching, options, debounceFetcher } =
- useDebounceFetcher<DouyinHotSentence>(async (keywords) => {
- setKeywords(keywords);
- const res = await icpGetDoytinHot(
- currChooseAccount.account!,
- keywords || '',
- );
- return res.sentences;
- });
-
- useEffect(() => {
- icpGetDoytinHotAll().then((res) => {
- setDoytinHotAll(res.all_sentences);
- });
- }, []);
return (
- <>
- <h1>
- 申请关联热点
- <Tooltip title="你可以申请和一个热点做关联,如果视频确实和热点非常相关,将会进入抖音热点榜,若不相关则不会生效。">
- <QuestionCircleOutlined style={{ marginLeft: '2px' }} />
- </Tooltip>
- </h1>
- <Select
- showSearch
- allowClear
- style={{ width: '100%' }}
- placeholder="输入热点词搜索"
- labelInValue
- filterOption={false}
- onSearch={debounceFetcher}
- notFoundContent={fetching ? <Spin size="small" /> : null}
- options={(!keywords ? doytinHotAll : options).map((v) => {
- return {
- ...v,
- label: v.word,
- value: v.sentence_id,
- };
- })}
- optionRender={({ data }) => {
- return (
- <div className={styles.hotspotSelect}>
- <div className="hotspotSelect-left">
- <img src={data.word_cover?.url_list[0]} />
- <span>{data.word}</span>
- </div>
- <div className="hotspotSelect-right">
- {describeNumber(data.hot_value)}在看
- </div>
- </div>
- );
- }}
- value={
- currChooseAccount.pubParams!.diffParams![AccountType.Douyin]!.hotPoint
- }
- onChange={(newValue) => {
- const newDiffParams = currChooseAccount.pubParams.diffParams!;
- newDiffParams[AccountType.Douyin]!.hotPoint = newValue;
- setOnePubParams(
- {
- diffParams: newDiffParams,
- },
- currChooseAccount.id,
- );
- }}
- />
- <VideoPubRestartLogin currChooseAccount={currChooseAccount} />
- </>
+ <CommonHotspotSelect
+ value={
+ currChooseAccount.pubParams!.diffParams![AccountType.Douyin]!.hotPoint
+ }
+ onChange={(newValue) => {
+ const newDiffParams = currChooseAccount.pubParams.diffParams!;
+ newDiffParams[AccountType.Douyin]!.hotPoint = newValue as ILableValue;
+ setOnePubParams(
+ {
+ diffParams: newDiffParams,
+ },
+ currChooseAccount.id,
+ );
+ }}
+ />
);
};
const ActivitySelect = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
- const [loading, setLoading] = useState(false);
- const [open, setOpen] = useState(false);
- const [options, setOptions] = useState<DouyinActivity[]>([]);
const { setOnePubParams } = useVideoPageStore(
useShallow((state) => ({
setOnePubParams: state.setOnePubParams,
})),
);
- // 活动标签数据
- const activityTagsMap = useRef<Map<number, DouyinQueryTags>>(new Map());
- const [activityDetails, setActivityDetails] =
- useState<DouyinActivityDetailResponse>();
-
- const init = () => {
- icpGetDouyinActivity(currChooseAccount.account!).then((res) => {
- setOptions(res.activity_list);
- });
- icpGetActivityTags(currChooseAccount.account!).then((res) => {
- res.data?.query_tags?.map((v) => {
- activityTagsMap.current.set(v.id, v);
- });
- });
- };
-
- useEffect(() => {
- init();
-
- return onAccountLoginFinish(() => {
- init();
- });
- }, []);
return (
- <>
- <Modal
- open={open}
- title="活动详情"
- footer={null}
- onCancel={() => setOpen(false)}
- >
- <Spin spinning={loading}>
- <div className={styles.activityDetails}>
- <div className="activityDetails-top">
- <div className="activityDetails-top-left">
- <div className="activityDetails-top-left-img">
- <img src={activityDetails?.activity_info.cover_image} />
- </div>
- <ul>
- <li className="activityDetails-top-left-title">
- {activityDetails?.activity_info.activity_name}
- </li>
- <li className="activityDetails-top-left-hot">
- 活动热度:{activityDetails?.activity_info.hot_score}
- </li>
- </ul>
- </div>
-
- <div className="activityDetails-top-tag">
- {
- activityTagsMap.current.get(
- activityDetails?.activity_info.query_tag || 0,
- )?.name
- }
- </div>
- </div>
-
- <div className="activityDetails-bottom">
- <h2>活动时间</h2>
- <div className="activityDetails-bottom-text">
- 活动时间:{activityDetails?.publish_start_time}-
- {activityDetails?.publish_end_time}
- </div>
- <h2>活动玩法</h2>
- <div className="activityDetails-bottom-text">
- {activityDetails?.activity_description}
- </div>
- <h2>关联话题</h2>
- <ul className="activityDetails-bottom-text">
- {activityDetails?.topics.map((v) => {
- return <li key={v}>#{v}</li>;
- })}
- </ul>
- <h2>流量奖励</h2>
- <div className="activityDetails-bottom-text">
- {activityDetails?.reward_rules
- ? JSON.parse(activityDetails?.reward_rules).text
- : ''}
- </div>
- </div>
- </div>
- </Spin>
- </Modal>
-
- <h1>
- 活动奖励
- <Tooltip title="添加活动将有机会获得流量奖励">
- <QuestionCircleOutlined style={{ marginLeft: '2px' }} />
- </Tooltip>
- </h1>
- <Select
- showSearch={false}
- allowClear
- style={{ width: '100%' }}
- placeholder="点击选择活动奖励"
- labelInValue
- mode="multiple"
- filterOption={false}
- maxCount={5 - currChooseAccount.pubParams!.topics!.length}
- optionRender={({ data }) => {
- return (
- <div className={styles.activitySelect}>
- <div className="activitySelect-left">
- <div className="activitySelect-left-img">
- <img src={data.cover_image} />
- </div>
- <ul>
- <li>{data.label}</li>
- <li>热度:{data.hot_score}</li>
- </ul>
- </div>
- <div className="activitySelect-right">
- <div className="activitySelect-right-top">
- {activityTagsMap.current.get(data.query_tag)?.name}
- </div>
- <div className="activitySelect-right-bottom">
- <span>时间:02.27~03.31</span>
- <Button
- type="link"
- onClick={async (e) => {
- e.stopPropagation();
- setOpen(true);
- setLoading(true);
- setActivityDetails(undefined);
- const res = await getDouyinActivityDetails(
- currChooseAccount.account!,
- data.activity_id,
- );
- setLoading(false);
- setActivityDetails(res);
- }}
- >
- 活动详情
- </Button>
- </div>
- </div>
- </div>
- );
- }}
- options={options?.map((v) => {
- return {
- ...v,
- label: v.activity_name,
- value: v.activity_id,
- };
- })}
- value={
- currChooseAccount.pubParams!.diffParams![AccountType.Douyin]!
- .activitys
- }
- onDropdownVisibleChange={() => {
- if (options.length === 0 && currChooseAccount.account?.status === 0) {
- init();
- }
- }}
- onChange={(newValue) => {
- const newDiffParams = currChooseAccount.pubParams.diffParams!;
- newDiffParams[AccountType.Douyin]!.activitys = newValue;
- setOnePubParams(
- {
- diffParams: newDiffParams,
- },
- currChooseAccount.id,
- );
- }}
- />
- <p className="videoPubSetModal_con-tips">
- 活动奖励 + 话题 最多不能超过五个。
- </p>
+ <CommonActivitySelect
+ account={currChooseAccount.account}
+ maxCount={5 - currChooseAccount.pubParams!.topics!.length}
+ value={
+ currChooseAccount.pubParams!.diffParams![AccountType.Douyin]!.activitys
+ }
+ onChange={(newValue) => {
+ const newDiffParams = currChooseAccount.pubParams.diffParams!;
+ newDiffParams[AccountType.Douyin]!.activitys =
+ newValue as ILableValue[];
+ console.log(newValue);
+ setOnePubParams(
+ {
+ diffParams: newDiffParams,
+ },
+ currChooseAccount.id,
+ );
+ }}
+ >
<VideoPubRestartLogin currChooseAccount={currChooseAccount} />
- </>
+ </CommonActivitySelect>
);
};
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 ad1d5e85..516fad46 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
@@ -3,7 +3,7 @@ import {
IVideoPubSetModalChildProps,
IVideoPubSetModalChildRef,
} from '@/views/publish/children/videoPage/components/VideoPubSetModal/videoPubSetModal.type';
-import { Input, Radio } from 'antd';
+import { Radio } from 'antd';
import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPageStore';
import { useShallow } from 'zustand/react/shallow';
import { VisibleTypeEnum } from '@@/publish/PublishEnum';
@@ -15,8 +15,6 @@ import {
ScheduledTimeSelect,
} from '../components/VideoPubSetModalCommon';
-const { TextArea } = Input;
-
const VideoPubSetModal_KWAI = memo(
forwardRef(
(
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 42637924..ba330a92 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
@@ -20,8 +20,6 @@ import { ipcUpdateAccountStatus } from '@/icp/account';
import { WxSphEventList } from '../../../../../../../../electron/plat/shipinhao/wxShp.type';
import UserSelect from '../components/UserSelect';
-const { TextArea } = Input;
-
const WXSphActivity = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
const { setOnePubParams, updateAccounts } = useVideoPageStore(
useShallow((state) => ({
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 6fd645d7..783b235a 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
@@ -3,7 +3,7 @@ import {
IVideoPubSetModalChildProps,
IVideoPubSetModalChildRef,
} from '@/views/publish/children/videoPage/components/VideoPubSetModal/videoPubSetModal.type';
-import { Input, Radio } from 'antd';
+import { Radio } from 'antd';
import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPageStore';
import { useShallow } from 'zustand/react/shallow';
import { VisibleTypeEnum } from '@@/publish/PublishEnum';
@@ -16,8 +16,6 @@ import {
} from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon';
import UserSelect from '../components/UserSelect';
-const { TextArea } = Input;
-
const VideoPubSetModal_KWAI = memo(
forwardRef(
(
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx
index 000e11a9..3f618e0f 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx
@@ -1,17 +1,11 @@
-import React, { useEffect, useRef } from 'react';
-import { Select, SelectProps, Spin } from 'antd';
-import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPageStore';
-import { useShallow } from 'zustand/react/shallow';
-import { icpGetLocationData } from '@/icp/publish';
-import { AccountStatus } from '@@/AccountEnum';
-import { ipcUpdateAccountStatus } from '@/icp/account';
+import React from 'react';
+import { SelectProps } from 'antd';
import { ILocationDataItem } from '../../../../../../../../electron/main/plat/plat.type';
-import useDebounceFetcher from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher';
import { IVideoChooseItem } from '@/views/publish/children/videoPage/videoPage';
-import styles from './videoPubSetModalCommon.module.scss';
// @ts-ignore
-import { icpGetLocation } from '@/icp/view';
-import { VideoPubRestartLogin } from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon';
+import CommonLocationSelect from '../../../../../components/CommonComponents/CommonLocationSelect';
+import { useVideoPageStore } from '../../../useVideoPageStore';
+import { useShallow } from 'zustand/react/shallow';
interface DebounceSelectProps<ValueType = any>
extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {
@@ -29,87 +23,23 @@ export default function LocationSelect({
updateAccounts: state.updateAccounts,
})),
);
- const { fetching, options, debounceFetcher } =
- useDebounceFetcher<ILocationDataItem>(async (keywords) => {
- if (location.current.loca.length === 0) await getLocation();
- const locationData = await icpGetLocationData({
- account: currChooseAccount.account!,
- keywords,
- latitude: location.current.loca[1],
- longitude: location.current.loca[0],
- cityName: location.current.city,
- });
- if (locationData.status !== 200 && locationData.status !== 201) {
- if (locationData.status === 401 || locationData.data === undefined) {
- currChooseAccount.account!.status = AccountStatus.DISABLE;
- updateAccounts({ accounts: [currChooseAccount.account!] });
- await ipcUpdateAccountStatus(
- currChooseAccount.account!.id,
- AccountStatus.DISABLE,
- );
- }
- return [];
- }
- return locationData.data || [];
- });
- // 位置 0=经度 1=纬度
- const location = useRef<{
- loca: number[];
- city: string;
- }>({
- loca: [],
- city: '',
- });
-
- useEffect(() => {
- getLocation();
- }, []);
-
- const getLocation = async () => {
- const res = await icpGetLocation();
- location.current.loca = res.gcj02;
- location.current.city = res.city;
- };
return (
- <>
- <h1>位置</h1>
- <Select
- showSearch
- allowClear
- style={{ width: '100%' }}
- placeholder="请选择关联位置"
- labelInValue
- filterOption={false}
- onSearch={debounceFetcher}
- notFoundContent={fetching ? <Spin size="small" /> : null}
- {...props}
- options={options?.map((v) => {
- return {
- value: v.id,
- label: v.name,
- ...v,
- };
- })}
- optionRender={({ data }) => {
- return (
- <div className={styles.locationSelect}>
- <p className="location-name">{data.name}</p>
- <p className="location-simpleAddress">{data.simpleAddress}</p>
- </div>
- );
- }}
- value={currChooseAccount.pubParams!.location as any}
- onChange={(_, value) => {
- setOnePubParams(
- {
- location: (value as ILocationDataItem) || null,
- },
- currChooseAccount.id,
- );
- }}
- />
- <VideoPubRestartLogin currChooseAccount={currChooseAccount} />
- </>
+ <CommonLocationSelect
+ {...props}
+ account={currChooseAccount.account}
+ value={currChooseAccount.pubParams!.location as any}
+ onAccountChange={(account) => {
+ updateAccounts({ accounts: [account] });
+ }}
+ onChange={(_, value) => {
+ setOnePubParams(
+ {
+ location: (value as ILocationDataItem) || null,
+ },
+ currChooseAccount.id,
+ );
+ }}
+ />
);
}
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/TopicSelect.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/TopicSelect.tsx
index 8dec4122..b13cff61 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/TopicSelect.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/TopicSelect.tsx
@@ -1,55 +1,23 @@
import React from 'react';
-import { SelectProps } from 'antd';
-import { Select, Spin } from 'antd';
-import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPageStore';
+import CommonTopicSelect, {
+ CommonTopicSelectProps,
+ CommonTopicSelectValueType,
+} from '../../../../../components/CommonComponents/CommonTopicSelect';
+import { IVideoChooseItem } from '../../../videoPage';
+import { useVideoPageStore } from '../../../useVideoPageStore';
import { useShallow } from 'zustand/react/shallow';
-import { IVideoChooseItem } from '@/views/publish/children/videoPage/videoPage';
-import { icpGetTopic } from '@/icp/publish';
-import { AccountStatus } from '@@/AccountEnum';
-import { ipcUpdateAccountStatus } from '@/icp/account';
-import useDebounceFetcher from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher';
-import { VideoPubRestartLogin } from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon';
+import { VideoPubRestartLogin } from './VideoPubSetModalCommon';
-interface DebounceSelectProps<ValueType = any>
- extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {
- tips: string;
+interface DebounceSelectProps
+ extends CommonTopicSelectProps<CommonTopicSelectValueType> {
currChooseAccount: IVideoChooseItem;
}
-type ValueType = {
- label: string;
- value: string | number;
-};
-
// 话题选择器
export default function TopicSelect({
currChooseAccount,
- tips,
...props
-}: DebounceSelectProps<ValueType>) {
- const { fetching, options, debounceFetcher } = useDebounceFetcher<ValueType>(
- async (keyword: string): Promise<ValueType[]> => {
- const topics = await icpGetTopic(currChooseAccount.account!, keyword);
- if (topics.status !== 200 && topics.status !== 201) {
- if (topics.status === 401) {
- currChooseAccount.account!.status = AccountStatus.DISABLE;
- updateAccounts({ accounts: [currChooseAccount.account!] });
- await ipcUpdateAccountStatus(
- currChooseAccount.account!.id,
- AccountStatus.DISABLE,
- );
- }
- return [];
- }
- return topics.data!.map((v) => {
- return {
- label: v.name,
- value: v.name,
- };
- }) as ValueType[];
- },
- );
-
+}: DebounceSelectProps) {
const { setOnePubParams, updateAccounts } = useVideoPageStore(
useShallow((state) => ({
setOnePubParams: state.setOnePubParams,
@@ -58,39 +26,33 @@ export default function TopicSelect({
);
return (
- <>
- <h1>话题</h1>
- <Select
- allowClear
- mode="multiple"
- style={{ width: '100%' }}
- placeholder="输入关键字搜索"
- labelInValue
- filterOption={false}
- onSearch={debounceFetcher}
- notFoundContent={fetching ? <Spin size="small" /> : null}
- {...props}
- options={options}
- value={currChooseAccount.pubParams!.topics!.map((v) => {
- return {
- value: v,
- label: v,
- };
- })}
- onChange={(newValue) => {
- setOnePubParams(
- {
- topics: (newValue as ValueType[]).map((v) => v.label),
- diffParams: {
- ...currChooseAccount.pubParams.diffParams,
- },
+ <CommonTopicSelect
+ {...props}
+ account={currChooseAccount.account}
+ value={currChooseAccount.pubParams!.topics!.map((v) => {
+ return {
+ value: v,
+ label: v,
+ };
+ })}
+ onAccountChange={(account) => {
+ updateAccounts({ accounts: [account] });
+ }}
+ onChange={(newValue) => {
+ setOnePubParams(
+ {
+ topics: (newValue as CommonTopicSelectValueType[]).map(
+ (v) => v.label,
+ ),
+ diffParams: {
+ ...currChooseAccount.pubParams.diffParams,
},
- currChooseAccount.id,
- );
- }}
- />
+ },
+ currChooseAccount.id,
+ );
+ }}
+ >
<VideoPubRestartLogin currChooseAccount={currChooseAccount} />
- <p className="videoPubSetModal_con-tips">{tips}</p>
- </>
+ </CommonTopicSelect>
);
}
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/UserSelect.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/UserSelect.tsx
index 2ab81b62..c4f89808 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/UserSelect.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/UserSelect.tsx
@@ -1,150 +1,64 @@
-import React, { useEffect } from 'react';
-import { Avatar, Select, SelectProps, Spin } from 'antd';
-import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPageStore';
-import { useShallow } from 'zustand/react/shallow';
-import { IUsersItem } from '../../../../../../../../electron/main/plat/plat.type';
-import useDebounceFetcher from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher';
import { IVideoChooseItem } from '@/views/publish/children/videoPage/videoPage';
-import styles from './videoPubSetModalCommon.module.scss';
-// @ts-ignore
-import { VideoPubRestartLogin } from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon';
-import { icpGetUsers } from '../../../../../../../icp/publish';
-import { AccountStatus } from '../../../../../../../../commont/AccountEnum';
-import { ipcUpdateAccountStatus } from '../../../../../../../icp/account';
-import { describeNumber } from '../../../../../../../utils';
-import { onAccountLoginFinish } from '../../../../../../../icp/receiveMsg';
+import CommonUserSelect, {
+ CommonUserSelectProps,
+} from '../../../../../components/CommonComponents/CommonUserSelect';
+import { IUsersItem } from '../../../../../../../../electron/main/plat/plat.type';
+import { useVideoPageStore } from '../../../useVideoPageStore';
+import { useShallow } from 'zustand/react/shallow';
+import { VideoPubRestartLogin } from './VideoPubSetModalCommon';
+import React from 'react';
-interface DebounceSelectProps<ValueType = any>
- extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {
+interface DebounceSelectProps extends CommonUserSelectProps<IUsersItem> {
currChooseAccount: IVideoChooseItem;
- tips?: string;
- title: string;
}
-// 话题选择器
+// 视频发布用户选择器
export default function UserSelect({
currChooseAccount,
...props
-}: DebounceSelectProps<IUsersItem>) {
+}: DebounceSelectProps) {
const { setOnePubParams, updateAccounts } = useVideoPageStore(
useShallow((state) => ({
setOnePubParams: state.setOnePubParams,
updateAccounts: state.updateAccounts,
})),
);
- const { fetching, options, debounceFetcher, setOptions } =
- useDebounceFetcher<IUsersItem>(async (keywords) => {
- return await getList(keywords);
- });
-
- const getList = async (keywords?: string) => {
- const res = await icpGetUsers({
- page: 1,
- keyword: keywords || '',
- account: currChooseAccount.account!,
- });
- if (res.status !== 200 && res.status !== 201) {
- if (res.status === 401) {
- currChooseAccount.account!.status = AccountStatus.DISABLE;
- updateAccounts({ accounts: [currChooseAccount.account!] });
- await ipcUpdateAccountStatus(
- currChooseAccount.account!.id,
- AccountStatus.DISABLE,
- );
- }
- return [];
- }
- return res.data || [];
- };
-
- useEffect(() => {
- if (props.showSearch === false) {
- getList().then((res) => {
- setOptions(res);
- });
-
- onAccountLoginFinish(() => {
- getList().then((res) => {
- setOptions(res);
- });
- });
- }
- }, []);
return (
- <>
- <h1>{props.title}</h1>
- <Select
- {...props}
- showSearch={
- props.hasOwnProperty('showSearch') ? props.showSearch : true
- }
- allowClear
- style={{ width: '100%' }}
- mode="multiple"
- placeholder="输入关键词搜索"
- labelInValue
- filterOption={false}
- onSearch={
- (props.hasOwnProperty('showSearch') ? props.showSearch : true)
- ? debounceFetcher
- : undefined
- }
- notFoundContent={fetching ? <Spin size="small" /> : null}
- fieldNames={{
- label: 'name',
- value: 'id',
- }}
- options={options}
- optionRender={({ data }) => {
- return (
- <div className={styles.usersSelect}>
- <Avatar src={data.image} />
- <div className="usersSelect-con">
- <div className="usersSelect-con-name">{data.name}</div>
- {(data.unique_id || data.follower_count) && (
- <div className="usersSelect-con-footer">
- <div className="usersSelect-con-footer-follower">
- 粉丝数:{describeNumber(data.follower_count || 0)}
- </div>
- {data.unique_id && (
- <div className="usersSelect-con-footer-unique">
- 抖音号:{data.unique_id}
- </div>
- )}
- </div>
- )}
- </div>
- </div>
- );
- }}
- value={
- currChooseAccount.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,
- },
- currChooseAccount.id,
- );
- }}
- />
- {props.tips && <p className="videoPubSetModal_con-tips">{props.tips}</p>}
+ <CommonUserSelect
+ {...props}
+ account={currChooseAccount.account!}
+ onAccountChange={(account) => {
+ updateAccounts({
+ accounts: [account],
+ });
+ }}
+ value={
+ currChooseAccount.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,
+ },
+ currChooseAccount.id,
+ );
+ }}
+ >
<VideoPubRestartLogin currChooseAccount={currChooseAccount} />
- </>
+ </CommonUserSelect>
);
}
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/videoPubSetModalCommon.module.scss b/src/views/publish/children/videoPage/components/VideoPubSetModal/components/videoPubSetModalCommon.module.scss
deleted file mode 100644
index 1a01bc02..00000000
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/components/videoPubSetModalCommon.module.scss
+++ /dev/null
@@ -1,163 +0,0 @@
-.locationSelect {
- :global {
- .location-name {
- margin-bottom: 2px;
- }
- .location-simpleAddress {
- font-size: var(--fs-xs);
- color: var(--lightGreyColor);
- }
- }
-}
-
-.hotspotSelect {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 3px 10px;
- :global {
- .hotspotSelect-left {
- display: flex;
- align-items: center;
- img {
- width: 35px;
- height: 35px;
- border-radius: 4px;
- object-fit: cover;
- margin-right: 10px;
- }
- }
-
- .hotspotSelect-right {
- }
- }
-}
-
-.activitySelect {
- :global {
- display: flex;
- align-items: center;
- justify-content: space-between;
- .activitySelect-left {
- display: flex;
- &-img {
- overflow: hidden;
- border-radius: 6px;
- }
- ul {
- }
- img {
- width: 35px;
- object-fit: contain;
- margin-right: 8px;
- }
- }
- .activitySelect-right {
- display: flex;
- flex-direction: column;
- align-items: end;
- &-top {
- padding: 1px 4px;
- border-radius: 6px;
- font-size: var(--fs-xs);
- margin-bottom: 6px;
- background: rgb(250, 250, 250);
- border: 1px solid #bbbbbb;
- }
- &-bottom {
- button {
- margin: 0 0 0 10px;
- padding: 0;
- height: auto;
- }
- }
- }
- }
-}
-
-.activityDetails {
- :global {
- .activityDetails-top {
- display: flex;
- justify-content: space-between;
- align-items: center;
- border-bottom: 1px solid #f1f1f1;
- padding: 30px 0;
- margin-bottom: 20px;
- &-left {
- display: flex;
- align-items: center;
- &-img {
- overflow: hidden;
- img {
- width: 50px;
- object-fit: contain;
- margin-right: 10px;
- border-radius: 6px;
- }
- }
- ul {
- display: flex;
- flex-direction: column;
- }
- &-title {
- font-weight: 900;
- font-size: var(--fs-md);
- margin-bottom: 3px;
- }
- &-hot {
- font-size: var(--fs-xs);
- color: var(--lightGreyColor);
- }
- }
-
- &-tag {
- padding: 1px 4px;
- border-radius: 6px;
- font-size: var(--fs-xs);
- margin-bottom: 6px;
- background: rgb(225, 225, 225);
- }
- }
-
- .activityDetails-bottom {
- h2 {
- font-size: var(--fs-sm);
- }
- &-text {
- color: var(--lightGreyColor);
- margin-bottom: 10px;
- }
- ul {
- li {
- margin-right: 5px;
- }
- }
- }
- }
-}
-
-.usersSelect {
- display: flex;
- padding: 3px 0;
- align-items: center;
- :global {
- .usersSelect-con {
- margin-left: 10px;
- &-name {
- font-size: var(--fs-md);
- }
- &-footer {
- margin-top: 5px;
- font-size: var(--fs-xs);
- display: flex;
- &-follower {
- color: var(--lightGreyColor);
- }
- &-unique {
- margin-left: 20px;
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/views/publish/components/CommonComponents/CommonLocationSelect.tsx b/src/views/publish/components/CommonComponents/CommonLocationSelect.tsx
new file mode 100644
index 00000000..7198623d
--- /dev/null
+++ b/src/views/publish/components/CommonComponents/CommonLocationSelect.tsx
@@ -0,0 +1,99 @@
+import React, { useEffect, useRef } from 'react';
+import { Select, SelectProps, Spin } from 'antd';
+import { icpGetLocationData } from '@/icp/publish';
+import { AccountStatus } from '@@/AccountEnum';
+import { ipcUpdateAccountStatus } from '@/icp/account';
+import { ILocationDataItem } from '@/../electron/main/plat/plat.type';
+import useDebounceFetcher from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher';
+import styles from './commonComponents.module.scss';
+import { icpGetLocation } from '@/icp/view';
+import { AccountInfo } from '../../../account/comment';
+
+interface CommonLocationSelectProps<ValueType = any>
+ extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {
+ account?: AccountInfo;
+ onAccountChange?: (account: AccountInfo) => void;
+ children?: React.ReactNode;
+}
+
+// 通用位置选择器
+export default function CommonLocationSelect({
+ children,
+ account,
+ onAccountChange,
+ ...props
+}: CommonLocationSelectProps<ILocationDataItem>) {
+ if (!account || !onAccountChange) return '';
+
+ const { fetching, options, debounceFetcher } =
+ useDebounceFetcher<ILocationDataItem>(async (keywords) => {
+ if (location.current.loca.length === 0) await getLocation();
+ const locationData = await icpGetLocationData({
+ account: account!,
+ keywords,
+ latitude: location.current.loca[1],
+ longitude: location.current.loca[0],
+ cityName: location.current.city,
+ });
+ if (locationData.status !== 200 && locationData.status !== 201) {
+ if (locationData.status === 401 || locationData.data === undefined) {
+ account!.status = AccountStatus.DISABLE;
+ onAccountChange(account);
+ await ipcUpdateAccountStatus(account!.id, AccountStatus.DISABLE);
+ }
+ return [];
+ }
+ return locationData.data || [];
+ });
+ // 位置 0=经度 1=纬度
+ const location = useRef<{
+ loca: number[];
+ city: string;
+ }>({
+ loca: [],
+ city: '',
+ });
+
+ useEffect(() => {
+ getLocation();
+ }, []);
+
+ const getLocation = async () => {
+ const res = await icpGetLocation();
+ location.current.loca = res.gcj02;
+ location.current.city = res.city;
+ };
+
+ return (
+ <>
+ <h1>位置</h1>
+ <Select
+ showSearch
+ allowClear
+ style={{ width: '100%' }}
+ placeholder="请选择关联位置"
+ labelInValue
+ filterOption={false}
+ onSearch={debounceFetcher}
+ notFoundContent={fetching ? <Spin size="small" /> : null}
+ {...props}
+ options={options?.map((v) => {
+ return {
+ value: v.id,
+ label: v.name,
+ ...v,
+ };
+ })}
+ optionRender={({ data }) => {
+ return (
+ <div className={styles.locationSelect}>
+ <p className="location-name">{data.name}</p>
+ <p className="location-simpleAddress">{data.simpleAddress}</p>
+ </div>
+ );
+ }}
+ />
+ {children}
+ </>
+ );
+}
diff --git a/src/views/publish/components/CommonComponents/CommonTopicSelect.tsx b/src/views/publish/components/CommonComponents/CommonTopicSelect.tsx
new file mode 100644
index 00000000..37af3693
--- /dev/null
+++ b/src/views/publish/components/CommonComponents/CommonTopicSelect.tsx
@@ -0,0 +1,73 @@
+import React from 'react';
+import { SelectProps } from 'antd';
+import { Select, Spin } from 'antd';
+import { icpGetTopic } from '@/icp/publish';
+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';
+
+export interface CommonTopicSelectProps<ValueType = any>
+ extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {
+ tips: string;
+ account?: AccountInfo;
+ onAccountChange?: (account: AccountInfo) => void;
+ children?: React.ReactNode;
+}
+
+export type CommonTopicSelectValueType = {
+ label: string;
+ value: string | number;
+};
+
+// 通用话题选择器
+export default function CommonTopicSelect({
+ tips,
+ children,
+ account,
+ onAccountChange,
+ ...props
+}: CommonTopicSelectProps<CommonTopicSelectValueType>) {
+ if (!account || !onAccountChange) return '';
+
+ const { fetching, options, debounceFetcher } =
+ useDebounceFetcher<CommonTopicSelectValueType>(
+ async (keyword: string): Promise<CommonTopicSelectValueType[]> => {
+ const topics = await icpGetTopic(account!, keyword);
+ if (topics.status !== 200 && topics.status !== 201) {
+ if (topics.status === 401) {
+ account!.status = AccountStatus.DISABLE;
+ onAccountChange(account);
+ await ipcUpdateAccountStatus(account!.id, AccountStatus.DISABLE);
+ }
+ return [];
+ }
+ return topics.data!.map((v) => {
+ return {
+ label: v.name,
+ value: v.name,
+ };
+ }) as CommonTopicSelectValueType[];
+ },
+ );
+
+ return (
+ <>
+ <h1>话题</h1>
+ <Select
+ allowClear
+ mode="multiple"
+ style={{ width: '100%' }}
+ placeholder="输入关键字搜索"
+ labelInValue
+ filterOption={false}
+ onSearch={debounceFetcher}
+ notFoundContent={fetching ? <Spin size="small" /> : null}
+ {...props}
+ options={options}
+ />
+ {children}
+ <p className="videoPubSetModal_con-tips">{tips}</p>
+ </>
+ );
+}
diff --git a/src/views/publish/components/CommonComponents/CommonUserSelect.tsx b/src/views/publish/components/CommonComponents/CommonUserSelect.tsx
new file mode 100644
index 00000000..0f54d636
--- /dev/null
+++ b/src/views/publish/components/CommonComponents/CommonUserSelect.tsx
@@ -0,0 +1,119 @@
+import React, { useEffect } from 'react';
+import { Avatar, Select, SelectProps, Spin } from 'antd';
+import { IUsersItem } from '@/../electron/main/plat/plat.type';
+import useDebounceFetcher from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher';
+import styles from './commonComponents.module.scss';
+import { icpGetUsers } from '@/icp/publish';
+import { AccountStatus } from '@/../commont/AccountEnum';
+import { ipcUpdateAccountStatus } from '@/icp/account';
+import { describeNumber } from '@/utils';
+import { onAccountLoginFinish } from '@/icp/receiveMsg';
+import { AccountInfo } from '../../../account/comment';
+
+export interface CommonUserSelectProps<ValueType = any>
+ extends Omit<SelectProps<ValueType | ValueType[]>, 'options' | 'children'> {
+ account?: AccountInfo;
+ tips?: string;
+ title: string;
+ children?: React.ReactNode;
+ onAccountChange?: (account: AccountInfo) => void;
+}
+
+// 通用用户选择器
+export default function CommonUserSelect({
+ account,
+ children,
+ onAccountChange,
+ ...props
+}: CommonUserSelectProps<IUsersItem>) {
+ if (!account || !onAccountChange) return '';
+
+ const { fetching, options, debounceFetcher, setOptions } =
+ useDebounceFetcher<IUsersItem>(async (keywords) => {
+ return await getList(keywords);
+ });
+
+ const getList = async (keywords?: string) => {
+ const res = await icpGetUsers({
+ page: 1,
+ keyword: keywords || '',
+ account: account,
+ });
+ if (res.status !== 200 && res.status !== 201) {
+ if (res.status === 401) {
+ account.status = AccountStatus.DISABLE;
+ onAccountChange(account);
+ await ipcUpdateAccountStatus(account.id, AccountStatus.DISABLE);
+ }
+ return [];
+ }
+ return res.data || [];
+ };
+
+ useEffect(() => {
+ if (props.showSearch === false) {
+ getList().then((res) => {
+ setOptions(res);
+ });
+
+ onAccountLoginFinish(() => {
+ getList().then((res) => {
+ setOptions(res);
+ });
+ });
+ }
+ }, []);
+
+ return (
+ <>
+ <h1>{props.title}</h1>
+ <Select
+ {...props}
+ showSearch={
+ props.hasOwnProperty('showSearch') ? props.showSearch : true
+ }
+ allowClear
+ style={{ width: '100%' }}
+ mode="multiple"
+ placeholder="输入关键词搜索"
+ labelInValue
+ filterOption={false}
+ onSearch={
+ (props.hasOwnProperty('showSearch') ? props.showSearch : true)
+ ? debounceFetcher
+ : undefined
+ }
+ notFoundContent={fetching ? <Spin size="small" /> : null}
+ fieldNames={{
+ label: 'name',
+ value: 'id',
+ }}
+ options={options}
+ optionRender={({ data }) => {
+ return (
+ <div className={styles.usersSelect}>
+ <Avatar src={data.image} />
+ <div className="usersSelect-con">
+ <div className="usersSelect-con-name">{data.name}</div>
+ {(data.unique_id || data.follower_count) && (
+ <div className="usersSelect-con-footer">
+ <div className="usersSelect-con-footer-follower">
+ 粉丝数:{describeNumber(data.follower_count || 0)}
+ </div>
+ {data.unique_id && (
+ <div className="usersSelect-con-footer-unique">
+ 抖音号:{data.unique_id}
+ </div>
+ )}
+ </div>
+ )}
+ </div>
+ </div>
+ );
+ }}
+ />
+ {children}
+ {props.tips && <p className="videoPubSetModal_con-tips">{props.tips}</p>}
+ </>
+ );
+}
diff --git a/src/views/publish/components/CommonComponents/DouyinCommonComponents.tsx b/src/views/publish/components/CommonComponents/DouyinCommonComponents.tsx
new file mode 100644
index 00000000..6b85afdd
--- /dev/null
+++ b/src/views/publish/components/CommonComponents/DouyinCommonComponents.tsx
@@ -0,0 +1,271 @@
+import React, { useEffect, useRef, useState } from 'react';
+import {
+ DouyinActivity,
+ DouyinActivityDetailResponse,
+ DouyinHotSentence,
+ DouyinQueryTags,
+} from '../../../../../electron/plat/douyin/douyin.type';
+import useDebounceFetcher from '../../children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher';
+import {
+ getDouyinActivityDetails,
+ icpGetActivityTags,
+ icpGetDouyinActivity,
+ icpGetDoytinHot,
+ icpGetDoytinHotAll,
+} from '../../../../icp/publish';
+import { Button, Modal, Select, SelectProps, Spin, Tooltip } from 'antd';
+import { QuestionCircleOutlined } from '@ant-design/icons';
+import styles from './commonComponents.module.scss';
+import { describeNumber } from '../../../../utils';
+import { onAccountLoginFinish } from '../../../../icp/receiveMsg';
+import { AccountInfo } from '../../../account/comment';
+import { ILableValue } from '../../../../../electron/db/models/video';
+
+interface DouyinCommonComponentsProps
+ extends Omit<
+ SelectProps<ILableValue[] | ILableValue>,
+ 'options' | 'children'
+ > {
+ account?: AccountInfo;
+ children?: React.ReactNode;
+}
+
+// 抖音热点
+export const CommonHotspotSelect = ({
+ account,
+ children,
+ ...props
+}: DouyinCommonComponentsProps) => {
+ if (!account) return '';
+
+ const [doytinHotAll, setDoytinHotAll] = useState<DouyinHotSentence[]>([]);
+ const [keywords, setKeywords] = useState('');
+
+ const { fetching, options, debounceFetcher } =
+ useDebounceFetcher<DouyinHotSentence>(async (keywords) => {
+ setKeywords(keywords);
+ const res = await icpGetDoytinHot(account, keywords || '');
+ return res.sentences;
+ });
+
+ useEffect(() => {
+ icpGetDoytinHotAll().then((res) => {
+ setDoytinHotAll(res.all_sentences);
+ });
+ }, []);
+
+ return (
+ <>
+ <h1>
+ 申请关联热点
+ <Tooltip title="你可以申请和一个热点做关联,如果视频确实和热点非常相关,将会进入抖音热点榜,若不相关则不会生效。">
+ <QuestionCircleOutlined style={{ marginLeft: '2px' }} />
+ </Tooltip>
+ </h1>
+ <Select
+ showSearch
+ allowClear
+ style={{ width: '100%' }}
+ placeholder="输入热点词搜索"
+ labelInValue
+ filterOption={false}
+ onSearch={debounceFetcher}
+ notFoundContent={fetching ? <Spin size="small" /> : null}
+ options={(!keywords ? doytinHotAll : options).map((v) => {
+ return {
+ ...v,
+ label: v.word,
+ value: v.sentence_id,
+ };
+ })}
+ optionRender={({ data }) => {
+ return (
+ <div className={styles.hotspotSelect}>
+ <div className="hotspotSelect-left">
+ <img src={data.word_cover?.url_list[0]} />
+ <span>{data.word}</span>
+ </div>
+ <div className="hotspotSelect-right">
+ {describeNumber(data.hot_value)}在看
+ </div>
+ </div>
+ );
+ }}
+ {...props}
+ />
+ {children}
+ </>
+ );
+};
+
+// 抖音活动
+export const CommonActivitySelect = ({
+ account,
+ children,
+ ...props
+}: DouyinCommonComponentsProps) => {
+ if (!account) return '';
+
+ const [loading, setLoading] = useState(false);
+ const [open, setOpen] = useState(false);
+ const [options, setOptions] = useState<DouyinActivity[]>([]);
+ // 活动标签数据
+ const activityTagsMap = useRef<Map<number, DouyinQueryTags>>(new Map());
+ const [activityDetails, setActivityDetails] =
+ useState<DouyinActivityDetailResponse>();
+
+ const init = () => {
+ icpGetDouyinActivity(account).then((res) => {
+ setOptions(res.activity_list);
+ });
+ icpGetActivityTags(account).then((res) => {
+ res.data?.query_tags?.map((v) => {
+ activityTagsMap.current.set(v.id, v);
+ });
+ });
+ };
+
+ useEffect(() => {
+ init();
+
+ return onAccountLoginFinish(() => {
+ init();
+ });
+ }, []);
+
+ return (
+ <>
+ <Modal
+ open={open}
+ title="活动详情"
+ footer={null}
+ onCancel={() => setOpen(false)}
+ >
+ <Spin spinning={loading}>
+ <div className={styles.activityDetails}>
+ <div className="activityDetails-top">
+ <div className="activityDetails-top-left">
+ <div className="activityDetails-top-left-img">
+ <img src={activityDetails?.activity_info.cover_image} />
+ </div>
+ <ul>
+ <li className="activityDetails-top-left-title">
+ {activityDetails?.activity_info.activity_name}
+ </li>
+ <li className="activityDetails-top-left-hot">
+ 活动热度:{activityDetails?.activity_info.hot_score}
+ </li>
+ </ul>
+ </div>
+
+ <div className="activityDetails-top-tag">
+ {
+ activityTagsMap.current.get(
+ activityDetails?.activity_info.query_tag || 0,
+ )?.name
+ }
+ </div>
+ </div>
+
+ <div className="activityDetails-bottom">
+ <h2>活动时间</h2>
+ <div className="activityDetails-bottom-text">
+ 活动时间:{activityDetails?.publish_start_time}-
+ {activityDetails?.publish_end_time}
+ </div>
+ <h2>活动玩法</h2>
+ <div className="activityDetails-bottom-text">
+ {activityDetails?.activity_description}
+ </div>
+ <h2>关联话题</h2>
+ <ul className="activityDetails-bottom-text">
+ {activityDetails?.topics.map((v) => {
+ return <li key={v}>#{v}</li>;
+ })}
+ </ul>
+ <h2>流量奖励</h2>
+ <div className="activityDetails-bottom-text">
+ {activityDetails?.reward_rules
+ ? JSON.parse(activityDetails?.reward_rules).text
+ : ''}
+ </div>
+ </div>
+ </div>
+ </Spin>
+ </Modal>
+
+ <h1>
+ 活动奖励
+ <Tooltip title="添加活动将有机会获得流量奖励">
+ <QuestionCircleOutlined style={{ marginLeft: '2px' }} />
+ </Tooltip>
+ </h1>
+ <Select
+ showSearch={false}
+ allowClear
+ style={{ width: '100%' }}
+ placeholder="点击选择活动奖励"
+ labelInValue
+ mode="multiple"
+ filterOption={false}
+ optionRender={({ data }) => {
+ return (
+ <div className={styles.activitySelect}>
+ <div className="activitySelect-left">
+ <div className="activitySelect-left-img">
+ <img src={data.cover_image} />
+ </div>
+ <ul>
+ <li>{data.label}</li>
+ <li>热度:{data.hot_score}</li>
+ </ul>
+ </div>
+ <div className="activitySelect-right">
+ <div className="activitySelect-right-top">
+ {activityTagsMap.current.get(data.query_tag)?.name}
+ </div>
+ <div className="activitySelect-right-bottom">
+ <span>时间:02.27~03.31</span>
+ <Button
+ type="link"
+ onClick={async (e) => {
+ e.stopPropagation();
+ setOpen(true);
+ setLoading(true);
+ setActivityDetails(undefined);
+ const res = await getDouyinActivityDetails(
+ account,
+ data.activity_id,
+ );
+ setLoading(false);
+ setActivityDetails(res);
+ }}
+ >
+ 活动详情
+ </Button>
+ </div>
+ </div>
+ </div>
+ );
+ }}
+ options={options?.map((v) => {
+ return {
+ ...v,
+ label: v.activity_name,
+ value: v.activity_id,
+ };
+ })}
+ onDropdownVisibleChange={() => {
+ if (options.length === 0 && account?.status === 0) {
+ init();
+ }
+ }}
+ {...props}
+ />
+ <p className="videoPubSetModal_con-tips">
+ 活动奖励 + 话题 最多不能超过五个。
+ </p>
+ {children}
+ </>
+ );
+};
diff --git a/src/views/publish/components/CommonComponents/commonComponents.module.scss b/src/views/publish/components/CommonComponents/commonComponents.module.scss
index 81295203..bca35d20 100644
--- a/src/views/publish/components/CommonComponents/commonComponents.module.scss
+++ b/src/views/publish/components/CommonComponents/commonComponents.module.scss
@@ -46,4 +46,168 @@
margin-bottom: 10px;
}
}
-}
\ No newline at end of file
+}
+
+.usersSelect {
+ display: flex;
+ padding: 3px 0;
+ align-items: center;
+ :global {
+ .usersSelect-con {
+ margin-left: 10px;
+ &-name {
+ font-size: var(--fs-md);
+ }
+ &-footer {
+ margin-top: 5px;
+ font-size: var(--fs-xs);
+ display: flex;
+ &-follower {
+ color: var(--lightGreyColor);
+ }
+ &-unique {
+ margin-left: 20px;
+ }
+ }
+ }
+ }
+}
+
+.locationSelect {
+ :global {
+ .location-name {
+ margin-bottom: 2px;
+ }
+ .location-simpleAddress {
+ font-size: var(--fs-xs);
+ color: var(--lightGreyColor);
+ }
+ }
+}
+
+.hotspotSelect {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 3px 10px;
+ :global {
+ .hotspotSelect-left {
+ display: flex;
+ align-items: center;
+ img {
+ width: 35px;
+ height: 35px;
+ border-radius: 4px;
+ object-fit: cover;
+ margin-right: 10px;
+ }
+ }
+
+ .hotspotSelect-right {
+ }
+ }
+}
+
+.activitySelect {
+ :global {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ .activitySelect-left {
+ display: flex;
+ &-img {
+ overflow: hidden;
+ border-radius: 6px;
+ }
+ ul {
+ }
+ img {
+ width: 35px;
+ object-fit: contain;
+ margin-right: 8px;
+ }
+ }
+ .activitySelect-right {
+ display: flex;
+ flex-direction: column;
+ align-items: end;
+ &-top {
+ padding: 1px 4px;
+ border-radius: 6px;
+ font-size: var(--fs-xs);
+ margin-bottom: 6px;
+ background: rgb(250, 250, 250);
+ border: 1px solid #bbbbbb;
+ }
+ &-bottom {
+ button {
+ margin: 0 0 0 10px;
+ padding: 0;
+ height: auto;
+ }
+ }
+ }
+ }
+}
+
+.activityDetails {
+ :global {
+ .activityDetails-top {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ border-bottom: 1px solid #f1f1f1;
+ padding: 30px 0;
+ margin-bottom: 20px;
+ &-left {
+ display: flex;
+ align-items: center;
+ &-img {
+ overflow: hidden;
+ img {
+ width: 50px;
+ object-fit: contain;
+ margin-right: 10px;
+ border-radius: 6px;
+ }
+ }
+ ul {
+ display: flex;
+ flex-direction: column;
+ }
+ &-title {
+ font-weight: 900;
+ font-size: var(--fs-md);
+ margin-bottom: 3px;
+ }
+ &-hot {
+ font-size: var(--fs-xs);
+ color: var(--lightGreyColor);
+ }
+ }
+
+ &-tag {
+ padding: 1px 4px;
+ border-radius: 6px;
+ font-size: var(--fs-xs);
+ margin-bottom: 6px;
+ background: rgb(225, 225, 225);
+ }
+ }
+
+ .activityDetails-bottom {
+ h2 {
+ font-size: var(--fs-sm);
+ }
+ &-text {
+ color: var(--lightGreyColor);
+ margin-bottom: 10px;
+ }
+ ul {
+ li {
+ margin-right: 5px;
+ }
+ }
+ }
+ }
+}