Skip to content

Let's use AI to Earn!

feat: 修复项目中一些类型错误

gaoSir647c3d8b3bd0
diff --git a/src/api/types/task.ts b/src/api/types/task.ts
deleted file mode 100644
index bbfb4308..00000000
--- a/src/api/types/task.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * @Author: nevin
- * @Date: 2025-03-01 19:27:35
- * @LastEditTime: 2025-03-24 14:10:43
- * @LastEditors: nevin
- * @Description:
- */
-import { Task, TaskDataInfo, TaskType } from 'commont/types/task';
-import { ApiCorrectQuery } from '.';
-import { AccountType } from '@@/AccountEnum';
-
-export enum UserTaskStatus {
- DODING = 'doing', // 进行中
- PENDING = 'pending', // 待审核
- APPROVED = 'approved', // 已通过
- REJECTED = 'rejected', // 已拒绝
- COMPLETED = 'completed', // 已完成
- CANCELLED = 'cancelled', // 已取消
- // PENDING_REWARD = 'pending_reward', // 待发放奖励
- REWARDED = 'rewarded', // 已发放奖励
-}
-
-export interface TaskListParams extends ApiCorrectQuery {
- type?: TaskType;
- keyword?: string;
- productLevel?: string;
- requiresShoppingCart?: boolean;
-}
-
-export interface MineTaskListParams extends ApiCorrectQuery {
- type?: TaskType;
- keyword?: string;
- status?: UserTaskStatus;
-}
-
-export interface UserTask<T extends Task<TaskDataInfo> | string> {
- _id: string;
- id: string;
- userId: string;
- taskId: T;
- status: UserTaskStatus;
- submissionUrl?: string; // 提交的视频、文章或截图URL
- screenshotUrls?: string[]; // 任务完成截图
- qrCodeScanResult?: string; // 二维码扫描结果
- submissionTime?: string; // 提交时间
- completionTime?: string; // 完成时间
- rejectionReason?: string; // 拒绝原因
- metadata?: Record<string, any>; // 额外信息,如审核反馈等
- isFirstTimeSubmission: boolean; // 是否首次提交,用于确定是否给予首次奖励
- verificationNote?: string; // 人工核查备注
- reward: number; // 佣金金额
- rewardTime?: string; // 奖励发放时间
- keyword?: string;
- productLevel?: string;
- verifiedBy?: string; // 核查人员ID
- createTime: string;
- updateTime: string;
-}
-
-export interface ApplyTask {
- account: string;
- uid: string;
- accountType: AccountType;
- taskMaterialId?: string; // 任务素材ID
-}
-
-export interface TaskArticleImg {
- content: string;
- imageUrl: string;
-}
-
-export interface TaskMaterial {
- id: string;
- taskId: string;
- type: TaskType;
- title?: string; // 标题
- coverUrl?: string; // 封面图
- temp?: string; // 模板字符
- desc?: string;
- imageList: TaskArticleImg[];
- usedCount: number;
- createTime: string;
- updateTime: string;
-}
diff --git a/src/api/types/viralTitles.ts b/src/api/types/viralTitles.ts
index 80a4c71a..25e41c17 100644
--- a/src/api/types/viralTitles.ts
+++ b/src/api/types/viralTitles.ts
@@ -1,4 +1,4 @@
-import { Platform } from '../platform';
+import { Platform } from "@/api/hot";
export interface ViralTitle {
_id: string;
diff --git a/src/app/[lng]/material/page.tsx b/src/app/[lng]/material/page.tsx
index 58c8f3fd..87fcf593 100644
--- a/src/app/[lng]/material/page.tsx
+++ b/src/app/[lng]/material/page.tsx
@@ -24,4 +24,4 @@ export default async function Page({ params }: PageParams) {
<MaterialPageCore />
</>
);
-}
\ No newline at end of file
+}
diff --git a/src/app/[lng]/publish/components/CommonComponents/DouyinCommonComponents.tsx b/src/app/[lng]/publish/components/CommonComponents/DouyinCommonComponents.tsx
deleted file mode 100644
index ee56ed25..00000000
--- a/src/app/[lng]/publish/components/CommonComponents/DouyinCommonComponents.tsx
+++ /dev/null
@@ -1,381 +0,0 @@
-import React, { useEffect, useMemo, useRef, useState } from "react";
-import {
- DouyinActivity,
- DouyinActivityDetailResponse,
- DouyinHotSentence,
- DouyinQueryTags,
-} from "@/app/plat/platChildren/douyin/douyin.type";
-import {
- Button,
- Checkbox,
- Empty,
- message,
- Modal,
- Select,
- SelectProps,
- Spin,
- Tabs,
- Tooltip,
-} from "antd";
-import { QuestionCircleOutlined } from "@ant-design/icons";
-import styles from "./commonComponents.module.scss";
-import useDebounceFetcher from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/useDebounceFetcher";
-import { describeNumber } from "@/utils";
-import {
- AccountInfo,
- ILableValue,
-} from "@/app/[lng]/publish/videoPage/videoPage.type";
-import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";
-
-interface DouyinCommonComponentsProps
- extends Omit<SelectProps<ILableValue[]>, "options" | "children"> {
- account?: AccountInfo;
- children?: React.ReactNode;
-}
-
-interface DouyinCommonComponentsHotProps
- extends Omit<SelectProps<ILableValue>, "options" | "children"> {
- account?: AccountInfo;
- children?: React.ReactNode;
-}
-
-// 抖音热点
-export const CommonHotspotSelect = ({
- account,
- children,
- ...props
-}: DouyinCommonComponentsHotProps) => {
- if (!account) return "";
-
- const [doytinHotAll, setDoytinHotAll] = useState<DouyinHotSentence[]>([]);
- const [keywords, setKeywords] = useState("");
-
- const { fetching, options, debounceFetcher } =
- useDebounceFetcher<DouyinHotSentence>(async (keywords) => {
- // TODO icpGetDoytinHot
- // setKeywords(keywords);
- // const res = await icpGetDoytinHot(account, keywords || "");
- // return res.sentences;
- return [];
- });
-
- useEffect(() => {
- // TODO icpGetDoytinHotAll
- // 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 [detailsOpen, setDetailsOpen] = useState(false);
- const [activityOpen, setActivityOpen] = useState(false);
- const [options, setOptions] = useState<DouyinActivity[]>([]);
- const activityTagsMap = useRef<Map<number, DouyinQueryTags>>(new Map());
- // 活动标签数据
- const [activityTagList, setActivityTagList] = useState<DouyinQueryTags[]>([]);
- const [activityDetails, setActivityDetails] =
- useState<DouyinActivityDetailResponse>();
- const [activityTag, setActivityTag] = useState<string>("");
- const [value, setValue] = useState<ILableValue[]>([]);
-
- const init = () => {
- // TODO icpGetDouyinActivity and icpGetActivityTags
- // icpGetDouyinActivity(account!).then((res) => {
- // setOptions(res.activity_list || []);
- // });
- // icpGetActivityTags(account!).then((res) => {
- // if (!res.data.query_tags) return;
- // res.data?.query_tags?.map((v) => {
- // activityTagsMap.current.set(v.id, v);
- // });
- // setActivityTagList(res.data.query_tags || []);
- // setActivityTag(`${res.data.query_tags[0]?.id}`);
- // });
- };
-
- useEffect(() => {
- init();
-
- // TODO onAccountLoginFinish
- // return onAccountLoginFinish((newAccount) => {
- // account = newAccount;
- // init();
- // });
- }, []);
-
- const selection = (data: DouyinActivity) => {
- if (value?.some((v) => v.value === data.activity_id)) {
- setValue(value?.filter((v) => v.value !== data.activity_id));
- } else {
- setValue([
- ...(value || []),
- {
- label: data.activity_name,
- value: data.activity_id,
- },
- ]);
- }
- };
-
- useEffect(() => {
- setValue(props.value || []);
- }, [props.value]);
-
- const closeSelectActivity = () => {
- setActivityOpen(false);
- setValue(props.value || []);
- };
-
- // 选择标签筛选后的数据
- const tagActivityData = useMemo(() => {
- return options?.filter((v) => v.query_tag === +activityTag);
- }, [activityTag, options]);
-
- return (
- <>
- <Modal
- open={detailsOpen}
- title="活动详情"
- footer={null}
- onCancel={() => setDetailsOpen(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>
-
- <Modal
- title="选择活动"
- width={700}
- open={activityOpen}
- onCancel={closeSelectActivity}
- onOk={() => {
- if (value.length > props.maxCount!) {
- message.warning(
- `话题和活动最多可添加 ${AccountPlatInfoMap.get(PlatType.Douyin)?.commonPubParamsConfig.topicMax} 个`,
- );
- } else {
- setActivityOpen(false);
- if (props.onChange) props.onChange(value);
- }
- }}
- >
- <Tabs
- activeKey={activityTag}
- onChange={setActivityTag}
- type="card"
- items={activityTagList?.map((v) => {
- return {
- key: `${v.id}`,
- label: v.name,
- };
- })}
- />
- {tagActivityData && tagActivityData.length !== 0 ? (
- tagActivityData?.map((data) => {
- return (
- <div
- className={styles.activitySelect}
- onClick={() => {
- selection(data);
- }}
- key={data.activity_id}
- >
- <div className="activitySelect-left">
- <Checkbox
- checked={value?.some((v) => v.value === data.activity_id)}
- onClick={(e) => {
- e.stopPropagation();
- }}
- onChange={(e) => {
- selection(data);
- }}
- />
- <div className="activitySelect-left-img">
- <img src={data.cover_image} />
- </div>
- <ul>
- <li>{data.activity_name}</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();
- setDetailsOpen(true);
- setLoading(true);
- setActivityDetails(undefined);
- // TODO getDouyinActivityDetails
- // const res = await getDouyinActivityDetails(
- // account!,
- // data.activity_id,
- // );
- setLoading(false);
- // setActivityDetails(res);
- }}
- >
- 活动详情
- </Button>
- </div>
- </div>
- </div>
- );
- })
- ) : (
- <Empty />
- )}
- </Modal>
-
- <h1>
- 活动奖励
- <Tooltip title="添加活动将有机会获得流量奖励">
- <QuestionCircleOutlined style={{ marginLeft: "2px" }} />
- </Tooltip>
- </h1>
- <Select
- showSearch={false}
- allowClear
- style={{ width: "100%" }}
- placeholder="点击选择活动奖励"
- labelInValue
- mode="multiple"
- filterOption={false}
- onClick={(e) => {
- e.preventDefault();
- e.stopPropagation();
- setActivityOpen(true);
- }}
- dropdownRender={() => {
- const customDropdownRef = useRef<HTMLDivElement>(null);
- if (customDropdownRef.current) {
- (
- customDropdownRef.current.parentNode!.parentNode as HTMLDivElement
- ).style.display = "none";
- }
- return <div ref={customDropdownRef} />;
- }}
- 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={styles.tips}>活动奖励 + 话题 最多不能超过五个。</p>
- {children}
- </>
- );
-};
diff --git a/src/app/[lng]/publish/components/PubAccountDetModule/PubAccountDetModule.tsx b/src/app/[lng]/publish/components/PubAccountDetModule/PubAccountDetModule.tsx
index 613211d0..89bd033b 100644
--- a/src/app/[lng]/publish/components/PubAccountDetModule/PubAccountDetModule.tsx
+++ b/src/app/[lng]/publish/components/PubAccountDetModule/PubAccountDetModule.tsx
@@ -63,14 +63,14 @@ const PubAccountDetModule = memo(
const [open, setOpen] = useState(false);
const [detLoading, setDetLoading] = useState(false);
// 失效 ids
- const [disabledIdSet, setDisabledIdSet] = useState<Set<number>>(
+ const [disabledIdSet, setDisabledIdSet] = useState<Set<string>>(
new Set([]),
);
const [progress, setProgress] = useState(0);
const [isFilterAccountOl, setIsFilterAccountOl] = useState(false);
// 代理失效的账户组Map
const [proxyInvalidAccountMap, setProxyInvalidAccountMap] = useState<
- Map<number, AccountGroupItem>
+ Map<string, AccountGroupItem>
>(new Map());
const { accountGroupMap, getAccountList } = useAccountStore(
useShallow((state) => ({
diff --git a/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx
index 5142d0f9..f2dae336 100644
--- a/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx
+++ b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx
@@ -2,8 +2,6 @@ import { ForwardedRef, forwardRef, memo, useMemo } from "react";
import styles from "./imageParamsSet.module.scss";
import { CloseOutlined, PlusOutlined } from "@ant-design/icons";
import { Alert, Avatar, Tooltip } from "antd";
-import ImageParamsSet_Douyin from "./children/ImageParamsSet_Douyin";
-import ImageParamsSet_XHS from "./children/ImageParamsSet_XHS";
import { IImageAccountItem } from "../../../imagePage.type";
import { useImagePageStore } from "../../../useImagePageStore";
import { useShallow } from "zustand/react/shallow";
@@ -136,14 +134,14 @@ const ParamsSettingDetails = memo(
id={currAccountItem?.account.id}
/>
- {(() => {
- switch (activePlat) {
- case PlatType.Douyin:
- return <ImageParamsSet_Douyin />;
- case PlatType.Xhs:
- return <ImageParamsSet_XHS />;
- }
- })()}
+ {/*{(() => {*/}
+ {/* switch (activePlat) {*/}
+ {/* case PlatType.Douyin:*/}
+ {/* return <ImageParamsSet_Douyin />;*/}
+ {/* case PlatType.Xhs:*/}
+ {/* return <ImageParamsSet_XHS />;*/}
+ {/* }*/}
+ {/*})()}*/}
</div>
);
},
diff --git a/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_Douyin.tsx b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_Douyin.tsx
deleted file mode 100644
index 33f73d14..00000000
--- a/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_Douyin.tsx
+++ /dev/null
@@ -1,124 +0,0 @@
-import React, { forwardRef, memo } from "react";
-import { ImageRightSettingChildProps } from "../ImageParamsSet.type";
-import {
- ImgTextDescTextArea,
- ImgTextLocationSelect,
- ImgTextMixSelect,
- ImgTextPubPermission,
- ImgTextPubRestartLogin,
- ImgTextScheduledTimeSelect,
- ImgTextTitleInput,
- ImgTextTopicSelect,
- ImgTextUserSelect,
-} from "../ImageRightSettingCommon";
-import { useShallow } from "zustand/react/shallow";
-import { useImagePlatParams } from "./hooks/useImagePlatParams";
-import { useImagePageStore } from "../../../../useImagePageStore";
-import {
- CommonActivitySelect,
- CommonHotspotSelect,
-} from "@/app/[lng]/publish/components/CommonComponents/DouyinCommonComponents";
-import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";
-import { ILableValue } from "@/app/[lng]/publish/videoPage/videoPage.type";
-
-const HotspotSelect = () => {
- const { imageAccountItem } = useImagePlatParams();
- const { setOnePubParams } = useImagePageStore(
- useShallow((state) => ({
- setOnePubParams: state.setOnePubParams,
- })),
- );
-
- return (
- <CommonHotspotSelect
- account={imageAccountItem.account}
- value={imageAccountItem.pubParams!.diffParams![PlatType.Douyin]!.hotPoint}
- onChange={(newValue) => {
- const newDiffParams = imageAccountItem.pubParams.diffParams!;
- newDiffParams[PlatType.Douyin]!.hotPoint = newValue as ILableValue;
- setOnePubParams(
- {
- diffParams: newDiffParams,
- },
- imageAccountItem.account.id,
- );
- }}
- />
- );
-};
-
-const ActivitySelect = () => {
- const { imageAccountItem } = useImagePlatParams();
- const { setOnePubParams } = useImagePageStore(
- useShallow((state) => ({
- setOnePubParams: state.setOnePubParams,
- })),
- );
- const { topicMax } = AccountPlatInfoMap.get(
- imageAccountItem.account.type,
- )!.commonPubParamsConfig;
-
- return (
- <CommonActivitySelect
- account={imageAccountItem.account}
- maxCount={topicMax - imageAccountItem.pubParams!.topics!.length}
- value={
- imageAccountItem.pubParams!.diffParams![PlatType.Douyin]!.activitys
- }
- onChange={(newValue) => {
- const newDiffParams = imageAccountItem.pubParams.diffParams!;
- newDiffParams[PlatType.Douyin]!.activitys = newValue as ILableValue[];
- setOnePubParams(
- {
- diffParams: newDiffParams,
- },
- imageAccountItem.account.id,
- );
- }}
- >
- <ImgTextPubRestartLogin />
- </CommonActivitySelect>
- );
-};
-
-const ImageParamsSet_Douyin = memo(
- forwardRef(({}: ImageRightSettingChildProps, _) => {
- const { imageAccountItem } = useImagePlatParams();
- const { topicMax } = AccountPlatInfoMap.get(
- imageAccountItem.account.type,
- )!.commonPubParamsConfig;
- return (
- <>
- <ImgTextTitleInput placeholder="添加作品标题" />
-
- <ImgTextDescTextArea placeholder="添加作品简介" />
-
- <ImgTextTopicSelect
- maxCount={
- topicMax -
- imageAccountItem.pubParams!.diffParams![PlatType.Douyin]!.activitys!
- .length
- }
- tips="最多可添加5个话题(包含活动奖励)"
- />
-
- <ActivitySelect />
-
- <ImgTextUserSelect maxCount={100} tips="您可以添加100个好友" />
-
- <HotspotSelect />
-
- <ImgTextLocationSelect />
-
- <ImgTextMixSelect />
-
- <ImgTextPubPermission />
-
- <ImgTextScheduledTimeSelect />
- </>
- );
- }),
-);
-ImageParamsSet_Douyin.displayName = "ImageParamsSet_Douyin";
-
-export default ImageParamsSet_Douyin;
diff --git a/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_XHS.tsx b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_XHS.tsx
deleted file mode 100644
index 2c12afdb..00000000
--- a/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_XHS.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import React, { forwardRef, memo } from "react";
-import { ImageRightSettingChildProps } from "../ImageParamsSet.type";
-import {
- ImgTextDescTextArea,
- ImgTextLocationSelect,
- ImgTextPubPermission,
- ImgTextScheduledTimeSelect,
- ImgTextTitleInput,
- ImgTextTopicSelect,
- ImgTextUserSelect,
-} from "../ImageRightSettingCommon";
-
-const ImageParamsSet_XHS = memo(
- forwardRef(({}: ImageRightSettingChildProps, _) => {
- return (
- <>
- <ImgTextTitleInput placeholder="填写标题,可能会有更多赞哦" />
-
- <ImgTextDescTextArea placeholder="填写更全面的描述信息,让更多人看到你吧!" />
-
- <ImgTextTopicSelect />
-
- <ImgTextUserSelect />
-
- <ImgTextLocationSelect />
-
- <ImgTextPubPermission />
-
- <ImgTextScheduledTimeSelect />
- </>
- );
- }),
-);
-ImageParamsSet_XHS.displayName = "ImageParamsSet_XHS";
-
-export default ImageParamsSet_XHS;
diff --git a/src/app/[lng]/publish/imagePage/page.tsx b/src/app/[lng]/publish/imagePage/page.tsx
index 5f746d31..b0898f76 100644
--- a/src/app/[lng]/publish/imagePage/page.tsx
+++ b/src/app/[lng]/publish/imagePage/page.tsx
@@ -71,7 +71,7 @@ export default function Page() {
const [pubProgressModuleOpen, setPubProgressModuleOpen] = useState(false);
// 主进程传过来的发布进度数据,key为用户id value为发布进度数据
const [pubProgressMap, setPubProgressMap] = useState<
- Map<number, PublishProgressRes>
+ Map<string, PublishProgressRes>
>(new Map());
// 敏感词检测
const [sensitiveDetLoading, setSensitiveDetLoading] = useState(false);
@@ -287,7 +287,7 @@ export default function Page() {
for (const [key, errVideoItem] of errParamsMap) {
if (errVideoItem) {
const imageAccount = imageAccounts.find(
- (v) => v.account.id === +key,
+ (v) => v.account.id === key,
)!;
const platType = imageAccount!.account.type;
const platActiveAccountMap = new Map(
diff --git a/src/app/[lng]/publish/imagePage/useImagePageStore.ts b/src/app/[lng]/publish/imagePage/useImagePageStore.ts
index a4da1ede..7dec80ca 100644
--- a/src/app/[lng]/publish/imagePage/useImagePageStore.ts
+++ b/src/app/[lng]/publish/imagePage/useImagePageStore.ts
@@ -182,7 +182,7 @@ export const useImagePageStore = create(
},
// 按照账号id删除
- delAccountById(accountId: number) {
+ delAccountById(accountId: string) {
const imageAccounts = get().imageAccounts.filter(
(v) => v.account.id !== accountId,
);
@@ -205,9 +205,9 @@ export const useImagePageStore = create(
addAccount(accounts: AccountInfo[]) {
let imageAccounts = [...get().imageAccounts];
// 新增账户
- const accountSet = new Set<number>(accounts.map((v) => v.id));
+ const accountSet = new Set<string>(accounts.map((v) => v.id));
// 已有账户
- const existAccountSet = new Set<number>(
+ const existAccountSet = new Set<string>(
imageAccounts.map((v) => v.account.id),
);
// 要添加到数据的账户
@@ -240,7 +240,7 @@ export const useImagePageStore = create(
},
// 设置单条数据的参数
- setOnePubParams(pubParmas: IPubParams, id: number) {
+ setOnePubParams(pubParmas: IPubParams, id: string) {
const imageAccounts = [...get().imageAccounts];
const findedData = imageAccounts.find((v) => v.account.id === id);
if (!findedData) return;
@@ -257,10 +257,10 @@ export const useImagePageStore = create(
// 更新用户数据
updateAccounts(accounts: AccountInfo[]) {
const imageAccounts = [...get().imageAccounts];
- const imageTextMap = new Map<number, IImageAccountItem>();
+ const imageTextMap = new Map<string, IImageAccountItem>();
imageAccounts.map((v) => {
- imageTextMap.set(v.account.id || 0, v);
+ imageTextMap.set(v.account.id || "0", v);
});
accounts.map((v) => {
diff --git a/src/app/[lng]/publish/pubRecord/page.tsx b/src/app/[lng]/publish/pubRecord/page.tsx
index 061d260e..43722af2 100644
--- a/src/app/[lng]/publish/pubRecord/page.tsx
+++ b/src/app/[lng]/publish/pubRecord/page.tsx
@@ -1,12 +1,26 @@
"use client";
-import { useEffect, useMemo, useState } from 'react';
-import styles from './pubRecord.module.scss';
-import { apiGetPublishList, PubStatus, AccountType } from '@/api/publish';
-import { Button, Image, Select, Table, TableProps, Tag, Modal, Descriptions, Avatar, Space, Typography } from 'antd';
-import { formatTime } from '@/utils';
-import { PubType } from '@/app/config/publishConfig';
-import { AccountPlatInfoMap, PlatType } from '@/app/config/platConfig';
+import { useEffect, useMemo, useState } from "react";
+import styles from "./pubRecord.module.scss";
+import { apiGetPublishList, PubStatus, AccountType } from "@/api/publish";
+import {
+ Button,
+ Image,
+ Select,
+ Table,
+ TableProps,
+ Tag,
+ Modal,
+ Descriptions,
+ Typography,
+} from "antd";
+import { formatTime } from "@/utils";
+import { PubType } from "@/app/config/publishConfig";
+import { PubRecordStatusTag } from "@/app/layout/BellMessage";
+import {
+ ImageView,
+ PlatformView,
+} from "@/app/[lng]/publish/pubRecord/pubRecord.common";
const { Text, Title } = Typography;
@@ -33,105 +47,21 @@ export interface PubRecordModel {
[key: string]: any;
}
-// 图片视图组件
-export const ImageView = ({
- prm,
- width,
- height,
-}: {
- prm: PubRecordModel;
- width: number | string;
- height: number | string;
-}) => {
- const [imgUrl, setImgUrl] = useState('');
-
- useEffect(() => {
- // 优先使用 coverUrl,如果没有则使用 coverPath
- const coverUrl = prm.coverUrl || prm.coverPath;
- if (coverUrl) {
- if (coverUrl.includes('https://') || coverUrl.includes('http://')) {
- setImgUrl(coverUrl);
- } else {
- // 如果是本地路径,可以转换为 URL
- setImgUrl(coverUrl);
- }
- }
- }, [prm.coverUrl, prm.coverPath]);
-
- const filename = useMemo(() => {
- const videoUrl = prm.videoUrl || prm.videoPath;
- if (videoUrl) {
- return videoUrl.split('/').pop() || '未知文件';
- }
- return '未知文件';
- }, [prm.videoUrl, prm.videoPath]);
-
- return (
- <div
- className={styles['pubRecord-pubCon']}
- style={{ minHeight: height + 'px' }}
- >
- {imgUrl ? (
- <Image src={imgUrl} height={height} width={width} />
- ) : (
- <div style={{ width, height, backgroundColor: '#f5f5f5', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
- <span>无封面</span>
- </div>
- )}
- <span title={filename} className="pubRecord-pubCon-name">
- {filename}
- </span>
- </div>
- );
-};
-
-// 平台展示组件
-export const PlatformView = ({ accountType }: { accountType: AccountType }) => {
- const platInfo = AccountPlatInfoMap.get(accountType as unknown as PlatType);
-
- if (!platInfo) {
- return <Tag color="default">未知平台</Tag>;
- }
-
- return (
- <Space>
- <Avatar size="small" src={platInfo.icon} />
- <Text>{platInfo.name}</Text>
- </Space>
- );
-};
-
-// 发布状态标签组件
-export const PubRecordStatusTag = ({ status }: { status: PubStatus }) => {
- switch (status) {
- case PubStatus.FAIL:
- return <Tag color="error">发布失败</Tag>;
- case PubStatus.RELEASED:
- return <Tag color="success">发布成功</Tag>;
- case PubStatus.PartSuccess:
- return <Tag color="warning">部分发布成功</Tag>;
- case PubStatus.UNPUBLISH:
- return <Tag color="processing">未发布</Tag>;
- default:
- return <Tag color="default">未知状态</Tag>;
- }
-};
-
// 详情弹窗内容组件
const DetailContent = ({ data }: { data: PubRecordModel }) => {
const renderValue = (key: string, value: any) => {
// 特殊字段处理
- if (key === 'imgList' || key === 'imgUrlList') {
+ if (key === "imgList" || key === "imgUrlList") {
if (Array.isArray(value) && value.length > 0) {
return (
- <div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px' }}>
+ <div style={{ display: "flex", flexWrap: "wrap", gap: "8px" }}>
{value.map((url: string, index: number) => (
<Image
key={index}
src={url}
width={80}
height={80}
- style={{ objectFit: 'cover', borderRadius: '4px' }}
+ style={{ objectFit: "cover", borderRadius: "4px" }}
fallback="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3Ik1RnG4W+FgYxN"
/>
))}
@@ -141,14 +71,19 @@ const DetailContent = ({ data }: { data: PubRecordModel }) => {
return <Text type="secondary">无图片</Text>;
}
- if (key === 'videoUrl' || key === 'coverUrl') {
- if (value && typeof value === 'string') {
+ if (key === "videoUrl" || key === "coverUrl") {
+ if (value && typeof value === "string") {
return (
<div>
<Text copyable>{value}</Text>
{value.match(/\.(jpg|jpeg|png|gif|webp)$/i) && (
- <div style={{ marginTop: '8px' }}>
- <Image src={value} width={120} height={80} style={{ objectFit: 'cover' }} />
+ <div style={{ marginTop: "8px" }}>
+ <Image
+ src={value}
+ width={120}
+ height={80}
+ style={{ objectFit: "cover" }}
+ />
</div>
)}
</div>
@@ -156,40 +91,56 @@ const DetailContent = ({ data }: { data: PubRecordModel }) => {
}
}
- if (key === 'option' && typeof value === 'object') {
+ if (key === "option" && typeof value === "object") {
return (
- <div style={{ backgroundColor: '#f5f5f5', padding: '8px', borderRadius: '4px' }}>
- <pre style={{ margin: 0, fontSize: '12px' }}>{JSON.stringify(value, null, 2)}</pre>
+ <div
+ style={{
+ backgroundColor: "#f5f5f5",
+ padding: "8px",
+ borderRadius: "4px",
+ }}
+ >
+ <pre style={{ margin: 0, fontSize: "12px" }}>
+ {JSON.stringify(value, null, 2)}
+ </pre>
</div>
);
}
- if (key === 'publishTime') {
+ if (key === "publishTime") {
return <Text>{formatTime(value)}</Text>;
}
- if (key === 'status') {
+ if (key === "status") {
return <PubRecordStatusTag status={value} />;
}
- if (key === 'type') {
+ if (key === "type") {
const typeMap: Record<string, string> = {
- [PubType.ARTICLE]: '文章发布',
- [PubType.VIDEO]: '视频发布',
- [PubType.ImageText]: '图文发布',
+ [PubType.ARTICLE]: "文章发布",
+ [PubType.VIDEO]: "视频发布",
+ [PubType.ImageText]: "图文发布",
};
- return <Tag color="blue">{typeMap[value] || '未知类型'}</Tag>;
+ return <Tag color="blue">{typeMap[value] || "未知类型"}</Tag>;
}
- if (key === 'accountType') {
+ if (key === "accountType") {
return <PlatformView accountType={value} />;
}
// 默认处理
- if (typeof value === 'object' && value !== null) {
+ if (typeof value === "object" && value !== null) {
return (
- <div style={{ backgroundColor: '#f5f5f5', padding: '8px', borderRadius: '4px' }}>
- <pre style={{ margin: 0, fontSize: '12px' }}>{JSON.stringify(value, null, 2)}</pre>
+ <div
+ style={{
+ backgroundColor: "#f5f5f5",
+ padding: "8px",
+ borderRadius: "4px",
+ }}
+ >
+ <pre style={{ margin: 0, fontSize: "12px" }}>
+ {JSON.stringify(value, null, 2)}
+ </pre>
</div>
);
}
@@ -198,39 +149,39 @@ const DetailContent = ({ data }: { data: PubRecordModel }) => {
};
const fieldLabels: Record<string, string> = {
- id: '记录ID',
- flowId: '流程ID',
- type: '发布类型',
- title: '标题',
- desc: '描述',
- accountId: '账户ID',
- accountType: '平台类型',
- uid: '用户ID',
- videoUrl: '视频链接',
- coverUrl: '封面链接',
- imgList: '图片列表',
- imgUrlList: '图片链接列表',
- publishTime: '发布时间',
- status: '发布状态',
- option: '发布选项',
- coverPath: '封面路径',
- videoPath: '视频路径',
+ id: "记录ID",
+ flowId: "流程ID",
+ type: "发布类型",
+ title: "标题",
+ desc: "描述",
+ accountId: "账户ID",
+ accountType: "平台类型",
+ uid: "用户ID",
+ videoUrl: "视频链接",
+ coverUrl: "封面链接",
+ imgList: "图片列表",
+ imgUrlList: "图片链接列表",
+ publishTime: "发布时间",
+ status: "发布状态",
+ option: "发布选项",
+ coverPath: "封面路径",
+ videoPath: "视频路径",
};
return (
- <div style={{ maxHeight: '60vh', overflow: 'auto' }}>
+ <div style={{ maxHeight: "60vh", overflow: "auto" }}>
<Descriptions
column={1}
bordered
size="small"
- labelStyle={{ fontWeight: 'bold', width: '120px' }}
- contentStyle={{ wordBreak: 'break-all' }}
+ labelStyle={{ fontWeight: "bold", width: "120px" }}
+ contentStyle={{ wordBreak: "break-all" }}
>
{Object.entries(data).map(([key, value]) => (
- <Descriptions.Item
- label={fieldLabels[key] || key}
+ <Descriptions.Item
+ label={fieldLabels[key] || key}
key={key}
- style={{ padding: '12px' }}
+ style={{ padding: "12px" }}
>
{renderValue(key, value)}
</Descriptions.Item>
@@ -241,66 +192,63 @@ const DetailContent = ({ data }: { data: PubRecordModel }) => {
};
// 主页面组件
-export default function Page({
- height = '75vh',
- onChange,
- defaultPubType,
-}: {
- height?: string;
- onChange?: (pubRecordModel: PubRecordModel) => void;
- defaultPubType?: PubType;
-}) {
+export default function Page() {
const [pubRecordList, setPubRecordList] = useState<PubRecordModel[]>([]);
- const [selectedRowKeys, setSelectedRowKeys] = useState<number[]>([]);
const [loading, setLoading] = useState(false);
const [detailOpen, setDetailOpen] = useState(false);
const [detailData, setDetailData] = useState<any>(null);
- // 发布类型的筛选
- const [pubType, setPubType] = useState<PubType | undefined>(defaultPubType);
+ const [pubType, setPubType] = useState<PubType | undefined>();
const columns = useMemo(() => {
- const columns: TableProps<PubRecordModel>['columns'] = [
+ const columns: TableProps<PubRecordModel>["columns"] = [
{
- title: '序号',
+ title: "序号",
render: (text, prm, ind) => ind + 1,
width: 70,
- key: '序号',
+ key: "序号",
},
{
- title: '发布内容',
+ title: "发布内容",
render: (text, prm) => <ImageView prm={prm} width={30} height={50} />,
width: 200,
- key: '发布内容',
+ key: "发布内容",
},
{
- title: '标题',
- dataIndex: 'title',
- key: 'title',
+ title: "标题",
+ dataIndex: "title",
+ key: "title",
width: 200,
render: (text) => (
- <div style={{ maxWidth: 180, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
+ <div
+ style={{
+ maxWidth: 180,
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ whiteSpace: "nowrap",
+ }}
+ >
{text}
</div>
),
},
{
- title: '平台',
- dataIndex: 'accountType',
- key: 'accountType',
+ title: "平台",
+ dataIndex: "accountType",
+ key: "accountType",
width: 120,
render: (text, prm) => <PlatformView accountType={prm.accountType} />,
},
{
- title: '发布时间',
- dataIndex: 'publishTime',
- key: 'publishTime',
+ title: "发布时间",
+ dataIndex: "publishTime",
+ key: "publishTime",
render: (text, prm) => formatTime(prm.publishTime),
width: 200,
},
{
- title: '发布类型',
- dataIndex: 'type',
- key: 'type',
+ title: "发布类型",
+ dataIndex: "type",
+ key: "type",
render: (_, prm) => {
switch (prm.type) {
case PubType.ARTICLE:
@@ -316,16 +264,16 @@ export default function Page({
width: 120,
},
{
- title: '状态',
- dataIndex: 'status',
- key: 'status',
+ title: "状态",
+ dataIndex: "status",
+ key: "status",
render: (text, prm) => <PubRecordStatusTag status={prm.status} />,
width: 100,
},
{
- title: '操作',
+ title: "操作",
width: 100,
- key: '操作',
+ key: "操作",
render: (text, prm) => (
<>
<Button
@@ -352,64 +300,33 @@ export default function Page({
async function getPubList() {
setLoading(true);
try {
- const res:any = await apiGetPublishList(
- 1,
- 10,
- {
- type: pubType,
- }
- );
+ const res: any = await apiGetPublishList(1, 10, {
+ type: pubType,
+ });
if (res?.data?.list) {
setPubRecordList(res.data.list);
} else {
setPubRecordList([]);
}
} catch (error) {
- console.error('获取发布记录失败:', error);
+ console.error("获取发布记录失败:", error);
setPubRecordList([]);
} finally {
setLoading(false);
}
}
- useEffect(() => {
- if (onChange) {
- const selectedRecord = pubRecordList.find((v) => v.id === selectedRowKeys[0]);
- if (selectedRecord) {
- onChange(selectedRecord);
- }
- }
- }, [selectedRowKeys, pubRecordList, onChange]);
-
- const rowSelection: TableProps<PubRecordModel>['rowSelection'] = {
- onChange: (
- selectedRowKeys: React.Key[],
- selectedRows: PubRecordModel[],
- ) => {
- setSelectedRowKeys(selectedRowKeys as number[]);
- },
- getCheckboxProps: (record: PubRecordModel) => ({
- name: record.title,
- }),
- selectedRowKeys,
- };
-
return (
- <div
- className={[
- styles.pubRecord,
- onChange && styles['pubRecord-component'],
- ].join(' ')}
- >
+ <div className={[styles.pubRecord].join(" ")}>
{/* 详情弹窗 */}
<Modal
open={detailOpen}
title={
- <div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
- <Title level={4} style={{ margin: 0 }}>发布记录详情</Title>
- {detailData && (
- <Tag color="blue">ID: {detailData.id}</Tag>
- )}
+ <div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
+ <Title level={4} style={{ margin: 0 }}>
+ 发布记录详情
+ </Title>
+ {detailData && <Tag color="blue">ID: {detailData.id}</Tag>}
</div>
}
onCancel={() => setDetailOpen(false)}
@@ -420,37 +337,29 @@ export default function Page({
{detailData && <DetailContent data={detailData} />}
</Modal>
- {!onChange && (
- <div className="pubRecord-options">
- <Select
- style={{ width: 120 }}
- placeholder="发布类型"
- allowClear
- value={pubType}
- onChange={(e) => {
- setPubType(e as PubType);
- }}
- options={[
- { value: PubType.ARTICLE, label: '文章' },
- { value: PubType.ImageText, label: '图文' },
- { value: PubType.VIDEO, label: '视频' },
- ]}
- />
- </div>
- )}
+ <div className="pubRecord-options">
+ <Select
+ style={{ width: 120 }}
+ placeholder="发布类型"
+ allowClear
+ value={pubType}
+ onChange={(e) => {
+ setPubType(e as PubType);
+ }}
+ options={[
+ { value: PubType.ARTICLE, label: "文章" },
+ { value: PubType.ImageText, label: "图文" },
+ { value: PubType.VIDEO, label: "视频" },
+ ]}
+ />
+ </div>
<Table<PubRecordModel>
columns={columns}
dataSource={pubRecordList}
- scroll={{ y: height }}
+ scroll={{ y: "70vh" }}
rowKey="id"
loading={loading}
- rowSelection={onChange ? { type: 'radio', ...rowSelection } : undefined}
- onRow={(record) => ({
- onClick: () => {
- setSelectedRowKeys([record.id]);
- },
- })}
pagination={{
total: pubRecordList.length,
pageSize: 10,
diff --git a/src/app/[lng]/publish/pubRecord/pubRecord.common.tsx b/src/app/[lng]/publish/pubRecord/pubRecord.common.tsx
new file mode 100644
index 00000000..c3b5eada
--- /dev/null
+++ b/src/app/[lng]/publish/pubRecord/pubRecord.common.tsx
@@ -0,0 +1,101 @@
+// 图片视图组件
+import { useEffect, useMemo, useState } from "react";
+import styles from "./pubRecord.module.scss";
+import { PubStatus, AccountType } from "@/api/publish";
+import { Image, Tag, Avatar, Space, Typography } from "antd";
+import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";
+import { PubRecordModel } from "@/app/[lng]/publish/pubRecord/page";
+
+const { Text, Title } = Typography;
+
+export const ImageView = ({
+ prm,
+ width,
+ height,
+}: {
+ prm: PubRecordModel;
+ width: number | string;
+ height: number | string;
+}) => {
+ const [imgUrl, setImgUrl] = useState("");
+
+ useEffect(() => {
+ // 优先使用 coverUrl,如果没有则使用 coverPath
+ const coverUrl = prm.coverUrl || prm.coverPath;
+ if (coverUrl) {
+ if (coverUrl.includes("https://") || coverUrl.includes("http://")) {
+ setImgUrl(coverUrl);
+ } else {
+ // 如果是本地路径,可以转换为 URL
+ setImgUrl(coverUrl);
+ }
+ }
+ }, [prm.coverUrl, prm.coverPath]);
+
+ const filename = useMemo(() => {
+ const videoUrl = prm.videoUrl || prm.videoPath;
+ if (videoUrl) {
+ return videoUrl.split("/").pop() || "未知文件";
+ }
+ return "未知文件";
+ }, [prm.videoUrl, prm.videoPath]);
+
+ return (
+ <div
+ className={styles["pubRecord-pubCon"]}
+ style={{ minHeight: height + "px" }}
+ >
+ {imgUrl ? (
+ <Image src={imgUrl} height={height} width={width} />
+ ) : (
+ <div
+ style={{
+ width,
+ height,
+ backgroundColor: "#f5f5f5",
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ }}
+ >
+ <span>无封面</span>
+ </div>
+ )}
+ <span title={filename} className="pubRecord-pubCon-name">
+ {filename}
+ </span>
+ </div>
+ );
+};
+
+// 平台展示组件
+export const PlatformView = ({ accountType }: { accountType: AccountType }) => {
+ const platInfo = AccountPlatInfoMap.get(accountType as unknown as PlatType);
+
+ if (!platInfo) {
+ return <Tag color="default">未知平台</Tag>;
+ }
+
+ return (
+ <Space>
+ <Avatar size="small" src={platInfo.icon} />
+ <Text>{platInfo.name}</Text>
+ </Space>
+ );
+};
+
+// 发布状态标签组件
+export const PubRecordStatusTag = ({ status }: { status: PubStatus }) => {
+ switch (status) {
+ case PubStatus.FAIL:
+ return <Tag color="error">发布失败</Tag>;
+ case PubStatus.RELEASED:
+ return <Tag color="success">发布成功</Tag>;
+ case PubStatus.PartSuccess:
+ return <Tag color="warning">部分发布成功</Tag>;
+ case PubStatus.UNPUBLISH:
+ return <Tag color="processing">未发布</Tag>;
+ default:
+ return <Tag color="default">未知状态</Tag>;
+ }
+};
diff --git a/src/app/[lng]/publish/videoPage/useVideoPageStore.ts b/src/app/[lng]/publish/videoPage/useVideoPageStore.ts
index d686f056..f60091f5 100644
--- a/src/app/[lng]/publish/videoPage/useVideoPageStore.ts
+++ b/src/app/[lng]/publish/videoPage/useVideoPageStore.ts
@@ -188,7 +188,7 @@ export const useVideoPageStore = create(
* 已经存在的账户ID做个去重
* 因为accounts会将所有选择的账户数据传入
*/
- const existAccountsSet = new Set<number>();
+ const existAccountsSet = new Set<string>();
newV.map((v) => v.account && existAccountsSet.add(v.account.id));
accounts = accounts.filter((v) => !existAccountsSet.has(v.id));
@@ -302,10 +302,10 @@ export const useVideoPageStore = create(
const newValue = [...get().videoListChoose];
if (newValue.length === 0) return;
// key=账户ID val= videoListChoose item
- const videoListMap = new Map<number, IVideoChooseItem>();
+ const videoListMap = new Map<string, IVideoChooseItem>();
newValue.map((v) => {
- videoListMap.set(v.account?.id || 0, v);
+ videoListMap.set(v.account?.id || "0", v);
});
accounts.map((v) => {
diff --git a/src/app/[lng]/youtube/page.tsx b/src/app/[lng]/youtube/page.tsx
index 3914000c..a8bd0bdf 100644
--- a/src/app/[lng]/youtube/page.tsx
+++ b/src/app/[lng]/youtube/page.tsx
@@ -1,29 +1,40 @@
-'use client';
+"use client";
-import React, { useState, useEffect } from 'react';
-import { useTransClient } from '@/app/i18n/client';
-import { Button, Input, message, Card, Upload, Select, Alert } from 'antd';
-import { MailOutlined, YoutubeOutlined, CheckOutlined, UploadOutlined, WarningOutlined } from '@ant-design/icons';
-import { getYouTubeAuthUrlApi, checkYouTubeAuthApi, uploadYouTubeVideoApi, getYouTubeChannelSectionsApi } from '@/api/youtube';
-import styles from './youtube.module.css';
+import React, { useState, useEffect } from "react";
+import { useTransClient } from "@/app/i18n/client";
+import { Button, Input, message, Card, Upload, Select, Alert } from "antd";
+import {
+ MailOutlined,
+ YoutubeOutlined,
+ CheckOutlined,
+ UploadOutlined,
+ WarningOutlined,
+} from "@ant-design/icons";
+import {
+ getYouTubeAuthUrlApi,
+ checkYouTubeAuthApi,
+ uploadYouTubeVideoApi,
+ getYouTubeChannelSectionsApi,
+} from "@/api/youtube";
+import styles from "./youtube.module.css";
const YouTubeAuth: React.FC = () => {
- const { t } = useTransClient('youtube');
- const [email, setEmail] = useState('[email protected]');
+ const { t } = useTransClient("youtube");
+ const [email, setEmail] = useState("[email protected]");
const [loading, setLoading] = useState(false);
const [checkLoading, setCheckLoading] = useState(false);
const [uploadLoading, setUploadLoading] = useState(false);
const [isAuthorized, setIsAuthorized] = useState(false);
const [sections, setSections] = useState([]);
- const [selectedSection, setSelectedSection] = useState('');
+ const [selectedSection, setSelectedSection] = useState("");
const [hasChannel, setHasChannel] = useState(false);
// 获取频道分区
const fetchChannelSections = async () => {
try {
- const response:any = await getYouTubeChannelSectionsApi({
+ const response: any = await getYouTubeChannelSectionsApi({
accountId: "117748783778429701407",
- mine: true
+ mine: true,
});
if (response?.data?.items?.length > 0) {
setHasChannel(true);
@@ -33,7 +44,7 @@ const YouTubeAuth: React.FC = () => {
setSections([]);
}
} catch (error) {
- console.error('获取频道分区失败:', error);
+ console.error("获取频道分区失败:", error);
setHasChannel(false);
}
};
@@ -47,23 +58,25 @@ const YouTubeAuth: React.FC = () => {
const handleCheck = async () => {
if (!email) {
- message.error(t('pleaseEnterEmail'));
+ message.error(t("pleaseEnterEmail"));
return;
}
setCheckLoading(true);
try {
- const response = await checkYouTubeAuthApi({ accountId: "117748783778429701407"});
-
+ const response = await checkYouTubeAuthApi({
+ accountId: "117748783778429701407",
+ });
+
if (response?.data) {
- message.success(t('alreadyAuthorized'));
+ message.success(t("alreadyAuthorized"));
setIsAuthorized(true);
} else {
- message.info(t('notAuthorized'));
+ message.info(t("notAuthorized"));
}
} catch (error) {
- console.error('检查授权状态失败:', error);
- message.error(t('checkFailed'));
+ console.error("检查授权状态失败:", error);
+ message.error(t("checkFailed"));
} finally {
setCheckLoading(false);
}
@@ -71,12 +84,12 @@ const YouTubeAuth: React.FC = () => {
const handleAuth = async () => {
if (!email) {
- message.error(t('pleaseEnterEmail'));
+ message.error(t("pleaseEnterEmail"));
return;
}
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
- message.error(t('invalidEmail'));
+ message.error(t("invalidEmail"));
return;
}
@@ -84,11 +97,11 @@ const YouTubeAuth: React.FC = () => {
try {
const response = await getYouTubeAuthUrlApi(email);
if (response?.data) {
- window.open(response.data?.url, '_blank', 'noopener,noreferrer');
+ window.open(response.data?.url, "_blank", "noopener,noreferrer");
}
} catch (error) {
- console.error('获取授权 URL 失败:', error);
- message.error(t('authFailed'));
+ console.error("获取授权 URL 失败:", error);
+ message.error(t("authFailed"));
} finally {
setLoading(false);
}
@@ -96,29 +109,29 @@ const YouTubeAuth: React.FC = () => {
const handleUpload = async (file: File) => {
if (!isAuthorized) {
- message.error(t('notAuthorized'));
+ message.error(t("notAuthorized"));
return;
}
setUploadLoading(true);
try {
const formData = new FormData();
- formData.append('file', file);
- formData.append('accountId', "117748783778429701407");
- formData.append('title', "你说这怎么样");
- formData.append('description', "糟糕啊,是心动的感觉!");
- formData.append('privacyStatus', "private");
+ formData.append("file", file);
+ formData.append("accountId", "117748783778429701407");
+ formData.append("title", "你说这怎么样");
+ formData.append("description", "糟糕啊,是心动的感觉!");
+ formData.append("privacyStatus", "private");
if (selectedSection) {
- formData.append('sectionId', selectedSection);
+ formData.append("sectionId", selectedSection);
}
-
+
const response = await uploadYouTubeVideoApi(formData);
if (response?.data) {
- message.success(t('uploadSuccess'));
+ message.success(t("uploadSuccess"));
}
} catch (error) {
- console.error('上传视频失败:', error);
- message.error(t('uploadFailed'));
+ console.error("上传视频失败:", error);
+ message.error(t("uploadFailed"));
} finally {
setUploadLoading(false);
}
@@ -127,24 +140,17 @@ const YouTubeAuth: React.FC = () => {
return (
<div className={styles.container}>
- <Card
- className={styles.card}
- bodyStyle={{ padding: '2.5rem' }}
- >
+ <Card className={styles.card} bodyStyle={{ padding: "2.5rem" }}>
<div className={styles.header}>
<YoutubeOutlined className={styles.icon} />
- <h2 className={styles.title}>
- {t('youtubeAuth')}
- </h2>
- <p className={styles.description}>
- {t('authDescription')}
- </p>
+ <h2 className={styles.title}>{t("youtubeAuth")}</h2>
+ <p className={styles.description}>{t("authDescription")}</p>
</div>
<div className={styles.form}>
<div className={styles.formItem}>
<label htmlFor="email" className={styles.label}>
- {t('email')}
+ {t("email")}
</label>
<Input
id="email"
@@ -153,7 +159,7 @@ const YouTubeAuth: React.FC = () => {
required
size="large"
className={styles.input}
- placeholder={t('enterEmail')}
+ placeholder={t("enterEmail")}
value={email}
onChange={(e) => setEmail(e.target.value)}
prefix={<MailOutlined className={styles.inputIcon} />}
@@ -169,7 +175,7 @@ const YouTubeAuth: React.FC = () => {
className={styles.checkButton}
icon={<CheckOutlined />}
>
- {t('checkAuth')}
+ {t("checkAuth")}
</Button>
<Button
@@ -180,7 +186,7 @@ const YouTubeAuth: React.FC = () => {
className={styles.button}
icon={<YoutubeOutlined />}
>
- {t('authorize')}
+ {t("authorize")}
</Button>
</div>
@@ -191,9 +197,14 @@ const YouTubeAuth: React.FC = () => {
description={
<div>
<p>请先创建 YouTube 频道后再上传视频</p>
- <Button
- type="primary"
- onClick={() => window.open('https://www.youtube.com/create_channel', '_blank')}
+ <Button
+ type="primary"
+ onClick={() =>
+ window.open(
+ "https://www.youtube.com/create_channel",
+ "_blank",
+ )
+ }
className={styles.createChannelButton}
>
创建频道
@@ -215,7 +226,7 @@ const YouTubeAuth: React.FC = () => {
onChange={setSelectedSection}
options={sections.map((section: any) => ({
label: section.title,
- value: section.id
+ value: section.id,
}))}
/>
)}
@@ -234,13 +245,11 @@ const YouTubeAuth: React.FC = () => {
icon={<UploadOutlined />}
disabled={!isAuthorized || !hasChannel}
>
- {t('uploadVideo')}
+ {t("uploadVideo")}
</Button>
</Upload>
{!isAuthorized && (
- <p className={styles.uploadTip}>
- {t('needAuthFirst')}
- </p>
+ <p className={styles.uploadTip}>{t("needAuthFirst")}</p>
)}
</div>
</div>
@@ -249,4 +258,4 @@ const YouTubeAuth: React.FC = () => {
);
};
-export default YouTubeAuth;
\ No newline at end of file
+export default YouTubeAuth;
diff --git a/src/app/plat/PlatBase.ts b/src/app/plat/PlatBase.ts
index a02ee5be..a98bfe8c 100644
--- a/src/app/plat/PlatBase.ts
+++ b/src/app/plat/PlatBase.ts
@@ -17,7 +17,7 @@ export abstract class PlatBase {
constructor(params: IPlatConstrParams) {
this.access_token = params.access_token;
this.refresh_token = params.refresh_token;
- this.account = params.account;
+ this.account = params.account!;
}
publishVideo(
diff --git a/src/app/plat/plat.type.ts b/src/app/plat/plat.type.ts
index d4c86c55..3b8023ed 100644
--- a/src/app/plat/plat.type.ts
+++ b/src/app/plat/plat.type.ts
@@ -2,12 +2,11 @@
import { SocialAccount } from "@/api/types/account.type";
import { IPubParams } from "@/app/[lng]/publish/videoPage/videoPage.type";
import { IVideoFile } from "@/app/[lng]/publish/components/Choose/VideoChoose";
-import { PlatType } from "@/app/config/platConfig";
export interface IPlatConstrParams {
access_token: string;
refresh_token: string;
- account: SocialAccount;
+ account?: SocialAccount;
}
export interface IMixItem {
diff --git a/src/app/plat/platChildren/bilibili/BilibiliPubCore.ts b/src/app/plat/platChildren/bilibili/BilibiliPubCore.ts
index a7aeafb3..2831a1f3 100644
--- a/src/app/plat/platChildren/bilibili/BilibiliPubCore.ts
+++ b/src/app/plat/platChildren/bilibili/BilibiliPubCore.ts
@@ -4,8 +4,7 @@ import {
IVideoPublishItem,
PubProgressType,
} from "@/app/plat/plat.type";
-import { calculateChunks, readBlobRange } from "@/app/plat/plat.util";
-import { KwaiApiUploadProxyUrl } from "@/constant";
+import { calculateChunks } from "@/app/plat/plat.util";
import {
apiInitBilibiliVideo,
apiUploadBilibiliCover,
@@ -60,10 +59,10 @@ export class BilibiliPubCore {
const publishData = {
flowId: `bilibili_${Date.now()}`, // 生成唯一的流程ID
type: PubType.VIDEO,
- title: this.videoPubParams.title || '',
- desc: this.videoPubParams.describe || '',
+ title: this.videoPubParams.title || "",
+ desc: this.videoPubParams.describe || "",
accountId: this.kwaiPlat.account.id,
- uid: this.kwaiPlat.account.uid || '',
+ uid: this.kwaiPlat.account.uid || "",
accountType: AccountType.BILIBILI,
videoUrl: result.worksUrl, // 使用构建的视频地址
coverUrl: coverUrl, // 使用实际上传的封面地址
@@ -73,23 +72,22 @@ export class BilibiliPubCore {
option: {
worksId: result.worksId,
worksUrl: result.worksUrl,
- platform: 'bilibili',
+ platform: "bilibili",
publishResult: result,
},
};
const res = await apiCreatePublish(publishData);
- console.log('发布记录创建成功:', res);
+ console.log("发布记录创建成功:", res);
return res;
} catch (error) {
- console.error('创建发布记录失败:', error);
+ console.error("创建发布记录失败:", error);
// 不抛出错误,避免影响主流程
}
}
// 视频发布
async publishVideo(): Promise<IPublishResult> {
-
console.log("视频发布");
console.log(this.videoPubParams);
console.log(this.kwaiPlat.account);
@@ -128,7 +126,7 @@ export class BilibiliPubCore {
this.kwaiPlat.account.id,
uploadToken,
i + 1,
- sliced
+ sliced,
);
if (res?.code !== 0) {
@@ -145,7 +143,7 @@ export class BilibiliPubCore {
this.onProgress?.(0.7, "开始合并分片");
const completeRes = await apiCompleteBilibiliVideo(
this.kwaiPlat.account.id,
- uploadToken
+ uploadToken,
);
if (completeRes?.code !== 0) {
throw new Error("分片合并失败");
@@ -153,13 +151,13 @@ export class BilibiliPubCore {
this.onProgress?.(0.8, "分片合并完成");
// 3. 上传封面
- let coverUrl:any = "";
+ let coverUrl: any = "";
if (this.videoPubParams.cover?.file) {
const formData = new FormData();
formData.append("file", this.videoPubParams.cover.file);
const coverRes = await apiUploadBilibiliCover(
this.kwaiPlat.account.id,
- formData
+ formData,
);
if (coverRes?.data) {
coverUrl = coverRes.data;
@@ -174,7 +172,7 @@ export class BilibiliPubCore {
uploadToken,
title: this.videoPubParams.title,
cover: coverUrl,
- tid: 21, // 默认使用日常分区
+ tid: 21, // 默认使用日常分区
// noReprint: this.videoPubParams.noReprint || 0,
desc: this.videoPubParams.describe,
tag: this.videoPubParams.topics || [],
@@ -182,7 +180,7 @@ export class BilibiliPubCore {
};
this.onProgress?.(0.95, "正在提交稿件");
- const submitRes:any = await apiSubmitBilibiliArchive(archiveData);
+ const submitRes: any = await apiSubmitBilibiliArchive(archiveData);
console.log("稿件提交结果:", submitRes);
if (submitRes?.code !== 0) {
@@ -201,10 +199,10 @@ export class BilibiliPubCore {
await this.createPublishRecord(result, coverUrl);
return result;
- } catch (error:any) {
+ } catch (error: any) {
console.error("发布视频失败:", error);
this.onProgress?.(0, "发布失败");
-
+
const result = {
worksId: "",
worksUrl: "",
@@ -213,7 +211,7 @@ export class BilibiliPubCore {
};
// 即使发布失败也创建记录
- await this.createPublishRecord(result, '');
+ await this.createPublishRecord(result, "");
return result;
}