Skip to content

Let's use AI to Earn!

feat: 添加抖音活动接口

gaoSir40240b297e80
diff --git a/electron/db/models/video.ts b/electron/db/models/video.ts
index 4d96965a..2296f60b 100644
--- a/electron/db/models/video.ts
+++ b/electron/db/models/video.ts
@@ -35,11 +35,13 @@ export type DiffParmasType = {
[AccountType.Douyin]?: {
// 申请关联的热点
hotPoint?: ILableValue;
+ // 申请关联的活动
+ activitys?: ILableValue[];
// 自主声明
selfDeclare?: DouyinDeclareEnum;
};
[AccountType.WxSph]?: {
- // 是否未原创
+ // 是否为原创
isOriginal?: boolean;
// 扩展链接
extLink?: string;
diff --git a/electron/main/plat/platforms/douyin/index.ts b/electron/main/plat/platforms/douyin/index.ts
index 46fd37c4..8abed831 100644
--- a/electron/main/plat/platforms/douyin/index.ts
+++ b/electron/main/plat/platforms/douyin/index.ts
@@ -188,18 +188,6 @@ export class Douyin extends PlatformBase {
};
}
- // 获取热点数据
- async getHotData(query: string, cookie: Electron.Cookie[]) {
- const hotDataRes = await douyinService.getHotspotData({ query, cookie });
- return hotDataRes.data;
- }
-
- // 获取所有热点数据
- async getAllHotData() {
- const hotDataRes = await douyinService.getAllHotspotData();
- return hotDataRes.data;
- }
-
async getLocationData(params: IGetLocationDataParams) {
const locationRes = await douyinService.getLocation({
...params,
diff --git a/electron/main/plat/platforms/wxSph/index.ts b/electron/main/plat/platforms/wxSph/index.ts
index 4839ec6c..fdbd3a2d 100644
--- a/electron/main/plat/platforms/wxSph/index.ts
+++ b/electron/main/plat/platforms/wxSph/index.ts
@@ -179,15 +179,6 @@ export class WxSph extends PlatformBase {
}),
};
}
-
- // 获取商品号的活动列表
- async getActivityList(params: { cookie: Electron.Cookie[]; query: string }) {
- const activityRes = await shipinhaoService.getActivityList(params);
- return {
- status: activityRes.status,
- data: activityRes.data,
- };
- }
}
const wxSph = new WxSph();
diff --git a/electron/main/publish/controller.ts b/electron/main/publish/controller.ts
index 0dc9bf05..756a1311 100644
--- a/electron/main/publish/controller.ts
+++ b/electron/main/publish/controller.ts
@@ -17,6 +17,8 @@ import { VideoModel } from '../../db/models/video';
import platController from '../plat';
import { AccountModel } from '../../db/models/account';
import type { IGetLocationDataParams } from '../plat/plat.type';
+import { douyinService } from '../../plat/douyin';
+import { shipinhaoService } from '../../plat/shipinhao';
@Controller()
export class PublishController {
@@ -137,7 +139,7 @@ export class PublishController {
return await this.publishService.deletePubRecordById(id);
}
- // 获取话题
+ // 获取所有平台话题
@Icp('ICP_PUBLISH_GET_TOPIC')
async getTopic(
event: Electron.IpcMainInvokeEvent,
@@ -147,7 +149,7 @@ export class PublishController {
return await platController.getTopic(account, keyword);
}
- // 获取位置数据
+ // 获取所有平台位置数据
@Icp('ICP_PUBLISH_GET_LOCATION')
async getLocationData(
event: Electron.IpcMainInvokeEvent,
@@ -155,4 +157,64 @@ export class PublishController {
) {
return await platController.getLocationData(params);
}
+
+ // 获取抖音热点数据
+ @Icp('ICP_PUBLISH_GET_DOYTIN_HOT')
+ async getDoytinHot(
+ event: Electron.IpcMainInvokeEvent,
+ account: AccountModel,
+ query: string,
+ ) {
+ const res = await douyinService.getHotspotData({
+ query: query,
+ cookie: JSON.parse(account.loginCookie),
+ });
+ return res.data;
+ }
+
+ // 获取抖音所有热点数据
+ @Icp('ICP_PUBLISH_GET_ALL_DOYTIN_HOT')
+ async getDoytinHotAll(event: Electron.IpcMainInvokeEvent) {
+ const res = await douyinService.getAllHotspotData();
+ return res.data;
+ }
+
+ // 获取抖音的活动列表
+ @Icp('ICP_PUBLISH_GET_DOUYIN_ACTIVITY')
+ async getDouyinActivity(
+ event: Electron.IpcMainInvokeEvent,
+ account: AccountModel,
+ ) {
+ const res = await douyinService.getActivity(
+ JSON.parse(account.loginCookie),
+ );
+ return res.data;
+ }
+
+ // 获取抖音的活动详情
+ @Icp('ICP_PUBLISH_GET_DOUYIN_ACTIVITY_DETAILS')
+ async getDouyinActivityDetails(
+ event: Electron.IpcMainInvokeEvent,
+ account: AccountModel,
+ activity_id: string,
+ ) {
+ const res = await douyinService.getActivityDetails(
+ JSON.parse(account.loginCookie),
+ activity_id,
+ );
+ return res.data;
+ }
+
+ // 获取微信视频号的活动
+ @Icp('ICP_PUBLISH_GET_WXSPH_ACTIVITY')
+ async getSphActivity(
+ event: Electron.IpcMainInvokeEvent,
+ account: AccountModel,
+ query: string,
+ ) {
+ return await shipinhaoService.getActivityList({
+ cookie: JSON.parse(account.loginCookie),
+ query,
+ });
+ }
}
diff --git a/electron/main/publish/video/controller.ts b/electron/main/publish/video/controller.ts
index 01a0fe11..ca181b4f 100644
--- a/electron/main/publish/video/controller.ts
+++ b/electron/main/publish/video/controller.ts
@@ -18,8 +18,6 @@ import { PublishService } from '../service';
import platController from '../../plat';
import { AccountService } from '../../account/service';
import { AccountType } from '../../../../commont/AccountEnum';
-import douyin from '../../plat/platforms/douyin';
-import { AccountModel } from '../../../db/models/account';
@Controller()
export class VideoPubController {
@@ -168,22 +166,6 @@ export class VideoPubController {
await this.videoPubService.deleteVideoPulByPubRecordId(pulRecordId);
}
- // 获取抖音热点数据
- @Icp('ICP_PUBLISH_GET_DOYTIN_HOT')
- async getDoytinHot(
- event: Electron.IpcMainInvokeEvent,
- account: AccountModel,
- query: string,
- ) {
- return await douyin.getHotData(query, JSON.parse(account.loginCookie));
- }
-
- // 获取抖音所有热点数据
- @Icp('ICP_PUBLISH_GET_ALL_DOYTIN_HOT')
- async getDoytinHotAll(event: Electron.IpcMainInvokeEvent) {
- return await douyin.getAllHotData();
- }
-
// 删除发布记录
@Icp('ICP_PUBLISH_DEL_PUB_RECORD_ITEM_VIDEO')
async delPubRecordItem(
diff --git a/electron/plat/douyin/douyin.type.ts b/electron/plat/douyin/douyin.type.ts
index b7a237f0..51da5575 100644
--- a/electron/plat/douyin/douyin.type.ts
+++ b/electron/plat/douyin/douyin.type.ts
@@ -147,6 +147,35 @@ interface Cover {
url_list: string[];
}
+interface Activity {
+ activity_id: string;
+ activity_level: number;
+ activity_name: string;
+ activity_status: number;
+ activity_type: number;
+ challenge: string[];
+ challenge_ids: number[];
+ collect_id: number;
+ collect_status: boolean;
+ cover_image: string;
+ game_id: string;
+ hot_score: number;
+ if_well_chosen: boolean;
+ jump_link: string;
+ jump_type: number;
+ query_tag: number;
+ reward_type: number;
+ show_end_time: string;
+ show_start_time: string;
+}
+
+interface Video {
+ big_thumbs?: any;
+ bit_rate?: any;
+ cover: Cover;
+ duration: number;
+}
+
export interface DouyinHotSentence {
aweme_infos: any;
challenge_id: string;
@@ -166,6 +195,72 @@ export interface DouyinHotSentence {
word_type: number;
}
+interface ActivityInfo {
+ activity_id: string;
+ activity_level: number;
+ activity_name: string;
+ activity_status: number;
+ activity_type: number;
+ challenge?: any;
+ challenge_ids: number[];
+ collect_id: number;
+ collect_status: boolean;
+ cover_image: string;
+ game_id: string;
+ hot_score: number;
+ if_well_chosen: boolean;
+ jump_link: string;
+ jump_type: number;
+ post_url: string;
+ query_tag: number;
+ reward_type: number;
+ show_end_time: string;
+ show_start_time: string;
+}
+
+export interface DemoVideo {
+ aweme_id: string;
+ cha_list?: any;
+ chapter_bar_color?: any;
+ chapter_list?: any;
+ comment_list?: any;
+ geofencing?: any;
+ image_infos?: any;
+ images?: any;
+ img_bitrate?: any;
+ interaction_stickers?: any;
+ label_top_text?: any;
+ long_video?: any;
+ promotions?: any;
+ text_extra?: any;
+ video: Video;
+ video_labels?: any;
+ video_text?: any;
+}
+
+// 抖音活动详情接口的返回值
+export interface DouyinActivityDetailResponse {
+ activity_description: string;
+ activity_info: ActivityInfo;
+ demo_videos: DemoVideo[];
+ extra: Extra;
+ my_publish_videos: any;
+ other_publish_videos: any;
+ publish_end_time: string;
+ publish_start_time: string;
+ reward_rules: string;
+ status_code: number;
+ topics: string[];
+ topics_ids: string[];
+}
+
+// 抖音活动列表
+export interface DouyinActivityListResponse {
+ activity_list: Activity[];
+ extra: Extra;
+ status_code: number;
+}
+
// 抖音的热点数据
export interface DouyinHotDataResponse {
extra: Extra;
diff --git a/electron/plat/douyin/index.ts b/electron/plat/douyin/index.ts
index 522c1d4c..a6a2d886 100644
--- a/electron/plat/douyin/index.ts
+++ b/electron/plat/douyin/index.ts
@@ -8,6 +8,8 @@ import { v4 as uuidv4 } from 'uuid';
import crc32 from 'crc32';
import { CookieToString, getFileContent } from '../utils';
import {
+ DouyinActivityDetailResponse,
+ DouyinActivityListResponse,
DouyinAllHotDataResponse,
DouyinHotDataResponse,
DouyinLocationDataResponse,
@@ -2043,6 +2045,28 @@ export class DouyinService {
method: 'GET',
});
}
+
+ // 查询抖音的活动列表
+ async getActivity(cookie: Electron.Cookie[]) {
+ return await requestNet<DouyinActivityListResponse>({
+ url: `https://creator.douyin.com/web/api/media/activity/get/?page=1&size=9999`,
+ headers: {
+ cookie: CookieToString(cookie),
+ },
+ method: 'GET',
+ });
+ }
+
+ // 获取活动详情
+ async getActivityDetails(cookie: Electron.Cookie[], activity_id: string) {
+ return await requestNet<DouyinActivityDetailResponse>({
+ url: `https://creator.douyin.com/web/api/media/activity/get/?page=1&size=9999&activity_id=${activity_id}`,
+ headers: {
+ cookie: CookieToString(cookie),
+ },
+ method: 'GET',
+ });
+ }
}
// 导出服务实例
diff --git a/src/icp/publish.ts b/src/icp/publish.ts
index 9c3761b6..826cb5a3 100644
--- a/src/icp/publish.ts
+++ b/src/icp/publish.ts
@@ -18,7 +18,14 @@ import {
} from '../../electron/main/plat/plat.type';
import { AccountInfo } from '@/views/account/comment';
import { AccountModel } from '../../electron/db/models/account';
-import { DouyinAllHotDataResponse, DouyinHotDataResponse } from "../../electron/plat/douyin/douyin.type";
+import {
+ DouyinActivityDetailResponse,
+ DouyinActivityListResponse,
+ DouyinAllHotDataResponse,
+ DouyinHotDataResponse,
+} from '../../electron/plat/douyin/douyin.type';
+import { IRequestNetResult } from '../../electron/plat/requestNet';
+import { WeChatLocationData } from '../../electron/plat/shipinhao/wxShp.type';
// 创建发布记录
export async function icpCreatePubRecord(pubRecord: Partial<PubRecordModel>) {
@@ -199,3 +206,35 @@ export async function icpGetDoytinHotAll() {
);
return res;
}
+
+// 获取抖音的活动列表
+export async function icpGetDouyinActivity(account: AccountModel) {
+ const res: IRequestNetResult<DouyinActivityListResponse> =
+ await window.ipcRenderer.invoke('ICP_PUBLISH_GET_DOUYIN_ACTIVITY', account);
+ return res;
+}
+
+// 获取抖音的活动详情
+export async function getDouyinActivityDetails(
+ account: AccountModel,
+ activity_id: string,
+) {
+ const res: IRequestNetResult<DouyinActivityDetailResponse> =
+ await window.ipcRenderer.invoke(
+ 'ICP_PUBLISH_GET_DOUYIN_ACTIVITY_DETAILS',
+ account,
+ activity_id,
+ );
+ return res;
+}
+
+// 获取微信视频号的活动详情
+export async function getSphActivity(account: AccountModel, query: string) {
+ const res: IRequestNetResult<WeChatLocationData> =
+ await window.ipcRenderer.invoke(
+ 'ICP_PUBLISH_GET_WXSPH_ACTIVITY',
+ account,
+ query,
+ );
+ return res;
+}
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 45bc9674..b0a4d60d 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
@@ -15,10 +15,9 @@ import { useShallow } from 'zustand/react/shallow';
import { DouyinDeclareEnum, 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 { AccountStatus, AccountType } from '@@/AccountEnum';
+import { AccountType } from '@@/AccountEnum';
import useDebounceFetcher from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher';
import { icpGetDoytinHot, icpGetDoytinHotAll } from '@/icp/publish';
-import { ipcUpdateAccountStatus } from '@/icp/account';
import { VideoPubRestartLogin } from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon';
import { DouyinHotSentence } from '../../../../../../../../electron/plat/douyin/douyin.type';
import styles from '../components/videoPubSetModalCommon.module.scss';
@@ -27,10 +26,9 @@ import { describeNumber } from '@/utils';
const { TextArea } = Input;
const HotspotSelect = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
- const { setOnePubParams, updateAccounts } = useVideoPageStore(
+ const { setOnePubParams } = useVideoPageStore(
useShallow((state) => ({
setOnePubParams: state.setOnePubParams,
- updateAccounts: state.updateAccounts,
})),
);
const [doytinHotAll, setDoytinHotAll] = useState<DouyinHotSentence[]>([]);
@@ -43,15 +41,6 @@ const HotspotSelect = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
currChooseAccount.account!,
keywords || '',
);
- if (res.status_code !== 0) {
- currChooseAccount.account!.status = AccountStatus.DISABLE;
- updateAccounts({ accounts: [currChooseAccount.account!] });
- await ipcUpdateAccountStatus(
- currChooseAccount.account!.id,
- AccountStatus.DISABLE,
- );
- return null;
- }
return res.sentences;
});
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 5c4ef2e0..9b563215 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
@@ -3,16 +3,63 @@ import {
IVideoPubSetModalChildProps,
IVideoPubSetModalChildRef,
} from '@/views/publish/children/videoPage/components/VideoPubSetModal/videoPubSetModal.type';
-import { Checkbox, Input, Radio, Select, Tooltip } from "antd";
+import { Checkbox, Input, Radio, Select, Spin, Tooltip } from 'antd';
import { useVideoPageStore } from '@/views/publish/children/videoPage/useVideoPageStore';
import { useShallow } from 'zustand/react/shallow';
import { VisibleTypeEnum } from '@@/publish/PublishEnum';
import LocationSelect from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/LocationSelect';
import { AccountType } from '@@/AccountEnum';
import { QuestionCircleOutlined } from '@ant-design/icons';
+import { DouyinHotSentence } from '../../../../../../../../electron/plat/douyin/douyin.type';
+import useDebounceFetcher from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/useDebounceFetcher';
+import { VideoPubRestartLogin } from '@/views/publish/children/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon';
const { TextArea } = Input;
+const WXSphActivity = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
+ const { setOnePubParams } = useVideoPageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ })),
+ );
+
+ const { fetching, options, debounceFetcher } =
+ useDebounceFetcher<DouyinHotSentence>(async (keywords) => {
+ console.log(keywords);
+ });
+
+ return (
+ <>
+ <h1>申请关联热点</h1>
+ <Select
+ showSearch
+ allowClear
+ style={{ width: '100%' }}
+ placeholder="输入热点词搜索"
+ labelInValue
+ filterOption={false}
+ onSearch={debounceFetcher}
+ notFoundContent={fetching ? <Spin size="small" /> : null}
+ options={[]}
+ 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} />
+ </>
+ );
+};
+
const VideoPubSetModal_KWAI = memo(
forwardRef(
(
@@ -109,6 +156,8 @@ const VideoPubSetModal_KWAI = memo(
<LocationSelect currChooseAccount={currChooseAccount} />
+ <WXSphActivity currChooseAccount={currChooseAccount} />
+
<h1>扩展链接</h1>
<Input
placeholder="粘贴链接"
diff --git a/src/views/publish/children/videoPage/useVideoPageStore.ts b/src/views/publish/children/videoPage/useVideoPageStore.ts
index 6bb1d143..a528acf6 100644
--- a/src/views/publish/children/videoPage/useVideoPageStore.ts
+++ b/src/views/publish/children/videoPage/useVideoPageStore.ts
@@ -48,6 +48,7 @@ const store: IVideoPageStore = {
[AccountType.Douyin]: {
hotPoint: undefined,
selfDeclare: undefined,
+ activitys: [],
},
[AccountType.WxSph]: {
isOriginal: false,