Skip to content

Let's use AI to Earn!

feat: 发布静态页搬运完成

gaoSir22dd91bfb55b
diff --git a/.env.development b/.env.development
index 183041cc..592beac3 100644
--- a/.env.development
+++ b/.env.development
@@ -2,4 +2,4 @@ NEXT_PUBLIC_EVN=dev
NEXT_PUBLIC_API_URL=http://localhost:3000/api/
-# NEXT_PUBLIC_API_URL=http://localhost:3000/api/
\ No newline at end of file
+#NEXT_PUBLIC_API_URL=https://platapi.aitoearn.cn/api/
\ No newline at end of file
diff --git a/@types/resources.d.ts b/@types/resources.d.ts
index e1bec60f..dab23378 100644
--- a/@types/resources.d.ts
+++ b/@types/resources.d.ts
@@ -1,87 +1,99 @@
interface Resources {
- "account": {
- "title": "账户",
- "describe": "账户页面"
- },
- "common": {
- "profile": "个人中心",
- "logout": "退出登录",
- "unknownUser": "未知用户",
- "login": "登录"
- },
- "demo": {
- "demoText": "测试文字",
- "title": "测试页面标题"
- },
+ account: {
+ title: "账户";
+ describe: "账户页面";
+ };
+ common: {
+ profile: "个人中心";
+ logout: "退出登录";
+ unknownUser: "未知用户";
+ login: "登录";
+ };
+ demo: {
+ demoText: "测试文字";
+ title: "测试页面标题";
+ };
"hot-content": {
- "all": "全部",
- "loading": "加载中...",
- "noData": "暂无数据",
- "rank": "排名",
- "cover": "封面",
- "title": "标题",
- "author": "作者",
- "category": "分类",
- "likes": "点赞",
- "shares": "分享",
- "comments": "评论数",
- "collections": "收藏数",
- "publishTime": "发布于",
- "fans": "粉丝",
- "viewMore": "查看更多",
- "timeRange": "时间范围",
- "filter": "筛选",
- "hotTopics": "热门专题",
- "viralTitles": "爆款标题",
- "topics": "专题",
- "engagement": "互动量",
- "rising": "热",
- "noHotTopics": "暂无热点数据",
- "noViralTitles": "暂无爆款标题数据",
- "noTopicData": "暂无专题数据",
- "total": "共",
- "items": "条",
- "video": "视频",
- "noImage": "暂无图片",
- "platform": "平台",
- "hotEvents": "热点事件",
- "hotContent": "热点内容"
- },
- "login": {
- "welcomeBack": "哎呦赚",
- "emailPlaceholder": "邮箱",
- "passwordPlaceholder": "密码",
- "login": "登录",
- "or": "或",
- "forgotPassword": "忘记密码?",
- "completeRegistration": "完成注册",
- "setPassword": "设置密码",
- "passwordRequired": "请输入密码",
- "passwordMinLength": "密码长度不能小于6位",
- "enterPassword": "请输入密码",
- "inviteCode": "邀请码(选填)",
- "enterInviteCode": "请输入邀请码",
- "waitingForActivation": "等待激活中...",
- "loginSuccess": "登录成功",
- "loginFailed": "登录失败",
- "loginError": "登录失败,请稍后重试",
- "activationEmailSent": "激活链接已发送至邮箱,请查收并点击激活",
- "registerSuccess": "注册成功,已自动登录",
- "checkStatusError": "检查注册状态失败",
- "registerError": "注册失败,请稍后重试",
- "googleLoginFailed": "Google 登录失败"
- },
- "route": {
- "home": "首页",
- "accounts": "账户",
- "publish": "发布",
- "hotContent": "热门内容",
- "hotContentNew": "热门内容新"
- },
- "translation": {
- "title": "AIToEarn官方网站",
- "content": "最好用的开源矩阵工具"
- }
+ all: "全部";
+ loading: "加载中...";
+ noData: "暂无数据";
+ rank: "排名";
+ cover: "封面";
+ title: "标题";
+ author: "作者";
+ category: "分类";
+ likes: "点赞";
+ shares: "分享";
+ comments: "评论数";
+ collections: "收藏数";
+ publishTime: "发布于";
+ fans: "粉丝";
+ viewMore: "查看更多";
+ timeRange: "时间范围";
+ filter: "筛选";
+ hotTopics: "热门专题";
+ viralTitles: "爆款标题";
+ topics: "专题";
+ engagement: "互动量";
+ rising: "热";
+ noHotTopics: "暂无热点数据";
+ noViralTitles: "暂无爆款标题数据";
+ noTopicData: "暂无专题数据";
+ total: "共";
+ items: "条";
+ video: "视频";
+ noImage: "暂无图片";
+ platform: "平台";
+ hotEvents: "热点事件";
+ hotContent: "热点内容";
+ };
+ login: {
+ welcomeBack: "哎呦赚";
+ emailPlaceholder: "邮箱";
+ passwordPlaceholder: "密码";
+ login: "登录";
+ or: "或";
+ forgotPassword: "忘记密码?";
+ completeRegistration: "完成注册";
+ setPassword: "设置密码";
+ passwordRequired: "请输入密码";
+ passwordMinLength: "密码长度不能小于6位";
+ enterPassword: "请输入密码";
+ inviteCode: "邀请码(选填)";
+ enterInviteCode: "请输入邀请码";
+ waitingForActivation: "等待激活中...";
+ loginSuccess: "登录成功";
+ loginFailed: "登录失败";
+ loginError: "登录失败,请稍后重试";
+ activationEmailSent: "激活链接已发送至邮箱,请查收并点击激活";
+ registerSuccess: "注册成功,已自动登录";
+ checkStatusError: "检查注册状态失败";
+ registerError: "注册失败,请稍后重试";
+ googleLoginFailed: "Google 登录失败";
+ };
+ route: {
+ home: "首页";
+ accounts: "账户";
+ publish: "发布";
+ hotContent: "热门内容";
+ hotContentNew: "热门内容新";
+ };
+ translation: {
+ title: "AIToEarn官方网站";
+ content: "最好用的开源矩阵工具";
+ };
+ youtube: {
+ youtubeAuth: "YouTube 授权";
+ authDescription: "请输入您的邮箱地址以获取 YouTube 授权";
+ email: "邮箱";
+ enterEmail: "请输入邮箱地址";
+ authorize: "授权";
+ pleaseEnterEmail: "请输入邮箱地址";
+ invalidEmail: "请输入有效的邮箱地址";
+ authFailed: "授权失败,请稍后重试";
+ checkAuth: "检查授权";
+ notAuthorized: "未授权";
+ };
}
export default Resources;
diff --git a/eslint.config.mjs b/eslint.config.mjs
index da6e1b3c..2883385a 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -32,7 +32,8 @@ const eslintConfig = [
"@typescript-eslint/no-unused-vars": "warn",
"prettier/prettier": ["error", { "endOfLine": "auto" }],
"@typescript-eslint/ban-ts-comment": "off",
- "react-hooks/rules-of-hooks": "off",
+ "react/display-name": "off",
+ "react-hooks/rules-of-hooks": "off"
},
}
];
diff --git a/package-lock.json b/package-lock.json
index c5104a38..6a0569d6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -17,6 +17,7 @@
"accept-language": "3.0.20",
"antd": "^5.25.2",
"cookies-next": "^4.3.0",
+ "cropperjs": "^1.6.2",
"dayjs": "^1.11.13",
"i18next": "24.2.3",
"i18next-browser-languagedetector": "8.0.4",
@@ -2544,6 +2545,12 @@
"toggle-selection": "^1.0.6"
}
},
+ "node_modules/cropperjs": {
+ "version": "1.6.2",
+ "resolved": "https://registry.npmmirror.com/cropperjs/-/cropperjs-1.6.2.tgz",
+ "integrity": "sha512-nhymn9GdnV3CqiEHJVai54TULFAE3VshJTXSqSJKa8yXAKyBKDWdhHarnlIPrshJ0WMFTGuFvG02YjLXfPiuOA==",
+ "license": "MIT"
+ },
"node_modules/cross-spawn": {
"version": "7.0.6",
"resolved": "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.6.tgz",
diff --git a/package.json b/package.json
index 0883d5b7..5227b6c1 100644
--- a/package.json
+++ b/package.json
@@ -23,6 +23,7 @@
"accept-language": "3.0.20",
"antd": "^5.25.2",
"cookies-next": "^4.3.0",
+ "cropperjs": "^1.6.2",
"dayjs": "^1.11.13",
"i18next": "24.2.3",
"i18next-browser-languagedetector": "8.0.4",
diff --git a/src/api/publish.ts b/src/api/publish.ts
index 0a6a948f..59649a86 100644
--- a/src/api/publish.ts
+++ b/src/api/publish.ts
@@ -1,8 +1,8 @@
-import { request } from '@/utils/request';
-import { PubType, PublishType, PubStatus } from '@/types/publish';
+import { request } from "@/utils/request";
+import { PubType } from "@/app/config/publishConfig";
export interface PublishParams {
- type: PublishType;
+ type: PubType;
title: string;
desc: string;
accountId: number;
@@ -28,7 +28,7 @@ export interface PublishListResponse {
export const getPublishListApi = (pageNo: number, pageSize: number) => {
return request<PublishListResponse>({
url: `/publish/list/${pageNo}/${pageSize}`,
- method: 'GET'
+ method: "GET",
});
};
@@ -36,16 +36,16 @@ export const getPublishListApi = (pageNo: number, pageSize: number) => {
export const getDraftsListApi = (pageNo: number, pageSize: number) => {
return request<PublishListResponse>({
url: `/publish/drafts/list/${pageNo}/${pageSize}`,
- method: 'GET'
+ method: "GET",
});
};
// 创建发布
export const createPublishApi = (data: PublishParams) => {
return request({
- url: '/publish',
- method: 'POST',
- data
+ url: "/publish",
+ method: "POST",
+ data,
});
};
@@ -53,8 +53,8 @@ export const createPublishApi = (data: PublishParams) => {
export const updatePublishStatusApi = (id: number, status: number) => {
return request({
url: `/publish/status/${id}`,
- method: 'POST',
- data: { status }
+ method: "POST",
+ data: { status },
});
};
@@ -62,6 +62,6 @@ export const updatePublishStatusApi = (id: number, status: number) => {
export const deletePublishApi = (id: number) => {
return request({
url: `/publish/${id}`,
- method: 'DELETE'
+ method: "DELETE",
});
-};
\ No newline at end of file
+};
diff --git a/src/api/signIn.ts b/src/api/signIn.ts
new file mode 100644
index 00000000..403d100f
--- /dev/null
+++ b/src/api/signIn.ts
@@ -0,0 +1,35 @@
+/*
+ * @Author: nevin
+ * @Date: 2025-02-22 12:02:55
+ * @LastEditTime: 2025-04-27 18:42:18
+ * @LastEditors: nevin
+ * @Description: feedback
+ */
+import http from "@/utils/request";
+
+export enum SignInType {
+ PUL_VIDEO = "pul_video",
+}
+
+export const signInApi = {
+ /**
+ * 创建签到
+ */
+ async createSignInRecord(type: SignInType = SignInType.PUL_VIDEO) {
+ const res = await http.post<any>(`/reward/signIn`, {
+ type,
+ });
+ return res!.data;
+ },
+
+ /**
+ * 获取签到列表
+ */
+ async getSignInList(params: { type: SignInType; time?: [Date, Date] }) {
+ const res = await http.get<any>(`/reward/signIn/list`, {
+ isToken: true,
+ params,
+ });
+ return res!.data;
+ },
+};
diff --git a/src/api/tools.ts b/src/api/tools.ts
new file mode 100644
index 00000000..cb4db328
--- /dev/null
+++ b/src/api/tools.ts
@@ -0,0 +1,118 @@
+/*
+ * @Author: nevin
+ * @Date: 2025-02-22 12:02:55
+ * @LastEditTime: 2025-03-02 22:21:01
+ * @LastEditors: nevin
+ * @Description: 工具
+ */
+import http, { request } from "@/utils/request";
+import { AiCreateType } from "./types/tools";
+
+export const toolsApi = {
+ /**
+ * 获取智能标题
+ * @param url
+ * @param type 1=标题 2=描述
+ * @param max
+ */
+ async apiVideoAiTitle(url: string, type: AiCreateType, max: number) {
+ const res = await http.post<string>("/tools/ai/video/title", {
+ url,
+ type,
+ max: max - 10,
+ });
+ return res!.data;
+ },
+
+ /**
+ * 智能图文
+ */
+ async apiReviewImgAi(data: {
+ imgUrl: string;
+ title?: string;
+ desc?: string;
+ max?: number;
+ }) {
+ const res = await http.post<string>("/tools/ai/reviewImg", data);
+ return res!.data;
+ },
+
+ /**
+ * 智能评论
+ */
+ async apiReviewAi(data: { title: string; desc?: string; max?: number }) {
+ const res = await http.post<string>("/tools/ai/review", data);
+ return res!.data;
+ },
+
+ /**
+ * 智能评论回复
+ */
+ async apiReviewAiRecover(data: {
+ content: string;
+ title?: string;
+ desc?: string;
+ max?: number;
+ }) {
+ const res = await http.post<string>("/tools/ai/recover/review", data);
+ return res!.data;
+ },
+
+ /**
+ * 生成AI的html图文 弃用: 时间太长得走sse
+ */
+ async aiArticleHtml(content: string) {
+ const res = await http.post<string>("/tools/ai/article/html", {
+ content,
+ });
+ return res!.data;
+ },
+
+ // TODO: sse生成AI的html图文
+ // /tools/ai/article/html/sse
+
+ /**
+ * 上传文件
+ */
+ async uploadFile(file: Blob) {
+ const formData = new FormData();
+ formData.append("file", file);
+
+ const res = await request<{ name: string }>({
+ url: "/oss/upload/permanent",
+ data: formData,
+ method: "POST",
+ headers: {
+ "Content-Type": "multipart/form-data",
+ },
+ });
+ return res!.data;
+ },
+
+ /**
+ * 上传文件临时
+ */
+ async uploadFileTemp(file: Blob) {
+ const formData = new FormData();
+ formData.append("file", file);
+ const res = await request<{ name: string }>({
+ url: "/oss/upload",
+ data: formData,
+ method: "POST",
+ headers: {
+ "Content-Type": "multipart/form-data",
+ },
+ });
+ return res!.data;
+ },
+
+ /**
+ * 文本内容安全
+ */
+ async textModeration(content: string) {
+ const res = await http.post<string>("/tools/common/text/moderation", {
+ content,
+ });
+ return res!.data;
+ },
+};
diff --git a/src/app/[lng]/publish/comment.ts b/src/app/[lng]/publish/comment.ts
new file mode 100644
index 00000000..8a18e894
--- /dev/null
+++ b/src/app/[lng]/publish/comment.ts
@@ -0,0 +1,27 @@
+import { SocialAccount } from "@/api/types/account.type";
+import { AccountStatus } from "@/app/config/accountConfig";
+
+// export type PubRecordModel = PubRecordModelLast;
+
+// 接口失效处理
+export async function accountFailureDispose<T>(
+ {
+ status,
+ data,
+ }: {
+ status: number;
+ data?: T;
+ },
+ account: SocialAccount,
+ callback: (account: SocialAccount) => void,
+) {
+ if (status !== 200 && status !== 201) {
+ if (status === 401) {
+ account.status = AccountStatus.DISABLE;
+ callback(account);
+ // await ipcUpdateAccountStatus(account.id, AccountStatus.DISABLE);
+ }
+ return [];
+ }
+ return data || [];
+}
diff --git a/src/app/[lng]/publish/components/AICreateTitle/AICreateTitle.tsx b/src/app/[lng]/publish/components/AICreateTitle/AICreateTitle.tsx
new file mode 100644
index 00000000..458aefe6
--- /dev/null
+++ b/src/app/[lng]/publish/components/AICreateTitle/AICreateTitle.tsx
@@ -0,0 +1,92 @@
+import React, { ForwardedRef, forwardRef, memo, useState } from "react";
+import styles from "./aICreateTitle.module.scss";
+import { Button, message, Tooltip } from "antd";
+import { ExclamationCircleOutlined } from "@ant-design/icons";
+import { useShallow } from "zustand/react/shallow";
+import { useAICreateTitleStore } from "./useAICreateTitle";
+import { toolsApi } from "@/api/tools";
+import { AiCreateType } from "@/api/types/tools";
+import { APP_HOT_URL } from "@/constant";
+import { IVideoFile } from "@/app/[lng]/publish/components/Choose/VideoChoose";
+
+const VITE_APP_FILE_HOST = APP_HOT_URL;
+
+export interface IAICreateTitleRef {}
+
+export interface IAICreateTitleProps {
+ type: AiCreateType;
+ // 提示信息
+ tips?: string;
+ // 用于生成文字的视频
+ videoFile?: IVideoFile;
+ onAiCreateFinish: (text: string) => void;
+ // 字数限制
+ max: number;
+}
+
+/**
+ * AI生成标题和描述
+ */
+const AICreateTitle = memo(
+ forwardRef(
+ (
+ { type, tips, videoFile, onAiCreateFinish, max }: IAICreateTitleProps,
+ ref: ForwardedRef<IAICreateTitleRef>,
+ ) => {
+ const [loading, setLoading] = useState(false);
+ const { getVideo, setVideo } = useAICreateTitleStore(
+ useShallow((state) => ({
+ getVideo: state.getVideo,
+ setVideo: state.setVideo,
+ })),
+ );
+
+ return (
+ <div className={styles.aICreateTitle}>
+ <Button
+ loading={loading}
+ type="link"
+ onClick={async () => {
+ if (!videoFile) return message.warning("您必须上传一个视频!");
+ if (videoFile.duration > 40)
+ return message.warning("视频超过40秒,不支持生成!");
+ if (loading) return;
+ setLoading(true);
+ const videoId = videoFile.size + videoFile.filename;
+ let videoOssUrl = "";
+ videoOssUrl = getVideo(videoId);
+ // 上传
+ if (!videoOssUrl) {
+ const { name } = await toolsApi.uploadFileTemp(videoFile.file);
+ if (name) {
+ videoOssUrl = VITE_APP_FILE_HOST + name;
+ setVideo(videoId, videoOssUrl);
+ } else {
+ setLoading(false);
+ return message.error("网络繁忙,请稍后重试!");
+ }
+ }
+ const res = await toolsApi.apiVideoAiTitle(
+ videoOssUrl,
+ type,
+ max,
+ );
+ onAiCreateFinish(res);
+ setLoading(false);
+ }}
+ >
+ {type === AiCreateType.TITLE ? "AI生成标题" : "AI生成描述"}
+ {tips && (
+ <Tooltip title={tips}>
+ <ExclamationCircleOutlined />
+ </Tooltip>
+ )}
+ </Button>
+ </div>
+ );
+ },
+ ),
+);
+AICreateTitle.displayName = "AICreateTitle";
+
+export default AICreateTitle;
diff --git a/src/app/[lng]/publish/components/AICreateTitle/aICreateTitle.module.scss b/src/app/[lng]/publish/components/AICreateTitle/aICreateTitle.module.scss
new file mode 100644
index 00000000..9c5d7fe7
--- /dev/null
+++ b/src/app/[lng]/publish/components/AICreateTitle/aICreateTitle.module.scss
@@ -0,0 +1,8 @@
+.aICreateTitle {
+ :global {
+ button {
+ margin: 0;
+ padding: 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/app/[lng]/publish/components/AICreateTitle/useAICreateTitle.ts b/src/app/[lng]/publish/components/AICreateTitle/useAICreateTitle.ts
new file mode 100644
index 00000000..205a09fd
--- /dev/null
+++ b/src/app/[lng]/publish/components/AICreateTitle/useAICreateTitle.ts
@@ -0,0 +1,55 @@
+import { create } from "zustand";
+import { combine } from "zustand/middleware";
+import lodash from "lodash";
+
+interface IAICreateTitleStore {
+ /**
+ * 视频列表
+ * key=视频名称+视频size,value=oss地址
+ */
+ aiCreateVideoMap: Map<string, string>;
+}
+
+const store: IAICreateTitleStore = {
+ aiCreateVideoMap: new Map([]),
+};
+
+const getStore = () => {
+ return lodash.cloneDeep(store);
+};
+
+/**
+ * 这个store是为了记录 [AICreateTitle.tsx] 组件上传的视频
+ * 防止同一个视频被上传多次
+ * 注意要在引用该组件的页面销毁后调用这个store的clear方法
+ */
+export const useAICreateTitleStore = create(
+ combine(
+ {
+ ...store,
+ },
+ (set, get, storeApi) => {
+ const methods = {
+ clear() {
+ set({
+ ...getStore(),
+ });
+ },
+
+ getVideo(key: string) {
+ return get().aiCreateVideoMap.get(key) || "";
+ },
+
+ setVideo(key: string, value: string) {
+ const aiCreateVideoMap = new Map(get().aiCreateVideoMap);
+ aiCreateVideoMap.set(key, value);
+
+ set({
+ aiCreateVideoMap,
+ });
+ },
+ };
+ return methods;
+ },
+ ),
+);
diff --git a/src/app/[lng]/publish/components/Choose/ImgChoose.tsx b/src/app/[lng]/publish/components/Choose/ImgChoose.tsx
new file mode 100644
index 00000000..9a845b96
--- /dev/null
+++ b/src/app/[lng]/publish/components/Choose/ImgChoose.tsx
@@ -0,0 +1,140 @@
+/*
+ * @Author: nevin
+ * @Date: 2025-01-22 21:59:36
+ * @LastEditTime: 2025-02-11 21:45:34
+ * @LastEditors: nevin
+ * @Description: 选择图片
+ */
+import { Button, message } from "antd";
+import { FC } from "react";
+import { generateUUID, getFilePathName } from "@/utils";
+// import { icpGetFileStream } from "@/icp/view";
+
+interface ImgChooseProps {
+ // 单选就使用单选方法,多选就使用单选方法
+
+ // 单选返回
+ onChoose?: (_: IImgFile) => void;
+ // 多选返回方法
+ onMultipleChoose?: (_: IImgFile[]) => void;
+ children?: React.ReactNode;
+}
+
+export interface IImgFile {
+ id: string;
+ size: number;
+ file: Blob;
+ // 前端临时路径,注意不要存到数据库
+ imgUrl: string;
+ filename: string;
+ // 图片在硬盘上的路径
+ imgPath: string;
+ // 图片宽度
+ width: number;
+ // 图片高度
+ height: number;
+}
+
+// 根据图片在硬盘上的路径获取文件
+// export const getImgFile = async (path: string): Promise<IImgFile> => {
+// const file = await icpGetFileStream(path);
+// return await formatImg({ path, file });
+// };
+
+/**
+ * 根据图片的Uint8Array和路径获取文件
+ * @param path
+ * @param file
+ * @param blob
+ */
+export const formatImg = async ({
+ path,
+ file,
+ blob,
+}: {
+ path: string;
+ file?: Uint8Array;
+ blob?: Blob;
+}): Promise<IImgFile> => {
+ return new Promise((resolve) => {
+ const { filename, suffix } = getFilePathName(path);
+ if (!blob) {
+ blob = new Blob([file!], {
+ type: `image/${suffix}`,
+ });
+ }
+ const imgUrl = URL.createObjectURL(blob);
+
+ const img = new Image();
+ img.onload = () => {
+ resolve({
+ id: generateUUID(),
+ width: img.width,
+ height: img.height,
+ imgPath: path,
+ size: blob!.size,
+ filename,
+ file: blob!,
+ imgUrl,
+ });
+ };
+ img.src = imgUrl;
+ });
+};
+
+const ImgChoose: FC<ImgChooseProps> = ({
+ onChoose,
+ onMultipleChoose,
+ children,
+}) => {
+ /**
+ * 发送上传的事件
+ */
+ const handleUploadImg = async () => {
+ // TODO 上传图片
+ // try {
+ // const result: {
+ // path: string;
+ // file: Uint8Array;
+ // }[] = await window.ipcRenderer.invoke(
+ // "ICP_VIEWS_CHOSE_IMG",
+ // !!onMultipleChoose,
+ // );
+ // if (!result) return;
+ // const tasks: Promise<IImgFile>[] = [];
+ // for (const v of result) {
+ // tasks.push(formatImg(v));
+ // }
+ // const imgFiles = await Promise.all(tasks);
+ //
+ // if (onMultipleChoose) {
+ // onMultipleChoose(imgFiles);
+ // } else if (onChoose) {
+ // onChoose(imgFiles[0]);
+ // }
+ // } catch (error) {
+ // message.error("选择图片失败");
+ // console.error(error);
+ // }
+ };
+
+ return (
+ <>
+ {children ? (
+ <div
+ className="imgChoose"
+ onClick={handleUploadImg}
+ style={{ cursor: "pointer" }}
+ >
+ {children}
+ </div>
+ ) : (
+ <Button type="primary" onClick={handleUploadImg}>
+ 选择图片
+ </Button>
+ )}
+ </>
+ );
+};
+
+export default ImgChoose;
diff --git a/src/app/[lng]/publish/components/Choose/VideoChoose.tsx b/src/app/[lng]/publish/components/Choose/VideoChoose.tsx
new file mode 100644
index 00000000..a69e6c1a
--- /dev/null
+++ b/src/app/[lng]/publish/components/Choose/VideoChoose.tsx
@@ -0,0 +1,190 @@
+/*
+ * @Author: nevin
+ * @Date: 2025-01-22 21:59:36
+ * @LastEditTime: 2025-01-23 15:40:37
+ * @LastEditors: nevin
+ * @Description: 选择视频
+ */
+import { Button } from "antd";
+import { FC } from "react";
+import { getFilePathName } from "@/utils";
+import { IImgFile } from "@/app/[lng]/publish/components/Choose/ImgChoose";
+// import { saveCropperImage } from "@/views/publish/children/videoPage/components/VideoCoverSeting";
+
+interface VideoChooseProps {
+ // 单选就使用单选方法,多选就使用单选方法
+
+ // 单选返回
+ onChoose?: (videoFile: IVideoFile) => void;
+ // 多选返回方法
+ onMultipleChoose?: (videoFiles: IVideoFile[]) => void;
+ children?: React.ReactNode;
+ // 开始选择
+ onStartShoose?: () => void;
+ onChooseFail?: () => void;
+}
+
+export interface IVideoFile {
+ size: number;
+ file: Blob;
+ // 前端临时路径,注意不要存到数据库
+ videoUrl: string;
+ filename: string;
+ // 视频在硬盘上的路径
+ videoPath: string;
+ // 视频宽度
+ width: number;
+ // 视频高度
+ height: number;
+ // 视频下取整的时长,单位秒
+ duration: number;
+ // 视频首帧图片
+ cover: IImgFile;
+}
+
+function getVideoInfo(
+ videoUrl: string,
+ fileName: string,
+): Promise<{
+ width: number;
+ height: number;
+ // 下取整的时长
+ duration: number;
+ // 视频首帧
+ cover: IImgFile;
+}> {
+ return new Promise((resolve) => {
+ // TODO 截帧
+ // // 创建一个临时的 video 元素
+ // const video = document.createElement("video");
+ //
+ // // 设置 video 元素的 src 属性
+ // video.src = videoUrl;
+ //
+ // // 当视频元数据加载完毕时执行回调
+ // video.addEventListener("loadedmetadata", () => {
+ // video.currentTime = 0;
+ // });
+ //
+ // video.addEventListener("seeked", function () {
+ // // 获取视频的宽度和高度
+ // const width = video.videoWidth;
+ // const height = video.videoHeight;
+ // // 获取视频的时长
+ // const duration = video.duration;
+ //
+ // // 获取视频首帧
+ // const canvas = document.createElement("canvas");
+ // canvas.width = width;
+ // canvas.height = height;
+ // const context = canvas.getContext("2d")!;
+ // context.fillStyle = "white";
+ // context.fillRect(0, 0, width, height);
+ // context.drawImage(video, 0, 0);
+ // canvas.toBlob(async (blob) => {
+ // const imgPath = await saveCropperImage(
+ // `${fileName}.${blob!.type.split("/")[1]}`,
+ // blob!,
+ // );
+ // const cover = await formatImg({
+ // blob: blob!,
+ // path: imgPath,
+ // });
+ // resolve({
+ // width,
+ // height,
+ // duration: Math.floor(duration),
+ // cover,
+ // });
+ // video.remove();
+ // });
+ // });
+ // // 加载视频
+ // video.load();
+ });
+}
+
+// 根据视频的Uint8Array和路径获取文件
+export const formatVideo = async (
+ path: string,
+ file: Uint8Array,
+): Promise<IVideoFile> => {
+ const { filename, suffix } = getFilePathName(path);
+ const blob = new Blob([file], { type: `video/${suffix}` });
+ const videoUrl = URL.createObjectURL(blob);
+
+ const videoInfo = await getVideoInfo(videoUrl, filename);
+ return {
+ videoPath: path,
+ size: file.length,
+ filename,
+ file: blob,
+ videoUrl,
+ ...videoInfo,
+ };
+};
+
+const VideoChoose: FC<VideoChooseProps> = ({
+ onChoose,
+ onMultipleChoose,
+ children,
+ onStartShoose,
+ onChooseFail,
+}) => {
+ /**
+ * 发送上传的事件
+ */
+ const handleUploadVideo = async () => {
+ // TODO 上传视频
+ // try {
+ // // if (onStartShoose) onStartShoose();
+ // const result: {
+ // path: string;
+ // video: Uint8Array;
+ // }[] = await window.ipcRenderer.invoke(
+ // "ICP_VIEWS_CHOSE_VIDEO",
+ // !!onMultipleChoose,
+ // );
+ // if (!result) {
+ // // if (onChooseFail) onChooseFail();
+ // return;
+ // }
+ // if (onStartShoose) onStartShoose();
+ //
+ // const tasks: Promise<IVideoFile>[] = [];
+ // for (const v of result) {
+ // tasks.push(formatVideo(v.path, v.video));
+ // }
+ // const videoFiles = await Promise.all(tasks);
+ //
+ // if (onMultipleChoose) {
+ // onMultipleChoose(videoFiles);
+ // } else if (onChoose) {
+ // onChoose(videoFiles[0]);
+ // }
+ // } catch (error) {
+ // message.error("选择视频失败");
+ // console.error(error);
+ // }
+ };
+
+ return (
+ <>
+ {children ? (
+ <div
+ className="videoChoose"
+ onClick={handleUploadVideo}
+ style={{ cursor: "pointer" }}
+ >
+ {children}
+ </div>
+ ) : (
+ <Button type="primary" onClick={handleUploadVideo}>
+ 选择视频
+ </Button>
+ )}
+ </>
+ );
+};
+
+export default VideoChoose;
diff --git a/src/app/[lng]/publish/components/ChooseAccountModule/ChooseAccountModule.tsx b/src/app/[lng]/publish/components/ChooseAccountModule/ChooseAccountModule.tsx
new file mode 100644
index 00000000..70115c3a
--- /dev/null
+++ b/src/app/[lng]/publish/components/ChooseAccountModule/ChooseAccountModule.tsx
@@ -0,0 +1,119 @@
+import {
+ ForwardedRef,
+ forwardRef,
+ memo,
+ useEffect,
+ useImperativeHandle,
+ useRef,
+ useState,
+} from "react";
+import { Modal, Tabs } from "antd";
+import { AccountInfo } from "@/app/[lng]/publish/videoPage/videoPage";
+import PlatChoose, {
+ IPlatChooseProps,
+ IPlatChooseRef,
+} from "@/app/[lng]/publish/components/ChooseAccountModule/components/PlatChoose";
+
+export interface IChooseAccountModuleRef {
+ getPlatChooseRef: () => IPlatChooseRef | null;
+}
+
+export interface IChooseAccountModuleProps {
+ open: boolean;
+ onClose: (open: boolean) => void;
+ // 按平台props
+ platChooseProps?: IPlatChooseProps;
+ // 按平台选择确认
+ onPlatConfirm?: (accounts: AccountInfo[]) => void;
+ // 按平台选择change
+ onPlatChange?: (accounts: AccountInfo[], account: AccountInfo) => void;
+}
+
+const ChooseAccountModule = memo(
+ forwardRef(
+ (
+ {
+ open,
+ onClose,
+ onPlatConfirm,
+ onPlatChange,
+ platChooseProps,
+ }: IChooseAccountModuleProps,
+ ref: ForwardedRef<IChooseAccountModuleRef>,
+ ) => {
+ const [newChoosedAccounts, setNewChoosedAccounts] = useState<
+ AccountInfo[]
+ >([]);
+ const platChooseRef = useRef<IPlatChooseRef>(null);
+
+ const handleOk = () => {
+ if (onPlatConfirm) onPlatConfirm(newChoosedAccounts);
+ close();
+ };
+
+ const handleCancel = () => {
+ setNewChoosedAccounts(platChooseProps?.choosedAccounts || []);
+ close();
+ };
+
+ const close = () => {
+ onClose(false);
+ };
+
+ useEffect(() => {
+ setTimeout(() => platChooseRef.current?.recover(), 1);
+ }, [platChooseProps?.choosedAccounts]);
+
+ useEffect(() => {
+ platChooseRef.current?.init();
+ }, [open]);
+
+ const ImperativeHandle: IChooseAccountModuleRef = {
+ getPlatChooseRef() {
+ return platChooseRef.current;
+ },
+ };
+ useImperativeHandle(ref, () => ImperativeHandle);
+
+ return (
+ <Modal
+ width={800}
+ title="账户选择"
+ open={open}
+ onOk={handleOk}
+ onCancel={handleCancel}
+ >
+ <Tabs
+ defaultActiveKey="1"
+ items={[
+ {
+ key: "1",
+ label: "按平台选择",
+ children: (
+ <>
+ {platChooseProps && (
+ <PlatChoose
+ {...platChooseProps}
+ disableAllSelect={
+ platChooseProps.disableAllSelect || false
+ }
+ ref={platChooseRef}
+ onChange={(aList, account) => {
+ setNewChoosedAccounts(aList);
+ if (onPlatChange) onPlatChange(aList, account);
+ }}
+ />
+ )}
+ </>
+ ),
+ },
+ ]}
+ />
+ </Modal>
+ );
+ },
+ ),
+);
+ChooseAccountModule.displayName = "ChooseAccountModule";
+
+export default ChooseAccountModule;
diff --git a/src/app/[lng]/publish/components/ChooseAccountModule/chooseAccountModule.module.scss b/src/app/[lng]/publish/components/ChooseAccountModule/chooseAccountModule.module.scss
new file mode 100644
index 00000000..1b8cafb5
--- /dev/null
+++ b/src/app/[lng]/publish/components/ChooseAccountModule/chooseAccountModule.module.scss
@@ -0,0 +1,102 @@
+.platChoose {
+ display: flex;
+
+ :global {
+ .platChoose-empty {
+ display: flex;
+ justify-content: center;
+ width: 100%;
+ }
+
+ .platChoose-platSelect {
+ padding-right: 20px;
+ .ant-checkbox-wrapper {
+ margin-bottom: 5px;
+ white-space: nowrap;
+ }
+
+ .ant-segmented {
+ width: 100%;
+ box-sizing: border-box;
+ .ant-segmented-item {
+ margin-bottom: 5px;
+ padding: 3px 60px 3px 0;
+ }
+
+ .ant-segmented-item-label {
+ display: flex;
+ align-items: center;
+ .ant-segmented-item-icon {
+ display: flex;
+ align-items: center;
+ }
+ }
+ }
+ }
+
+ .platChoose-con {
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ &-wrapper {
+ width: 100%;
+ }
+ }
+
+ .platChoose-tips {
+ color: var(--errerColor);
+ font-size: var(--fs-xs);
+ }
+
+ .platChoose-accounts {
+ margin-top: 10px;
+ width: 100%;
+ display: grid;
+ grid-template-columns: repeat(2, 1fr);
+ gap: 15px;
+
+ &-item {
+ background: rgb(247, 250, 250);
+ cursor: pointer;
+ padding: 10px;
+ box-sizing: border-box;
+ border-radius: 6px 0 6px 6px;
+ align-items: center;
+ min-width: 0;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ position: relative;
+ &-nickname {
+ margin-left: 5px;
+ }
+
+ &-choose {
+ position: absolute;
+ top: 0;
+ right: 0;
+ padding: 0 4px;
+ text-align: center;
+ background: rgb(225, 230, 230);
+ border-radius: 0 0 0 12px;
+ color: #fff;
+ font-size: 12px;
+ }
+
+ &--active {
+ background: var(--colorPrimary2);
+
+ .platChoose-accounts-item-choose {
+ background: var(--colorPrimary5);
+ }
+ }
+
+ &--disable {
+ cursor: no-drop;
+ opacity: 0.5;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/app/[lng]/publish/components/ChooseAccountModule/components/PlatChoose.tsx b/src/app/[lng]/publish/components/ChooseAccountModule/components/PlatChoose.tsx
new file mode 100644
index 00000000..b7989794
--- /dev/null
+++ b/src/app/[lng]/publish/components/ChooseAccountModule/components/PlatChoose.tsx
@@ -0,0 +1,390 @@
+import {
+ ForwardedRef,
+ forwardRef,
+ memo,
+ useEffect,
+ useImperativeHandle,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
+import styles from "../chooseAccountModule.module.scss";
+import {
+ Avatar,
+ Badge,
+ Checkbox,
+ ConfigProvider,
+ Empty,
+ Segmented,
+ Tooltip,
+} from "antd";
+import { CheckOutlined } from "@ant-design/icons";
+import { useShallow } from "zustand/react/shallow";
+import useCssVariables from "@/app/hooks/useCssVariables";
+import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";
+import { PubType } from "@/app/config/publishConfig";
+import { useAccountStore } from "@/store/account";
+import { AccountInfo } from "@/app/[lng]/publish/videoPage/videoPage";
+import Link from "next/link";
+
+export interface IPlatChooseRef {
+ /**
+ * 恢复选中状态
+ * @param choosedAccounts
+ */
+ recover: () => void;
+ // 每次关闭弹框的时候需要初始化一些状态
+ init: () => void;
+ // 设置选中平台
+ setActivePlat: (activePlat: PlatType) => void;
+}
+
+export interface IPlatChooseProps {
+ pubType: PubType;
+ // 默认选择的平台
+ defaultPlat?: PlatType;
+ onChange?: (
+ choosedAcounts: AccountInfo[],
+ choosedAcount: AccountInfo,
+ ) => void;
+ // 外部传入的已经选中的数据,这个值只有在确认更改才会更新
+ choosedAccounts?: AccountInfo[];
+ // 按平台 是否禁用多选,true=禁用,false=不禁用
+ disableAllSelect?: boolean;
+ // 可选择的平台,默认为全部
+ allowPlatSet?: Set<PlatType>;
+ // 是否可以取消已经选择的账户,默认为 false
+ isCancelChooseAccount?: boolean;
+}
+
+const PlatChoose = memo(
+ forwardRef(
+ (
+ {
+ pubType,
+ onChange,
+ choosedAccounts,
+ disableAllSelect = false,
+ isCancelChooseAccount = false,
+ allowPlatSet,
+ defaultPlat,
+ }: IPlatChooseProps,
+ ref: ForwardedRef<IPlatChooseRef>,
+ ) => {
+ const cssVars = useCssVariables();
+ // 所有账户数据
+ const [accountMap, setAccountMap] = useState<
+ Map<PlatType, AccountInfo[]>
+ >(new Map());
+ // 当前选择的平台
+ const [activePlat, setActivePlat] = useState<PlatType | undefined>();
+ // 当前选择的账户数据
+ const [choosedAcountMap, setChoosedAcountMap] = useState<
+ Map<PlatType, AccountInfo[]>
+ >(new Map());
+ // 每次change操作的数据
+ const recentData = useRef<AccountInfo>();
+ const { accountList } = useAccountStore(
+ useShallow((state) => ({
+ accountList: state.accountList,
+ })),
+ );
+
+ // 经过 allowPlatSet 过滤后的账户数据
+ const accountMapLast = useMemo(() => {
+ const newVal = new Map<PlatType, AccountInfo[]>();
+ for (const [accountType, accountList] of accountMap) {
+ if (!allowPlatSet ? true : allowPlatSet.has(accountType)) {
+ newVal.set(accountType, accountList);
+ }
+ }
+ return newVal;
+ }, [accountMap, allowPlatSet]);
+
+ // 默认平台设置
+ useEffect(() => {
+ setActivePlat(defaultPlat || Array.from(accountMapLast.keys())[0]);
+ }, [accountMapLast]);
+
+ // 所有平台的账户数据
+ const getAllAccountList = useMemo(() => {
+ const allAccountList = [];
+ for (const [_, accountList] of accountMapLast) {
+ allAccountList.push(...accountList);
+ }
+ return allAccountList;
+ }, [accountMapLast]);
+
+ // 当前选择的所有平台的账户数据
+ const getChoosedAllAccountList = useMemo(() => {
+ const allAccountList = [];
+ for (const [_, accountList] of choosedAcountMap) {
+ allAccountList.push(...accountList);
+ }
+ return allAccountList;
+ }, [choosedAcountMap]);
+
+ // 当前平台的所有用户数据
+ const currAccountList = useMemo(
+ () => (activePlat && accountMapLast.get(activePlat)) || [],
+ [activePlat, accountMapLast],
+ );
+
+ // 当前平台的选择账户的数据
+ const currChoosedAcount = useMemo(
+ () => (activePlat && choosedAcountMap.get(activePlat)) || [],
+ [activePlat, choosedAcountMap],
+ );
+
+ useEffect(() => {
+ setAccountMap((prevMap) => {
+ const newMap = new Map(prevMap);
+ Array.from(AccountPlatInfoMap).map(([key, value]) => {
+ if (value.pubTypes.has(pubType)) {
+ newMap.set(key, []);
+ }
+ });
+ // 添加渲染账户数据值
+ accountList.map((v) => {
+ newMap.get(v.type)?.push(v);
+ });
+ return newMap;
+ });
+ }, [accountList]);
+
+ useEffect(() => {
+ return () => {
+ setAccountMap(new Map());
+ setChoosedAcountMap(new Map());
+ init();
+ };
+ }, []);
+
+ // change事件
+ useEffect(() => {
+ if (!recentData.current) return;
+ let accounts: AccountInfo[] = [];
+ Array.from(choosedAcountMap).map(([key, value]) => {
+ accounts = [...accounts, ...value];
+ });
+ if (onChange) onChange(accounts, recentData.current!);
+ }, [choosedAcountMap]);
+
+ const init = () => {
+ recentData.current = undefined;
+ };
+
+ useImperativeHandle(ref, () => ({
+ // 恢复到本次操作之前的状态
+ recover() {
+ if (!choosedAccounts || choosedAccounts.length === 0)
+ return setChoosedAcountMap(new Map());
+
+ setChoosedAcountMap(() => {
+ const newV = new Map();
+ choosedAccounts.map((v) => {
+ if (!newV.has(v.type)) newV.set(v.type, []);
+ newV.get(v.type)!.push(v);
+ });
+ return newV;
+ });
+ },
+ setActivePlat,
+ init,
+ }));
+
+ return (
+ <div className={styles.platChoose}>
+ {getAllAccountList.length === 0 ? (
+ <div className="platChoose-empty">
+ <Empty
+ description={
+ <>
+ 无账户数据,请前往 <Link href="/">账户</Link>添加数据
+ </>
+ }
+ />
+ </div>
+ ) : (
+ <>
+ <div className="platChoose-platSelect">
+ {!disableAllSelect && (
+ <Checkbox
+ indeterminate={
+ getChoosedAllAccountList.length > 0 &&
+ getChoosedAllAccountList.length < getAllAccountList.length
+ }
+ onChange={(e) => {
+ const { checked } = e.target;
+ setChoosedAcountMap((v) => {
+ const newMap = new Map(v);
+ recentData.current = currAccountList[0];
+
+ for (const [
+ accountType,
+ accountList,
+ ] of accountMapLast) {
+ if (checked) {
+ newMap.set(accountType, accountList);
+ } else {
+ newMap.set(accountType, []);
+ }
+ }
+ return newMap;
+ });
+ }}
+ checked={
+ getAllAccountList.length ===
+ getChoosedAllAccountList.length
+ }
+ >
+ 选择所有平台账户
+ </Checkbox>
+ )}
+ <ConfigProvider
+ theme={{
+ components: {
+ Segmented: {
+ trackBg: "#fff",
+ itemSelectedBg: cssVars["--colorPrimary1"],
+ itemHoverBg: cssVars["--colorPrimary2"],
+ itemActiveBg: cssVars["--colorPrimary3"],
+ itemSelectedColor: cssVars["--colorPrimary9"],
+ },
+ },
+ }}
+ >
+ <Segmented
+ vertical
+ size="large"
+ value={activePlat}
+ options={Array.from(accountMapLast)
+ .map(([key, value]) => {
+ if (value.length === 0) return undefined;
+ const platInfo = AccountPlatInfoMap.get(key)!;
+ return {
+ value: key,
+ label: platInfo.name,
+ icon: (
+ <Badge
+ count={choosedAcountMap.get(key)?.length}
+ size="small"
+ >
+ <img src={platInfo.icon} />
+ </Badge>
+ ),
+ };
+ })
+ .filter((v) => v !== undefined)
+ .filter((v) =>
+ allowPlatSet ? allowPlatSet.has(v.value) : true,
+ )}
+ onChange={setActivePlat}
+ />
+ </ConfigProvider>
+ </div>
+
+ <div className="platChoose-con">
+ {currAccountList && (
+ <div className="platChoose-con-wrapper">
+ {!disableAllSelect ? (
+ <Checkbox
+ indeterminate={
+ currChoosedAcount.length > 0 &&
+ currChoosedAcount.length < currAccountList.length
+ }
+ onChange={(e) => {
+ setChoosedAcountMap((v) => {
+ recentData.current = currAccountList[0];
+ return new Map(v).set(
+ activePlat!,
+ e.target.checked ? currAccountList : [],
+ );
+ });
+ }}
+ checked={
+ currChoosedAcount.length === currAccountList.length
+ }
+ >
+ 全选 已选择 {currChoosedAcount.length} 个
+ </Checkbox>
+ ) : (
+ <span>已选择 {currChoosedAcount.length} 个</span>
+ )}
+ <div className="platChoose-accounts">
+ {currAccountList.map((v) => {
+ // true=禁用
+ const isDisable =
+ choosedAccounts?.find((k) => k.id === v.id) &&
+ isCancelChooseAccount;
+ return (
+ <div
+ key={v.id}
+ className={[
+ "platChoose-accounts-item",
+ currChoosedAcount.find((k) => k.id === v.id) &&
+ "platChoose-accounts-item--active",
+ isDisable && "platChoose-accounts-item--disable",
+ ].join(" ")}
+ onClick={() => {
+ if (isDisable) return;
+ recentData.current = v;
+ setChoosedAcountMap((prevV) => {
+ const newV = new Map(prevV);
+ let list = newV.get(activePlat!);
+ if (!list) {
+ list = [];
+ newV.set(activePlat!, list);
+ }
+ // 是否存在
+ if (list.some((k) => k.id === v.id)) {
+ // 有、去掉
+ list = list.filter((k) => k.id !== v.id);
+ } else {
+ // 无、添加
+ list.push(v);
+ }
+ newV.set(activePlat!, list);
+ return newV;
+ });
+ }}
+ >
+ <Tooltip
+ title={
+ <>
+ <p>昵称:{v.nickname}</p>
+ </>
+ }
+ >
+ <Avatar src={v.avatar} />
+ <span className="platChoose-accounts-item-nickname">
+ {v.nickname}
+ </span>
+ </Tooltip>
+
+ <div className="platChoose-accounts-item-choose">
+ <CheckOutlined />
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ )}
+
+ {AccountPlatInfoMap.get(activePlat!)?.tips && (
+ <div className="platChoose-tips">
+ {AccountPlatInfoMap.get(activePlat!)?.tips?.publish}
+ </div>
+ )}
+ </div>
+ </>
+ )}
+ </div>
+ );
+ },
+ ),
+);
+PlatChoose.displayName = "PlatChoose";
+
+export default PlatChoose;
diff --git a/src/app/[lng]/publish/components/CommonComponents/CommonComponents.tsx b/src/app/[lng]/publish/components/CommonComponents/CommonComponents.tsx
new file mode 100644
index 00000000..690ef141
--- /dev/null
+++ b/src/app/[lng]/publish/components/CommonComponents/CommonComponents.tsx
@@ -0,0 +1,202 @@
+import { Button, Radio, Select, SelectProps } from "antd";
+import styles from "./commonComponents.module.scss";
+import React, { ReactNode, useEffect, useState } from "react";
+import { PlusOutlined, UserAddOutlined } from "@ant-design/icons";
+import { AccountStatus } from "@/app/config/accountConfig";
+import { AccountInfo } from "@/app/[lng]/publish/videoPage/videoPage";
+import { VisibleTypeEnum } from "@/app/config/publishConfig";
+import { IMixItem } from "@/app/plat/plat.type";
+
+// 本地上传、素材上传展示的块
+export const ChooseChunk = ({
+ onClick,
+ imgUrl,
+ color,
+ text,
+ hoverColor,
+ style,
+}: {
+ onClick?: () => void;
+ imgUrl: string;
+ hoverColor?: string;
+ color: string;
+ text: string;
+ style?: React.CSSProperties;
+}) => {
+ const [isHovered, setIsHovered] = useState(false);
+
+ return (
+ <>
+ <div
+ className={styles.chooseChunk}
+ onClick={() => {
+ if (onClick) onClick();
+ }}
+ style={
+ isHovered
+ ? {
+ borderColor: hoverColor || color,
+ ...(style || {}),
+ }
+ : style || {}
+ }
+ onMouseEnter={() => setIsHovered(true)}
+ onMouseLeave={() => setIsHovered(false)}
+ >
+ <img src={imgUrl} />
+ <Button type="primary" size="large" style={{ background: color }}>
+ {text}
+ </Button>
+ </div>
+ </>
+ );
+};
+
+// 选择账户展示的块
+export const ChooseAccountChunk = ({
+ onClick,
+ children,
+}: {
+ onClick: () => void;
+ children?: ReactNode;
+}) => {
+ return (
+ <div className={styles.chooseAccountChunk} onClick={onClick}>
+ <UserAddOutlined className="chooseAccountChunk-user" />
+ <Button icon={<PlusOutlined />} type="primary">
+ 选择发布账号
+ </Button>
+ {children}
+ </div>
+ );
+};
+
+export interface PubPermissionProps {
+ onChange?: (visibleType: VisibleTypeEnum) => void;
+ value?: VisibleTypeEnum;
+ title?: string;
+ style?: React.CSSProperties;
+}
+
+// 权限设置
+export const PubPermission = ({
+ onChange,
+ value,
+ style,
+ title = "权限设置",
+}: PubPermissionProps) => {
+ return (
+ <>
+ <h1>{title}</h1>
+ <Radio.Group
+ style={style}
+ options={[
+ {
+ label: "公开(所有人可见)",
+ value: VisibleTypeEnum.Public,
+ },
+ { label: "好友可见", value: VisibleTypeEnum.Friend },
+ {
+ label: "私密(仅自己可见)",
+ value: VisibleTypeEnum.Private,
+ },
+ ]}
+ onChange={(e) => {
+ if (onChange) onChange(e.target.value);
+ }}
+ value={value}
+ />
+ </>
+ );
+};
+
+// 账户重新登录
+export const AccountRestartLogin = ({
+ account,
+ onAccountRestart,
+}: {
+ account?: AccountInfo;
+ onAccountRestart: () => void;
+}) => {
+ return (
+ <>
+ {account?.status === AccountStatus.DISABLE && (
+ <div className={styles.accountRestartLogin}>
+ 账户已失效,
+ <Button
+ type="link"
+ onClick={() => {
+ onAccountRestart();
+ }}
+ >
+ 重新登录
+ </Button>
+ 后可获取
+ </div>
+ )}
+ </>
+ );
+};
+
+// 合集
+export const CommonMixSelect = ({
+ account,
+ onAccountChange,
+ children,
+ ...props
+}: {
+ account?: AccountInfo;
+ children?: React.ReactNode;
+ onAccountChange?: (account: AccountInfo) => void;
+} & SelectProps) => {
+ if (!account || !onAccountChange) return "";
+
+ const [options, setOptions] = useState<IMixItem[]>([]);
+
+ const getList = async () => {
+ // TODO 获取合集
+ // const res = await icpGetMixList(account!);
+ // const data = await accountFailureDispose(res, account!, onAccountChange);
+ // setOptions(data);
+ };
+
+ useEffect(() => {
+ getList();
+ // TODO onAccountLoginFinish
+ // return onAccountLoginFinish((newAccount) => {
+ // account = newAccount;
+ // getList();
+ // });
+ }, []);
+
+ return (
+ <>
+ <h1>合集</h1>
+ <Select
+ options={options}
+ allowClear
+ style={{ width: "100%" }}
+ placeholder="选择合集"
+ fieldNames={{
+ label: "name",
+ value: "id",
+ }}
+ optionRender={({ data }) => {
+ return (
+ <div className={styles.mixSelectItem}>
+ <div className="mixSelectItem-left">
+ {data.coverImg && <img src={data.coverImg} />}
+ {data.name}
+ </div>
+ <div className="mixSelectItem-right">
+ 共{data.feedCount}个作品
+ </div>
+ </div>
+ );
+ }}
+ {...props}
+ />
+ {children}
+ </>
+ );
+};
diff --git a/src/app/[lng]/publish/components/CommonComponents/CommonLocationSelect.tsx b/src/app/[lng]/publish/components/CommonComponents/CommonLocationSelect.tsx
new file mode 100644
index 00000000..e4b19831
--- /dev/null
+++ b/src/app/[lng]/publish/components/CommonComponents/CommonLocationSelect.tsx
@@ -0,0 +1,96 @@
+import React, { useEffect, useRef } from "react";
+import { Select, SelectProps, Spin } from "antd";
+import styles from "./commonComponents.module.scss";
+import useDebounceFetcher from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/useDebounceFetcher";
+import {
+ AccountInfo,
+ ILocationDataItem,
+} from "@/app/[lng]/publish/videoPage/videoPage";
+
+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) => {
+ // TODO 位置获取
+ // 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,
+ // });
+ // return await accountFailureDispose(
+ // locationData,
+ // account,
+ // onAccountChange,
+ // );
+ return undefined;
+ });
+ // 位置 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/app/[lng]/publish/components/CommonComponents/CommonScheduledTimeSelect.tsx b/src/app/[lng]/publish/components/CommonComponents/CommonScheduledTimeSelect.tsx
new file mode 100644
index 00000000..e8a1ddea
--- /dev/null
+++ b/src/app/[lng]/publish/components/CommonComponents/CommonScheduledTimeSelect.tsx
@@ -0,0 +1,105 @@
+import React, { ForwardedRef, forwardRef, memo, useMemo } from "react";
+import dayjs from "dayjs";
+import { DatePicker } from "antd";
+import styles from "./commonComponents.module.scss";
+import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";
+
+export interface ICommonScheduledTimeSelectRef {}
+
+export interface ICommonScheduledTimeSelectProps {
+ // 分钟、当前时间 + 这个分钟之后的时间才可以选择
+ timeOffset?: number;
+ // 天,昨天 ~ maxDate
+ maxDate?: number;
+ value?: dayjs.Dayjs | null | undefined;
+ onChange?:
+ | ((date: dayjs.Dayjs, dateString: string | string[]) => void)
+ | undefined;
+ platType?: PlatType;
+ isTitle?: boolean;
+}
+
+// 通用定时发布
+const CommonScheduledTimeSelect = memo(
+ forwardRef(
+ (
+ {
+ timeOffset,
+ maxDate,
+ value,
+ onChange,
+ platType,
+ isTitle = true,
+ }: ICommonScheduledTimeSelectProps,
+ ref: ForwardedRef<ICommonScheduledTimeSelectRef>,
+ ) => {
+ const getMaxTimes = useMemo(() => {
+ const accountPlatInfo = AccountPlatInfoMap.get(
+ platType || PlatType.Douyin,
+ )!;
+ const timingMax = accountPlatInfo.commonPubParamsConfig.timingMax;
+
+ return {
+ timeOffset: timeOffset || timingMax!.timeOffset,
+ maxDate: maxDate || timingMax!.maxDate,
+ };
+ }, [platType]);
+
+ const range = (start: number, end: number) => {
+ const result = [];
+ for (let i = start; i < end; i++) {
+ result.push(i);
+ }
+ return result;
+ };
+
+ const disabledDate = (current: dayjs.Dayjs) => {
+ const yesterday = dayjs().subtract(0, "day").startOf("day");
+ const futureDate = dayjs().add(getMaxTimes.maxDate, "day").endOf("day");
+ return (
+ current &&
+ (current.isBefore(yesterday, "day") ||
+ current.isAfter(futureDate, "day"))
+ );
+ };
+
+ const disabledTime = (current: dayjs.Dayjs | null) => {
+ const now = dayjs();
+ const minutesOffset = now.add(getMaxTimes.timeOffset, "minute");
+ if (current && current.isBefore(minutesOffset)) {
+ const hours = minutesOffset.hour();
+ const minutes = minutesOffset.minute();
+ return {
+ disabledHours: () => range(0, hours),
+ disabledMinutes: () => range(0, minutes),
+ };
+ }
+ return {
+ disabledHours: () => [],
+ disabledMinutes: () => [],
+ };
+ };
+
+ return (
+ <>
+ {isTitle && <h1>定时发布</h1>}
+ <DatePicker
+ format="YYYY-MM-DD HH:mm"
+ disabledDate={disabledDate}
+ disabledTime={disabledTime}
+ showTime={{ defaultValue: dayjs("00:00:00", "HH:mm:ss") }}
+ value={value}
+ onChange={onChange}
+ />
+ <p className={styles.tips}>
+ 支持{getMaxTimes.timeOffset}分钟后及{getMaxTimes.maxDate}
+ 天内的定时发布
+ </p>
+ </>
+ );
+ },
+ ),
+);
+CommonScheduledTimeSelect.displayName = "CommonScheduledTimeSelect";
+
+export default CommonScheduledTimeSelect;
diff --git a/src/app/[lng]/publish/components/CommonComponents/CommonTopicSelect.tsx b/src/app/[lng]/publish/components/CommonComponents/CommonTopicSelect.tsx
new file mode 100644
index 00000000..4425dfbc
--- /dev/null
+++ b/src/app/[lng]/publish/components/CommonComponents/CommonTopicSelect.tsx
@@ -0,0 +1,71 @@
+import React from "react";
+import { SelectProps } from "antd";
+import { Select, Spin } from "antd";
+import styles from "./commonComponents.module.scss";
+import useDebounceFetcher from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/useDebounceFetcher";
+import { AccountInfo } from "@/app/[lng]/publish/videoPage/videoPage";
+
+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[]> => {
+ // TODO 话题获取
+ // const topics = await icpGetTopic(account!, keyword);
+ //
+ // const res = await accountFailureDispose(
+ // topics,
+ // account,
+ // onAccountChange,
+ // );
+ // return res!.map((v) => {
+ // return {
+ // label: v.name,
+ // value: v.name,
+ // };
+ // }) as CommonTopicSelectValueType[];
+ return [];
+ },
+ );
+
+ 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={styles.tips}>{tips}</p>
+ </>
+ );
+}
diff --git a/src/app/[lng]/publish/components/CommonComponents/CommonUserSelect.tsx b/src/app/[lng]/publish/components/CommonComponents/CommonUserSelect.tsx
new file mode 100644
index 00000000..d9115096
--- /dev/null
+++ b/src/app/[lng]/publish/components/CommonComponents/CommonUserSelect.tsx
@@ -0,0 +1,109 @@
+import React, { useEffect } from "react";
+import { Avatar, Select, SelectProps, Spin } from "antd";
+import styles from "./commonComponents.module.scss";
+import { describeNumber } from "@/utils";
+import { IUsersItem } from "@/app/plat/plat.type";
+import useDebounceFetcher from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/useDebounceFetcher";
+import { AccountInfo } from "@/app/[lng]/publish/videoPage/videoPage";
+
+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) => {
+ // TODO 获取用户列表
+ // const res = await icpGetUsers({
+ // page: 1,
+ // keyword: keywords || "",
+ // account: account!,
+ // });
+ // const data = await accountFailureDispose(res, account!, onAccountChange);
+ // setOptions(data);
+ // return data;
+ return [];
+ };
+
+ useEffect(() => {
+ if (props.showSearch === false) {
+ getList();
+
+ // TODO 登录完成
+ // return onAccountLoginFinish((newAccount) => {
+ // account = newAccount;
+ // getList();
+ // });
+ }
+ }, []);
+
+ 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={styles.tips}>{props.tips}</p>}
+ </>
+ );
+}
diff --git a/src/app/[lng]/publish/components/CommonComponents/DouyinCommonComponents.tsx b/src/app/[lng]/publish/components/CommonComponents/DouyinCommonComponents.tsx
new file mode 100644
index 00000000..a08711ad
--- /dev/null
+++ b/src/app/[lng]/publish/components/CommonComponents/DouyinCommonComponents.tsx
@@ -0,0 +1,381 @@
+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";
+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/CommonComponents/commonComponents.module.scss b/src/app/[lng]/publish/components/CommonComponents/commonComponents.module.scss
new file mode 100644
index 00000000..dc864ed5
--- /dev/null
+++ b/src/app/[lng]/publish/components/CommonComponents/commonComponents.module.scss
@@ -0,0 +1,270 @@
+.chooseChunk {
+ display: flex;
+ cursor: pointer;
+ flex-direction: column;
+ background: rgb(247, 250, 250);
+ width: 160px;
+ height: 160px;
+ box-sizing: border-box;
+ padding: 20px;
+ justify-content: center;
+ align-items: center;
+ border-radius: 10px;
+ border: 1px solid transparent;
+ transition: 0.3s;
+ img {
+ width: 50px;
+ height: 45px;
+ object-fit: contain;
+ }
+ button {
+ margin-top: 20px;
+ width: 110px;
+ &:hover {
+ opacity: 0.8;
+ }
+ }
+}
+
+.chooseAccountChunk {
+ height: 180px;
+ background: var(--colorPrimary1);
+ border: 1px dashed transparent;
+ border-radius: 8px;
+ cursor: pointer;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ &:hover {
+ border-color: var(--colorPrimary6);
+ }
+ :global {
+ .chooseAccountChunk-user {
+ font-size: 60px;
+ color: var(--colorPrimary4);
+ margin-bottom: 10px;
+ }
+ }
+}
+
+.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(--grayColor7);
+ }
+ &-unique {
+ margin-left: 20px;
+ }
+ }
+ }
+ }
+}
+
+.locationSelect {
+ :global {
+ .location-name {
+ margin-bottom: 2px;
+ }
+ .location-simpleAddress {
+ font-size: var(--fs-xs);
+ color: var(--grayColor7);
+ }
+ }
+}
+
+.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 {
+ border-bottom: 1px solid var(--grayColor3);
+ height: 50px;
+ cursor: pointer;
+ padding: 10px 0;
+ &:last-of-type {
+ border-bottom: none;
+ }
+ :global {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ .activitySelect-left {
+ display: flex;
+ align-items: center;
+ height: 100%;
+ &-img {
+ overflow: hidden;
+ border-radius: 6px;
+ margin-left: 10px;
+ }
+ ul {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ justify-content: space-between;
+ li {
+ &:nth-child(1) {
+ font-weight: 900;
+ }
+ }
+ }
+ img {
+ display: block;
+ width: 36px;
+ height: 42px;
+ border-radius: 8px;
+ margin-right: 8px;
+ }
+ }
+ .activitySelect-right {
+ display: flex;
+ flex-direction: column;
+ align-items: end;
+ justify-content: space-between;
+ height: 100%;
+ &-top {
+ padding: 1px 4px;
+ border-radius: 6px;
+ font-size: var(--fs-xs);
+ 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(--grayColor7);
+ }
+ }
+
+ &-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(--grayColor7);
+ margin-bottom: 10px;
+ }
+ ul {
+ li {
+ margin-right: 5px;
+ }
+ }
+ }
+ }
+}
+
+.tips {
+ color: rgb(178, 185, 185);
+ text-align: left;
+ font-size: var(--fs-sm);
+}
+
+.accountRestartLogin {
+ display: flex;
+ align-items: center;
+ font-size: var(--fs-sm);
+ button {
+ margin: 0;
+ padding: 0;
+ height: auto;
+ }
+}
+
+.mixSelectItem {
+ justify-content: space-between;
+ align-items: center;
+ display: flex;
+ :global {
+ .mixSelectItem-left {
+ display: flex;
+ align-items: center;
+ img {
+ height: 100%;
+ width: 30px;
+ object-fit: contain;
+ margin-right: 8px;
+ }
+ }
+ }
+}
diff --git a/src/app/[lng]/publish/components/CreatePublish.tsx b/src/app/[lng]/publish/components/CreatePublish.tsx
deleted file mode 100644
index ca7a9a6a..00000000
--- a/src/app/[lng]/publish/components/CreatePublish.tsx
+++ /dev/null
@@ -1,192 +0,0 @@
-"use client";
-
-import { useState, useEffect } from "react";
-import { Modal, Form, Input, Button, message, DatePicker, Select } from "antd";
-import { createPublishApi } from "@/api/publish";
-import type { PublishParams } from "@/api/publish";
-import { useAccountStore } from "@/store/account";
-import { PubType, PublishType, PubStatus } from "@/types/publish";
-import dayjs from "dayjs";
-
-const { Option } = Select;
-
-interface CreatePublishProps {
- visible: boolean;
- type: PublishType;
- onClose: () => void;
-}
-
-export default function CreatePublish({
- visible,
- type,
- onClose,
-}: CreatePublishProps) {
- const [form] = Form.useForm();
- const [loading, setLoading] = useState(false);
- const { accountList, accountInit } = useAccountStore();
-
- useEffect(() => {
- if (visible) {
- accountInit();
- }
- }, [visible, accountInit]);
-
- const handleSubmit = async (values: any) => {
- try {
- setLoading(true);
- const params: PublishParams = {
- type,
- title: values.title,
- desc: values.desc,
- accountId: values.accountId,
- videoPath: values.videoPath,
- timingTime: values.timingTime
- ? dayjs(values.timingTime).toISOString()
- : undefined,
- coverPath: values.coverPath,
- commonCoverPath: values.commonCoverPath,
- publishTime: values.publishTime
- ? dayjs(values.publishTime).toISOString()
- : undefined,
- status: values.status || PubStatus.UNPUBLISH,
- };
-
- const response = await createPublishApi(params);
- if (response?.code === 0) {
- message.success("创建成功");
- onClose();
- form.resetFields();
- } else {
- message.error(response?.msg || "创建失败");
- }
- } catch (error) {
- message.error("创建失败");
- } finally {
- setLoading(false);
- }
- };
-
- const getTitle = () => {
- switch (type) {
- case PubType.VIDEO:
- return "视频";
- case PubType.ARTICLE:
- return "文章";
- case PubType.IMAGE_TEXT:
- return "图文";
- default:
- return "";
- }
- };
-
- return (
- <Modal
- title={`创建${getTitle()}发布`}
- open={visible}
- onCancel={onClose}
- footer={null}
- width={600}
- >
- <Form form={form} layout="vertical" onFinish={handleSubmit}>
- <Form.Item
- name="accountId"
- label="选择账户"
- rules={[{ required: true, message: "请选择账户" }]}
- >
- <Select placeholder="请选择账户">
- {accountList.map((account) => (
- <Option key={account.id} value={account.id}>
- {account.nickname} ({account.type})
- </Option>
- ))}
- </Select>
- </Form.Item>
-
- <Form.Item
- name="title"
- label="标题"
- rules={[{ required: true, message: "请输入标题" }]}
- >
- <Input placeholder="请输入标题" />
- </Form.Item>
-
- <Form.Item
- name="desc"
- label="描述"
- rules={[{ required: true, message: "请输入描述" }]}
- >
- <Input.TextArea rows={4} placeholder="请输入描述" />
- </Form.Item>
-
- {type === PubType.VIDEO && (
- <>
- <Form.Item
- name="videoPath"
- label="视频路径"
- rules={[{ required: true, message: "请输入视频路径" }]}
- >
- <Input placeholder="请输入视频路径" />
- </Form.Item>
-
- <Form.Item
- name="coverPath"
- label="封面路径"
- rules={[{ required: true, message: "请输入封面路径" }]}
- >
- <Input placeholder="请输入封面路径" />
- </Form.Item>
-
- <Form.Item name="commonCoverPath" label="通用封面路径">
- <Input placeholder="请输入通用封面路径" />
- </Form.Item>
- </>
- )}
-
- {type === PubType.IMAGE_TEXT && (
- <Form.Item
- name="imagePath"
- label="图片路径"
- rules={[{ required: true, message: "请输入图片路径" }]}
- >
- <Input placeholder="请输入图片路径" />
- </Form.Item>
- )}
-
- <Form.Item
- name="status"
- label="发布状态"
- initialValue={PubStatus.UNPUBLISH}
- >
- <Select placeholder="请选择发布状态">
- <Option value={PubStatus.UNPUBLISH}>未发布</Option>
- <Option value={PubStatus.RELEASED}>已发布</Option>
- <Option value={PubStatus.FAIL}>发布失败</Option>
- <Option value={PubStatus.PART_SUCCESS}>部分成功</Option>
- </Select>
- </Form.Item>
-
- <Form.Item name="timingTime" label="定时发布时间">
- <DatePicker
- showTime
- placeholder="请选择定时发布时间"
- style={{ width: "100%" }}
- />
- </Form.Item>
-
- <Form.Item name="publishTime" label="发布时间">
- <DatePicker
- showTime
- placeholder="请选择发布时间"
- style={{ width: "100%" }}
- />
- </Form.Item>
-
- <Form.Item>
- <Button type="primary" htmlType="submit" loading={loading} block>
- 提交
- </Button>
- </Form.Item>
- </Form>
- </Modal>
- );
-}
diff --git a/src/app/[lng]/publish/components/DraftList.tsx b/src/app/[lng]/publish/components/DraftList.tsx
deleted file mode 100644
index 47b73635..00000000
--- a/src/app/[lng]/publish/components/DraftList.tsx
+++ /dev/null
@@ -1,124 +0,0 @@
-"use client";
-
-import { useEffect, useState } from 'react';
-import { Table, message, Tag } from 'antd';
-import type { ColumnsType } from 'antd/es/table';
-import { getDraftsListApi } from '@/api/publish';
-import { PubType, PubStatus } from '@/types/publish';
-
-interface DraftItem {
- id: number;
- title: string;
- type: string;
- status: number;
- createTime: string;
- updateTime: string;
-}
-
-export default function DraftList() {
- const [loading, setLoading] = useState(false);
- const [data, setData] = useState<DraftItem[]>([]);
- const [pagination, setPagination] = useState({
- current: 1,
- pageSize: 10,
- total: 0,
- });
-
- const getStatusTag = (status: number) => {
- switch (status) {
- case PubStatus.UNPUBLISH:
- return <Tag color="default">未发布</Tag>;
- case PubStatus.RELEASED:
- return <Tag color="success">已发布</Tag>;
- case PubStatus.FAIL:
- return <Tag color="error">发布失败</Tag>;
- case PubStatus.PART_SUCCESS:
- return <Tag color="warning">部分成功</Tag>;
- default:
- return <Tag>未知状态</Tag>;
- }
- };
-
- const getTypeText = (type: string) => {
- switch (type) {
- case PubType.VIDEO:
- return '视频';
- case PubType.ARTICLE:
- return '文章';
- case PubType.IMAGE_TEXT:
- return '图文';
- default:
- return type;
- }
- };
-
- const columns: ColumnsType<DraftItem> = [
- {
- title: '标题',
- dataIndex: 'title',
- key: 'title',
- },
- {
- title: '类型',
- dataIndex: 'type',
- key: 'type',
- render: (type) => getTypeText(type),
- },
- {
- title: '状态',
- dataIndex: 'status',
- key: 'status',
- render: (status) => getStatusTag(status),
- },
- {
- title: '创建时间',
- dataIndex: 'createTime',
- key: 'createTime',
- },
- {
- title: '更新时间',
- dataIndex: 'updateTime',
- key: 'updateTime',
- },
- ];
-
- const fetchData = async (page = 1, pageSize = 10) => {
- try {
- setLoading(true);
- const response: any = await getDraftsListApi(page, pageSize);
- if (response?.code === 0) {
- setData(response.data.list);
- setPagination({
- ...pagination,
- current: page,
- total: response.data.total,
- });
- } else {
- message.error(response?.msg || '获取草稿列表失败');
- }
- } catch (error) {
- message.error('获取草稿列表失败');
- } finally {
- setLoading(false);
- }
- };
-
- useEffect(() => {
- fetchData();
- }, []);
-
- const handleTableChange = (newPagination: any) => {
- fetchData(newPagination.current, newPagination.pageSize);
- };
-
- return (
- <Table
- columns={columns}
- dataSource={data}
- rowKey="id"
- pagination={pagination}
- loading={loading}
- onChange={handleTableChange}
- />
- );
-}
\ No newline at end of file
diff --git a/src/app/[lng]/publish/components/PubAccountDetModule/PubAccountDetModule.tsx b/src/app/[lng]/publish/components/PubAccountDetModule/PubAccountDetModule.tsx
new file mode 100644
index 00000000..4a8b552a
--- /dev/null
+++ b/src/app/[lng]/publish/components/PubAccountDetModule/PubAccountDetModule.tsx
@@ -0,0 +1,358 @@
+import {
+ ForwardedRef,
+ forwardRef,
+ memo,
+ useEffect,
+ useImperativeHandle,
+ useState,
+} from "react";
+import styles from "./pubAccountDetModule.module.scss";
+import { Alert, Button, Checkbox, Modal, Tooltip } from "antd";
+import { CheckCircleOutlined, CloseCircleOutlined } from "@ant-design/icons";
+import { LoadingOutlined } from "@ant-design/icons";
+import { AvatarPlat } from "../PubProgressModule/PubProgressModule";
+import { useAccountStore } from "@/store/account";
+import { useShallow } from "zustand/react/shallow";
+import { AccountInfo } from "@/app/[lng]/publish/videoPage/videoPage";
+import { AccountGroupItem } from "@/api/types/account.type";
+
+export interface IPubAccountDetModuleRef {
+ // 打开弹框并且开始检测
+ startDet: () => void;
+}
+
+export interface IPubAccountDetModuleProps {
+ // 待检测的账户
+ accounts: AccountInfo[];
+ // 弹框关闭
+ onClose?: () => void;
+ // 发布
+ onPubClick?: () => void;
+ /**
+ * 检测完成
+ * @param accounts 检测过后的账户数据
+ */
+ onDetFinish?: (accounts: AccountInfo[]) => void;
+ // 重新登录完成事件
+ onRestartLoginFinish?: (accounts: AccountInfo) => void;
+ title?: string;
+ tips?: string;
+ // 是否需要footer操作栏
+ isFooter?: boolean;
+ // 是否需要校验代理地址
+ isCheckProxy?: boolean;
+}
+
+// 发布用户检测
+const PubAccountDetModule = memo(
+ forwardRef(
+ (
+ {
+ onRestartLoginFinish,
+ accounts,
+ onClose,
+ onPubClick,
+ onDetFinish,
+ title = "发布检测",
+ tips = "以下账号将发布至平台",
+ isFooter = true,
+ isCheckProxy = false,
+ }: IPubAccountDetModuleProps,
+ ref: ForwardedRef<IPubAccountDetModuleRef>,
+ ) => {
+ const [open, setOpen] = useState(false);
+ const [detLoading, setDetLoading] = useState(false);
+ // 失效 ids
+ const [disabledIdSet, setDisabledIdSet] = useState<Set<number>>(
+ new Set([]),
+ );
+ const [progress, setProgress] = useState(0);
+ const [isFilterAccountOl, setIsFilterAccountOl] = useState(false);
+ // 代理失效的账户组Map
+ const [proxyInvalidAccountMap, setProxyInvalidAccountMap] = useState<
+ Map<number, AccountGroupItem>
+ >(new Map());
+ const { accountGroupMap, getAccountList } = useAccountStore(
+ useShallow((state) => ({
+ accountGroupMap: state.accountGroupMap,
+ getAccountList: state.getAccountList,
+ })),
+ );
+
+ useEffect(() => {
+ if (open) {
+ setDisabledIdSet(new Set([]));
+ setIsFilterAccountOl(false);
+ }
+ }, [open]);
+
+ useEffect(() => {
+ if (disabledIdSet.size === 0) {
+ setIsFilterAccountOl(false);
+ }
+ }, [disabledIdSet]);
+
+ const close = () => {
+ if (detLoading) return;
+ setOpen(false);
+ if (onClose) onClose();
+ };
+
+ // 检测账户状态
+ const retLoginStatusCore = async (account: AccountInfo) => {
+ // TODO 检测账户状态
+ // const res = await acpAccountLoginCheck(
+ // account.type,
+ // account.uid,
+ // false,
+ // );
+ // setProgress((prevProgress) => prevProgress + 1);
+ // return res;
+ };
+
+ // TODO 检测代理地址有效性
+ const retProxyCheckCore = async (group: AccountGroupItem) => {
+ // let status = true;
+ // if (group.proxyIp) {
+ // status = await icpProxyCheck(group.proxyIp);
+ // }
+ // return {
+ // status,
+ // group,
+ // };
+ };
+
+ const getIp = (account: AccountInfo) => {
+ // TODO 获取ip name
+ // if (!isCheckProxy) return "";
+ // const group = accountGroupMap.get(account.groupId!)!;
+ // if (!group.proxyOpen || !group.proxyIp) return "";
+ // return "代理" + ` ${group.proxyIp}`;
+ return "";
+ };
+
+ const imperative: IPubAccountDetModuleRef = {
+ async startDet() {
+ // TODO 账户检测
+ // setProxyInvalidAccountMap(new Map());
+ // setDisabledIdSet(new Set([]));
+ // setOpen(true);
+ // setDetLoading(true);
+ //
+ // // 账户状态
+ // const tasksAccountStatus: Promise<AccountInfo>[] = [];
+ // // 代理地址有效性检测
+ // const tasksProxyCheck: Promise<{
+ // status: boolean;
+ // group: AccountGroupItem;
+ // }>[] = [];
+ // // 代理地址需要检测的账户组
+ // const proxyGroupSet = new Set<number>([]);
+ // for (let i = 0; i < accounts.length; i++) {
+ // const account = accounts[i];
+ // tasksAccountStatus.push(retLoginStatusCore(account));
+ //
+ // if (isCheckProxy) {
+ // // 代理有效性检测
+ // if (!proxyGroupSet.has(account.groupId!)) {
+ // const group = accountGroupMap.get(account.groupId!)!;
+ // if (group.proxyOpen) {
+ // tasksProxyCheck.push(
+ // retProxyCheckCore(accountGroupMap.get(account.groupId!)!),
+ // );
+ // }
+ // proxyGroupSet.add(account.groupId!);
+ // }
+ // }
+ // }
+ //
+ // // 等待代理和账号有效性检测...
+ // const resGroupProxyStatus = await Promise.all(tasksProxyCheck);
+ // const resAccountStatus = await Promise.all(tasksAccountStatus);
+ //
+ // await getAccountList();
+ //
+ // setTimeout(() => {
+ // if (onDetFinish) onDetFinish(resAccountStatus);
+ // setDetLoading(false);
+ //
+ // const disabledIdSet = new Set<number>([]);
+ // resAccountStatus.map((v) =>
+ // v.status === AccountStatus.DISABLE ? disabledIdSet.add(v.id) : "",
+ // );
+ // setDisabledIdSet(disabledIdSet);
+ // setProgress(0);
+ //
+ // resGroupProxyStatus.map((v) => {
+ // if (!v.status) {
+ // setProxyInvalidAccountMap((prevState) => {
+ // const newState = new Map<number, AccountGroupItem>(prevState);
+ // newState.set(v.group.id, v.group);
+ // return newState;
+ // });
+ // }
+ // });
+ // }, 50);
+ },
+ };
+ useImperativeHandle(ref, () => imperative);
+
+ return (
+ <Modal
+ width={530}
+ title={title}
+ maskClosable={false}
+ open={open}
+ onCancel={close}
+ footer={null}
+ >
+ <div className={styles.pubAccountDetModule}>
+ <div className="pubAccountDetModule-tips">
+ {!detLoading ? (
+ <>
+ {disabledIdSet.size === 0 ? (
+ proxyInvalidAccountMap.size === 0 && `${tips}`
+ ) : (
+ <Alert
+ style={{ marginBottom: "10px" }}
+ message={
+ <div className={styles.loginStatusDisable}>
+ <span>账号登录状态失效,点击账户重新登录</span>
+ <Checkbox
+ checked={isFilterAccountOl}
+ onChange={(e) =>
+ setIsFilterAccountOl(e.target.checked)
+ }
+ >
+ 过滤在线账户
+ </Checkbox>
+ </div>
+ }
+ type="error"
+ showIcon
+ />
+ )}
+
+ {proxyInvalidAccountMap.size !== 0 && (
+ <Alert
+ message={
+ <div>
+ <span>以下代理不可用,请调整后重试:</span>
+ <ul>
+ {Array.from(proxyInvalidAccountMap).map(
+ ([_, v]) => {
+ return (
+ <li key={v.id}>
+ {/* TODO 代理不可用展示 */}
+ {/*用户组:{v.name},代理地址:{v.proxyIp}{" "}*/}
+ 不可用
+ </li>
+ );
+ },
+ )}
+ </ul>
+ </div>
+ }
+ type="error"
+ showIcon
+ />
+ )}
+ </>
+ ) : (
+ <>
+ 正在检测账号状态 {progress} / {accounts.length}
+ <LoadingOutlined />
+ </>
+ )}
+ </div>
+ <div className="pubAccountDetModule-accounts">
+ {accounts
+ .filter((v) =>
+ isFilterAccountOl
+ ? disabledIdSet.has(v.id) && !detLoading
+ : true,
+ )
+ .map((v) => {
+ return (
+ <div
+ className={[
+ "pubAccountDetModule-accounts-account",
+ disabledIdSet.has(v.id) ||
+ proxyInvalidAccountMap.get(v.groupId)
+ ? "pubAccountDetModule-accounts-disable"
+ : !disabledIdSet.has(v.id) &&
+ !detLoading &&
+ "pubAccountDetModule-accounts-ol",
+ ].join(" ")}
+ style={{
+ cursor: disabledIdSet.has(v.id) ? "pointer" : "auto",
+ }}
+ key={v.id}
+ onClick={async () => {
+ // TODO 重新登录
+ // if (disabledIdSet.has(v.id)) {
+ // const res = await accountLogin(v.type);
+ // if (!res) return;
+ // message.success("登录成功!");
+ // if (onRestartLoginFinish) onRestartLoginFinish(res);
+ // setDisabledIdSet((prevState) => {
+ // const newState = new Set<number>(prevState);
+ // newState.delete(res.id);
+ // return newState;
+ // });
+ // }
+ }}
+ >
+ <AvatarPlat account={v} size="default" />
+ <Tooltip title={v.nickname}>
+ <div
+ className={["pubAccountDetModule-accounts-name"].join(
+ " ",
+ )}
+ >
+ <div className="pubAccountDetModule-accounts-name-wrapper">
+ <CloseCircleOutlined className="pubAccountDetModule-accounts-disable-icon" />
+ <CheckCircleOutlined className="pubAccountDetModule-accounts-ol-icon" />
+ <span>{v.nickname}</span>
+ </div>
+ </div>
+ </Tooltip>
+ <div className="pubAccountDetModule-accounts-proxy">
+ <Tooltip title={getIp(v)}>
+ <span>{getIp(v)}</span>
+ </Tooltip>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ </div>
+
+ {isFooter && (
+ <div style={{ display: "flex", justifyContent: "right" }}>
+ <Button style={{ marginRight: "10px" }} onClick={close}>
+ 取消
+ </Button>
+ <Button
+ type="primary"
+ loading={detLoading}
+ disabled={
+ disabledIdSet.size !== 0 || proxyInvalidAccountMap.size !== 0
+ }
+ onClick={() => {
+ setOpen(false);
+ if (onPubClick) onPubClick();
+ }}
+ >
+ 发布至平台
+ </Button>
+ </div>
+ )}
+ </Modal>
+ );
+ },
+ ),
+);
+PubAccountDetModule.displayName = "PubAccountDetModule";
+
+export default PubAccountDetModule;
diff --git a/src/app/[lng]/publish/components/PubAccountDetModule/pubAccountDetModule.module.scss b/src/app/[lng]/publish/components/PubAccountDetModule/pubAccountDetModule.module.scss
new file mode 100644
index 00000000..3be9b5b1
--- /dev/null
+++ b/src/app/[lng]/publish/components/PubAccountDetModule/pubAccountDetModule.module.scss
@@ -0,0 +1,75 @@
+.pubAccountDetModule {
+ min-height: 300px;
+ :global {
+ .pubAccountDetModule-tips {
+ margin-bottom: 20px;
+ & > .anticon {
+ margin-left: 10px;
+ color: var(--colorPrimary6);
+ }
+ }
+
+ .pubAccountDetModule-accounts {
+ display: grid;
+ grid-template-columns: repeat(4, 1fr);
+ max-height: 60vh;
+ overflow: auto;
+ gap: 10px;
+ &-account {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ overflow: hidden;
+ }
+ &-name {
+ white-space: nowrap;
+ margin-top: 5px;
+ text-overflow: ellipsis;
+ width: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ &-wrapper {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ .anticon {
+ margin-right: 3px;
+ display: none;
+ }
+ }
+ &-proxy {
+ color: var(--grayColor7);
+ font-size: var(--fs-xs);
+ white-space: nowrap;
+ width: 100%;
+ text-overflow: ellipsis;
+ overflow: hidden;
+ }
+ &-disable {
+ color: var(--errerColor);
+ .pubAccountDetModule-accounts-disable-icon {
+ display: inline-block;
+ }
+ .pubAccountDetModule-accounts-proxy {
+ color: var(--errerColor);
+ }
+ }
+ &-ol {
+ color: var(--successColor);
+ .pubAccountDetModule-accounts-ol-icon {
+ display: inline-block;
+ }
+ .pubAccountDetModule-accounts-proxy {
+ color: var(--successColor);
+ }
+ }
+ }
+ }
+}
+
+.loginStatusDisable {
+ display: flex;
+ justify-content: space-between;
+}
diff --git a/src/app/[lng]/publish/components/PubProgressModule/PubProgressModule.tsx b/src/app/[lng]/publish/components/PubProgressModule/PubProgressModule.tsx
new file mode 100644
index 00000000..37cca0f4
--- /dev/null
+++ b/src/app/[lng]/publish/components/PubProgressModule/PubProgressModule.tsx
@@ -0,0 +1,114 @@
+import { ForwardedRef, forwardRef, memo } from "react";
+import { Alert, Avatar, Modal, Progress, Tooltip } from "antd";
+import styles from "./pubProgressModule.module.scss";
+import { MinusOutlined } from "@ant-design/icons";
+import type { AvatarSize } from "antd/es/avatar/AvatarContext";
+import { SocialAccount } from "@/api/types/account.type";
+import { PublishProgressRes } from "@/app/plat/plat.type";
+import { AccountPlatInfoMap } from "@/app/config/platConfig";
+
+export interface IPubProgressModuleRef {}
+
+export interface IPubProgressModuleProps {
+ pubProgressData: PublishProgressRes[];
+ open: boolean;
+ onClose: () => void;
+}
+
+function getMsg(progressData: PublishProgressRes) {
+ if (progressData.progress === 100) {
+ return "发布成功";
+ } else if (progressData.progress === -1) {
+ return "发布错误";
+ } else {
+ return progressData.msg || "正在加载...";
+ }
+}
+
+export const AvatarPlat = ({
+ account,
+ size = "default",
+}: {
+ account: SocialAccount;
+ size?: AvatarSize;
+}) => {
+ const plat = AccountPlatInfoMap.get(account.type)!;
+ return (
+ <>
+ <div className={styles.avatarPlat}>
+ <Avatar src={account.avatar} size={size} />
+ <img
+ src={plat.icon}
+ style={{
+ width: size === "large" ? 15 : size === "default" ? 12.5 : 10,
+ }}
+ />
+ </div>
+ </>
+ );
+};
+
+// 发布进度展示
+const PubProgressModule = memo(
+ forwardRef(
+ (
+ { pubProgressData, open, onClose }: IPubProgressModuleProps,
+ ref: ForwardedRef<IPubProgressModuleRef>,
+ ) => {
+ return (
+ <Modal
+ width={700}
+ title="内容分发"
+ maskClosable={false}
+ open={open}
+ onCancel={onClose}
+ footer={null}
+ closeIcon={<MinusOutlined />}
+ >
+ <Alert
+ message={
+ <>
+ 关闭此弹框和页面不会影响发布流程,
+ <b>关闭后可在右上角小铃铛查看发布进度</b>,但请不要关闭哎哟赚哦~
+ </>
+ }
+ type="success"
+ />
+ <div className={styles.pubProgressModule}>
+ {pubProgressData.map((v) => {
+ const { account } = v;
+ const plat = AccountPlatInfoMap.get(account.type);
+ if (!plat) return;
+
+ return (
+ <div className="pubProgressModule-item" key={account.id}>
+ <div className="pubProgressModule-item-left">
+ <AvatarPlat account={account} size="large" />
+ <Tooltip title={account.nickname}>
+ <span className="pubProgressModule-item-left-name">
+ {account.nickname}
+ </span>
+ </Tooltip>
+ </div>
+
+ <div className="pubProgressModule-item-right">
+ <Progress
+ percent={v.progress}
+ status={v.progress === -1 ? "exception" : undefined}
+ />
+ <p className="pubProgressModule-item-right-msg">
+ {getMsg(v)}
+ </p>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ </Modal>
+ );
+ },
+ ),
+);
+PubProgressModule.displayName = "PubProgressModule";
+
+export default PubProgressModule;
diff --git a/src/app/[lng]/publish/components/PubProgressModule/pubProgressModule.module.scss b/src/app/[lng]/publish/components/PubProgressModule/pubProgressModule.module.scss
new file mode 100644
index 00000000..f4461b6a
--- /dev/null
+++ b/src/app/[lng]/publish/components/PubProgressModule/pubProgressModule.module.scss
@@ -0,0 +1,44 @@
+.pubProgressModule {
+ padding-top: 20px;
+ :global {
+ .pubProgressModule-item {
+ display: flex;
+ justify-content: space-between;
+ margin-bottom: 30px;
+ &-left {
+ width: 50%;
+ display: flex;
+ align-items: center;
+ white-space: nowrap;
+ &-name {
+ text-overflow: ellipsis;
+ overflow: hidden;
+ margin-left: 6px;
+ padding-right: 20px;
+ }
+ }
+
+ &-right {
+ width: 50%;
+ flex-shrink: 0;
+ &-msg {
+ color: var(--grayColor7);
+ font-size: var(--fs-xs);
+ }
+ }
+ }
+ }
+}
+
+.avatarPlat {
+ position: relative;
+ display: flex;
+ justify-content: center;
+ & > img {
+ position: absolute;
+ bottom: 0;
+ right: 0;
+ transform: translate(-10%, 20%);
+ border-radius: 50%;
+ }
+}
\ No newline at end of file
diff --git a/src/app/[lng]/publish/components/PublishList.tsx b/src/app/[lng]/publish/components/PublishList.tsx
deleted file mode 100644
index fd4d4ab1..00000000
--- a/src/app/[lng]/publish/components/PublishList.tsx
+++ /dev/null
@@ -1,182 +0,0 @@
-"use client";
-
-import { useEffect, useState } from 'react';
-import { Table, message, Tag, Space, Button, Popconfirm } from 'antd';
-import type { ColumnsType } from 'antd/es/table';
-import { getPublishListApi, updatePublishStatusApi, deletePublishApi } from '@/api/publish';
-import { PubType, PubStatus } from '@/types/publish';
-
-interface PublishItem {
- id: number;
- title: string;
- type: string;
- status: number;
- createTime: string;
- publishTime: string;
-}
-
-export default function PublishList() {
- const [loading, setLoading] = useState(false);
- const [data, setData] = useState<PublishItem[]>([]);
- const [pagination, setPagination] = useState({
- current: 1,
- pageSize: 10,
- total: 0,
- });
-
- const getStatusTag = (status: number) => {
- switch (status) {
- case PubStatus.UNPUBLISH:
- return <Tag color="default">未发布</Tag>;
- case PubStatus.RELEASED:
- return <Tag color="success">已发布</Tag>;
- case PubStatus.FAIL:
- return <Tag color="error">发布失败</Tag>;
- case PubStatus.PART_SUCCESS:
- return <Tag color="warning">部分成功</Tag>;
- default:
- return <Tag>未知状态</Tag>;
- }
- };
-
- const getTypeText = (type: string) => {
- switch (type) {
- case PubType.VIDEO:
- return '视频';
- case PubType.ARTICLE:
- return '文章';
- case PubType.IMAGE_TEXT:
- return '图文';
- default:
- return type;
- }
- };
-
- const handleUpdateStatus = async (id: number, status: number) => {
- try {
- const response = await updatePublishStatusApi(id, status);
- if (response?.code === 0) {
- message.success('状态更新成功');
- fetchData(pagination.current, pagination.pageSize);
- } else {
- message.error(response?.msg || '状态更新失败');
- }
- } catch (error) {
- message.error('状态更新失败');
- }
- };
-
- const handleDelete = async (id: number) => {
- try {
- const response = await deletePublishApi(id);
- if (response?.code === 0) {
- message.success('删除成功');
- fetchData(pagination.current, pagination.pageSize);
- } else {
- message.error(response?.msg || '删除失败');
- }
- } catch (error) {
- message.error('删除失败');
- }
- };
-
- const columns: ColumnsType<PublishItem> = [
- {
- title: '标题',
- dataIndex: 'title',
- key: 'title',
- },
- {
- title: '类型',
- dataIndex: 'type',
- key: 'type',
- render: (type) => getTypeText(type),
- },
- {
- title: '状态',
- dataIndex: 'status',
- key: 'status',
- render: (status) => getStatusTag(status),
- },
- {
- title: '创建时间',
- dataIndex: 'createTime',
- key: 'createTime',
- },
- {
- title: '发布时间',
- dataIndex: 'publishTime',
- key: 'publishTime',
- },
- {
- title: '操作',
- key: 'action',
- render: (_, record) => (
- <Space size="middle">
- <Button
- type="link"
- onClick={() => handleUpdateStatus(record.id, PubStatus.RELEASED)}
- disabled={record.status === PubStatus.RELEASED}
- >
- 发布
- </Button>
- <Button
- type="link"
- onClick={() => handleUpdateStatus(record.id, PubStatus.UNPUBLISH)}
- disabled={record.status === PubStatus.UNPUBLISH}
- >
- 取消发布
- </Button>
- <Popconfirm
- title="确定要删除这条记录吗?"
- onConfirm={() => handleDelete(record.id)}
- okText="确定"
- cancelText="取消"
- >
- <Button type="link" danger>删除</Button>
- </Popconfirm>
- </Space>
- ),
- },
- ];
-
- const fetchData = async (page = 1, pageSize = 10) => {
- try {
- setLoading(true);
- const response: any = await getPublishListApi(page, pageSize);
- if (response?.code === 0) {
- setData(response.data.list);
- setPagination({
- ...pagination,
- current: page,
- total: response.data.total,
- });
- } else {
- message.error(response?.msg || '获取列表失败');
- }
- } catch (error) {
- message.error('获取列表失败');
- } finally {
- setLoading(false);
- }
- };
-
- useEffect(() => {
- fetchData();
- }, []);
-
- const handleTableChange = (newPagination: any) => {
- fetchData(newPagination.current, newPagination.pageSize);
- };
-
- return (
- <Table
- columns={columns}
- dataSource={data}
- rowKey="id"
- pagination={pagination}
- loading={loading}
- onChange={handleTableChange}
- />
- );
-}
\ No newline at end of file
diff --git a/src/app/[lng]/publish/components/PublishSidebar.tsx b/src/app/[lng]/publish/components/PublishSidebar.tsx
new file mode 100644
index 00000000..7edf6aad
--- /dev/null
+++ b/src/app/[lng]/publish/components/PublishSidebar.tsx
@@ -0,0 +1,58 @@
+"use client";
+
+import { ForwardedRef, forwardRef, memo, useMemo } from "react";
+import { Segmented } from "antd";
+import {
+ VideoCameraOutlined,
+ FileImageOutlined,
+ ContainerOutlined,
+} from "@ant-design/icons";
+import { usePathname, useRouter } from "next/navigation";
+
+export interface IPublishSidebarRef {}
+
+export interface IPublishSidebarProps {}
+
+const PublishSidebar = memo(
+ forwardRef(
+ ({}: IPublishSidebarProps, ref: ForwardedRef<IPublishSidebarRef>) => {
+ const pathname = usePathname();
+ const router = useRouter();
+
+ const currChooseRoute = useMemo(() => {
+ return pathname.split("/publish/")[1];
+ }, [pathname]);
+
+ return (
+ <Segmented
+ value={currChooseRoute}
+ vertical
+ size="large"
+ options={[
+ {
+ label: "视频发布",
+ value: "imagePage",
+ icon: <VideoCameraOutlined />,
+ },
+ // { label: '文章发布', value: '/publish/text', icon: <FileOutlined /> },
+ {
+ label: "图片发布",
+ value: "imagePage",
+ icon: <FileImageOutlined />,
+ },
+ {
+ label: "发布记录",
+ value: "pubRecord",
+ icon: <ContainerOutlined />,
+ },
+ ]}
+ onChange={(value) => {
+ router.push(value);
+ }}
+ />
+ );
+ },
+ ),
+);
+
+export default PublishSidebar;
diff --git a/src/app/[lng]/publish/components/SupportPlat/SupportPlat.tsx b/src/app/[lng]/publish/components/SupportPlat/SupportPlat.tsx
new file mode 100644
index 00000000..7cf47b44
--- /dev/null
+++ b/src/app/[lng]/publish/components/SupportPlat/SupportPlat.tsx
@@ -0,0 +1,47 @@
+import { ForwardedRef, forwardRef, memo } from "react";
+import styles from "./supportPlat.module.scss";
+import { PubType } from "@/app/config/publishConfig";
+import { AccountPlatInfoMap } from "@/app/config/platConfig";
+
+export interface ISupportPlatRef {}
+
+export interface ISupportPlatProps {
+ pubType: PubType;
+ style?: React.CSSProperties;
+}
+
+const SupportPlat = memo(
+ forwardRef(
+ (
+ { pubType, style }: ISupportPlatProps,
+ ref: ForwardedRef<ISupportPlatRef>,
+ ) => {
+ return (
+ <div
+ className={`${styles.supportPlat} ${pubType !== PubType.VIDEO && styles.supportPlatBg}`}
+ style={style}
+ >
+ <div className="supportPlatBg-title">支持平台</div>
+ <div className="supportPlat-tip">
+ <p className="supportPlat-tip--line" />
+ <p className="supportPlat-tip-text">支持以下平台</p>
+ <p className="supportPlat-tip--line" />
+ </div>
+ <ul className="supportPlat-con">
+ {Array.from(AccountPlatInfoMap).map(([k, v]) => {
+ if (!v.pubTypes.has(pubType)) return null;
+ return (
+ <li key={v.name}>
+ <img src={v.icon} />
+ </li>
+ );
+ })}
+ </ul>
+ </div>
+ );
+ },
+ ),
+);
+SupportPlat.displayName = "SupportPlat";
+
+export default SupportPlat;
diff --git a/src/app/[lng]/publish/components/SupportPlat/supportPlat.module.scss b/src/app/[lng]/publish/components/SupportPlat/supportPlat.module.scss
new file mode 100644
index 00000000..3faf2f3a
--- /dev/null
+++ b/src/app/[lng]/publish/components/SupportPlat/supportPlat.module.scss
@@ -0,0 +1,60 @@
+.supportPlat {
+ :global {
+ .supportPlat-tip {
+ margin-bottom: 10px;
+ font-size: var(--fs-xs);
+ display: flex;
+ align-items: center;
+ &--line {
+ width: 100%;
+ height: 1px;
+ background: rgb(243, 243, 243);
+ }
+ &-text {
+ white-space: nowrap;
+ padding: 0 15px;
+ color: rgb(136, 145, 145);
+ }
+ }
+ .supportPlat-con {
+ //display: grid;
+ //grid-template-columns: repeat(8, 1fr);
+ gap: 20px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ min-width: 340px;
+ img {
+ width: 25px;
+ }
+ }
+ .supportPlatBg-title {
+ display: none;
+ }
+ }
+}
+
+.supportPlatBg {
+ padding: 15px;
+ display: flex;
+ border-radius: 10px;
+ background: rgb(247, 250, 250);
+ :global {
+ .supportPlat-tip {
+ display: none;
+ }
+ .supportPlat-con {
+ display: grid;
+ gap: 10px;
+ grid-template-columns: repeat(7, 1fr);
+ }
+ .supportPlatBg-title {
+ display: block;
+ font-weight: 900;
+ font-size: var(--fs-xs);
+ color: rgb(157, 164, 164);
+ margin: 3px 10px 0 0;
+ white-space: nowrap;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/app/[lng]/publish/hooks/usePubParamsVerify.tsx b/src/app/[lng]/publish/hooks/usePubParamsVerify.tsx
new file mode 100644
index 00000000..9d132686
--- /dev/null
+++ b/src/app/[lng]/publish/hooks/usePubParamsVerify.tsx
@@ -0,0 +1,250 @@
+import { memo, useMemo } from "react";
+import { parseTopicString } from "@/utils";
+import { Alert, Tooltip } from "antd";
+import { InfoCircleOutlined } from "@ant-design/icons";
+import {
+ AccountInfo,
+ IPubParams,
+} from "@/app/[lng]/publish/videoPage/videoPage";
+import {
+ AccountPlatInfoMap,
+ IAccountPlatInfo,
+ PlatType,
+} from "@/app/config/platConfig";
+import { AccountStatus } from "@/app/config/accountConfig";
+
+// 错误状态
+export enum PubParamsErrStatusEnum {
+ // 登录错误
+ LOGIN = 1,
+ // 参数错误
+ PARAMS = 2,
+}
+export interface ErrPubParamsItem {
+ // 这个错误提示会在账户tab显示
+ message: string;
+ // 错误类型,用户区分是否需要显示重新登录的错误提示
+ errType: PubParamsErrStatusEnum;
+ // 参数错误提示消息
+ parErrMsg?: string;
+ // 发生错误的平台
+ plat?: PlatType;
+}
+
+export type ErrPubParamsMapType = Map<string | number, ErrPubParamsItem>;
+
+interface IPubParamsVerifyItem<T = undefined> {
+ id: string | number;
+ account?: AccountInfo;
+ pubParams: IPubParams;
+ other: T;
+}
+
+/**
+ * 发布参数校验是否复合平台规范
+ * @param data
+ * @param moreVerify
+ */
+export default function <T>(
+ data: IPubParamsVerifyItem<T>[],
+ moreVerify?: {
+ // 错误参数扩展
+ moreErrorVerifyCallback?: (
+ item: IPubParamsVerifyItem<T>,
+ errParamsMapTemp: ErrPubParamsMapType,
+ platInfo: IAccountPlatInfo,
+ ) => void;
+ // 警告参数扩展
+ moreWranVerifyCallback?: (
+ item: IPubParamsVerifyItem<T>,
+ wranParamsMapTemp: ErrPubParamsMapType,
+ platInfo: IAccountPlatInfo,
+ ) => void;
+ },
+) {
+ // 用于判断描述中的话题是否符合规范
+ const descTopicRegex = /#\S+#\S+/;
+
+ // 错误参数,发布之前会检测错误参数,防止平台无法发布
+ const errParamsMap = useMemo(() => {
+ const errParamsMapTemp: ErrPubParamsMapType = new Map();
+ for (const v of data) {
+ if (!v.account) continue;
+ const platInfo = AccountPlatInfoMap.get(v.account!.type)!;
+ const { topics } = parseTopicString(v.pubParams.describe || "");
+ const topicsAll = [...new Set(v.pubParams.topics?.concat(topics))];
+ const { topicMax } = platInfo.commonPubParamsConfig;
+
+ (() => {
+ // 错误信息---------------------
+ // 登录状态校验
+ if (v.account && v.account.status === AccountStatus.DISABLE) {
+ return errParamsMapTemp.set(v.id, {
+ message: "登录失效",
+ errType: PubParamsErrStatusEnum.LOGIN,
+ parErrMsg: "登录失效,请重新登录",
+ });
+ }
+ // 快手要求封面必须大于 400x400
+ if (
+ v.account?.type === PlatType.KWAI &&
+ v.pubParams.cover &&
+ (v.pubParams.cover.width < 400 || v.pubParams.cover.height < 400)
+ ) {
+ return errParamsMapTemp.set(v.id, {
+ message: "参数错误",
+ errType: PubParamsErrStatusEnum.PARAMS,
+ parErrMsg: "封面最小尺寸400*400",
+ });
+ }
+ // 话题校验
+ if (topicsAll.length > topicMax) {
+ return errParamsMapTemp.set(v.id, {
+ message: "参数错误",
+ errType: PubParamsErrStatusEnum.PARAMS,
+ parErrMsg: `${platInfo.name}话题最多不能超过${topicMax}个`,
+ });
+ }
+ /**
+ * 抖音的话题和活动奖励校验
+ * 抖音规定活动奖励 + 话题不能超过5个
+ */
+ if (
+ v.account?.type === PlatType.Douyin &&
+ topicsAll.length +
+ v.pubParams.diffParams![PlatType.Douyin]!.activitys!.length >
+ topicMax
+ ) {
+ return errParamsMapTemp.set(v.id, {
+ message: "参数错误",
+ errType: PubParamsErrStatusEnum.PARAMS,
+ parErrMsg: `话题 + 活动奖励不能超过${topicMax}个`,
+ });
+ }
+ // 判断描述中的话题中间是否用空格分割,如:#话题1#话题2#话题3 这种格式错误
+ if (descTopicRegex.test(v.pubParams.describe || "")) {
+ return errParamsMapTemp.set(v.id, {
+ message: "参数错误",
+ errType: PubParamsErrStatusEnum.PARAMS,
+ parErrMsg: `描述中的话题必须使用空格分割,如:“#话题1 #话题2”`,
+ });
+ }
+
+ if (moreVerify?.moreErrorVerifyCallback)
+ moreVerify?.moreErrorVerifyCallback(v, errParamsMapTemp, platInfo);
+ })();
+
+ // 通用参数
+ if (errParamsMapTemp.has(v.id)) {
+ errParamsMapTemp.set(v.id, {
+ ...errParamsMapTemp.get(v.id)!,
+ plat: v.account.type,
+ });
+ }
+ }
+ return errParamsMapTemp;
+ }, [data]);
+
+ // 警告参数,警告参数只会展示,不会阻止平台发布
+ const warnParamsMap = useMemo(() => {
+ const warnParamsMapTemp: ErrPubParamsMapType = new Map();
+ for (const v of data) {
+ if (!v.account) continue;
+ const platInfo = AccountPlatInfoMap.get(v.account!.type)!;
+
+ if (moreVerify?.moreWranVerifyCallback)
+ moreVerify?.moreWranVerifyCallback(v, warnParamsMapTemp, platInfo);
+ }
+ return warnParamsMapTemp;
+ }, [data]);
+
+ return {
+ errParamsMap,
+ warnParamsMap,
+ };
+}
+
+// 用于展示校验的结果
+export const PubParamsVerifyInfo = memo(
+ ({
+ id,
+ warnParamsMap,
+ errParamsMap,
+ onAccountRestart,
+ style,
+ }: {
+ id?: string | number;
+ errParamsMap?: ErrPubParamsMapType;
+ warnParamsMap?: ErrPubParamsMapType;
+ onAccountRestart: (plat?: PlatType) => void;
+ style?: React.CSSProperties;
+ }) => {
+ const errPubParams = useMemo(() => {
+ let errPubParams: ErrPubParamsItem | undefined = undefined;
+ if (!errParamsMap) return errPubParams;
+ for (const [itemId, errPubParamsItem] of errParamsMap) {
+ if (itemId === id) {
+ errPubParams = errPubParamsItem;
+ break;
+ }
+ }
+ return errPubParams;
+ }, [id, errParamsMap]);
+
+ const paramsWarningList = useMemo(() => {
+ if (!warnParamsMap) return [];
+ return Array.from(warnParamsMap)
+ .map(([itemId, item]) => (itemId === id ? item : undefined))
+ .filter((v) => v !== undefined);
+ }, [warnParamsMap, id]);
+
+ return (
+ <>
+ {errPubParams && (
+ <Alert
+ type="error"
+ showIcon
+ message={
+ errPubParams.errType === PubParamsErrStatusEnum.LOGIN ? (
+ <>
+ 登录失效,请
+ <a
+ style={{ fontSize: "13px" }}
+ onClick={() => {
+ onAccountRestart(errPubParams.plat);
+ }}
+ >
+ 重新登录
+ </a>
+ </>
+ ) : (
+ errPubParams.parErrMsg
+ )
+ }
+ style={style}
+ />
+ )}
+
+ {paramsWarningList.length !== 0 && (
+ <Alert
+ type="warning"
+ showIcon
+ icon={
+ <Tooltip title="这是参数警告,参数警告不会阻止您的发布!">
+ <InfoCircleOutlined />
+ </Tooltip>
+ }
+ message={
+ <>
+ {paramsWarningList.map((v, i) => {
+ return <p key={i}>{v.parErrMsg}</p>;
+ })}
+ </>
+ }
+ style={style}
+ />
+ )}
+ </>
+ );
+ },
+);
diff --git a/src/app/[lng]/publish/imagePage/components/ImageLeftSetting/ImageLeftSetting.tsx b/src/app/[lng]/publish/imagePage/components/ImageLeftSetting/ImageLeftSetting.tsx
new file mode 100644
index 00000000..c6770f8d
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/components/ImageLeftSetting/ImageLeftSetting.tsx
@@ -0,0 +1,105 @@
+import React, { ForwardedRef, forwardRef, memo } from "react";
+import styles from "../../image.module.scss";
+import localUpload from "../../../videoPage/images/localUpload.png";
+import { Input } from "antd";
+import { useShallow } from "zustand/react/shallow";
+import { useImagePageStore } from "../../useImagePageStore";
+import ImgTextImagesView from "./ImgTextImagesView";
+import { ChooseChunk } from "@/app/[lng]/publish/components/CommonComponents/CommonComponents";
+import ImgChoose from "@/app/[lng]/publish/components/Choose/ImgChoose";
+
+const { TextArea } = Input;
+
+export interface IImageLeftSettingRef {}
+
+export interface IImageLeftSettingProps {}
+
+const ImageLeftSetting = memo(
+ forwardRef(
+ ({}: IImageLeftSettingProps, ref: ForwardedRef<IImageLeftSettingRef>) => {
+ const { commonPubParams, setCommonPubParams, addImages, images } =
+ useImagePageStore(
+ useShallow((state) => ({
+ setAllPubParams: state.setAllPubParams,
+ commonPubParams: state.commonPubParams,
+ setCommonPubParams: state.setCommonPubParams,
+ addImages: state.addImages,
+ images: state.images,
+ })),
+ );
+
+ return (
+ <div className={styles.imageLeftSetting}>
+ <div className="imageLeftSetting-upload">
+ {images.length === 0 ? (
+ <ImgChoose
+ onMultipleChoose={(imgFiles) => {
+ if (imgFiles.length !== 0) {
+ addImages(imgFiles);
+ }
+ }}
+ >
+ <ChooseChunk
+ text="本地上传"
+ imgUrl={localUpload.src}
+ color="linear-gradient(to right, rgb(255, 142, 28), rgb(255, 124, 24))"
+ hoverColor="rgb(255, 142, 28)"
+ style={{
+ marginRight: "15px",
+ width: "260px",
+ height: "180px",
+ }}
+ />
+ </ImgChoose>
+ ) : (
+ <ImgTextImagesView />
+ )}
+ </div>
+
+ <div className="imageLeftSetting-commonPar">
+ <div className="imageLeftSetting-commonPar-titles">
+ <label>通用发布设置</label>
+ </div>
+
+ <div className="imageLeftSetting-commonPar-item">
+ <label>一键设置标题:</label>
+ <Input
+ value={commonPubParams.title}
+ placeholder="请输入标题"
+ showCount
+ variant="filled"
+ onChange={(e) => {
+ setCommonPubParams({
+ title: e.target.value,
+ });
+ }}
+ />
+ </div>
+
+ <div
+ className="imageLeftSetting-commonPar-item"
+ style={{ alignItems: "baseline" }}
+ >
+ <label>一键设置简介:</label>
+ <TextArea
+ value={commonPubParams.describe}
+ maxLength={1000}
+ placeholder="请输入简介"
+ showCount
+ variant="filled"
+ onChange={(e) => {
+ setCommonPubParams({
+ describe: e.target.value,
+ });
+ }}
+ />
+ </div>
+ </div>
+ </div>
+ );
+ },
+ ),
+);
+ImageLeftSetting.displayName = "ImageLeftSetting";
+
+export default ImageLeftSetting;
diff --git a/src/app/[lng]/publish/imagePage/components/ImageLeftSetting/ImgTextImagesView.tsx b/src/app/[lng]/publish/imagePage/components/ImageLeftSetting/ImgTextImagesView.tsx
new file mode 100644
index 00000000..6e52ab22
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/components/ImageLeftSetting/ImgTextImagesView.tsx
@@ -0,0 +1,95 @@
+import { ForwardedRef, forwardRef, memo, useEffect, useState } from "react";
+import styles from "./imgTextImagesView.module.scss";
+import { Button } from "antd";
+import { CloseOutlined, PlusOutlined } from "@ant-design/icons";
+import { useImagePageStore } from "../../useImagePageStore";
+import { useShallow } from "zustand/react/shallow";
+import { ReactSortable } from "react-sortablejs";
+import ImgChoose from "@/app/[lng]/publish/components/Choose/ImgChoose";
+
+export interface IImgTextImagesViewRef {}
+
+export interface IImgTextImagesViewProps {}
+
+const ImgTextImagesView = memo(
+ forwardRef(
+ ({}: IImgTextImagesViewProps, ref: ForwardedRef<IImgTextImagesViewRef>) => {
+ const { images, setImages, addImages, imgUploadLimit } =
+ useImagePageStore(
+ useShallow((state) => ({
+ images: state.images,
+ setImages: state.setImages,
+ addImages: state.addImages,
+ imgUploadLimit: state.imgUploadLimit,
+ })),
+ );
+ const [srcollEl, setSrcollEl] = useState<HTMLElement>();
+
+ useEffect(() => {
+ const el = document.getElementById("imgTextImagesView-wrapper");
+ setSrcollEl(el!);
+ }, []);
+
+ return (
+ <div className={styles.imgTextImagesView}>
+ <div className="imgTextImagesView_head">
+ <div className="imgTextImagesView_head-left">
+ 图片编辑({images.length}/{imgUploadLimit})
+ </div>
+ <div className="imgTextImagesView_head-right">
+ <div className="imgTextImagesView_head-right-tips">
+ 长按拖动排序
+ </div>
+ <ImgChoose
+ onMultipleChoose={(imgFiles) => {
+ if (imgFiles.length !== 0) {
+ addImages(imgFiles);
+ }
+ }}
+ >
+ <Button type="link" icon={<PlusOutlined />}>
+ 本地上传
+ </Button>
+ </ImgChoose>
+ </div>
+ </div>
+
+ <div id="imgTextImagesView-wrapper">
+ {srcollEl && (
+ <ReactSortable
+ className="imgTextImagesView_content"
+ list={images}
+ animation={250}
+ setList={setImages}
+ scrollSensitivity={100}
+ scroll={srcollEl}
+ scrollSpeed={15}
+ >
+ {images.map((v, i) => {
+ return (
+ <div className="imgTextImagesView_content-item" key={v.id}>
+ <img src={v.imgUrl} alt={v.filename} />
+ <div
+ className="imgTextImagesView_content-item-close"
+ onClick={() => {
+ const newImages = [...images];
+ newImages.splice(i, 1);
+ setImages(newImages);
+ }}
+ >
+ <CloseOutlined />
+ </div>
+ </div>
+ );
+ })}
+ </ReactSortable>
+ )}
+ </div>
+ </div>
+ );
+ },
+ ),
+);
+ImgTextImagesView.displayName = "ImgTextImagesView";
+
+export default ImgTextImagesView;
diff --git a/src/app/[lng]/publish/imagePage/components/ImageLeftSetting/imgTextImagesView.module.scss b/src/app/[lng]/publish/imagePage/components/ImageLeftSetting/imgTextImagesView.module.scss
new file mode 100644
index 00000000..a99008d4
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/components/ImageLeftSetting/imgTextImagesView.module.scss
@@ -0,0 +1,83 @@
+.imgTextImagesView {
+ width: 100%;
+ border-radius: 6px;
+ padding: 10px;
+ box-sizing: border-box;
+ font-size: 15px;
+ border: 10px solid rgb(247, 250, 250);
+ :global {
+ .imgTextImagesView_head {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 10px;
+ &-left {
+ }
+ &-right {
+ display: flex;
+ align-items: center;
+ &-tips {
+ color: var(--grayColor7);
+ margin-right: 8px;
+ }
+ button {
+ margin: 0;
+ padding: 0;
+ gap: 3px;
+ display: flex;
+ align-items: center;
+ font-size: 15px;
+ }
+ }
+ }
+
+
+ .imgTextImagesView_content {
+ display: grid;
+ grid-template-columns: repeat(5, 1fr);
+ gap: 10px;
+ height: 100%;
+ box-sizing: border-box;
+ &-item {
+ min-width: 100px;
+ height: 102px;
+ border: 1px solid var(--grayColor3);
+ cursor: move;
+ position: relative;
+ &:hover {
+ .imgTextImagesView_content-item-close {
+ display: block !important;
+ }
+ }
+ img {
+ width: 100%;
+ height: 100%;
+ object-fit: contain;
+ user-select: none;
+ display: block;
+ }
+ &-close {
+ display: none;
+ cursor: pointer;
+ background: rgba(0, 0, 0, 0.7);
+ width: 16px;
+ height: 16px;
+ line-height: 15px;
+ font-size: 10px;
+ text-align: center;
+ position: absolute;
+ right: 0;
+ top: 0;
+ color: #fff;
+ }
+ }
+ }
+
+ #imgTextImagesView-wrapper {
+ overflow-y: auto;
+ overflow-x: hidden;
+ max-height: 500px;
+ box-sizing: border-box;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/app/[lng]/publish/imagePage/components/ImageRightSetting/ImageRightSetting.tsx b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/ImageRightSetting.tsx
new file mode 100644
index 00000000..19a9c183
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/ImageRightSetting.tsx
@@ -0,0 +1,95 @@
+import { ForwardedRef, forwardRef, memo, useRef, useState } from "react";
+import styles from "../../image.module.scss";
+import { Steps } from "antd";
+import { useShallow } from "zustand/react/shallow";
+import { useImagePageStore } from "../../useImagePageStore";
+import ImageParamsSet from "./components/ImageParamsSet";
+import ChooseAccountModule, {
+ IChooseAccountModuleRef,
+} from "@/app/[lng]/publish/components/ChooseAccountModule/ChooseAccountModule";
+import { ChooseAccountChunk } from "@/app/[lng]/publish/components/CommonComponents/CommonComponents";
+import SupportPlat from "@/app/[lng]/publish/components/SupportPlat/SupportPlat";
+import { PubType } from "@/app/config/publishConfig";
+
+export interface IImageRightSettingRef {}
+
+export interface IImageRightSettingProps {}
+
+const ImageRightSetting = memo(
+ forwardRef(
+ ({}: IImageRightSettingProps, ref: ForwardedRef<IImageRightSettingRef>) => {
+ const [chooseAccountOpen, setChooseAccountOpen] = useState(false);
+ const { imageAccounts, addAccount, activePlat } = useImagePageStore(
+ useShallow((state) => ({
+ imageAccounts: state.imageAccounts,
+ addAccount: state.addAccount,
+ activePlat: state.activePlat,
+ })),
+ );
+ const chooseAccountModuleRef = useRef<IChooseAccountModuleRef>(null);
+
+ return (
+ <>
+ <ChooseAccountModule
+ ref={chooseAccountModuleRef}
+ open={chooseAccountOpen}
+ onClose={setChooseAccountOpen}
+ platChooseProps={{
+ choosedAccounts: imageAccounts
+ .map((v) => v.account)
+ .filter((v) => v !== undefined),
+ pubType: PubType.ImageText,
+ defaultPlat: activePlat,
+ }}
+ onPlatConfirm={(aList) => {
+ addAccount(aList);
+ }}
+ />
+ {imageAccounts.length === 0 ? (
+ <div className={styles.imageRightSetting}>
+ <SupportPlat
+ pubType={PubType.ImageText}
+ style={{ marginTop: "15px" }}
+ />
+
+ <h2 className="imageRightSetting-title">发布账户</h2>
+ <ChooseAccountChunk
+ onClick={() => {
+ setChooseAccountOpen(true);
+ }}
+ />
+
+ <Steps
+ direction="vertical"
+ size="small"
+ items={[
+ {
+ title: "选择发布账号",
+ description: "选择将要推文的账号",
+ },
+ {
+ title: "调整发文规则",
+ description:
+ "完成账号选择后,撰写推文,按需调整各个平台发文规则",
+ },
+ ]}
+ />
+ </div>
+ ) : (
+ <ImageParamsSet
+ openChooseAccount={() => {
+ setChooseAccountOpen(true);
+ chooseAccountModuleRef
+ .current!.getPlatChooseRef()
+ ?.setActivePlat(activePlat!);
+ }}
+ />
+ )}
+ </>
+ );
+ },
+ ),
+);
+ImageRightSetting.displayName = "ImageRightSetting";
+
+export default ImageRightSetting;
diff --git a/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx
new file mode 100644
index 00000000..6da39cf4
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx
@@ -0,0 +1,169 @@
+import { ForwardedRef, forwardRef, memo, useEffect, useMemo } from "react";
+import { useImagePageStore } from "../../../useImagePageStore";
+import { useShallow } from "zustand/react/shallow";
+import styles from "./imageParamsSet.module.scss";
+import { IImageAccountItem } from "../../../imagePage.type";
+import { CloseOutlined, InfoOutlined } from "@ant-design/icons";
+import ParamsSettingDetails from "./ParamsSettingDetails";
+import { Tooltip } from "antd";
+import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";
+import { ErrPubParamsItem } from "@/app/[lng]/publish/hooks/usePubParamsVerify";
+
+export interface IImageParamsSetRef {}
+
+export interface IImageParamsSetProps {
+ openChooseAccount: () => void;
+}
+
+// 图片发布右侧参数设置
+const ImageParamsSet = memo(
+ forwardRef(
+ (
+ { openChooseAccount }: IImageParamsSetProps,
+ ref: ForwardedRef<IImageParamsSetRef>,
+ ) => {
+ const {
+ imageAccounts,
+ activePlat,
+ setActivePlat,
+ setPlatActiveAccountMap,
+ platActiveAccountMap,
+ delAccountByPalt,
+ errParamsMap,
+ } = useImagePageStore(
+ useShallow((state) => ({
+ imageAccounts: state.imageAccounts,
+ setActivePlat: state.setActivePlat,
+ activePlat: state.activePlat,
+ setPlatActiveAccountMap: state.setPlatActiveAccountMap,
+ platActiveAccountMap: state.platActiveAccountMap,
+ delAccountByPalt: state.delAccountByPalt,
+ errParamsMap: state.errParamsMap,
+ })),
+ );
+
+ const platAccountImagesMap = useMemo(() => {
+ // 平台账户map
+ const platAccountMap = new Map<PlatType, IImageAccountItem[]>([]);
+
+ for (const imageAccount of imageAccounts) {
+ if (!platAccountMap.has(imageAccount.account.type)) {
+ platAccountMap.set(imageAccount.account.type, []);
+ }
+ platAccountMap.get(imageAccount.account.type)?.push(imageAccount);
+ }
+ return platAccountMap;
+ }, [imageAccounts]);
+
+ useEffect(() => {
+ // 当前选择的平台不存在了便重新选择
+ if (!activePlat || !platAccountImagesMap.has(activePlat)) {
+ setActivePlat(Array.from(platAccountImagesMap)[0][0]);
+ }
+
+ // 默认选中的平台map
+ const newPlatActiveAccountMap = new Map<PlatType, IImageAccountItem>();
+
+ for (const [accountType, imageAccountItems] of platAccountImagesMap) {
+ if (!newPlatActiveAccountMap.has(accountType)) {
+ newPlatActiveAccountMap.set(accountType, imageAccountItems[0]);
+ }
+ }
+
+ // 将旧的选中的平台账户设置为新的
+ for (const [accountType, imageAccountItem] of newPlatActiveAccountMap) {
+ // 旧的选中账户
+ const activeImageAccountItem = platActiveAccountMap.get(accountType);
+ if (
+ !activeImageAccountItem ||
+ activeImageAccountItem.account.id === imageAccountItem.account.id
+ )
+ continue;
+
+ // 旧的选中账户新的账户列表是否存在,如果存在则使用上一次选中的状态
+ if (
+ platAccountImagesMap
+ .get(accountType)!
+ .some((v) => v.account.id === activeImageAccountItem.account.id)
+ ) {
+ newPlatActiveAccountMap.set(
+ accountType,
+ platActiveAccountMap.get(accountType)!,
+ );
+ break;
+ }
+ }
+
+ // 设置store当前选择的平台账户
+ setPlatActiveAccountMap(newPlatActiveAccountMap);
+ }, [platAccountImagesMap]);
+
+ // key=平台,val==错误消息
+ const errParamsPlatMap = useMemo(() => {
+ if (!errParamsMap) return undefined;
+ const errParamsMapTemp = new Map<PlatType, ErrPubParamsItem>();
+ for (const [_, errParamsItem] of errParamsMap) {
+ if (!errParamsMapTemp.has(errParamsItem.plat!)) {
+ errParamsMapTemp.set(errParamsItem.plat!, errParamsItem);
+ }
+ }
+ return errParamsMapTemp;
+ }, [errParamsMap]);
+
+ 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={`${styles.closeIcon} imageParamsSet_plats-item-close`}
+ onClick={(e) => {
+ e.stopPropagation();
+ delAccountByPalt(accountType);
+ }}
+ >
+ <CloseOutlined />
+ </div>
+ {errParamsPlatMap?.get(accountType) && (
+ <Tooltip
+ title={errParamsPlatMap?.get(accountType)?.parErrMsg}
+ >
+ <div className="imageParamsSet_plats-item-err">
+ <InfoOutlined />
+ </div>
+ </Tooltip>
+ )}
+ </div>
+ <span>{platInfo.name}</span>
+ </div>
+ );
+ })}
+ </div>
+ {activePlat && platAccountImagesMap.get(activePlat) && (
+ <ParamsSettingDetails
+ openChooseAccount={openChooseAccount}
+ imageAccountList={platAccountImagesMap.get(activePlat)!}
+ />
+ )}
+ </div>
+ );
+ },
+ ),
+);
+ImageParamsSet.displayName = "ImageParamsSet";
+
+export default ImageParamsSet;
diff --git a/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ImageParamsSet.type.ts b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ImageParamsSet.type.ts
new file mode 100644
index 00000000..8c4f0393
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ImageParamsSet.type.ts
@@ -0,0 +1 @@
+export interface ImageRightSettingChildProps {}
diff --git a/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ImageRightSettingCommon.tsx b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ImageRightSettingCommon.tsx
new file mode 100644
index 00000000..84111f24
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ImageRightSettingCommon.tsx
@@ -0,0 +1,387 @@
+import { useShallow } from "zustand/react/shallow";
+import React, { useEffect, useState } from "react";
+import { Input, SelectProps, Tooltip } from "antd";
+import { useImagePageStore } from "../../../useImagePageStore";
+import { useImagePlatParams } from "./children/hooks/useImagePlatParams";
+import { QuestionCircleOutlined } from "@ant-design/icons";
+import dayjs from "dayjs";
+import { VideoPubRestartLogin } from "../../../../videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon";
+import { ILocationDataItem } from "@/app/[lng]/publish/videoPage/videoPage";
+import { IMixItem, IUsersItem } from "@/app/plat/plat.type";
+import CommonLocationSelect from "@/app/[lng]/publish/components/CommonComponents/CommonLocationSelect";
+import CommonTopicSelect, {
+ CommonTopicSelectProps,
+ CommonTopicSelectValueType,
+} from "@/app/[lng]/publish/components/CommonComponents/CommonTopicSelect";
+import CommonUserSelect, {
+ CommonUserSelectProps,
+} from "@/app/[lng]/publish/components/CommonComponents/CommonUserSelect";
+import CommonScheduledTimeSelect, {
+ ICommonScheduledTimeSelectProps,
+} from "@/app/[lng]/publish/components/CommonComponents/CommonScheduledTimeSelect";
+import {
+ AccountRestartLogin,
+ CommonMixSelect,
+ PubPermission,
+ PubPermissionProps,
+} from "@/app/[lng]/publish/components/CommonComponents/CommonComponents";
+import { AccountPlatInfoMap } from "@/app/config/platConfig";
+
+interface DebounceSelectProps<ValueType = any>
+ extends Omit<SelectProps<ValueType | ValueType[]>, "options" | "children"> {}
+
+const { TextArea } = Input;
+
+// 重新登录
+export const ImgTextPubRestartLogin = () => {
+ const { imageAccountItem } = useImagePlatParams();
+ const { accountRestart } = useImagePageStore(
+ useShallow((state) => ({
+ accountRestart: state.accountRestart,
+ })),
+ );
+
+ return (
+ <AccountRestartLogin
+ account={imageAccountItem.account}
+ onAccountRestart={() => {
+ accountRestart(imageAccountItem.account!.type);
+ }}
+ />
+ );
+};
+
+// 位置选择器
+export const ImgTextLocationSelect = ({
+ ...props
+}: DebounceSelectProps<ILocationDataItem>) => {
+ const { imageAccountItem } = useImagePlatParams();
+ const { setOnePubParams, updateAccounts } = useImagePageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ updateAccounts: state.updateAccounts,
+ })),
+ );
+
+ return (
+ <CommonLocationSelect
+ {...props}
+ account={imageAccountItem.account}
+ value={imageAccountItem.pubParams!.location}
+ onAccountChange={(account) => {
+ updateAccounts([account]);
+ }}
+ onChange={(_, value) => {
+ setOnePubParams(
+ {
+ location: (value as ILocationDataItem) || null,
+ },
+ imageAccountItem.account.id,
+ );
+ }}
+ >
+ <ImgTextPubRestartLogin />
+ </CommonLocationSelect>
+ );
+};
+
+// 话题选择器
+export const ImgTextTopicSelect = ({ ...props }: CommonTopicSelectProps) => {
+ const { imageAccountItem } = useImagePlatParams();
+ const { setOnePubParams, updateAccounts } = useImagePageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ updateAccounts: state.updateAccounts,
+ })),
+ );
+ const { topicMax } = AccountPlatInfoMap.get(
+ imageAccountItem.account.type,
+ )!.commonPubParamsConfig;
+ props.maxCount = props.maxCount || topicMax;
+ props.tips = props.tips || `您可以添加${topicMax}个话题`;
+
+ return (
+ <CommonTopicSelect
+ {...props}
+ account={imageAccountItem.account}
+ value={imageAccountItem.pubParams!.topics!.map((v) => {
+ return {
+ value: v,
+ label: v,
+ };
+ })}
+ onAccountChange={(account) => {
+ updateAccounts([account]);
+ }}
+ onChange={(newValue) => {
+ setOnePubParams(
+ {
+ topics: (newValue as CommonTopicSelectValueType[]).map(
+ (v) => v.label,
+ ),
+ diffParams: {
+ ...imageAccountItem.pubParams.diffParams,
+ },
+ },
+ imageAccountItem.account.id,
+ );
+ }}
+ >
+ <ImgTextPubRestartLogin />
+ </CommonTopicSelect>
+ );
+};
+
+// 用户选择器
+export const ImgTextUserSelect = ({
+ ...props
+}: CommonUserSelectProps<IUsersItem>) => {
+ const { imageAccountItem } = useImagePlatParams();
+ const { setOnePubParams, updateAccounts } = useImagePageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ updateAccounts: state.updateAccounts,
+ })),
+ );
+
+ return (
+ <CommonUserSelect
+ {...props}
+ account={imageAccountItem.account!}
+ onAccountChange={(account) => {
+ updateAccounts([account]);
+ }}
+ value={
+ imageAccountItem.pubParams!.mentionedUserInfo?.map((v) => {
+ return {
+ ...v,
+ id: v.value,
+ name: v.label,
+ };
+ }) as any
+ }
+ onChange={(_, value) => {
+ setOnePubParams(
+ {
+ mentionedUserInfo: value
+ ? (value as IUsersItem[]).map((v) => {
+ return {
+ value: v.id,
+ label: v.name,
+ };
+ })
+ : undefined,
+ },
+ imageAccountItem.account.id,
+ );
+ }}
+ >
+ <ImgTextPubRestartLogin />
+ </CommonUserSelect>
+ );
+};
+
+// 标题
+export const ImgTextTitleInput = ({
+ placeholder,
+ tips,
+ title = "标题",
+ maxLength = 20,
+}: {
+ placeholder: string;
+ tips?: string;
+ title?: string;
+ maxLength?: number;
+}) => {
+ const { imageAccountItem } = useImagePlatParams();
+ const { setOnePubParams } = useImagePageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ })),
+ );
+ const [value, setValue] = useState(imageAccountItem.pubParams.title);
+
+ useEffect(() => {
+ setOnePubParams(
+ {
+ title: value,
+ },
+ imageAccountItem.account.id,
+ );
+ }, [value]);
+ useEffect(() => {
+ setValue(imageAccountItem.pubParams.title);
+ }, [imageAccountItem.pubParams.title]);
+
+ return (
+ <>
+ <h1>
+ {title}
+ {tips && (
+ <Tooltip title={tips}>
+ <QuestionCircleOutlined style={{ marginLeft: "2px" }} />
+ </Tooltip>
+ )}
+ </h1>
+ <Input
+ spellCheck={false}
+ value={value}
+ maxLength={maxLength}
+ placeholder={placeholder}
+ showCount
+ variant="filled"
+ onChange={(e) => {
+ setValue(e.target.value);
+ }}
+ />
+ </>
+ );
+};
+
+// 描述
+export const ImgTextDescTextArea = ({
+ placeholder,
+ title = "描述",
+ maxLength = 1000,
+}: {
+ placeholder: string;
+ tips?: string;
+ title?: string;
+ maxLength?: number;
+}) => {
+ const { imageAccountItem } = useImagePlatParams();
+ const { setOnePubParams } = useImagePageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ })),
+ );
+ const [value, setValue] = useState(imageAccountItem?.pubParams.describe);
+
+ useEffect(() => {
+ setOnePubParams(
+ {
+ describe: value,
+ },
+ imageAccountItem.account!.id,
+ );
+ }, [value]);
+ useEffect(() => {
+ setValue(imageAccountItem?.pubParams.describe || "");
+ }, [imageAccountItem?.pubParams.describe]);
+
+ return (
+ <>
+ <h1>{title}</h1>
+ <TextArea
+ spellCheck={false}
+ value={value}
+ placeholder={placeholder}
+ variant="filled"
+ showCount
+ maxLength={maxLength}
+ autoSize={{ minRows: 6, maxRows: 6 }}
+ onChange={(e) => {
+ setValue(e.target.value);
+ }}
+ />
+ </>
+ );
+};
+
+// 权限设置
+export const ImgTextPubPermission = ({ ...props }: PubPermissionProps) => {
+ const { imageAccountItem } = useImagePlatParams();
+ const { setOnePubParams } = useImagePageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ })),
+ );
+ return (
+ <PubPermission
+ style={{
+ display: "flex",
+ gap: 4,
+ flexDirection: "column",
+ }}
+ onChange={(e) => {
+ setOnePubParams(
+ {
+ visibleType: e,
+ },
+ imageAccountItem.account!.id,
+ );
+ }}
+ value={imageAccountItem?.pubParams.visibleType}
+ {...props}
+ />
+ );
+};
+
+// 定时发布
+export const ImgTextScheduledTimeSelect = ({
+ ...props
+}: ICommonScheduledTimeSelectProps) => {
+ const { imageAccountItem } = useImagePlatParams();
+ const { setOnePubParams } = useImagePageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ })),
+ );
+
+ return (
+ <CommonScheduledTimeSelect
+ {...props}
+ platType={imageAccountItem?.account?.type}
+ value={
+ imageAccountItem?.pubParams.timingTime
+ ? dayjs(imageAccountItem?.pubParams.timingTime)
+ : undefined
+ }
+ onChange={(e) => {
+ if (!imageAccountItem) return;
+ setOnePubParams(
+ {
+ timingTime: e ? e.toDate() : undefined,
+ },
+ imageAccountItem.account.id,
+ );
+ }}
+ />
+ );
+};
+
+// 合集
+export const ImgTextMixSelect = () => {
+ const { imageAccountItem } = useImagePlatParams();
+ const { setOnePubParams, updateAccounts } = useImagePageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ updateAccounts: state.updateAccounts,
+ })),
+ );
+
+ return (
+ <CommonMixSelect
+ account={imageAccountItem.account}
+ onAccountChange={(account) => {
+ updateAccounts([account]);
+ }}
+ value={imageAccountItem.pubParams.mixInfo?.value}
+ onChange={(_, value) => {
+ setOnePubParams(
+ {
+ mixInfo: !value
+ ? undefined
+ : {
+ label: (value as IMixItem).name,
+ value: (value as IMixItem).id,
+ },
+ },
+ imageAccountItem.account.id,
+ );
+ }}
+ >
+ <VideoPubRestartLogin />
+ </CommonMixSelect>
+ );
+};
diff --git a/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx
new file mode 100644
index 00000000..5142d0f9
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx
@@ -0,0 +1,154 @@
+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";
+import { PubParamsVerifyInfo } from "@/app/[lng]/publish/hooks/usePubParamsVerify";
+import { AccountStatus } from "@/app/config/accountConfig";
+import { PlatType } from "@/app/config/platConfig";
+
+export interface IParamsSettingDetailsRef {}
+
+export interface IParamsSettingDetailsProps {
+ imageAccountList: IImageAccountItem[];
+ openChooseAccount: () => void;
+}
+
+// 图文发布右侧参数设置的具体参数设置,为了防止代码冗余拆分
+const ParamsSettingDetails = memo(
+ forwardRef(
+ (
+ { imageAccountList, openChooseAccount }: IParamsSettingDetailsProps,
+ ref: ForwardedRef<IParamsSettingDetailsRef>,
+ ) => {
+ const {
+ activePlat,
+ platActiveAccountMap,
+ delAccountById,
+ setPlatActiveAccountMap,
+ accountRestart,
+ errParamsMap,
+ warnParamsMap,
+ } = useImagePageStore(
+ useShallow((state) => ({
+ activePlat: state.activePlat,
+ platActiveAccountMap: state.platActiveAccountMap,
+ setPlatActiveAccountMap: state.setPlatActiveAccountMap,
+ delAccountById: state.delAccountById,
+ accountRestart: state.accountRestart,
+ errParamsMap: state.errParamsMap,
+ warnParamsMap: state.warnParamsMap,
+ })),
+ );
+
+ const currAccountItem = useMemo(() => {
+ if (!activePlat) return undefined;
+ return platActiveAccountMap.get(activePlat);
+ }, [platActiveAccountMap, activePlat]);
+
+ return (
+ <div className={styles.paramsSettingItem}>
+ <h1 style={{ marginTop: "10px" }}>
+ <span>发布账号</span>
+ <i>*</i>
+ </h1>
+ <div className="paramsSettingItem-users">
+ <div
+ className="paramsSettingItem-users-item"
+ onClick={openChooseAccount}
+ >
+ <div className="paramsSettingItem-users-item-img">
+ <Avatar size="large" icon={<PlusOutlined />} />
+ </div>
+ <p className="paramsSettingItem-users-item-name">发布账号</p>
+ </div>
+
+ {imageAccountList.map((v) => {
+ return (
+ <div
+ className={[
+ "paramsSettingItem-users-item",
+ currAccountItem?.account?.id === v.account.id &&
+ "paramsSettingItem-users-item--active",
+ ].join(" ")}
+ key={v.account.id}
+ onClick={() => {
+ const newPlatActiveAccountMap = new Map(
+ platActiveAccountMap,
+ );
+ newPlatActiveAccountMap.set(activePlat!, v);
+ setPlatActiveAccountMap(newPlatActiveAccountMap);
+ }}
+ >
+ <div className="paramsSettingItem-users-item-img">
+ <div
+ className={`paramsSettingItem-users-item-close ${styles.closeIcon}`}
+ onClick={(e) => {
+ e.stopPropagation();
+ delAccountById(v.account.id);
+ }}
+ >
+ <CloseOutlined />
+ </div>
+ <Avatar src={v.account.avatar} size="large" />
+ </div>
+ {v.account.status === AccountStatus.DISABLE ? (
+ <Tooltip
+ title={
+ <>
+ 账号已失效,请
+ <a
+ onClick={() => {
+ accountRestart(v.account.type);
+ }}
+ >
+ 重新登录
+ </a>
+ 。
+ </>
+ }
+ >
+ <Alert message="登录失效" type="error" />
+ </Tooltip>
+ ) : (
+ <Tooltip title={v.account.nickname}>
+ <p className="paramsSettingItem-users-item-name">
+ {v.account.nickname}
+ </p>
+ </Tooltip>
+ )}
+ </div>
+ );
+ })}
+ </div>
+
+ <PubParamsVerifyInfo
+ style={{ marginTop: "20px" }}
+ onAccountRestart={() => {
+ accountRestart(activePlat!);
+ }}
+ warnParamsMap={warnParamsMap}
+ errParamsMap={errParamsMap}
+ id={currAccountItem?.account.id}
+ />
+
+ {(() => {
+ switch (activePlat) {
+ case PlatType.Douyin:
+ return <ImageParamsSet_Douyin />;
+ case PlatType.Xhs:
+ return <ImageParamsSet_XHS />;
+ }
+ })()}
+ </div>
+ );
+ },
+ ),
+);
+ParamsSettingDetails.displayName = "ParamsSettingDetails";
+
+export default ParamsSettingDetails;
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
new file mode 100644
index 00000000..ebacec4f
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_Douyin.tsx
@@ -0,0 +1,124 @@
+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";
+
+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
new file mode 100644
index 00000000..2c12afdb
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/children/ImageParamsSet_XHS.tsx
@@ -0,0 +1,36 @@
+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/components/ImageRightSetting/components/children/hooks/useImagePlatParams.ts b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/children/hooks/useImagePlatParams.ts
new file mode 100644
index 00000000..1918b623
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/children/hooks/useImagePlatParams.ts
@@ -0,0 +1,20 @@
+import { useImagePageStore } from "../../../../../useImagePageStore";
+import { useShallow } from "zustand/react/shallow";
+import { useMemo } from "react";
+
+export function useImagePlatParams() {
+ const { activePlat, platActiveAccountMap } = useImagePageStore(
+ useShallow((state) => ({
+ activePlat: state.activePlat,
+ platActiveAccountMap: state.platActiveAccountMap,
+ })),
+ );
+
+ const imageAccountItem = useMemo(() => {
+ return platActiveAccountMap.get(activePlat!)!;
+ }, [activePlat, platActiveAccountMap]);
+
+ return {
+ imageAccountItem,
+ };
+}
diff --git a/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/imageParamsSet.module.scss b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/imageParamsSet.module.scss
new file mode 100644
index 00000000..4b5b6b6e
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/components/ImageRightSetting/components/imageParamsSet.module.scss
@@ -0,0 +1,142 @@
+.imageParamsSet {
+ width: 45%;
+ min-width: 0;
+ display: flex;
+ :global {
+ .imageParamsSet_plats {
+ padding: 15px 10px;
+ border-right: 1px solid var(--grayColor3);
+ margin-right: 15px;
+ &-item {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ font-size: var(--fs-xs);
+ color: var(--grayColor10);
+ cursor: pointer;
+ padding: 20px 15px 15px;
+ border-radius: 6px;
+ white-space: nowrap;
+ &:hover {
+ .imageParamsSet_plats-item-close {
+ display: flex !important;
+ }
+ }
+ &-err {
+ position: absolute;
+ bottom: 2px;
+ right: -5px;
+ color: #fff;
+ background: red;
+ width: 12px;
+ height: 12px;
+ line-height: 10px;
+ text-align: center;
+ border-radius: 50%;
+ }
+ &-img {
+ position: relative;
+ img {
+ width: 35px;
+ margin-bottom: 4px;
+ }
+ }
+ &-close {
+ }
+
+ &--active {
+ background: var(--colorPrimary1);
+ }
+ }
+ }
+ }
+}
+
+.closeIcon {
+ 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;
+}
+
+.paramsSettingItem {
+ width: 100%;
+ overflow: auto;
+ padding-right: 15px;
+ text-align: left;
+ :global {
+ h1 {
+ font-size: var(--fs-md);
+ font-weight: 400;
+ display: flex;
+ align-items: center;
+ color: var(--grayColor10);
+ margin: 30px 0 10px 0;
+ span {
+ margin-right: 5px;
+ }
+ i {
+ color: red;
+ }
+ }
+
+ .paramsSettingItem-users {
+ display: flex;
+ &-item {
+ width: 70px;
+ font-size: var(--fs-sm);
+ cursor: pointer;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ margin-right: 5px;
+ .ant-alert {
+ padding: 2px 4px;
+ font-size: var(--fs-xs);
+ font-weight: 900;
+ margin-top: 4px;
+ border-radius: 6px;
+ color: var(--errerColor);
+ }
+ &--active {
+ .paramsSettingItem-users-item-img {
+ border-color: var(--colorPrimary6);
+ }
+ .paramsSettingItem-users-item-name {
+ color: var(--colorPrimary6);
+ }
+ }
+ &:hover {
+ .paramsSettingItem-users-item-close {
+ display: flex !important;
+ }
+ }
+ &-img {
+ border: 2px solid transparent;
+ display: inline-block;
+ position: relative;
+ transition: 0.3s;
+ border-radius: 50%;
+ }
+ &-close {
+ }
+ &-name {
+ width: 100%;
+ margin-top: 6px;
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ text-align: center;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/app/[lng]/publish/imagePage/image.module.scss b/src/app/[lng]/publish/imagePage/image.module.scss
new file mode 100644
index 00000000..61b43328
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/image.module.scss
@@ -0,0 +1,100 @@
+.image {
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ height: 100%;
+ :global {
+ .image-wrapper {
+ width: 1200px;
+ margin: 0 auto;
+ height: 100%;
+ min-height: 0;
+ box-sizing: border-box;
+ padding: 15px 0;
+ display: flex;
+ @media (max-width: 1450px) {
+ width: 90%;
+ }
+ }
+ .image-footer {
+ border-top: 1px solid var(--grayColor3);
+ padding: 15px 0;
+ text-align: center;
+ button {
+ margin-right: 20px;
+ &:last-of-type {
+ margin-right: 0;
+ }
+ }
+ }
+ }
+}
+
+.imageLeftSetting {
+ width: 65%;
+ display: flex;
+ flex-direction: column;
+ overflow: auto;
+ height: 100%;
+ min-height: 0;
+ box-sizing: border-box;
+ padding: 25px 20px 0 0;
+ border-right: 1px solid var(--grayColor3);
+ :global {
+ .imageLeftSetting-upload {
+ width: 100%;
+ display: flex;
+ justify-content: center;
+ border-bottom: 1px solid var(--grayColor3);
+ padding-bottom: 30px;
+ margin-bottom: 25px;
+ }
+ .imageLeftSetting-commonPar {
+ height: 100%;
+ &-titles, &-item {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ font-size: var(--fs-sm);
+ margin-bottom: 30px;
+ & > label {
+ flex-shrink: 0;
+ }
+ }
+ &-item {
+ textarea {
+ height: 150px;
+ resize: none;
+ }
+ }
+ }
+ }
+}
+
+.imageRightSetting {
+ width: 45%;
+ box-sizing: border-box;
+ margin-left: 20px;
+ :global {
+ .imageRightSetting-title {
+ text-align: left;
+ font-size: var(--fs-sm);
+ margin: 25px 0 5px 0;
+ }
+
+ .ant-steps {
+ margin-top: 30px;
+ .ant-steps-item {
+ height: 70px;
+ }
+ .ant-steps-item-title {
+ color: #222 !important;
+ font-weight: 900;
+ }
+ .ant-steps-item-description {
+ color: var(--grayColor7) !important;
+ font-size: var(--fs-xs);
+ }
+ }
+ }
+}
diff --git a/src/app/[lng]/publish/imagePage/imagePage.type.ts b/src/app/[lng]/publish/imagePage/imagePage.type.ts
new file mode 100644
index 00000000..48fdc04e
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/imagePage.type.ts
@@ -0,0 +1,7 @@
+import { IPubParams } from "../videoPage/videoPage";
+import { SocialAccount } from "@/api/types/account.type";
+
+export interface IImageAccountItem {
+ account: SocialAccount;
+ pubParams: IPubParams;
+}
diff --git a/src/app/[lng]/publish/imagePage/page.tsx b/src/app/[lng]/publish/imagePage/page.tsx
new file mode 100644
index 00000000..23ed9bed
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/page.tsx
@@ -0,0 +1,320 @@
+"use client";
+
+import styles from "./image.module.scss";
+import { useShallow } from "zustand/react/shallow";
+import { useImagePageStore } from "./useImagePageStore";
+import ImageLeftSetting from "./components/ImageLeftSetting/ImageLeftSetting";
+import ImageRightSetting from "./components/ImageRightSetting/ImageRightSetting";
+import { Button, message, Popconfirm, Space } from "antd";
+import React, { useEffect, useMemo, useRef, useState } from "react";
+// import {
+// icpCreateImgTextPubRecord,
+// icpCreatePubRecord,
+// icpPubImgText,
+// } from "@/icp/publish";
+// import { useNavigate } from "react-router-dom";
+// import { usePubStroe } from "@/store/pubStroe";
+import { signInApi } from "@/api/signIn";
+import { toolsApi } from "@/api/tools";
+import { sensitivityLoading } from "@/utils";
+import usePubParamsVerify, {
+ PubParamsErrStatusEnum,
+} from "@/app/[lng]/publish/hooks/usePubParamsVerify";
+import PubAccountDetModule, {
+ IPubAccountDetModuleRef,
+} from "@/app/[lng]/publish/components/PubAccountDetModule/PubAccountDetModule";
+import { PublishProgressRes } from "@/app/plat/plat.type";
+import PubProgressModule from "@/app/[lng]/publish/components/PubProgressModule/PubProgressModule";
+// import { PubType } from "@/app/config/publishConfig";
+// import { useCommontStore } from "@/store/commont";
+import { IImageAccountItem } from "@/app/[lng]/publish/imagePage/imagePage.type";
+
+export default function Page() {
+ const {
+ clear,
+ images,
+ imageAccounts,
+ setActivePlat,
+ setPlatActiveAccountMap,
+ setErrParamsMap,
+ updateAccounts,
+ commonPubParams,
+ } = useImagePageStore(
+ useShallow((state) => ({
+ clear: state.clear,
+ images: state.images,
+ imageAccounts: state.imageAccounts,
+ setPlatActiveAccountMap: state.setPlatActiveAccountMap,
+ setActivePlat: state.setActivePlat,
+ setErrParamsMap: state.setErrParamsMap,
+ updateAccounts: state.updateAccounts,
+ commonPubParams: state.commonPubParams,
+ })),
+ );
+ const { errParamsMap, warnParamsMap } = usePubParamsVerify(
+ imageAccounts.map((v) => {
+ return {
+ id: v.account.id,
+ account: v.account,
+ pubParams: v.pubParams,
+ } as any;
+ }),
+ {
+ moreWranVerifyCallback(item, wranParamsMapTemp, platInfo) {
+ const { imgTextConfig } = platInfo.commonPubParamsConfig;
+ if (imgTextConfig) {
+ const { imagesMax } = imgTextConfig;
+ if (images.length > imagesMax) {
+ wranParamsMapTemp.set(item.id, {
+ message: "参数警告",
+ errType: PubParamsErrStatusEnum.PARAMS,
+ parErrMsg: `${platInfo.name}的图片上传数最多不能超过${imagesMax}个,多余的图片会被系统过滤!`,
+ });
+ }
+ }
+ },
+ },
+ );
+ const pubAccountDetModuleRef = useRef<IPubAccountDetModuleRef>(null);
+ const [loading, setLoading] = useState(false);
+ const [pubProgressModuleOpen, setPubProgressModuleOpen] = useState(false);
+ // 主进程传过来的发布进度数据,key为用户id value为发布进度数据
+ const [pubProgressMap, setPubProgressMap] = useState<
+ Map<number, PublishProgressRes>
+ >(new Map());
+ // 敏感词检测
+ const [sensitiveDetLoading, setSensitiveDetLoading] = useState(false);
+
+ useEffect(() => {
+ setErrParamsMap(errParamsMap, warnParamsMap);
+ }, [errParamsMap, warnParamsMap]);
+
+ useEffect(() => {
+ return () => {
+ clear();
+ };
+ }, []);
+
+ // 发布
+ const pubCore = async () => {
+ setPubProgressModuleOpen(true);
+ setLoading(true);
+ await signInApi.createSignInRecord();
+
+ const err = () => {
+ setLoading(false);
+ message.error("网络繁忙,请稍后重试!");
+ };
+ // 创建一级记录
+ // const recordRes = await icpCreatePubRecord({
+ // title: commonPubParams.title,
+ // desc: commonPubParams.describe,
+ // type: PubType.ImageText,
+ // coverPath: images[0].imgPath,
+ // });
+ // if (!recordRes) return err();
+ //
+ // for (const vData of imageAccounts) {
+ // const account = vData.account!;
+ // // 创建二级记录
+ // await icpCreateImgTextPubRecord({
+ // ...vData.pubParams,
+ // type: account.type,
+ // accountId: account.id,
+ // pubRecordId: recordRes.id,
+ // publishTime: new Date(),
+ // desc: vData.pubParams.describe,
+ // coverPath: images[0].imgPath,
+ // imagesPath: images.map((v) => v.imgPath),
+ // });
+ // }
+ // const okRes = await icpPubImgText(recordRes.id);
+ // setLoading(false);
+ // setPubProgressModuleOpen(false);
+ // usePubStroe.getState().clearImgTextPubSave();
+ // const successList = okRes.filter((v) => v.code === 1);
+ // useCommontStore.getState().notification!.open({
+ // message: "发布结果",
+ // description: (
+ // <>
+ // 一共发布 {okRes.length} 条数据,成功 {successList.length} 条,失败{" "}
+ // {okRes.length - successList.length} 条
+ // </>
+ // ),
+ // showProgress: true,
+ // btn: (
+ // <Space>
+ // <Button
+ // type="primary"
+ // size="small"
+ // onClick={() => {
+ // navigate("/publish/pubRecord");
+ // }}
+ // >
+ // 查看发布记录
+ // </Button>
+ // </Space>
+ // ),
+ // key: Date.now(),
+ // });
+ };
+
+ // 进度
+ const pubProgressData = useMemo(() => {
+ return imageAccounts.map((v) => {
+ const progress = pubProgressMap.get(v.account!.id);
+ return {
+ account: v.account!,
+ progress: progress?.progress || 0,
+ msg: progress?.msg || "",
+ };
+ });
+ }, [pubProgressMap, imageAccounts]);
+
+ // 一键发布点击
+ const pubClick = () => {
+ pubAccountDetModuleRef.current!.startDet();
+ setLoading(true);
+ };
+
+ const sensitiveDetCore = async (
+ content: string,
+ accountItem: IImageAccountItem,
+ ) => {
+ const res = await toolsApi.textModeration(content);
+
+ return {
+ sensitive: res !== "Normal",
+ accountItem,
+ };
+ };
+
+ return (
+ <div className={styles.image}>
+ <PubProgressModule
+ open={pubProgressModuleOpen}
+ pubProgressData={pubProgressData as any}
+ onClose={() => setPubProgressModuleOpen(false)}
+ />
+ <PubAccountDetModule
+ isCheckProxy={true}
+ ref={pubAccountDetModuleRef}
+ accounts={imageAccounts
+ .map((v) => v.account)
+ .filter((v) => v !== undefined)}
+ onClose={() => {
+ setLoading(false);
+ }}
+ onPubClick={() => {
+ pubCore();
+ }}
+ onRestartLoginFinish={(account) => {
+ updateAccounts([account]);
+ }}
+ onDetFinish={(accounts) => {
+ updateAccounts(accounts);
+ }}
+ />
+ <div className="image-wrapper">
+ <ImageLeftSetting />
+ <ImageRightSetting />
+ </div>
+ <div className="image-footer">
+ <Popconfirm
+ title="温馨提示"
+ description="是否确认清空内容和账号?"
+ onConfirm={() => {
+ clear();
+ }}
+ okText="确认"
+ cancelText="取消"
+ >
+ <Button>一键清空</Button>
+ </Popconfirm>
+ <Button
+ loading={sensitiveDetLoading}
+ color="danger"
+ variant="solid"
+ disabled={imageAccounts.length === 0 || images.length === 0}
+ onClick={async () => {
+ setSensitiveDetLoading(true);
+ const core = async () => {
+ const tasks: Promise<{
+ // 作品
+ accountItem: IImageAccountItem;
+ // 是否敏感 true=敏感 false=正常
+ sensitive: boolean;
+ }>[] = [];
+ // 如果检测内容重复不会进行检测
+ const contentSet = new Set<string>();
+
+ imageAccounts.map((v) => {
+ const content = `
+ ${v.pubParams.title}
+ ${v.pubParams.describe}
+ `;
+ if (content.trim() !== "" && !contentSet.has(content)) {
+ contentSet.add(content);
+ tasks.push(sensitiveDetCore(content, v));
+ }
+ });
+ return await Promise.all(tasks);
+ };
+
+ const taskRes = await Promise.all([core(), sensitivityLoading()]);
+ const res = taskRes[0];
+
+ setSensitiveDetLoading(false);
+
+ if (res.length === 0) return message.success("检测正常");
+
+ if (res.every((v) => !v.sensitive)) {
+ message.success("检测正常");
+ return;
+ }
+ for (const { sensitive, accountItem } of res) {
+ if (sensitive) {
+ message.warning("检测到此条作品存在敏感信息!");
+ setActivePlat(accountItem.account.type);
+ const platActiveAccountMap = new Map(
+ useImagePageStore.getState().platActiveAccountMap,
+ );
+ platActiveAccountMap.set(accountItem.account.type, accountItem);
+ setPlatActiveAccountMap(platActiveAccountMap);
+ break;
+ }
+ }
+ }}
+ >
+ 内容安全检测
+ </Button>
+ <Button
+ loading={loading}
+ type="primary"
+ disabled={imageAccounts.length === 0 || images.length === 0}
+ onClick={() => {
+ for (const [key, errVideoItem] of errParamsMap) {
+ if (errVideoItem) {
+ const imageAccount = imageAccounts.find(
+ (v) => v.account.id === +key,
+ )!;
+ const platType = imageAccount!.account.type;
+ const platActiveAccountMap = new Map(
+ useImagePageStore.getState().platActiveAccountMap,
+ );
+ setActivePlat(platType);
+ platActiveAccountMap.set(platType, imageAccount);
+ setPlatActiveAccountMap(platActiveAccountMap);
+ message.warning(errVideoItem.parErrMsg);
+ return;
+ }
+ }
+ pubClick();
+ }}
+ >
+ 一键发布
+ </Button>
+ </div>
+ </div>
+ );
+}
diff --git a/src/app/[lng]/publish/imagePage/useImagePageStore.ts b/src/app/[lng]/publish/imagePage/useImagePageStore.ts
new file mode 100644
index 00000000..dc912ac1
--- /dev/null
+++ b/src/app/[lng]/publish/imagePage/useImagePageStore.ts
@@ -0,0 +1,283 @@
+import { create } from "zustand";
+import { combine } from "zustand/middleware";
+import { IImgFile } from "../components/Choose/ImgChoose";
+import { IImageAccountItem } from "./imagePage.type";
+import lodash from "lodash";
+import { useVideoPageStore } from "../videoPage/useVideoPageStore";
+import { AccountInfo, IPubParams } from "../videoPage/videoPage";
+import { message } from "antd";
+import { PlatType } from "@/app/config/platConfig";
+import { ErrPubParamsMapType } from "@/app/[lng]/publish/hooks/usePubParamsVerify";
+
+export interface IImagePageStore {
+ // 账户数据和对应参数
+ imageAccounts: IImageAccountItem[];
+ // 选择的图片数据
+ images: IImgFile[];
+ // 每个平台当前选择的账户
+ platActiveAccountMap: Map<PlatType, IImageAccountItem>;
+ // 当前选择的平台
+ activePlat?: PlatType;
+ // 通用参数
+ commonPubParams: IPubParams;
+ // 图片上传上限
+ imgUploadLimit: number;
+ /**
+ * 这个属性在 imagePage/page.tsx 中进行计算,然后实时的放到这里
+ * 因为别的组件需要这个属性,为了使其只计算一次,特此放到store引用
+ */
+ errParamsMap?: ErrPubParamsMapType;
+ warnParamsMap?: ErrPubParamsMapType;
+}
+
+const store: IImagePageStore = {
+ imgUploadLimit: 35,
+ images: [],
+ imageAccounts: [],
+ platActiveAccountMap: new Map<PlatType, IImageAccountItem>(),
+ activePlat: undefined,
+ commonPubParams: useVideoPageStore.getState().pubParamsInit(),
+ errParamsMap: undefined,
+ warnParamsMap: undefined,
+};
+
+const getStore = () => {
+ return lodash.cloneDeep(store);
+};
+
+// 视频发布所有组件的共享状态和方法
+export const useImagePageStore = create(
+ combine(
+ {
+ ...getStore(),
+ },
+ (set, get, storeApi) => {
+ const methods = {
+ setPlatActiveAccountMap(
+ platActiveAccountMap: Map<PlatType, IImageAccountItem>,
+ ) {
+ set({
+ platActiveAccountMap,
+ });
+ },
+ setErrParamsMap(
+ errParamsMap: ErrPubParamsMapType,
+ warnParamsMap: ErrPubParamsMapType,
+ ) {
+ set({
+ errParamsMap,
+ warnParamsMap,
+ });
+ },
+ setActivePlat(activePlat: PlatType) {
+ set({
+ activePlat,
+ });
+ },
+ // 设置图片
+ setImages(images: IImgFile[]) {
+ set({
+ images,
+ });
+ },
+
+ // TODO 恢复临时图文记录
+ // async setTempSaveParams({
+ // images,
+ // commonPubParams,
+ // imageAccounts,
+ // }: {
+ // images?: IImgFile[];
+ // commonPubParams?: IPubParams;
+ // imageAccounts?: IImageAccountItem[];
+ // }) {
+ // if (images) {
+ // const tasks: Promise<IImgFile>[] = [];
+ // for (const image of images) {
+ // tasks.push(getImgFile(image.imgPath));
+ // }
+ // const imgFiles = await Promise.all(tasks);
+ // set({
+ // images: imgFiles,
+ // });
+ // }
+ //
+ // if (imageAccounts) {
+ // const accountList = useAccountStore.getState().accountList;
+ // imageAccounts = imageAccounts.map((v) => {
+ // v.account = accountList.find(
+ // (account) => v.account?.id === account.id,
+ // )!;
+ // return v;
+ // });
+ // set({
+ // imageAccounts,
+ // });
+ // }
+ //
+ // if (commonPubParams) {
+ // set({
+ // commonPubParams,
+ // });
+ // }
+ // },
+
+ /**
+ * TODO 账户重新登录。登录成功后会自动更新该条账户数据
+ */
+ async accountRestart(pType: PlatType) {
+ // const res = await accountLogin(pType);
+ // if (!res) return;
+ // message.success("登录成功!");
+ // // 更新此条账户数据
+ // methods.updateAccounts([res]);
+ },
+
+ // 添加图片
+ addImages(images: IImgFile[]) {
+ if (images.length + get().images.length > get().imgUploadLimit) {
+ return message.warning(`最多上传${get().imgUploadLimit}张图片!`);
+ }
+ set({
+ images: [...get().images, ...images],
+ });
+ },
+
+ // 设置所有参数
+ setAllPubParams(pubParmas: IPubParams) {
+ const imageAccounts = [...get().imageAccounts];
+
+ imageAccounts.map((v) => {
+ // 替换
+ Object.keys(pubParmas).map((key) => {
+ if (pubParmas.hasOwnProperty(key)) {
+ v.pubParams[key as "topics"] = pubParmas[key as "topics"];
+ }
+ });
+ });
+ set({
+ imageAccounts,
+ });
+ },
+
+ // 设置通用发布参数
+ setCommonPubParams(pubParmas: IPubParams) {
+ const commonPubParams = { ...get().commonPubParams };
+ const imageAccounts = [...get().imageAccounts];
+
+ for (const key in commonPubParams) {
+ if (pubParmas.hasOwnProperty(key)) {
+ const keyType = key as "title";
+ const val = pubParmas[keyType];
+ commonPubParams[keyType] = pubParmas[keyType];
+ imageAccounts.map((v) => {
+ v.pubParams[keyType] = val;
+ });
+ }
+ }
+ set({
+ commonPubParams,
+ imageAccounts,
+ });
+ },
+
+ // 按照账号id删除
+ delAccountById(accountId: number) {
+ const imageAccounts = get().imageAccounts.filter(
+ (v) => v.account.id !== accountId,
+ );
+ set({
+ imageAccounts,
+ });
+ },
+
+ // 按平台删除
+ delAccountByPalt(accountType: PlatType) {
+ const imageAccounts = get().imageAccounts.filter(
+ (v) => v.account.type !== accountType,
+ );
+ set({
+ imageAccounts,
+ });
+ },
+
+ // 添加账户
+ addAccount(accounts: AccountInfo[]) {
+ 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) {
+ 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: lodash.cloneDeep(get().commonPubParams),
+ });
+ }
+
+ set({
+ imageAccounts,
+ });
+ },
+
+ // 设置单条数据的参数
+ setOnePubParams(pubParmas: IPubParams, id: number) {
+ const imageAccounts = [...get().imageAccounts];
+ const findedData = imageAccounts.find((v) => v.account.id === id);
+ if (!findedData) return;
+
+ for (const key in pubParmas) {
+ if (pubParmas.hasOwnProperty(key)) {
+ findedData.pubParams[key as "title"] = pubParmas[key as "title"];
+ }
+ }
+
+ set({ imageAccounts });
+ },
+
+ // 更新用户数据
+ updateAccounts(accounts: AccountInfo[]) {
+ const imageAccounts = [...get().imageAccounts];
+ const imageTextMap = new Map<number, IImageAccountItem>();
+
+ imageAccounts.map((v) => {
+ imageTextMap.set(v.account.id || 0, v);
+ });
+
+ accounts.map((v) => {
+ imageTextMap.get(v.id)!.account = v;
+ });
+
+ set({ imageAccounts });
+ },
+
+ // 清除本store所有数据
+ clear() {
+ set({
+ ...getStore(),
+ });
+ },
+ };
+ return methods;
+ },
+ ),
+);
diff --git a/src/app/[lng]/publish/layout.tsx b/src/app/[lng]/publish/layout.tsx
new file mode 100644
index 00000000..69d39aea
--- /dev/null
+++ b/src/app/[lng]/publish/layout.tsx
@@ -0,0 +1,17 @@
+import styles from "./publish.module.scss";
+import PublishSidebar from "@/app/[lng]/publish/components/PublishSidebar";
+
+export default function RootLayout({
+ children,
+ params,
+}: Readonly<{
+ children: React.ReactNode;
+ params: Promise<{ lng: string }>;
+}>) {
+ return (
+ <div className={styles.publish}>
+ <PublishSidebar />
+ {children}
+ </div>
+ );
+}
diff --git a/src/app/[lng]/publish/page.tsx b/src/app/[lng]/publish/page.tsx
index 86e7b93a..7d1e0b71 100644
--- a/src/app/[lng]/publish/page.tsx
+++ b/src/app/[lng]/publish/page.tsx
@@ -1,77 +1,3 @@
-"use client";
-
-import { useState } from 'react';
-import { Button, Tabs } from 'antd';
-import styles from './publish.module.css';
-import PublishList from './components/PublishList';
-import DraftList from './components/DraftList';
-import CreatePublish from './components/CreatePublish';
-import { PubType, PublishType } from '@/types/publish';
-
-export default function PublishPage() {
- const [activeTab, setActiveTab] = useState('1');
- const [isCreateModalVisible, setIsCreateModalVisible] = useState(false);
- const [createType, setCreateType] = useState<PublishType>(PubType.VIDEO);
-
- const handleCreateClick = (type: PublishType) => {
- setCreateType(type);
- setIsCreateModalVisible(true);
- };
-
- const items = [
- {
- key: '1',
- label: '发布列表',
- children: <PublishList />,
- },
- {
- key: '2',
- label: '草稿箱',
- children: <DraftList />,
- },
- ];
-
- return (
- <div className={styles.container}>
- <div className={styles.header}>
- <h1>内容发布</h1>
- <div className={styles.actions}>
- <Button
- type="primary"
- onClick={() => handleCreateClick(PubType.IMAGE_TEXT)}
- className={styles.createButton}
- >
- 创建图文发布
- </Button>
- <Button
- type="primary"
- onClick={() => handleCreateClick(PubType.VIDEO)}
- className={styles.createButton}
- >
- 创建视频发布
- </Button>
- <Button
- type="primary"
- onClick={() => handleCreateClick(PubType.ARTICLE)}
- className={styles.createButton}
- >
- 创建文章发布
- </Button>
- </div>
- </div>
-
- <Tabs
- activeKey={activeTab}
- onChange={setActiveTab}
- items={items}
- className={styles.tabs}
- />
-
- <CreatePublish
- visible={isCreateModalVisible}
- type={createType}
- onClose={() => setIsCreateModalVisible(false)}
- />
- </div>
- );
-}
\ No newline at end of file
+export default function Page() {
+ return <></>;
+}
diff --git a/src/app/[lng]/publish/publish.module.css b/src/app/[lng]/publish/publish.module.css
deleted file mode 100644
index 6cd995b9..00000000
--- a/src/app/[lng]/publish/publish.module.css
+++ /dev/null
@@ -1,34 +0,0 @@
-.container {
- padding: 24px;
- max-width: 1200px;
- margin: 0 auto;
-}
-
-.header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 24px;
-}
-
-.header h1 {
- margin: 0;
- font-size: 24px;
- font-weight: 600;
-}
-
-.actions {
- display: flex;
- gap: 16px;
-}
-
-.createButton {
- min-width: 120px;
-}
-
-.tabs {
- background: #fff;
- padding: 16px;
- border-radius: 8px;
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
-}
\ No newline at end of file
diff --git a/src/app/[lng]/publish/publish.module.scss b/src/app/[lng]/publish/publish.module.scss
new file mode 100644
index 00000000..2abb36ea
--- /dev/null
+++ b/src/app/[lng]/publish/publish.module.scss
@@ -0,0 +1,16 @@
+.publish {
+ width: 100%;
+ height: 100%;
+ display: flex;
+
+ :global {
+ .ant-segmented {
+ padding: 30px 10px;
+
+ .ant-segmented-item {
+ margin-bottom: 5px;
+ padding: 3px 40px 3px 0;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/app/[lng]/publish/videoPage/comment.ts b/src/app/[lng]/publish/videoPage/comment.ts
new file mode 100644
index 00000000..865e3eab
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/comment.ts
@@ -0,0 +1,11 @@
+/*
+ * @Author: nevin
+ * @Date: 2025-01-23 23:15:08
+ * @LastEditTime: 2025-02-10 13:24:38
+ * @LastEditors: nevin
+ * @Description:
+ */
+
+// import { VideoModel } from '../../../../../electron/db/models/video';
+
+export type VideoPul = any;
diff --git a/src/app/[lng]/publish/videoPage/components/CommonPubSetting.tsx b/src/app/[lng]/publish/videoPage/components/CommonPubSetting.tsx
new file mode 100644
index 00000000..37cd14a1
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/CommonPubSetting.tsx
@@ -0,0 +1,246 @@
+import React, { ForwardedRef, forwardRef, memo, useMemo } from "react";
+import { Input, Tooltip } from "antd";
+import { ExclamationCircleOutlined } from "@ant-design/icons";
+import { useVideoPageStore } from "@/app/[lng]/publish/videoPage/useVideoPageStore";
+import { useShallow } from "zustand/react/shallow";
+import { ScheduledTimeSelect } from "./VideoPubSetModal/components/VideoPubSetModalCommon";
+import { AiCreateType } from "@/api/types/tools";
+import VideoCoverSeting from "@/app/[lng]/publish/videoPage/components/VideoCoverSeting";
+import {
+ AccountPlatInfoMap,
+ IAccountPlatInfo,
+ PlatType,
+} from "@/app/config/platConfig";
+import AICreateTitle from "@/app/[lng]/publish/components/AICreateTitle/AICreateTitle";
+
+const { TextArea } = Input;
+
+export interface ICommonPubSettingRef {}
+
+export interface ICommonPubSettingProps {}
+
+// 通用参数设置组件
+const CommonPubSetting = memo(
+ forwardRef(
+ ({}: ICommonPubSettingProps, ref: ForwardedRef<ICommonPubSettingRef>) => {
+ const {
+ setPubParams,
+ videoListChoose,
+ setVideoCoverFirst,
+ commonPubParams,
+ } = useVideoPageStore(
+ useShallow((state) => ({
+ setPubParams: state.setPubParams,
+ videoListChoose: state.videoListChoose,
+ setVideoCoverFirst: state.setVideoCoverFirst,
+ commonPubParams: state.commonPubParams,
+ })),
+ );
+
+ // 获取选择的账户的所有相关平台
+ const getChoosedAccountPlatList = useMemo(() => {
+ const platMap = new Map<PlatType, IAccountPlatInfo>();
+ videoListChoose.map((v) => {
+ if (v.account) {
+ platMap.set(
+ v.account.type,
+ AccountPlatInfoMap.get(v.account.type)!,
+ );
+ }
+ });
+ return Array.from(platMap.values());
+ }, [videoListChoose]);
+
+ // 所有平台通用发布参数的最大值获取,做为默认值
+ const getPlatCommonParamsMax = useMemo(() => {
+ const platList = Array.from(AccountPlatInfoMap.values());
+
+ const maxValue = (getValue: (v: any) => number) =>
+ Math.max(...platList.map((v) => getValue(v) || -Infinity));
+
+ return {
+ maxDate: maxValue((v) => v.commonPubParamsConfig.timingMax?.maxDate),
+ timeOffset: maxValue(
+ (v) => v.commonPubParamsConfig.timingMax?.timeOffset,
+ ),
+ titleMax: maxValue((v) => v.commonPubParamsConfig.titleMax),
+ };
+ }, [AccountPlatInfoMap]);
+
+ return (
+ <div className="commonPubSetting">
+ <h1>通用发布设置</h1>
+ <p className="commonPubSetting-tip">
+ 通用设置中的参数将会应用于所有账号
+ </p>
+ <h2>通用封面</h2>
+ <VideoCoverSeting
+ videoFile={videoListChoose.find((v) => v.video)?.video}
+ value={commonPubParams.cover}
+ saveImgId="common"
+ onClose={() => {
+ setPubParams({
+ cover: undefined,
+ });
+ setVideoCoverFirst(true);
+ }}
+ onChoosed={(imgFile) => {
+ setPubParams({
+ cover: imgFile,
+ });
+ }}
+ />
+ <p className="commonPubSetting-tip">
+ 支持常用图片格式上传,暂不支持 GIF,上传后图片将按平台要求自动裁剪
+ </p>
+ <p className="commonPubSetting-tip">
+ 未上传任何图片的情况下,默认选择视频第一帧。
+ </p>
+
+ <h2>
+ 标题
+ <Tooltip
+ title={
+ <div>
+ {Array.from(AccountPlatInfoMap.values()).map((platInfo) => {
+ const titleMax = platInfo.commonPubParamsConfig.titleMax;
+ return (
+ <p key={platInfo.name}>
+ <b>{platInfo.name}</b>
+ {!titleMax
+ ? `没有标题参数`
+ : `标题字数限制${titleMax}字`}
+ </p>
+ );
+ })}
+ </div>
+ }
+ >
+ <ExclamationCircleOutlined />
+ </Tooltip>
+ </h2>
+ <Input
+ showCount
+ value={commonPubParams.title}
+ maxLength={Math.min(
+ getPlatCommonParamsMax.titleMax,
+ ...getChoosedAccountPlatList.map(
+ (v) => v.commonPubParamsConfig.titleMax || 30,
+ ),
+ )}
+ placeholder="请输入视频标题"
+ variant="filled"
+ onChange={(e) => {
+ setPubParams({
+ title: e.target.value,
+ });
+ }}
+ />
+ <AICreateTitle
+ type={AiCreateType.TITLE}
+ tips="在通用发布参数会选择第一个视频作为生成标题的对象"
+ onAiCreateFinish={(text) => {
+ setPubParams({
+ title: text,
+ });
+ }}
+ videoFile={videoListChoose[0]?.video}
+ max={Math.min(
+ getPlatCommonParamsMax.titleMax,
+ ...getChoosedAccountPlatList.map(
+ (v) => v.commonPubParamsConfig.titleMax || 30,
+ ),
+ )}
+ />
+
+ <h2>描述</h2>
+ <TextArea
+ placeholder="请输入视频描述"
+ variant="filled"
+ showCount
+ maxLength={500}
+ value={commonPubParams.describe}
+ style={{ height: 200, resize: "none" }}
+ onChange={(e) => {
+ setPubParams({
+ describe: e.target.value,
+ });
+ }}
+ />
+ <AICreateTitle
+ type={AiCreateType.DESC}
+ tips="在通用发布参数会选择第一个视频作为生成描述的对象"
+ onAiCreateFinish={(text) => {
+ setPubParams({
+ describe: text,
+ });
+ }}
+ videoFile={videoListChoose[0]?.video}
+ max={500}
+ />
+ <p className="commonPubSetting-tip">
+ 描述中可带话题,以‘#’开头、‘空格’结尾,
+ <Tooltip title="更多详情中单独设置的话题和描述中带的话题都是有效的,发布时将合并去重处理">
+ <span style={{ color: "rgb(250, 173, 20)" }}>
+ <ExclamationCircleOutlined style={{ marginRight: "3px" }} />
+ 发布时
+ </span>
+ </Tooltip>
+ 将根据平台自动处理 如:这是一段文字描述#最美中国 #夏日穿搭
+ </p>
+
+ <h2>
+ 定时发布
+ <Tooltip
+ styles={{
+ root: {
+ maxWidth: "none",
+ },
+ }}
+ title={
+ <div>
+ {Array.from(AccountPlatInfoMap.values()).map((platInfo) => {
+ const timingMax = platInfo.commonPubParamsConfig.timingMax;
+ return (
+ <p key={platInfo.name}>
+ <b>{platInfo.name}</b>
+ {!timingMax
+ ? `没有定时发布参数;`
+ : `支持${timingMax.timeOffset}分钟后及${timingMax.maxDate}天内的定时发布;`}
+ </p>
+ );
+ })}
+ </div>
+ }
+ >
+ <ExclamationCircleOutlined />
+ </Tooltip>
+ </h2>
+ <ScheduledTimeSelect
+ maxDate={Math.min(
+ getPlatCommonParamsMax.maxDate,
+ ...getChoosedAccountPlatList.map(
+ (v) => v.commonPubParamsConfig.timingMax?.maxDate || Infinity,
+ ),
+ )}
+ timeOffset={Math.min(
+ getPlatCommonParamsMax.timeOffset,
+ ...getChoosedAccountPlatList.map(
+ (v) =>
+ v.commonPubParamsConfig.timingMax?.timeOffset || Infinity,
+ ),
+ )}
+ onChange={(e) => {
+ setPubParams({
+ timingTime: e ? e.toDate() : undefined,
+ });
+ }}
+ />
+ </div>
+ );
+ },
+ ),
+);
+CommonPubSetting.displayName = "CommonPubSetting";
+
+export default CommonPubSetting;
diff --git a/src/app/[lng]/publish/videoPage/components/NoChoosePage.tsx b/src/app/[lng]/publish/videoPage/components/NoChoosePage.tsx
new file mode 100644
index 00000000..8e6823c1
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/NoChoosePage.tsx
@@ -0,0 +1,63 @@
+import { ForwardedRef, forwardRef, memo } from "react";
+import { useVideoPageStore } from "@/app/[lng]/publish/videoPage/useVideoPageStore";
+import { useShallow } from "zustand/react/shallow";
+import localUpload from "../images/localUpload.png";
+import VideoChoose from "@/app/[lng]/publish/components/Choose/VideoChoose";
+import { ChooseChunk } from "@/app/[lng]/publish/components/CommonComponents/CommonComponents";
+import { PubType } from "@/app/config/publishConfig";
+import SupportPlat from "@/app/[lng]/publish/components/SupportPlat/SupportPlat";
+
+export interface INoChoosePageRef {}
+
+export interface INoChoosePageProps {}
+
+// 未选择视频时暂时的组件
+const NoChoosePage = memo(
+ forwardRef(({}: INoChoosePageProps, ref: ForwardedRef<INoChoosePageRef>) => {
+ const { addVideos, setLoadingPageLoading, setOperateId } =
+ useVideoPageStore(
+ useShallow((state) => ({
+ addVideos: state.addVideos,
+ setLoadingPageLoading: state.setLoadingPageLoading,
+ setOperateId: state.setOperateId,
+ })),
+ );
+
+ return (
+ <div className="video-pubBefore">
+ <h1>视频发布</h1>
+ <p className="video-pubBefore-tip">
+ 支持多视频、多平台、多账号同时发布
+ </p>
+
+ <div className="video-pubBefore-con">
+ <VideoChoose
+ onMultipleChoose={(videoFiles) => {
+ setOperateId();
+ addVideos(videoFiles);
+ }}
+ onStartShoose={() => {
+ setLoadingPageLoading(true);
+ }}
+ onChooseFail={() => {
+ setLoadingPageLoading(false);
+ }}
+ >
+ <ChooseChunk
+ text="本地上传"
+ imgUrl={localUpload.src}
+ color="linear-gradient(to right, rgb(255, 142, 28), rgb(255, 124, 24))"
+ hoverColor="rgb(255, 142, 28)"
+ style={{ marginRight: "15px" }}
+ />
+ </VideoChoose>
+ </div>
+
+ <SupportPlat pubType={PubType.VIDEO} style={{ marginTop: "15px" }} />
+ </div>
+ );
+ }),
+);
+NoChoosePage.displayName = "NoChoosePage";
+
+export default NoChoosePage;
diff --git a/src/app/[lng]/publish/videoPage/components/VideoChooseItem.tsx b/src/app/[lng]/publish/videoPage/components/VideoChooseItem.tsx
new file mode 100644
index 00000000..6c20610b
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoChooseItem.tsx
@@ -0,0 +1,252 @@
+import React, { ForwardedRef, forwardRef, memo, useMemo } from "react";
+import { Alert, Avatar, Button, Tooltip } from "antd";
+import {
+ CaretRightOutlined,
+ DeleteOutlined,
+ EditOutlined,
+ PlusOutlined,
+ VideoCameraFilled,
+ SwapOutlined,
+ ExclamationCircleOutlined,
+} from "@ant-design/icons";
+import { useVideoPageStore } from "@/app/[lng]/publish/videoPage/useVideoPageStore";
+import { useShallow } from "zustand/react/shallow";
+import { formatSeconds } from "@/utils";
+import { AccountChooseType } from "../page";
+import { IVideoChooseItem } from "@/app/[lng]/publish/videoPage/videoPage";
+import { AccountStatus } from "@/app/config/accountConfig";
+import VideoChoose from "@/app/[lng]/publish/components/Choose/VideoChoose";
+import { AccountPlatInfoMap } from "@/app/config/platConfig";
+
+export interface IVideoChooseItemRef {}
+
+export interface IVideoChooseItemProps {
+ videoChooseItem: IVideoChooseItem;
+ // 用户单选触发
+ onAccountOneChoose: (id: string, type: AccountChooseType) => void;
+}
+
+// 选择视频完成后渲染的列表 item
+const VideoChooseItem = memo(
+ forwardRef(
+ (
+ { videoChooseItem, onAccountOneChoose }: IVideoChooseItemProps,
+ ref: ForwardedRef<IVideoChooseItemRef>,
+ ) => {
+ // 数据是否准备完毕
+ const prepareEnd = !!(videoChooseItem.video && videoChooseItem.account);
+ const {
+ deleteAloneVideo,
+ aloneAdd,
+ deleteData,
+ setCurrChooseAccountId,
+ setVideoPubSetModalOpen,
+ setLoadingPageLoading,
+ accountRestart,
+ } = useVideoPageStore(
+ useShallow((state) => ({
+ deleteAloneVideo: state.deleteAloneVideo,
+ aloneAdd: state.aloneAdd,
+ deleteData: state.deleteData,
+ setCurrChooseAccountId: state.setCurrChooseAccountId,
+ setVideoPubSetModalOpen: state.setVideoPubSetModalOpen,
+ setLoadingPageLoading: state.setLoadingPageLoading,
+ accountRestart: state.accountRestart,
+ })),
+ );
+
+ // 分辨率是否合规
+ const isDpiCompliance = useMemo(() => {
+ if (!videoChooseItem.video) return true;
+ return (
+ videoChooseItem.video.height < 640 ||
+ videoChooseItem.video.width < 480
+ );
+ }, []);
+
+ return (
+ <div className="videoChooseItem">
+ <div className="videoChooseItem-core">
+ <div
+ className="videoChooseItem-left"
+ key={videoChooseItem.video?.videoPath}
+ >
+ {videoChooseItem.video ? (
+ <>
+ <div className="videoChooseItem-video">
+ <div
+ className="videoChooseItem-video-close"
+ onClick={() => deleteAloneVideo(videoChooseItem.id)}
+ >
+ x
+ </div>
+ <div className="videoChooseItem-video-play">
+ <img src={videoChooseItem.video.cover.imgUrl} />
+ {prepareEnd && (
+ <div
+ className="videoChooseItem-video-play-click"
+ onClick={() => {
+ setVideoPubSetModalOpen(true);
+ setCurrChooseAccountId(videoChooseItem.id);
+ }}
+ >
+ <CaretRightOutlined />
+ </div>
+ )}
+ </div>
+ </div>
+ <div className="videoChooseItem-left-info">
+ <p
+ className="videoChooseItem-left-title"
+ title={videoChooseItem.video?.filename}
+ >
+ {videoChooseItem.video?.filename}
+ </p>
+ <div className="videoChooseItem-left-bottom">
+ <div className="videoChooseItem-left-bottom-item">
+ <label>时长</label>
+ <span>
+ {formatSeconds(videoChooseItem.video.duration)}
+ </span>
+ </div>
+ <div
+ className={[
+ "videoChooseItem-left-bottom-item",
+ isDpiCompliance &&
+ "videoChooseItem-left-bottom-item--warning",
+ ].join(" ")}
+ >
+ <label>分辨率</label>
+ <span>
+ {videoChooseItem.video.width}*
+ {videoChooseItem.video.height}
+ </span>
+ {isDpiCompliance && (
+ <Tooltip title="视频清晰度过低,有概率被平台限流或不能发布,推荐您上传 460*640 分辨率以上的视频">
+ <ExclamationCircleOutlined />
+ </Tooltip>
+ )}
+ </div>
+ </div>
+ </div>
+ </>
+ ) : (
+ <div className="videoChooseItem-left-chooseVideo">
+ <VideoChoose
+ onChoose={(videoFile) => {
+ setLoadingPageLoading(false);
+ aloneAdd({
+ video: videoFile,
+ id: videoChooseItem.id,
+ });
+ }}
+ onStartShoose={() => {
+ setLoadingPageLoading(true);
+ }}
+ >
+ <VideoCameraFilled />
+ <span className="videoChooseItem-left-chooseVideo-name">
+ 添加视频
+ </span>
+ </VideoChoose>
+ </div>
+ )}
+ </div>
+
+ <div className="videoChooseItem-right">
+ {videoChooseItem.account ? (
+ <div className="videoChooseItem-account">
+ <div className="videoChooseItem-account-avatar">
+ <Avatar src={videoChooseItem.account.avatar} size="large" />
+ <div
+ className="videoChooseItem-account-avatar-replace"
+ onClick={() => {
+ onAccountOneChoose(
+ videoChooseItem.id,
+ AccountChooseType.Replace,
+ );
+ }}
+ >
+ <SwapOutlined />
+ </div>
+ </div>
+ <div className="videoChooseItem-account-con">
+ <div className="videoChooseItem-account-top">
+ <Tooltip title={videoChooseItem.account.nickname}>
+ <span className="videoChooseItem-account-top-name">
+ {videoChooseItem.account.nickname}
+ </span>
+ </Tooltip>
+ <img
+ src={
+ AccountPlatInfoMap.get(videoChooseItem.account.type)
+ ?.icon
+ }
+ />
+ </div>
+ {videoChooseItem.account.status ===
+ AccountStatus.DISABLE && (
+ <Alert
+ message="登录失效"
+ type="error"
+ showIcon
+ onClick={() => {
+ accountRestart(videoChooseItem.account!.type);
+ }}
+ />
+ )}
+ </div>
+ </div>
+ ) : (
+ <div
+ className="videoChooseItem-noAccount"
+ onClick={() => {
+ onAccountOneChoose(
+ videoChooseItem.id,
+ AccountChooseType.Radio,
+ );
+ }}
+ >
+ <div className="videoChooseItem-noAccount-icon">
+ <PlusOutlined />
+ </div>
+ <span>添加账号</span>
+ </div>
+ )}
+ </div>
+ </div>
+
+ <div className="videoChooseItem-options">
+ <Button
+ color="primary"
+ type="text"
+ size="small"
+ icon={<EditOutlined />}
+ disabled={!prepareEnd}
+ onClick={() => {
+ setVideoPubSetModalOpen(true);
+ setCurrChooseAccountId(videoChooseItem.id);
+ }}
+ >
+ 发布设置
+ </Button>
+ <Button
+ onClick={() => {
+ deleteData(videoChooseItem.id);
+ }}
+ type="text"
+ size="small"
+ danger
+ icon={<DeleteOutlined />}
+ >
+ 删除
+ </Button>
+ </div>
+ </div>
+ );
+ },
+ ),
+);
+VideoChooseItem.displayName = "VideoChooseItem";
+
+export default VideoChooseItem;
diff --git a/src/app/[lng]/publish/videoPage/components/VideoCoverSeting.tsx b/src/app/[lng]/publish/videoPage/components/VideoCoverSeting.tsx
new file mode 100644
index 00000000..a0ccbb33
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoCoverSeting.tsx
@@ -0,0 +1,237 @@
+import {
+ ForwardedRef,
+ forwardRef,
+ memo,
+ useEffect,
+ useRef,
+ useState,
+} from "react";
+import ImgChoose, {
+ formatImg,
+ IImgFile,
+} from "../../components/Choose/ImgChoose";
+import styles from "./videoCoverSeting.module.scss";
+import { Alert, Button, message, Modal, Slider, Spin } from "antd";
+import { IVideoFile } from "../../components/Choose/VideoChoose";
+import Cropper from "cropperjs";
+import "cropperjs/dist/cropper.css";
+import { useVideoPageStore } from "@/app/[lng]/publish/videoPage/useVideoPageStore";
+import { useShallow } from "zustand/react/shallow";
+import { CloseCircleOutlined } from "@ant-design/icons";
+
+export interface IVideoCoverSetingRef {}
+
+export interface IVideoCoverSetingProps {
+ // 封面选择完成
+ onChoosed: (imgFile: IImgFile) => void;
+ // 当前选择的封面
+ value?: IImgFile;
+ // 需要截帧的视频
+ videoFile?: IVideoFile;
+ // 保存图片的唯一值
+ saveImgId: string;
+ // 关闭按钮点击事件,如果有这个事件就会显示关闭按钮
+ onClose?: () => void;
+}
+
+// 保存裁剪的图片
+export const saveCropperImage = (
+ filename: string,
+ file: Blob,
+): Promise<string> => {
+ return new Promise((resolve) => {
+ const reader = new FileReader();
+ reader.onload = async function (event) {
+ const arrayBuffer = event.target!.result as ArrayBuffer;
+ const uint8Array = new Uint8Array(arrayBuffer);
+
+ // TODO 报错裁剪的图片
+ // const imgPath = await icpSaveFile({
+ // file: uint8Array,
+ // saveDir: "/images/cropper",
+ // filename: filename,
+ // });
+ // resolve(imgPath);
+ };
+ reader.readAsArrayBuffer(file);
+ });
+};
+
+// 视频封面设置
+const VideoCoverSeting = memo(
+ forwardRef(
+ (
+ {
+ onChoosed,
+ value,
+ videoFile,
+ saveImgId,
+ onClose,
+ }: IVideoCoverSetingProps,
+ ref: ForwardedRef<IVideoCoverSetingRef>,
+ ) => {
+ const [imgFile, setImgFile] = useState<IImgFile>();
+ const [videoCoverSetingModal, setVideoCoverSetingModal] = useState(false);
+ const cropper = useRef<Cropper>();
+ const cropperImg = useRef<HTMLImageElement>(null);
+ const [videoCoverLoading, setVideoCoverLoading] = useState(false);
+ const [sliderVal, setSliderVal] = useState(0);
+ const { operateId } = useVideoPageStore(
+ useShallow((state) => ({
+ operateId: state.operateId,
+ })),
+ );
+
+ useEffect(() => {
+ if (!videoCoverSetingModal) return;
+ if (value) {
+ setImgFile(value);
+ return;
+ }
+ getVideoCover(0);
+ }, [videoCoverSetingModal]);
+
+ useEffect(() => {
+ if (!imgFile) return;
+ initCropper();
+ }, [imgFile]);
+
+ /* 获取封面 */
+ const getVideoCover = async (n: number) => {
+ // TODO 读取文件
+ // if (!videoFile!.videoPath) return;
+ // setSliderVal(n);
+ // setVideoCoverLoading(true);
+ // const pathVideo = await ipcGetVideoCover(
+ // videoFile!.videoPath!,
+ // formatSeconds(n),
+ // );
+ // const imgFile = await getImgFile(pathVideo);
+ // setVideoCoverLoading(false);
+ // setImgFile(imgFile);
+ };
+
+ const close = () => {
+ setVideoCoverSetingModal(false);
+ };
+
+ // 初始化裁剪工具
+ const initCropper = () => {
+ if (!cropperImg.current) return;
+
+ if (cropper.current) {
+ cropper.current.destroy();
+ cropper.current = undefined;
+ }
+
+ cropper.current = new Cropper(cropperImg.current!, {
+ viewMode: 2,
+ zoomable: false,
+ minCropBoxWidth: 100,
+ minCropBoxHeight: 100,
+ ready() {
+ cropper.current!.setCropBoxData({
+ left: 0,
+ top: 0,
+ width: cropperImg.current!.naturalWidth,
+ height: cropperImg.current!.naturalHeight,
+ });
+ },
+ });
+ };
+
+ return (
+ <>
+ <div
+ className={styles.videoCoverSeting}
+ onClick={() => {
+ if (!videoFile) return message.warning("您必须上传一个视频!");
+ setVideoCoverSetingModal(true);
+ }}
+ >
+ <div className="videoCoverSeting-img">
+ {value && (
+ <div className="videoCoverSeting-choosed">
+ <img src={value?.imgUrl} />
+ {onClose && (
+ <CloseCircleOutlined
+ onClick={(e) => {
+ e.stopPropagation();
+ onClose();
+ }}
+ />
+ )}
+ </div>
+ )}
+ </div>
+ <div className="videoCoverSeting-text">上传图片</div>
+ </div>
+
+ <Modal
+ width={600}
+ title="设置封面"
+ maskClosable={false}
+ open={videoCoverSetingModal}
+ onCancel={close}
+ onOk={async () => {
+ const canvas = cropper.current!.getCroppedCanvas();
+ canvas.toBlob(async function (blob) {
+ const imgPath = await saveCropperImage(
+ `${operateId}_${saveImgId}.${imgFile?.file.type.split("/")[1]}`,
+ blob!,
+ );
+ const cover = await formatImg({
+ blob: blob!,
+ path: imgPath,
+ });
+ onChoosed(cover);
+ close();
+ }, "image/png");
+ }}
+ >
+ <Spin spinning={videoCoverLoading}>
+ <div className={styles.videoCoverSetingModal}>
+ <div className="videoCoverSetingModal-top">
+ <Alert
+ message="支持常用图片格式上传,暂不支持 GIF,上传后图片将按平台要求自动裁剪"
+ type="info"
+ showIcon
+ />
+ <ImgChoose
+ onChoose={(imgFile) => {
+ if (!imgFile) return;
+ setImgFile(imgFile);
+ }}
+ >
+ <Button>本地上传</Button>
+ </ImgChoose>
+ </div>
+
+ <div className="videoCoverSetingModal-cropper">
+ <img
+ style={{ opacity: imgFile?.imgUrl ? "1" : "0" }}
+ ref={cropperImg}
+ src={imgFile?.imgUrl || "/"}
+ />
+ </div>
+
+ <Slider
+ value={sliderVal}
+ style={{ margin: "50px 0" }}
+ step={1}
+ min={0}
+ max={videoFile?.duration}
+ onChange={setSliderVal}
+ onChangeComplete={getVideoCover}
+ />
+ </div>
+ </Spin>
+ </Modal>
+ </>
+ );
+ },
+ ),
+);
+VideoCoverSeting.displayName = "VideoCoverSeting";
+
+export default VideoCoverSeting;
diff --git a/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
new file mode 100644
index 00000000..042bfa89
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
@@ -0,0 +1,451 @@
+import React, {
+ ForwardedRef,
+ forwardRef,
+ memo,
+ useEffect,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
+import { Alert, Avatar, message, Modal, Switch, Tabs, Tooltip } from "antd";
+import { useVideoPageStore } from "@/app/[lng]/publish/videoPage/useVideoPageStore";
+import { useShallow } from "zustand/react/shallow";
+import styles from "./videoPubSetModal.module.scss";
+import { useBellMessageStroe } from "@/store/bellMessageStroe";
+import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";
+import VideoCoverSeting from "@/app/[lng]/publish/videoPage/components/VideoCoverSeting";
+import PubAccountDetModule, {
+ IPubAccountDetModuleRef,
+} from "@/app/[lng]/publish/components/PubAccountDetModule/PubAccountDetModule";
+import VideoPubSetModal_KWAI from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI";
+import VideoPubSetModal_DouYin from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin";
+import VideoPubSetModal_XSH from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH";
+import VideoPubSetModal_WxSph from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph";
+import PubProgressModule from "@/app/[lng]/publish/components/PubProgressModule/PubProgressModule";
+import VideoPubSetModalVideo, {
+ IVideoPubSetModalVideoRef,
+} from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/VideoPubSetModalVideo";
+import usePubParamsVerify, {
+ PubParamsErrStatusEnum,
+ PubParamsVerifyInfo,
+} from "@/app/[lng]/publish/hooks/usePubParamsVerify";
+import { IVideoFile } from "@/app/[lng]/publish/components/Choose/VideoChoose";
+import { useRouter } from "next/navigation";
+import { useSystemStore } from "@/store/system";
+
+export interface IVideoPubSetModalRef {}
+
+export interface IVideoPubSetModalProps {
+ onClose: (open: boolean) => void;
+}
+
+const PubSetModalChild = ({}: {}) => {
+ const { currChooseAccount } = useVideoPageStore(
+ useShallow((state) => ({
+ currChooseAccount: state.currChooseAccount,
+ })),
+ );
+
+ const renderedComponent = useMemo(() => {
+ switch (currChooseAccount?.account?.type) {
+ case PlatType.KWAI:
+ return <VideoPubSetModal_KWAI />;
+ case PlatType.Douyin:
+ return <VideoPubSetModal_DouYin />;
+ case PlatType.Xhs:
+ return <VideoPubSetModal_XSH />;
+ case PlatType.WxSph:
+ return <VideoPubSetModal_WxSph />;
+ }
+ return <></>;
+ }, [currChooseAccount?.account?.type]);
+
+ return renderedComponent || <></>;
+};
+
+// 设置发布参数弹框
+const VideoPubSetModal = memo(
+ forwardRef(
+ (
+ { onClose }: IVideoPubSetModalProps,
+ ref: ForwardedRef<IVideoPubSetModalRef>,
+ ) => {
+ const router = useRouter();
+ const { addNotice, noticeMap } = useBellMessageStroe(
+ useShallow((state) => ({
+ noticeMap: state.noticeMap,
+ addNotice: state.addNotice,
+ })),
+ );
+ const {
+ videoListChoose,
+ setOnePubParams,
+ currChooseAccountId,
+ setCurrChooseAccountId,
+ videoPubSetModalOpen,
+ setVideoPubSetModalOpen,
+ updateAccounts,
+ accountRestart,
+ commonPubParams,
+ clear,
+ setCurrChooseAccount,
+ } = useVideoPageStore(
+ useShallow((state) => ({
+ videoListChoose: state.videoListChoose,
+ setOnePubParams: state.setOnePubParams,
+ setCurrChooseAccountId: state.setCurrChooseAccountId,
+ currChooseAccountId: state.currChooseAccountId,
+ videoPubSetModalOpen: state.videoPubSetModalOpen,
+ setVideoPubSetModalOpen: state.setVideoPubSetModalOpen,
+ updateAccounts: state.updateAccounts,
+ accountRestart: state.accountRestart,
+ clear: state.clear,
+ commonPubParams: state.commonPubParams,
+ setCurrChooseAccount: state.setCurrChooseAccount,
+ })),
+ );
+ const [loading, setLoading] = useState(false);
+ const pubAccountDetModuleRef = useRef<IPubAccountDetModuleRef>(null);
+ const [pubProgressModuleOpen, setPubProgressModuleOpen] = useState(false);
+ const videoPubSetModalVideoRef = useRef<IVideoPubSetModalVideoRef>(null);
+ const { moreParamsOpen, setMoreParamsOpen } = useSystemStore(
+ useShallow((state) => ({
+ moreParamsOpen: state.moreParamsOpen,
+ setMoreParamsOpen: state.setMoreParamsOpen,
+ })),
+ );
+ const { errParamsMap, warnParamsMap } = usePubParamsVerify<IVideoFile>(
+ videoListChoose.map((v) => {
+ return {
+ id: v.id,
+ account: v.account,
+ pubParams: v.pubParams,
+ other: v.video!,
+ };
+ }),
+ {
+ moreErrorVerifyCallback(item, errParamsMapTemp) {
+ if (
+ item?.account?.type === PlatType.Douyin &&
+ item.other?.duration > 3600
+ ) {
+ errParamsMapTemp.set(item.id, {
+ message: "视频错误",
+ errType: PubParamsErrStatusEnum.PARAMS,
+ parErrMsg: `抖音平台规定视频时长最多不能超过60分钟!`,
+ });
+ }
+ },
+ },
+ );
+ const recordId = useRef(-1);
+
+ useEffect(() => {
+ if (!currChooseAccountId)
+ setCurrChooseAccountId(videoListChoose[0]?.id);
+ }, [videoListChoose]);
+
+ // 发布进度获取
+ const pubProgressData = useMemo(() => {
+ // TODO 发布进度处理
+ // return (
+ // (noticeMap.get(NoticeType.PubNotice) || []).find(
+ // (v) => v.id === recordId.current,
+ // )?.pub?.progressList || []
+ // );
+ return [];
+ }, [noticeMap]);
+
+ // 当前选择的账户数据
+ const currChooseAccount = useMemo(() => {
+ if (!currChooseAccountId) return videoListChoose[0];
+ return videoListChoose.find((v) => v.id === currChooseAccountId);
+ }, [currChooseAccountId, videoListChoose]);
+
+ useEffect(() => {
+ if (currChooseAccount) setCurrChooseAccount({ ...currChooseAccount });
+ }, [currChooseAccount, videoListChoose]);
+
+ const pubCore = async () => {
+ // TODO 发布
+ // setLoading(false);
+ //
+ // await signInApi.createSignInRecord();
+ // const err = () => {
+ // setLoading(false);
+ // message.error("网络繁忙,请稍后重试!");
+ // };
+ // // 创建一级记录
+ // const recordRes = await icpCreatePubRecord({
+ // title: commonPubParams.title,
+ // desc: commonPubParams.describe,
+ // type: PubType.VIDEO,
+ // timingTime: commonPubParams.timingTime,
+ // videoPath: videoListChoose[0].video?.videoPath,
+ // coverPath: videoListChoose[0].pubParams.cover?.imgPath,
+ // commonCoverPath: commonPubParams.cover?.imgPath,
+ // });
+ // recordId.current = recordRes.id;
+ // if (!recordRes) return err();
+ //
+ // setPubProgressModuleOpen(true);
+ // setLoading(true);
+ //
+ // // 发布记录通知消息初始化
+ // const initialNotice: NoticeItem = {
+ // title:
+ // [
+ // ...new Set(
+ // videoListChoose.map(
+ // (v) => AccountPlatInfoMap.get(v.account!.type)!.name,
+ // ),
+ // ),
+ // ].join("、") + "发布任务",
+ // time: recordRes.createTime!,
+ // id: recordRes.id,
+ // pub: {
+ // status: PubStatus.UNPUBLISH,
+ // progressList: [],
+ // },
+ // };
+ //
+ // for (const vData of videoListChoose) {
+ // const account = vData.account!;
+ // const video = vData.video!;
+ // // 创建二级记录
+ // await icpCreateVideoPubRecord({
+ // ...vData.pubParams,
+ // type: account.type,
+ // accountId: account.id,
+ // pubRecordId: recordRes.id,
+ // publishTime: new Date(),
+ // desc: vData.pubParams.describe,
+ // videoPath: video.videoPath,
+ // coverPath: vData.pubParams.cover?.imgPath,
+ // });
+ //
+ // initialNotice.pub!.progressList.push({
+ // account: vData.account!,
+ // progress: 0,
+ // msg: "加载中...",
+ // id: vData.account!.id!,
+ // });
+ // }
+ // const noticeList = noticeMap.get(NoticeType.PubNotice) || [];
+ // noticeList.unshift(initialNotice);
+ // addNotice(NoticeType.PubNotice, noticeList);
+ //
+ // // 发布
+ // const okRes = await icpPubVideo(recordRes.id);
+ // setLoading(false);
+ // close();
+ // setPubProgressModuleOpen(false);
+ //
+ // // 成功数据
+ // const successList = okRes.filter((v) => v.code === 1);
+ //
+ // initialNotice.pub!.status =
+ // successList.length === okRes.length
+ // ? PubStatus.RELEASED
+ // : PubStatus.PartSuccess;
+ // addNotice(NoticeType.PubNotice, noticeList);
+ //
+ // setTimeout(() => {
+ // useCommontStore.getState().notification!.open({
+ // message: "发布结果",
+ // description: (
+ // <>
+ // 一共发布 {okRes.length} 条数据,成功 {successList.length}{" "}
+ // 条,失败 {okRes.length - successList.length} 条
+ // </>
+ // ),
+ // showProgress: true,
+ // btn: (
+ // <Space>
+ // <Button
+ // type="primary"
+ // size="small"
+ // onClick={() => {
+ // router.push("/publish/pubRecord");
+ // }}
+ // >
+ // 查看发布记录
+ // </Button>
+ // </Space>
+ // ),
+ // key: Date.now(),
+ // });
+ // }, 10);
+ };
+
+ const handleOk = async () => {
+ // 数据校验
+ for (const [key, errVideoItem] of errParamsMap) {
+ if (errVideoItem) {
+ setCurrChooseAccountId(`${key}`);
+ message.warning(errVideoItem.parErrMsg);
+ setMoreParamsOpen(true);
+ return;
+ }
+ }
+ setLoading(true);
+ pubAccountDetModuleRef.current!.startDet();
+ };
+
+ const close = () => {
+ setVideoPubSetModalOpen(false);
+ videoPubSetModalVideoRef.current?.pause();
+ };
+
+ return (
+ <>
+ <PubProgressModule
+ pubProgressData={pubProgressData}
+ open={pubProgressModuleOpen}
+ onClose={() => {
+ setPubProgressModuleOpen(false);
+ if (loading) {
+ close();
+ }
+ }}
+ />
+ <PubAccountDetModule
+ ref={pubAccountDetModuleRef}
+ isCheckProxy={true}
+ accounts={videoListChoose
+ .map((v) => v.account)
+ .filter((v) => v !== undefined)}
+ onClose={() => {
+ setLoading(false);
+ }}
+ onPubClick={() => {
+ pubCore();
+ }}
+ onRestartLoginFinish={(account) => {
+ updateAccounts({
+ accounts: [account],
+ });
+ }}
+ onDetFinish={(accounts) => {
+ updateAccounts({
+ accounts,
+ });
+ }}
+ />
+ <Modal
+ width={moreParamsOpen ? 900 : 500}
+ maskClosable={false}
+ title={
+ <div className={styles.videoPubSetModal_titleWrap}>
+ <div className="videoPubSetModal-title">预览及发布</div>
+ <div className="videoPubSetModal-more">
+ <div className="videoPubSetModal-more-core">
+ <label>填写更多参数</label>
+ <Switch
+ size="small"
+ value={moreParamsOpen}
+ onClick={(e) => setMoreParamsOpen(e)}
+ />
+ </div>
+ <div className="videoPubSetModal-more-tips">
+ 开启后,将显示更多发布参数供您填写
+ </div>
+ </div>
+ </div>
+ }
+ open={videoPubSetModalOpen}
+ onOk={handleOk}
+ onCancel={close}
+ confirmLoading={loading}
+ okText="发布检测"
+ >
+ <div className={styles.videoPubSetModal}>
+ <Tabs
+ activeKey={currChooseAccountId}
+ onChange={setCurrChooseAccountId}
+ items={videoListChoose
+ .map((v) => {
+ const account = v.account!;
+ const errItem = errParamsMap.get(v.id);
+ if (!account || !v.video) return undefined;
+
+ return {
+ key: v.id,
+ label: (
+ <div className="videoPubSetModal-tabLabel">
+ {errItem && (
+ <Tooltip title={errItem.parErrMsg}>
+ <Alert
+ message={errItem.message}
+ type="error"
+ showIcon
+ />
+ </Tooltip>
+ )}
+ <Tooltip title={account.nickname}>
+ <Avatar src={account?.avatar} size="small" />
+ <span className="videoPubSetModal-tabLabel-name">
+ {account?.nickname}
+ </span>
+ <img
+ src={AccountPlatInfoMap.get(account?.type)?.icon}
+ />
+ </Tooltip>
+ </div>
+ ),
+ };
+ })
+ .filter((v) => v !== undefined)}
+ />
+
+ <div
+ className={[
+ "videoPubSetModal_con",
+ !moreParamsOpen && "videoPubSetModal_con--noMore",
+ ].join(" ")}
+ >
+ <div className="videoPubSetModal_con-left">
+ <PubParamsVerifyInfo
+ style={{ marginBottom: "5px" }}
+ id={currChooseAccount?.id}
+ warnParamsMap={warnParamsMap}
+ errParamsMap={errParamsMap}
+ onAccountRestart={() => {
+ accountRestart(currChooseAccount!.account!.type);
+ }}
+ />
+ <div className="videoPubSetModal_con-tips">
+ <span>*下方参数只应用于当前账号</span>
+ </div>
+ <h1>
+ <span className="videoPubSetModal_con-red">*</span>封面
+ </h1>
+ <VideoCoverSeting
+ saveImgId={currChooseAccount?.id || ""}
+ videoFile={currChooseAccount?.video}
+ value={currChooseAccount?.pubParams.cover}
+ onChoosed={(imgFile) => {
+ setOnePubParams({
+ cover: imgFile,
+ });
+ }}
+ />
+
+ {currChooseAccount && <PubSetModalChild />}
+ </div>
+ <div className="videoPubSetModal_con-right">
+ {currChooseAccount && (
+ <VideoPubSetModalVideo ref={videoPubSetModalVideoRef} />
+ )}
+ </div>
+ </div>
+ </div>
+ </Modal>
+ </>
+ );
+ },
+ ),
+);
+VideoPubSetModal.displayName = "VideoPubSetModal";
+
+export default VideoPubSetModal;
diff --git a/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx
new file mode 100644
index 00000000..ea39b74c
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx
@@ -0,0 +1,171 @@
+import React, { ForwardedRef, forwardRef, memo } from "react";
+import { Select } from "antd";
+import { useVideoPageStore } from "@/app/[lng]/publish/videoPage/useVideoPageStore";
+import { useShallow } from "zustand/react/shallow";
+import {
+ DescTextArea,
+ ScheduledTimeSelect,
+ TitleInput,
+ VideoPubMixSelect,
+ VideoPubPermission,
+ VideoPubRestartLogin,
+} from "../components/VideoPubSetModalCommon";
+import UserSelect from "../components/UserSelect";
+import useVideoPubSetModal from "./hooks/useVideoPubSetModal";
+import { PlatType } from "@/app/config/platConfig";
+import {
+ IVideoPubSetModalChildProps,
+ IVideoPubSetModalChildRef,
+} from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/videoPubSetModal.type";
+import TopicSelect from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/TopicSelect";
+import LocationSelect from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/LocationSelect";
+import {
+ CommonActivitySelect,
+ CommonHotspotSelect,
+} from "@/app/[lng]/publish/components/CommonComponents/DouyinCommonComponents";
+import {
+ DeclarationDouyin,
+ ILableValue,
+} from "@/app/[lng]/publish/videoPage/videoPage";
+
+const HotspotSelect = ({}: IVideoPubSetModalChildProps) => {
+ const { setOnePubParams, currChooseAccount } = useVideoPageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ currChooseAccount: state.currChooseAccount!,
+ })),
+ );
+
+ return (
+ <CommonHotspotSelect
+ account={currChooseAccount.account}
+ value={
+ currChooseAccount.pubParams!.diffParams![PlatType.Douyin]!.hotPoint
+ }
+ onChange={(newValue) => {
+ const newDiffParams = currChooseAccount.pubParams.diffParams!;
+ newDiffParams[PlatType.Douyin]!.hotPoint = newValue as ILableValue;
+ setOnePubParams({
+ diffParams: newDiffParams,
+ });
+ }}
+ />
+ );
+};
+
+const ActivitySelect = ({}: IVideoPubSetModalChildProps) => {
+ const { setOnePubParams, platInfo, currChooseAccount } =
+ useVideoPubSetModal();
+ const { topicMax } = platInfo.commonPubParamsConfig;
+
+ return (
+ <CommonActivitySelect
+ account={currChooseAccount.account}
+ maxCount={topicMax - currChooseAccount.pubParams!.topics!.length}
+ value={
+ currChooseAccount.pubParams!.diffParams![PlatType.Douyin]!.activitys
+ }
+ onChange={(newValue) => {
+ const newDiffParams = currChooseAccount.pubParams.diffParams!;
+ newDiffParams[PlatType.Douyin]!.activitys = newValue as ILableValue[];
+ setOnePubParams({
+ diffParams: newDiffParams,
+ });
+ }}
+ >
+ <VideoPubRestartLogin />
+ </CommonActivitySelect>
+ );
+};
+
+const VideoPubSetModal_DouYin = memo(
+ forwardRef(
+ (
+ props: IVideoPubSetModalChildProps,
+ ref: ForwardedRef<IVideoPubSetModalChildRef>,
+ ) => {
+ const { setOnePubParams, platInfo, currChooseAccount } =
+ useVideoPubSetModal();
+ const { topicMax } = platInfo.commonPubParamsConfig;
+
+ return (
+ <>
+ <TitleInput placeholder="好的标题可以获得更多浏览" />
+
+ <DescTextArea placeholder="添加作品简介" maxLength={1000} />
+
+ <TopicSelect
+ maxCount={
+ topicMax -
+ currChooseAccount.pubParams!.diffParams![PlatType.Douyin]!
+ .activitys!.length
+ }
+ tips={`最多可添加${topicMax}个话题(包含活动奖励)`}
+ />
+ <ActivitySelect />
+
+ <UserSelect maxCount={100} tips="您可以添加100个好友" title="@好友" />
+
+ <HotspotSelect {...props} />
+
+ <LocationSelect />
+
+ <ScheduledTimeSelect />
+
+ <VideoPubMixSelect />
+
+ <h1>自主声明</h1>
+ <Select
+ allowClear
+ value={
+ currChooseAccount?.pubParams.diffParams![PlatType.Douyin]!
+ .selfDeclare
+ }
+ style={{ width: "100%" }}
+ placeholder="选择声明"
+ labelInValue
+ filterOption={false}
+ options={[
+ {
+ label: "内容自行拍摄",
+ value: DeclarationDouyin.SelfShoot,
+ },
+ {
+ label: "内容取材网络",
+ value: DeclarationDouyin.FromNetV3,
+ },
+ {
+ label: "内容由AI生成",
+ value: DeclarationDouyin.AIGC,
+ },
+ {
+ label: "可能引人不适",
+ value: DeclarationDouyin.MaybeUnsuitable,
+ },
+ {
+ label: "虚构演绎,仅供娱乐",
+ value: DeclarationDouyin.OnlyFunNew,
+ },
+ {
+ label: "危险行为,请勿模仿",
+ value: DeclarationDouyin.DangerousBehavior,
+ },
+ ]}
+ onChange={(newValue: any) => {
+ const newDiffParams = currChooseAccount.pubParams.diffParams!;
+ newDiffParams[PlatType.Douyin]!.selfDeclare = newValue?.value;
+ setOnePubParams({
+ diffParams: newDiffParams,
+ });
+ }}
+ />
+
+ <VideoPubPermission title="谁可以看" />
+ </>
+ );
+ },
+ ),
+);
+VideoPubSetModal_DouYin.displayName = "VideoPubSetModal_DouYin";
+
+export default VideoPubSetModal_DouYin;
diff --git a/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx
new file mode 100644
index 00000000..0755acd1
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_KWAI.tsx
@@ -0,0 +1,49 @@
+import React, { ForwardedRef, forwardRef, memo } from "react";
+import LocationSelect from "../components/LocationSelect";
+import UserSelect from "../components/UserSelect";
+import {
+ DescTextArea,
+ ScheduledTimeSelect,
+ VideoPubPermission,
+} from "../components/VideoPubSetModalCommon";
+import TopicSelect from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/TopicSelect";
+import {
+ IVideoPubSetModalChildProps,
+ IVideoPubSetModalChildRef,
+} from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/videoPubSetModal.type";
+
+const VideoPubSetModal_KWAI = memo(
+ forwardRef(
+ (
+ {}: IVideoPubSetModalChildProps,
+ ref: ForwardedRef<IVideoPubSetModalChildRef>,
+ ) => {
+ return (
+ <>
+ <DescTextArea
+ placeholder="填写合适的话题和描述,作品能获得更多推荐~"
+ maxLength={500}
+ />
+
+ <TopicSelect />
+
+ <UserSelect
+ maxCount={3}
+ title="@好友"
+ tips="您可以添加3个好友"
+ showSearch={false}
+ />
+
+ <LocationSelect />
+
+ <VideoPubPermission />
+
+ <ScheduledTimeSelect />
+ </>
+ );
+ },
+ ),
+);
+VideoPubSetModal_KWAI.displayName = "VideoPubSetModal_KWAI";
+
+export default VideoPubSetModal_KWAI;
diff --git a/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx
new file mode 100644
index 00000000..d7dd7743
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_WxSph.tsx
@@ -0,0 +1,192 @@
+import React, { ForwardedRef, forwardRef, memo, useState } from "react";
+import { Checkbox, Input, Select, Spin } from "antd";
+import { useVideoPageStore } from "@/app/[lng]/publish/videoPage/useVideoPageStore";
+import { useShallow } from "zustand/react/shallow";
+import {
+ DescTextArea,
+ ScheduledTimeSelect,
+ TitleInput,
+ VideoPubMixSelect,
+ VideoPubRestartLogin,
+} from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon";
+import UserSelect from "../components/UserSelect";
+import useVideoPubSetModal from "./hooks/useVideoPubSetModal";
+import {
+ IVideoPubSetModalChildProps,
+ IVideoPubSetModalChildRef,
+} from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/videoPubSetModal.type";
+import LocationSelect from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/LocationSelect";
+import { PlatType } from "@/app/config/platConfig";
+import useDebounceFetcher from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/useDebounceFetcher";
+import { WxSphEventList } from "@/app/plat/platChildren/wxSph/wxShp.type";
+
+const WXSphActivity = ({}: IVideoPubSetModalChildProps) => {
+ const { setOnePubParams, updateAccounts, currChooseAccount } =
+ useVideoPageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ updateAccounts: state.updateAccounts,
+ currChooseAccount: state.currChooseAccount!,
+ })),
+ );
+
+ const { fetching, options, debounceFetcher } =
+ useDebounceFetcher<WxSphEventList>(async (keywords) => {
+ // TODO 微信活动
+ // const res = await getSphActivity(currChooseAccount.account!, keywords);
+ // if (res.data.errCode === 300334 || res.data.errCode === 300333) {
+ // currChooseAccount.account!.status = AccountStatus.DISABLE;
+ // updateAccounts({ accounts: [currChooseAccount.account!] });
+ // await ipcUpdateAccountStatus(
+ // currChooseAccount.account!.id,
+ // AccountStatus.DISABLE,
+ // );
+ // return [];
+ // }
+ // return res?.data?.data?.eventList || [];
+ return [];
+ });
+
+ return (
+ <>
+ <h1>参与活动</h1>
+ <Select
+ showSearch
+ allowClear
+ style={{ width: "100%" }}
+ placeholder="输入关键词搜索活动"
+ labelInValue
+ filterOption={false}
+ onSearch={debounceFetcher}
+ notFoundContent={fetching ? <Spin size="small" /> : null}
+ options={options?.map((v) => {
+ return {
+ ...v,
+ label: v.eventName,
+ value: v.eventTopicId,
+ };
+ })}
+ value={
+ currChooseAccount.pubParams!.diffParams![PlatType.WxSph]!.activity
+ }
+ onChange={(_, value) => {
+ const newDiffParams = currChooseAccount.pubParams.diffParams!;
+ newDiffParams[PlatType.WxSph]!.activity = value as WxSphEventList;
+ setOnePubParams({
+ diffParams: newDiffParams,
+ });
+ }}
+ />
+ <VideoPubRestartLogin />
+ </>
+ );
+};
+
+const VideoPubSetModal_WxSph = memo(
+ forwardRef(
+ (
+ {}: IVideoPubSetModalChildProps,
+ ref: ForwardedRef<IVideoPubSetModalChildRef>,
+ ) => {
+ const { setOnePubParams, platInfo, currChooseAccount } =
+ useVideoPubSetModal();
+ const { topicMax } = platInfo.commonPubParamsConfig;
+ const [topicSearch, setTopicSearch] = useState("");
+
+ return (
+ <>
+ <TitleInput
+ title="短标题"
+ tips="短标题会出现在搜索、话题、活动、地点、订阅号消息、发现页红点等场景"
+ placeholder="概况视频的主要内容。字数建议6-16个字符"
+ />
+
+ <DescTextArea
+ placeholder="填写更全面的描述信息,让更多人看到你吧!"
+ maxLength={1000}
+ />
+
+ <h1>话题</h1>
+ <Select
+ allowClear
+ mode="multiple"
+ style={{ width: "100%" }}
+ maxCount={topicMax}
+ placeholder="请输入并选择话题"
+ labelInValue
+ onSearch={setTopicSearch}
+ filterOption={false}
+ options={
+ topicSearch
+ ? [
+ {
+ label: topicSearch,
+ value: topicSearch,
+ },
+ ]
+ : []
+ }
+ value={currChooseAccount.pubParams!.topics}
+ onChange={(newValue) => {
+ setOnePubParams({
+ topics: newValue,
+ });
+ }}
+ />
+ <p className="videoPubSetModal_con-tips">
+ 您可添加{topicMax}个标签,按回车键确认
+ </p>
+
+ <UserSelect
+ maxCount={10}
+ tips="您可以添加10个视频号"
+ title="@视频号"
+ />
+
+ <LocationSelect />
+
+ <WXSphActivity />
+
+ <VideoPubMixSelect />
+
+ <h1>扩展链接</h1>
+ <Input
+ placeholder="粘贴链接"
+ value={
+ currChooseAccount?.pubParams.diffParams![PlatType.WxSph]!.extLink
+ }
+ onChange={(e) => {
+ const newDiffParams = currChooseAccount.pubParams.diffParams!;
+ newDiffParams[PlatType.WxSph]!.extLink = e.target.value;
+ setOnePubParams({
+ diffParams: newDiffParams,
+ });
+ }}
+ />
+
+ <h1>声明原创</h1>
+ <Checkbox
+ checked={
+ currChooseAccount?.pubParams.diffParams![PlatType.WxSph]!
+ .isOriginal
+ }
+ onChange={(e) => {
+ const newDiffParams = currChooseAccount.pubParams.diffParams!;
+ newDiffParams[PlatType.WxSph]!.isOriginal = e.target.checked;
+ setOnePubParams({
+ diffParams: newDiffParams,
+ });
+ }}
+ >
+ 声明后,作品将展示原创标记,有机会获得广告收入
+ </Checkbox>
+
+ <ScheduledTimeSelect />
+ </>
+ );
+ },
+ ),
+);
+VideoPubSetModal_WxSph.displayName = "VideoPubSetModal_WxSph";
+
+export default VideoPubSetModal_WxSph;
diff --git a/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx
new file mode 100644
index 00000000..5d00dcea
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_XSH.tsx
@@ -0,0 +1,47 @@
+import React, { ForwardedRef, forwardRef, memo } from "react";
+import UserSelect from "../components/UserSelect";
+import {
+ IVideoPubSetModalChildProps,
+ IVideoPubSetModalChildRef,
+} from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/videoPubSetModal.type";
+import {
+ DescTextArea,
+ ScheduledTimeSelect,
+ TitleInput,
+ VideoPubPermission,
+} from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon";
+import LocationSelect from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/LocationSelect";
+import TopicSelect from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/TopicSelect";
+
+const VideoPubSetModal_XSH = memo(
+ forwardRef(
+ (
+ {}: IVideoPubSetModalChildProps,
+ ref: ForwardedRef<IVideoPubSetModalChildRef>,
+ ) => {
+ return (
+ <>
+ <TitleInput title="标题" placeholder="填写标题,可能会有更多赞哦" />
+
+ <DescTextArea
+ placeholder="填写更全面的描述信息,让更多人看到你吧!"
+ maxLength={1000}
+ />
+
+ <TopicSelect />
+
+ <UserSelect title="@用户" />
+
+ <LocationSelect />
+
+ <VideoPubPermission title="谁可以看" />
+
+ <ScheduledTimeSelect />
+ </>
+ );
+ },
+ ),
+);
+VideoPubSetModal_XSH.displayName = "VideoPubSetModal_XSH";
+
+export default VideoPubSetModal_XSH;
diff --git a/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/hooks/useVideoPubSetModal.tsx b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/hooks/useVideoPubSetModal.tsx
new file mode 100644
index 00000000..6ea1ef0e
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/children/hooks/useVideoPubSetModal.tsx
@@ -0,0 +1,20 @@
+import { useVideoPageStore } from "../../../../useVideoPageStore";
+import { useShallow } from "zustand/react/shallow";
+import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";
+
+export default function useVideoPubSetModal() {
+ const { setOnePubParams, currChooseAccount } = useVideoPageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ currChooseAccount: state.currChooseAccount,
+ })),
+ );
+
+ return {
+ setOnePubParams,
+ platInfo: currChooseAccount?.account
+ ? AccountPlatInfoMap.get(currChooseAccount!.account!.type)!
+ : AccountPlatInfoMap.get(PlatType.Douyin)!,
+ currChooseAccount: currChooseAccount!,
+ };
+}
diff --git a/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx
new file mode 100644
index 00000000..4a9ea78f
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/LocationSelect.tsx
@@ -0,0 +1,42 @@
+import React from "react";
+import { SelectProps } from "antd";
+import { useVideoPageStore } from "../../../useVideoPageStore";
+import { useShallow } from "zustand/react/shallow";
+import { VideoPubRestartLogin } from "./VideoPubSetModalCommon";
+import useVideoPubSetModal from "../children/hooks/useVideoPubSetModal";
+import { ILocationDataItem } from "@/app/[lng]/publish/videoPage/videoPage";
+import CommonLocationSelect from "@/app/[lng]/publish/components/CommonComponents/CommonLocationSelect";
+
+interface DebounceSelectProps<ValueType = any>
+ extends Omit<SelectProps<ValueType | ValueType[]>, "options" | "children"> {}
+
+// 位置选择器
+export default function LocationSelect({
+ ...props
+}: DebounceSelectProps<ILocationDataItem>) {
+ const { setOnePubParams, updateAccounts } = useVideoPageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ updateAccounts: state.updateAccounts,
+ })),
+ );
+ const { currChooseAccount } = useVideoPubSetModal();
+
+ return (
+ <CommonLocationSelect
+ {...props}
+ account={currChooseAccount.account}
+ value={currChooseAccount.pubParams!.location}
+ onAccountChange={(account) => {
+ updateAccounts({ accounts: [account] });
+ }}
+ onChange={(_, value) => {
+ setOnePubParams({
+ location: value as ILocationDataItem,
+ });
+ }}
+ >
+ <VideoPubRestartLogin />
+ </CommonLocationSelect>
+ );
+}
diff --git a/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/TopicSelect.tsx b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/TopicSelect.tsx
new file mode 100644
index 00000000..aa7b4217
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/TopicSelect.tsx
@@ -0,0 +1,54 @@
+import React from "react";
+import { useVideoPageStore } from "../../../useVideoPageStore";
+import { useShallow } from "zustand/react/shallow";
+import { VideoPubRestartLogin } from "./VideoPubSetModalCommon";
+import useVideoPubSetModal from "../children/hooks/useVideoPubSetModal";
+import CommonTopicSelect, {
+ CommonTopicSelectProps,
+ CommonTopicSelectValueType,
+} from "@/app/[lng]/publish/components/CommonComponents/CommonTopicSelect";
+
+interface DebounceSelectProps
+ extends CommonTopicSelectProps<CommonTopicSelectValueType> {}
+
+// 话题选择器
+export default function TopicSelect({ ...props }: DebounceSelectProps) {
+ const { updateAccounts } = useVideoPageStore(
+ useShallow((state) => ({
+ updateAccounts: state.updateAccounts,
+ })),
+ );
+ const { setOnePubParams, platInfo, currChooseAccount } =
+ useVideoPubSetModal();
+ const { topicMax } = platInfo.commonPubParamsConfig;
+ props.maxCount = props.maxCount || topicMax;
+ props.tips = props.tips || `您可以添加${topicMax}个话题`;
+
+ return (
+ <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,
+ },
+ });
+ }}
+ >
+ <VideoPubRestartLogin />
+ </CommonTopicSelect>
+ );
+}
diff --git a/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/UserSelect.tsx b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/UserSelect.tsx
new file mode 100644
index 00000000..179175aa
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/UserSelect.tsx
@@ -0,0 +1,56 @@
+import { useVideoPageStore } from "../../../useVideoPageStore";
+import { useShallow } from "zustand/react/shallow";
+import { VideoPubRestartLogin } from "./VideoPubSetModalCommon";
+import React from "react";
+import useVideoPubSetModal from "../children/hooks/useVideoPubSetModal";
+import { IUsersItem } from "@/app/plat/plat.type";
+import CommonUserSelect, {
+ CommonUserSelectProps,
+} from "@/app/[lng]/publish/components/CommonComponents/CommonUserSelect";
+
+interface DebounceSelectProps extends CommonUserSelectProps<IUsersItem> {}
+
+// 视频发布用户选择器
+export default function UserSelect({ ...props }: DebounceSelectProps) {
+ const { updateAccounts } = useVideoPageStore(
+ useShallow((state) => ({
+ updateAccounts: state.updateAccounts,
+ })),
+ );
+ const { setOnePubParams, currChooseAccount } = useVideoPubSetModal();
+
+ return (
+ <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,
+ });
+ }}
+ >
+ <VideoPubRestartLogin />
+ </CommonUserSelect>
+ );
+}
diff --git a/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx
new file mode 100644
index 00000000..689736a3
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/VideoPubSetModalCommon.tsx
@@ -0,0 +1,263 @@
+import { Input, Tooltip } from "antd";
+import React, { useEffect, useMemo, useState } from "react";
+import { useVideoPageStore } from "@/app/[lng]/publish/videoPage/useVideoPageStore";
+import { useShallow } from "zustand/react/shallow";
+import dayjs from "dayjs";
+import { QuestionCircleOutlined } from "@ant-design/icons";
+import { AiCreateType } from "@/api/types/tools";
+import useVideoPubSetModal from "../children/hooks/useVideoPubSetModal";
+import { AccountPlatInfoMap } from "@/app/config/platConfig";
+import AICreateTitle from "@/app/[lng]/publish/components/AICreateTitle/AICreateTitle";
+import CommonScheduledTimeSelect, {
+ ICommonScheduledTimeSelectProps,
+} from "@/app/[lng]/publish/components/CommonComponents/CommonScheduledTimeSelect";
+import {
+ AccountRestartLogin,
+ CommonMixSelect,
+ PubPermission,
+ PubPermissionProps,
+} from "@/app/[lng]/publish/components/CommonComponents/CommonComponents";
+import { IMixItem } from "@/app/plat/plat.type";
+
+const { TextArea } = Input;
+
+export const VideoPubRestartLogin = () => {
+ const { accountRestart, currChooseAccount } = useVideoPageStore(
+ useShallow((state) => ({
+ accountRestart: state.accountRestart,
+ currChooseAccount: state.currChooseAccount!,
+ })),
+ );
+
+ return (
+ currChooseAccount && (
+ <AccountRestartLogin
+ account={currChooseAccount.account}
+ onAccountRestart={() => {
+ accountRestart(currChooseAccount.account!.type);
+ }}
+ />
+ )
+ );
+};
+
+// 定时发布
+export const ScheduledTimeSelect = ({
+ ...props
+}: ICommonScheduledTimeSelectProps) => {
+ const { value, onChange } = props;
+ const { setOnePubParams, currChooseAccount } = useVideoPageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ currChooseAccount: state.currChooseAccount,
+ })),
+ );
+
+ return (
+ <CommonScheduledTimeSelect
+ {...props}
+ platType={currChooseAccount?.account?.type}
+ value={
+ value
+ ? value
+ : currChooseAccount?.pubParams.timingTime
+ ? dayjs(currChooseAccount?.pubParams.timingTime)
+ : undefined
+ }
+ isTitle={!onChange}
+ onChange={
+ onChange
+ ? onChange
+ : (e) => {
+ if (!currChooseAccount) return;
+ setOnePubParams({
+ timingTime: e ? e.toDate() : undefined,
+ });
+ }
+ }
+ />
+ );
+};
+
+// 标题
+export const TitleInput = ({
+ placeholder,
+ tips,
+ title = "标题",
+}: {
+ placeholder: string;
+ tips?: string;
+ title?: string;
+}) => {
+ const { setOnePubParams, currChooseAccount } = useVideoPageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ currChooseAccount: state.currChooseAccount,
+ })),
+ );
+ const [value, setValue] = useState(currChooseAccount?.pubParams.title || "");
+ if (!currChooseAccount) return "";
+ const max = AccountPlatInfoMap.get(currChooseAccount.account!.type)
+ ?.commonPubParamsConfig.titleMax;
+
+ const titleValue = useMemo(() => {
+ return currChooseAccount.pubParams.title || "";
+ }, [currChooseAccount.pubParams.title]);
+
+ useEffect(() => {
+ setValue(titleValue);
+ }, [titleValue]);
+ useEffect(() => {
+ setOnePubParams({
+ title: value,
+ });
+ }, [value]);
+
+ return (
+ <>
+ <h1>
+ {title}
+ {tips && (
+ <Tooltip title={tips}>
+ <QuestionCircleOutlined style={{ marginLeft: "2px" }} />
+ </Tooltip>
+ )}
+ </h1>
+ <Input
+ spellCheck={false}
+ defaultValue={titleValue}
+ value={value}
+ maxLength={max}
+ placeholder={placeholder}
+ showCount
+ variant="filled"
+ onChange={(e) => {
+ setValue(e.target.value);
+ }}
+ />
+ <AICreateTitle
+ type={AiCreateType.TITLE}
+ onAiCreateFinish={(text) => {
+ setOnePubParams({
+ title: text,
+ });
+ }}
+ videoFile={currChooseAccount.video}
+ max={max || 20}
+ />
+ </>
+ );
+};
+
+// 描述
+export const DescTextArea = ({
+ placeholder,
+ title = "描述",
+ maxLength,
+}: {
+ placeholder: string;
+ tips?: string;
+ title?: string;
+ maxLength: number;
+}) => {
+ const { setOnePubParams, currChooseAccount } = useVideoPageStore(
+ useShallow((state) => ({
+ setOnePubParams: state.setOnePubParams,
+ currChooseAccount: state.currChooseAccount,
+ })),
+ );
+ const [value, setValue] = useState(
+ currChooseAccount?.pubParams.describe || "",
+ );
+ if (!currChooseAccount) return "";
+
+ const describe = useMemo(() => {
+ return currChooseAccount.pubParams.describe || "";
+ }, [currChooseAccount]);
+ useEffect(() => {
+ setValue(describe);
+ }, [describe]);
+ useEffect(() => {
+ setOnePubParams({
+ describe: value,
+ });
+ }, [value]);
+
+ return (
+ <>
+ <h1>{title}</h1>
+ <TextArea
+ spellCheck={false}
+ defaultValue={currChooseAccount.pubParams.describe}
+ value={value}
+ placeholder={placeholder}
+ variant="filled"
+ showCount
+ maxLength={maxLength}
+ onChange={(e) => {
+ setValue(e.target.value);
+ }}
+ />
+ <AICreateTitle
+ type={AiCreateType.DESC}
+ onAiCreateFinish={(text) => {
+ setOnePubParams({
+ describe: text,
+ });
+ }}
+ videoFile={currChooseAccount.video}
+ max={maxLength}
+ />
+ </>
+ );
+};
+
+// 可见性
+export const VideoPubPermission = ({ ...props }: PubPermissionProps) => {
+ const { setOnePubParams, currChooseAccount } = useVideoPubSetModal();
+ return (
+ <PubPermission
+ onChange={(e) => {
+ setOnePubParams({
+ visibleType: e,
+ });
+ }}
+ value={currChooseAccount?.pubParams.visibleType}
+ {...props}
+ />
+ );
+};
+
+// 合集
+export const VideoPubMixSelect = ({}: {}) => {
+ const { setOnePubParams, currChooseAccount } = useVideoPubSetModal();
+ const { updateAccounts } = useVideoPageStore(
+ useShallow((state) => ({
+ updateAccounts: state.updateAccounts,
+ })),
+ );
+
+ return (
+ <CommonMixSelect
+ account={currChooseAccount.account}
+ value={currChooseAccount.pubParams.mixInfo?.value}
+ onAccountChange={(account) => {
+ updateAccounts({
+ accounts: [account],
+ });
+ }}
+ onChange={(_, value) => {
+ setOnePubParams({
+ mixInfo: !value
+ ? undefined
+ : {
+ label: (value as IMixItem).name,
+ value: (value as IMixItem).id,
+ },
+ });
+ }}
+ >
+ <VideoPubRestartLogin />
+ </CommonMixSelect>
+ );
+};
diff --git a/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/VideoPubSetModalVideo.tsx b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/VideoPubSetModalVideo.tsx
new file mode 100644
index 00000000..b3403f4e
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/VideoPubSetModalVideo.tsx
@@ -0,0 +1,142 @@
+import {
+ ForwardedRef,
+ forwardRef,
+ memo,
+ useImperativeHandle,
+ useRef,
+ useState,
+} from "react";
+import { Avatar, Segmented } from "antd";
+import { HeartFilled } from "@ant-design/icons";
+import { useVideoPageStore } from "@/app/[lng]/publish/videoPage/useVideoPageStore";
+import { useShallow } from "zustand/react/shallow";
+
+export interface IVideoPubSetModalVideoRef {
+ play: () => void;
+ pause: () => void;
+}
+
+export interface IVideoPubSetModalVideoProps {}
+
+const CoverPreview = ({
+ avatar,
+ nickname,
+ height,
+ coverUrl,
+}: {
+ avatar?: string;
+ nickname?: string;
+ height?: number;
+ coverUrl?: string;
+}) => {
+ return (
+ <div className="videoPubSetModalVideo-coverPreview-box">
+ <div
+ className="videoPubSetModalVideo-coverPreview-box-img"
+ style={{ height: `${height || 100}px` }}
+ >
+ {coverUrl && <img src={coverUrl} />}
+ </div>
+ <div className="videoPubSetModalVideo-coverPreview-box-bottom">
+ <p>***********</p>
+ <ul className="videoPubSetModalVideo-coverPreview-box-info">
+ <li>
+ <Avatar size="small" src={avatar} />
+ <span>{nickname}</span>
+ </li>
+ <li>
+ <HeartFilled />
+ <span>1</span>
+ </li>
+ </ul>
+ </div>
+ </div>
+ );
+};
+
+const VideoPubSetModalVideo = memo(
+ forwardRef(
+ (
+ {}: IVideoPubSetModalVideoProps,
+ ref: ForwardedRef<IVideoPubSetModalVideoRef>,
+ ) => {
+ const videoRef = useRef<HTMLVideoElement>(null);
+ const [active, setActive] = useState(1);
+ const { chooseAccountItem } = useVideoPageStore(
+ useShallow((state) => ({
+ chooseAccountItem: state.currChooseAccount!,
+ })),
+ );
+ const imperativeMethods: IVideoPubSetModalVideoRef = {
+ play: () => {
+ videoRef.current?.play();
+ },
+ pause: () => {
+ videoRef.current?.pause();
+ },
+ };
+ useImperativeHandle(ref, () => imperativeMethods, []);
+
+ return (
+ <div className="videoPubSetModalVideo">
+ <Segmented
+ value={active}
+ options={[
+ { label: "预览视频", value: 1 },
+ { label: "预览封面/标题", value: 2 },
+ ]}
+ defaultValue={1}
+ onChange={setActive}
+ />
+
+ <div className="videoPubSetModalVideo-video">
+ <div
+ className="videoPubSetModalVideo-video-wrapper"
+ style={
+ active !== 1
+ ? {
+ justifyContent: "left",
+ }
+ : {}
+ }
+ >
+ {active === 1 ? (
+ <>
+ <div className="videoPubSetModalVideo-video-top" />
+ <video
+ ref={videoRef}
+ src={chooseAccountItem?.video?.videoUrl}
+ controls
+ />
+ </>
+ ) : (
+ chooseAccountItem.account && (
+ <div className="videoPubSetModalVideo-coverPreview">
+ <div className="videoPubSetModalVideo-coverPreview-con">
+ <CoverPreview height={150} />
+ <CoverPreview
+ height={150}
+ avatar={chooseAccountItem.account.avatar}
+ nickname={chooseAccountItem.account.nickname}
+ coverUrl={chooseAccountItem.pubParams.cover?.imgUrl}
+ />
+ <CoverPreview />
+ </div>
+ <div className="videoPubSetModalVideo-coverPreview-con">
+ <CoverPreview height={120} />
+ <CoverPreview height={110} />
+ <CoverPreview height={120} />
+ </div>
+ </div>
+ )
+ )}
+ </div>
+ </div>
+ </div>
+ );
+ },
+ ),
+);
+VideoPubSetModalVideo.displayName = "VideoPubSetModalVideo";
+
+export default VideoPubSetModalVideo;
diff --git a/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/useDebounceFetcher.ts b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/useDebounceFetcher.ts
new file mode 100644
index 00000000..2868df73
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/components/useDebounceFetcher.ts
@@ -0,0 +1,39 @@
+import { useMemo, useRef, useState } from "react";
+import lodash from "lodash";
+
+export default function useDebounceFetcher<T>(
+ fetchOptions: (_: string) => Promise<any>,
+ debounceTimeout = 300,
+) {
+ const fetchRef = useRef(0);
+ const [options, setOptions] = useState<T[]>([]);
+ const [fetching, setFetching] = useState(false);
+
+ const debounceFetcher = useMemo(() => {
+ const loadOptions = (value: string) => {
+ fetchRef.current += 1;
+ const fetchId = fetchRef.current;
+ setOptions([]);
+ setFetching(true);
+
+ fetchOptions(value).then((newOptions) => {
+ if (fetchId !== fetchRef.current) {
+ return;
+ }
+
+ console.log(newOptions);
+ setOptions(newOptions);
+ setFetching(false);
+ });
+ };
+
+ return lodash.debounce(loadOptions, debounceTimeout);
+ }, [fetchOptions, debounceTimeout]);
+
+ return {
+ options,
+ fetching,
+ debounceFetcher,
+ setOptions,
+ };
+}
diff --git a/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/videoPubSetModal.module.scss b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/videoPubSetModal.module.scss
new file mode 100644
index 00000000..20dd5949
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/videoPubSetModal.module.scss
@@ -0,0 +1,253 @@
+.videoPubSetModal {
+ :global {
+ textarea {
+ resize: none;
+ height: 150px !important;
+ }
+
+ .ant-tabs-tab {
+ padding: 0;
+ margin: 0 10px 0 0 !important;
+ background: #fff;
+ transition: 0.3s;
+ }
+ .ant-tabs-ink-bar {
+ height: 3px !important;
+ }
+ .ant-tabs-tab-active {
+ background: var(--colorPrimary2);
+ }
+ .videoPubSetModal_con {
+ display: flex;
+ justify-content: space-between;
+ &--noMore {
+ justify-content: center;
+ .videoPubSetModal_con-left {
+ display: none !important;
+ }
+ .videoPubSetModal_con-right {
+ width: 250px;
+ }
+ }
+ &-red {
+ color: var(--errerColor);
+ margin-right: 5px;
+ }
+ &-tips {
+ color: rgb(178, 185, 185);
+ }
+ &_top {
+ margin-bottom: 10px;
+ button {
+ width: 100%;
+ }
+ }
+ &-left {
+ width: calc(70% - 50px);
+ height: 55vh;
+ overflow: auto;
+ padding: 0 20px 20px 0;
+
+ h1 {
+ font-weight: 400;
+ font-size: var(--fs-sm);
+ display: flex;
+ align-items: center;
+ margin: 20px 0 8px 0;
+ }
+ }
+ &-right {
+ width: 30%;
+ video {
+ width: 100%;
+ border-radius: 20px;
+ }
+ }
+ }
+ .ant-tabs-nav-wrap {
+ border: 1px solid #e3e3e3;
+ border-right: none;
+ border-left: none;
+ }
+ .videoPubSetModal-tabLabel {
+ height: 70px;
+ width: 100px;
+ padding: 0 10px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ .ant-alert {
+ position: absolute;
+ z-index: 10;
+ top: 0;
+ width: 100%;
+ height: 20px;
+ padding: 0;
+ border-radius: 0 0 10px 10px;
+ display: flex;
+ border-top: none;
+ justify-content: center;
+ .ant-alert-content {
+ flex: none;
+ }
+ .anticon {
+ font-size: var(--fs-xs);
+ margin-right: 4px;
+ }
+ .ant-alert-message {
+ font-size: var(--fs-xs);
+ }
+ }
+ & > span {
+ display: flex;
+ overflow: hidden;
+ & > img {
+ width: 15px;
+ }
+ }
+ .ant-avatar {
+ flex-shrink: 0 !important;
+ }
+ &-name {
+ display: block;
+ margin: 0 3px;
+ max-width: 100%;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ }
+
+ .videoPubSetModalVideo {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ min-height: 500px;
+ .ant-segmented {
+ margin-bottom: 15px;
+ }
+
+ &-video {
+ background: black;
+ border-radius: 30px;
+ overflow: hidden;
+ box-sizing: border-box;
+ position: relative;
+ width: 100%;
+ height: 510px;
+ &-wrapper {
+ margin: 5px;
+ box-sizing: border-box;
+ height: 100%;
+ border-radius: 30px;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ }
+ &-top {
+ position: absolute;
+ width: 50%;
+ height: 20px;
+ z-index: 10;
+ border-radius: 0 0 15px 15px;
+ top: 0;
+ left: 50%;
+ transform: translateX(-50%);
+ background: black;
+ }
+ video {
+ width: 100%;
+ max-height: 100%;
+ object-fit: cover;
+ border-radius: 0;
+ }
+ }
+
+ &-coverPreview {
+ display: flex;
+ justify-content: space-between;
+ &-con {
+ width: calc(50% - 5px);
+ }
+ &-box {
+ width: 100%;
+ margin-bottom: 5px;
+ border-radius: 10px;
+ overflow: hidden;
+ &-img {
+ background: rgb(196, 196, 196);
+ width: 100%;
+ img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
+ }
+ &-bottom {
+ background: rgb(188, 188, 188);
+ color: #fff;
+ padding: 8px;
+ box-sizing: border-box;
+ p {
+ font-size: 10px;
+ }
+ ul {
+ display: flex;
+ justify-content: space-between;
+ li {
+ white-space: nowrap;
+ font-size: 7px;
+ display: flex;
+ align-items: center;
+ box-sizing: border-box;
+ &:nth-child(1) {
+ max-width: 80%;
+ }
+ span {
+ text-overflow: ellipsis;
+ overflow: hidden;
+ }
+ .anticon {
+ margin-right: 2px;
+ }
+ .ant-avatar {
+ width: 16px;
+ height: 16px;
+ margin-right: 3px;
+ flex-shrink: 0;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+.videoPubSetModal_titleWrap {
+ padding-bottom: 10px;
+ display: flex;
+ align-items: center;
+
+ :global {
+ .videoPubSetModal-title {
+ }
+ .videoPubSetModal-more {
+ margin-left: 30px;
+ font-size: var(--fs-sm);
+ &-core {
+ display: flex;
+ align-items: center;
+ label {
+ margin-right: 5px;
+ }
+ }
+ &-tips {
+ font-weight: 400;
+ font-size: var(--fs-xs);
+ color: var(--grayColor7);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/videoPubSetModal.type.ts b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/videoPubSetModal.type.ts
new file mode 100644
index 00000000..8377be22
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/VideoPubSetModal/videoPubSetModal.type.ts
@@ -0,0 +1,3 @@
+export interface IVideoPubSetModalChildRef {}
+
+export interface IVideoPubSetModalChildProps {}
diff --git a/src/app/[lng]/publish/videoPage/components/videoCoverSeting.module.scss b/src/app/[lng]/publish/videoPage/components/videoCoverSeting.module.scss
new file mode 100644
index 00000000..64afc623
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/components/videoCoverSeting.module.scss
@@ -0,0 +1,73 @@
+.videoCoverSeting {
+ width: 70px;
+ height: 100px;
+ background: rgb(103, 105, 105);
+ border-radius: 6px;
+ overflow: hidden;
+ position: relative;
+ cursor: pointer;
+ :global {
+ .imgChoose {
+ height: 100%;
+ }
+ .videoCoverSeting-img, img {
+ width: 100%;
+ height: 100%;
+ }
+ .videoCoverSeting-choosed {
+ height: 100%;
+ position: relative;
+
+ .anticon {
+ position: absolute;
+ z-index: 10;
+ color: red;
+ right: 3px;
+ top: 3px;
+ display: none;
+ }
+
+ &:hover {
+ .anticon {
+ display: block;
+ }
+ }
+ }
+ img {
+ object-fit: contain;
+ }
+ .videoCoverSeting-text {
+ position: absolute;
+ bottom: 0;
+ width: 100%;
+ background: rgba(0, 0, 0, 0.8);
+ font-size: var(--fs-xs);
+ color: #fff;
+ padding: 5px 0;
+ text-align: center;
+ }
+ }
+}
+
+.videoCoverSetingModal {
+ :global {
+ .videoCoverSetingModal-top {
+ display: flex;
+ align-items: center;
+ margin: 20px 0;
+ .ant-alert {
+ margin-right: 30px;
+ }
+ }
+
+ .videoCoverSetingModal-cropper {
+ img {
+ height: 300px;
+ object-fit: contain;
+ }
+ }
+
+ #videoCoverSetingModal--cropper {
+ }
+ }
+}
diff --git a/src/app/[lng]/publish/videoPage/images/importRecord.png b/src/app/[lng]/publish/videoPage/images/importRecord.png
new file mode 100644
index 00000000..956e8421
Binary files /dev/null and b/src/app/[lng]/publish/videoPage/images/importRecord.png differ
diff --git a/src/app/[lng]/publish/videoPage/images/localUpload.png b/src/app/[lng]/publish/videoPage/images/localUpload.png
new file mode 100644
index 00000000..456106bd
Binary files /dev/null and b/src/app/[lng]/publish/videoPage/images/localUpload.png differ
diff --git a/src/app/[lng]/publish/videoPage/page.tsx b/src/app/[lng]/publish/videoPage/page.tsx
new file mode 100644
index 00000000..91c4ac0f
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/page.tsx
@@ -0,0 +1,284 @@
+"use client";
+
+import styles from "./video.module.scss";
+import { Button, message, Popconfirm, Spin, Tooltip } from "antd";
+import { DeleteOutlined, PlusOutlined } from "@ant-design/icons";
+import { useShallow } from "zustand/react/shallow";
+import { toolsApi } from "@/api/tools";
+import { sensitivityLoading } from "@/utils";
+import VideoChoose from "@/app/[lng]/publish/components/Choose/VideoChoose";
+import ChooseAccountModule from "@/app/[lng]/publish/components/ChooseAccountModule/ChooseAccountModule";
+import NoChoosePage from "@/app/[lng]/publish/videoPage/components/NoChoosePage";
+import { useVideoPageStore } from "@/app/[lng]/publish/videoPage/useVideoPageStore";
+import { PubType } from "@/app/config/publishConfig";
+import VideoChooseItem from "@/app/[lng]/publish/videoPage/components/VideoChooseItem";
+import CommonPubSetting from "@/app/[lng]/publish/videoPage/components/CommonPubSetting";
+import VideoPubSetModal from "@/app/[lng]/publish/videoPage/components/VideoPubSetModal/VideoPubSetModal";
+import { IVideoChooseItem } from "@/app/[lng]/publish/videoPage/videoPage";
+import { useEffect, useRef, useState } from "react";
+
+export enum AccountChooseType {
+ // 多选
+ MultiSelect = 0,
+ // 单选
+ Radio = 1,
+ // 替换
+ Replace = 2,
+}
+
+export default function Page() {
+ const {
+ videoListChoose,
+ addVideos,
+ clearVideoList,
+ clear,
+ addAccount,
+ aloneAdd,
+ setVideoPubSetModalOpen,
+ loadingPageLoading,
+ setLoadingPageLoading,
+ setCurrChooseAccountId,
+ } = useVideoPageStore(
+ useShallow((state) => ({
+ videoListChoose: state.videoListChoose,
+ addVideos: state.addVideos,
+ addAccount: state.addAccount,
+ clearVideoList: state.clearVideoList,
+ clear: state.clear,
+ aloneAdd: state.aloneAdd,
+ setVideoPubSetModalOpen: state.setVideoPubSetModalOpen,
+ loadingPageLoading: state.loadingPageLoading,
+ setLoadingPageLoading: state.setLoadingPageLoading,
+ setCurrChooseAccountId: state.setCurrChooseAccountId,
+ })),
+ );
+ // 账户选择弹框显示隐藏状态
+ const [chooseAccountOpen, setChooseAccountOpen] = useState(false);
+ // 账户选择类型
+ const accountChooseType = useRef(AccountChooseType.MultiSelect);
+ // 用户单选ID
+ const accountOneChooseId = useRef<string>();
+ const [sensitiveDetLoading, setSensitiveDetLoading] = useState(false);
+
+ useEffect(() => {
+ return () => {
+ clear();
+ };
+ }, []);
+
+ const sensitiveDetCore = async (
+ content: string,
+ videoItem: IVideoChooseItem,
+ ) => {
+ const res = await toolsApi.textModeration(content);
+
+ return {
+ sensitive: res !== "Normal",
+ videoItem,
+ };
+ };
+
+ return (
+ <div className={styles.video}>
+ <Spin spinning={loadingPageLoading}>
+ <VideoPubSetModal onClose={setVideoPubSetModalOpen} />
+ <ChooseAccountModule
+ platChooseProps={{
+ disableAllSelect:
+ accountChooseType.current === AccountChooseType.Radio ||
+ accountChooseType.current === AccountChooseType.Replace,
+ choosedAccounts: videoListChoose
+ .map((v) => v.account)
+ .filter((v) => v !== undefined),
+ pubType: PubType.VIDEO,
+ isCancelChooseAccount: true,
+ }}
+ open={chooseAccountOpen}
+ onClose={setChooseAccountOpen}
+ onPlatConfirm={(aList) => {
+ addAccount(aList);
+ }}
+ onPlatChange={(_, account) => {
+ if (
+ accountChooseType.current === AccountChooseType.Radio ||
+ accountChooseType.current === AccountChooseType.Replace
+ ) {
+ setChooseAccountOpen(false);
+ aloneAdd({
+ account,
+ id: accountOneChooseId.current!,
+ });
+ }
+ }}
+ />
+
+ {videoListChoose.length !== 0 ? (
+ // 视频已选择
+ <div className="video-pubAfter">
+ <div className="video-pubAfter-con">
+ <div className="video-pubAfter-left">
+ <div className="video-pubAfter-left-options">
+ <div className="video-pubAfter-left-options-video">
+ <h1>视频</h1>
+ <VideoChoose
+ onMultipleChoose={addVideos}
+ onStartShoose={() => {
+ setLoadingPageLoading(true);
+ }}
+ onChooseFail={() => {
+ setLoadingPageLoading(false);
+ }}
+ >
+ <Tooltip title="批量添加视频">
+ <Button type="dashed" icon={<PlusOutlined />}>
+ 批量添加
+ </Button>
+ </Tooltip>
+ </VideoChoose>
+ <Tooltip title="删除所有视频">
+ <Button
+ type="dashed"
+ icon={<DeleteOutlined />}
+ onClick={() => clearVideoList(0)}
+ >
+ 清空视频
+ </Button>
+ </Tooltip>
+ </div>
+ <div className="video-pubAfter-left-options-account">
+ <h1>账号</h1>
+ <Tooltip title="批量添加账号">
+ <Button
+ type="dashed"
+ icon={<PlusOutlined />}
+ onClick={() => {
+ accountChooseType.current =
+ AccountChooseType.MultiSelect;
+ setChooseAccountOpen(true);
+ }}
+ >
+ 批量添加
+ </Button>
+ </Tooltip>
+ <Tooltip title="删除所有账号">
+ <Button
+ type="dashed"
+ icon={<DeleteOutlined />}
+ onClick={() => {
+ clearVideoList(1);
+ }}
+ >
+ 清空账号
+ </Button>
+ </Tooltip>
+ </div>
+ </div>
+
+ <div className="video-pubAfter-left-list">
+ {videoListChoose.map((v) => {
+ return (
+ <VideoChooseItem
+ key={v.id + v.video + v.account}
+ videoChooseItem={v}
+ onAccountOneChoose={(id, type) => {
+ accountChooseType.current = type;
+ accountOneChooseId.current = id;
+ setChooseAccountOpen(true);
+ }}
+ />
+ );
+ })}
+ </div>
+ </div>
+ <div className="video-pubAfter-right">
+ <CommonPubSetting />
+ </div>
+ </div>
+ <div className="video-pubAfter-footer">
+ <Popconfirm
+ title="温馨提示"
+ description="是否确认清空内容和账号?"
+ onConfirm={() => {
+ clear();
+ }}
+ okText="确认"
+ cancelText="取消"
+ >
+ <Button>一键清空</Button>
+ </Popconfirm>
+
+ <Button
+ loading={sensitiveDetLoading}
+ color="danger"
+ variant="solid"
+ disabled={!videoListChoose.every((v) => v.account && v.video)}
+ onClick={async () => {
+ setSensitiveDetLoading(true);
+ const core = async () => {
+ const tasks: Promise<{
+ // 作品
+ videoItem: IVideoChooseItem;
+ // 是否敏感 true=敏感 false=正常
+ sensitive: boolean;
+ }>[] = [];
+ // 如果检测内容重复不会进行检测
+ const contentSet = new Set<string>();
+ videoListChoose.map((v) => {
+ const content = `
+ ${v.pubParams.title}
+ ${v.pubParams.describe}
+ `;
+ if (content.trim() !== "" && !contentSet.has(content)) {
+ contentSet.add(content);
+ tasks.push(sensitiveDetCore(content, v));
+ }
+ });
+ return await Promise.all(tasks);
+ };
+
+ const taskRes = await Promise.all([
+ core(),
+ sensitivityLoading(),
+ ]);
+ const res = taskRes[0];
+
+ setSensitiveDetLoading(false);
+
+ if (res.length === 0) return message.success("检测正常");
+ if (res.every((v) => !v.sensitive)) {
+ message.success("检测正常");
+ return;
+ }
+ for (const { sensitive, videoItem } of res) {
+ if (sensitive) {
+ message.warning("检测到此条作品存在敏感信息!");
+ setVideoPubSetModalOpen(true);
+ setCurrChooseAccountId(videoItem.id);
+ break;
+ }
+ }
+ }}
+ >
+ 内容安全检测
+ </Button>
+
+ <Button
+ type="primary"
+ disabled={!videoListChoose.every((v) => v.account && v.video)}
+ onClick={() => {
+ setVideoPubSetModalOpen(true);
+ setCurrChooseAccountId(videoListChoose[0].id);
+ }}
+ >
+ 预览及发布
+ </Button>
+ </div>
+ </div>
+ ) : (
+ // 视频未选择
+ <NoChoosePage />
+ )}
+ </Spin>
+ </div>
+ );
+}
diff --git a/src/app/[lng]/publish/videoPage/useVideoPageStore.ts b/src/app/[lng]/publish/videoPage/useVideoPageStore.ts
new file mode 100644
index 00000000..b48d0716
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/useVideoPageStore.ts
@@ -0,0 +1,376 @@
+import { create } from "zustand";
+import { combine } from "zustand/middleware";
+import { generateUUID } from "@/utils";
+import lodash from "lodash";
+import { useAICreateTitleStore } from "../components/AICreateTitle/useAICreateTitle";
+import {
+ IPubParams,
+ IVideoChooseItem,
+} from "@/app/[lng]/publish/videoPage/videoPage";
+import { SocialAccount } from "@/api/types/account.type";
+import { PlatType } from "@/app/config/platConfig";
+import { VisibleTypeEnum } from "@/app/config/publishConfig";
+import { IVideoFile } from "@/app/[lng]/publish/components/Choose/VideoChoose";
+
+export interface IVideoPageStore {
+ // 选择的视频数据
+ videoListChoose: IVideoChooseItem[];
+ // 视频发布设置弹框的 tab选择
+ currChooseAccountId: string;
+ // 视频发布设置弹框显示隐藏状态
+ videoPubSetModalOpen: boolean;
+ // 通用发布参数
+ commonPubParams: IPubParams;
+ // 在视频页的loading状态
+ loadingPageLoading: boolean;
+ /**
+ * 当前操作的ID
+ * 每次操作都会分配一个操作ID
+ */
+ operateId: string;
+ // 当前选择的账户数据
+ currChooseAccount?: IVideoChooseItem;
+}
+
+const store: IVideoPageStore = {
+ videoListChoose: [],
+ currChooseAccountId: "",
+ videoPubSetModalOpen: false,
+ commonPubParams: {
+ title: "",
+ describe: "",
+ cover: undefined,
+ visibleType: VisibleTypeEnum.Public,
+ topics: [],
+ timingTime: undefined,
+ mixInfo: undefined,
+ diffParams: {
+ [PlatType.Xhs]: {},
+ [PlatType.Douyin]: {
+ hotPoint: undefined,
+ selfDeclare: undefined,
+ activitys: [],
+ },
+ [PlatType.WxSph]: {
+ isOriginal: false,
+ extLink: undefined,
+ activity: undefined,
+ },
+ },
+ },
+ loadingPageLoading: false,
+ operateId: "",
+ currChooseAccount: undefined,
+};
+
+const getStore = () => {
+ return lodash.cloneDeep(store);
+};
+
+// 视频发布所有组件的共享状态和方法
+export const useVideoPageStore = create(
+ combine(
+ {
+ ...getStore(),
+ },
+ (set, get, storeApi) => {
+ const methods = {
+ // 设置当前的账户数据
+ setCurrChooseAccount(currChooseAccount: IVideoChooseItem) {
+ set({
+ currChooseAccount,
+ });
+ },
+
+ // 设置操作ID
+ setOperateId(operateId?: string) {
+ // if (get().operateId) return;
+ set({
+ operateId: operateId || generateUUID(),
+ });
+ },
+
+ // 设置在视频页的loading状态
+ setLoadingPageLoading(loadingPageLoading: boolean) {
+ set({
+ loadingPageLoading,
+ });
+ },
+
+ // 设置视频发布设置弹框显示隐藏状态
+ setVideoPubSetModalOpen(videoPubSetModalOpen: boolean) {
+ set({
+ videoPubSetModalOpen,
+ });
+ },
+
+ // 设置发布弹框设置tab选择
+ setCurrChooseAccountId(currChooseAccountId: string) {
+ set({
+ currChooseAccountId,
+ });
+ },
+
+ // 初始化发布参数
+ pubParamsInit(): IPubParams {
+ return lodash.cloneDeep(get().commonPubParams);
+ },
+
+ // 添加视频数据
+ addVideos(videoFiles: IVideoFile[]) {
+ const { videoListChoose } = get();
+ const newValue = [...get().videoListChoose];
+ // 是否所有数据的视频全部为空
+ const isAllVideoNull =
+ newValue.every((v) => !v.video) && videoFiles.length === 1;
+ // 记录视频
+ let videoPointer = 0;
+
+ videoListChoose.map((v) => {
+ // 有数据缺少视频就填视频
+ if (!v.video) {
+ if (isAllVideoNull) {
+ v.video = videoFiles[0];
+ } else {
+ const videoFile = videoFiles[videoPointer];
+ if (!videoFile) return;
+ v.video = videoFile;
+ }
+ videoPointer++;
+ }
+ });
+
+ // 填完剩下的视频添加数据
+ for (let i = videoPointer; i < videoFiles.length; i++) {
+ const videoFile = videoFiles[i];
+ const temp = {
+ video: videoFile,
+ pubParams: methods.pubParamsInit(),
+ id: generateUUID(),
+ };
+ newValue.push(temp);
+ }
+ set({
+ videoListChoose: newValue,
+ loadingPageLoading: false,
+ });
+ setTimeout(() => methods.setVideoCoverFirst(), 10);
+ },
+
+ /**
+ * 将所有视频设置为首帧封面
+ * @param force 不管该条数据的参数是否存在 cover 字段强制覆盖
+ */
+ setVideoCoverFirst(force?: boolean) {
+ const videoListChoose = [...get().videoListChoose];
+
+ videoListChoose.map((v) => {
+ if (force) {
+ v.pubParams.cover = v.video?.cover;
+ } else {
+ if (!get().commonPubParams.cover) {
+ v.pubParams.cover = v.video?.cover;
+ }
+ }
+ });
+
+ set({
+ videoListChoose,
+ });
+ },
+
+ // 添加账户数据
+ addAccount(accounts: SocialAccount[]) {
+ const newV = [...get().videoListChoose];
+ // 判断是否只有一个视频数据
+ const isAloneVideo = !!(newV.length === 1 && newV[0].video);
+ /**
+ * 已经存在的账户ID做个去重
+ * 因为accounts会将所有选择的账户数据传入
+ */
+ const existAccountsSet = new Set<number>();
+ newV.map((v) => v.account && existAccountsSet.add(v.account.id));
+ accounts = accounts.filter((v) => !existAccountsSet.has(v.id));
+
+ // 记录账户
+ let accountPointer = 0;
+ newV.map((v) => {
+ // 有数据缺少账户就填账户
+ if (!v.account) {
+ v.account = accounts[accountPointer];
+ accountPointer++;
+ }
+ });
+
+ // 填完剩下的账户添加数据
+ for (let i = accountPointer; i < accounts.length; i++) {
+ const video = newV[0].video;
+ newV.push({
+ account: accounts[i],
+ video: isAloneVideo ? video : undefined,
+ pubParams: methods.pubParamsInit(),
+ id: generateUUID(),
+ });
+ }
+
+ set({
+ videoListChoose: newV,
+ });
+ setTimeout(() => methods.setVideoCoverFirst(), 10);
+ },
+
+ /**
+ * 清空视频或账号
+ * @param type 0=清空视频,1=清空账号
+ */
+ clearVideoList(type: 0 | 1) {
+ let newValue = [...get().videoListChoose];
+ newValue = newValue
+ .map((v) => {
+ if (type === 0) {
+ v.video = undefined;
+ return !v.account ? undefined : v;
+ } else {
+ v.account = undefined;
+ return !v.video ? undefined : v;
+ }
+ })
+ .filter(Boolean) as IVideoChooseItem[];
+ set({
+ videoListChoose: newValue,
+ });
+ },
+
+ // 清空所有数据
+ clear() {
+ set({
+ ...getStore(),
+ });
+ useAICreateTitleStore.getState().clear();
+ },
+
+ // 删除某个视频
+ deleteAloneVideo(id: string) {
+ const newValue = [...get().videoListChoose];
+ for (const videoChooseItem of newValue) {
+ if (id === videoChooseItem.id) {
+ videoChooseItem.video = undefined;
+ break;
+ }
+ }
+ set({
+ videoListChoose: newValue.filter((v) => v.video || v.account),
+ });
+ },
+
+ // 删除某一条数据
+ deleteData(id: string) {
+ set({
+ videoListChoose: [...get().videoListChoose].filter(
+ (v) => v.id !== id,
+ ),
+ });
+ },
+
+ // 单个视频或者账户添加
+ aloneAdd({
+ video,
+ account,
+ id,
+ }: {
+ video?: IVideoFile;
+ account?: SocialAccount;
+ id: string;
+ }) {
+ const newValue = [...get().videoListChoose];
+
+ const vci = newValue.find((v) => v.id === id);
+ if (!vci) return console.error(`找不到id为 ${id} 个数据`);
+ if (video) vci.video = video;
+ if (account) vci.account = account;
+
+ set({
+ videoListChoose: newValue,
+ });
+ setTimeout(() => methods.setVideoCoverFirst(), 10);
+ },
+
+ // 账户数据批量更新
+ updateAccounts({ accounts }: { accounts: SocialAccount[] }) {
+ if (!accounts) return;
+
+ const newValue = [...get().videoListChoose];
+ if (newValue.length === 0) return;
+ // key=账户ID val= videoListChoose item
+ const videoListMap = new Map<number, IVideoChooseItem>();
+
+ newValue.map((v) => {
+ videoListMap.set(v.account?.id || 0, v);
+ });
+
+ accounts.map((v) => {
+ const videoItem = videoListMap.get(v.id);
+ if (videoItem) videoItem.account = v;
+ });
+
+ set({
+ videoListChoose: newValue,
+ });
+ },
+
+ // 设置所有视频数据的发布参数
+ setPubParams(pubParmas: IPubParams) {
+ const videoListChoose = [...get().videoListChoose];
+ const commonPubParams = { ...get().commonPubParams };
+
+ videoListChoose.map((v) => {
+ Object.keys(pubParmas).map((key) => {
+ if (pubParmas.hasOwnProperty(key)) {
+ v.pubParams[key as "title"] = pubParmas[key as "title"];
+ commonPubParams[key as "title"] = pubParmas[key as "title"];
+ }
+ });
+ });
+ set({
+ videoListChoose,
+ commonPubParams,
+ });
+ },
+
+ // 设置单条数据的发布参数
+ setOnePubParams(pubParmas: IPubParams, id?: string) {
+ const newValue = [...get().videoListChoose];
+
+ const findedData = newValue.find(
+ (v) => v.id === (id || get().currChooseAccount!.id),
+ );
+ if (findedData) {
+ for (const key in pubParmas) {
+ if (pubParmas.hasOwnProperty(key)) {
+ findedData.pubParams[key as "title"] =
+ pubParmas[key as "title"];
+ }
+ }
+ }
+ set({
+ videoListChoose: newValue,
+ });
+ },
+
+ /**
+ * 账户重新登录。登录成功后会自动更新该条账户数据
+ */
+ async accountRestart(pType: PlatType) {
+ // TODO 重新登录
+ // const res = await accountLogin(pType);
+ // if (!res) return;
+ // console.log(res);
+ // message.success("登录成功!");
+ // // 更新此条账户数据
+ // methods.updateAccounts({ accounts: [res] });
+ },
+ };
+ return methods;
+ },
+ ),
+);
diff --git a/src/app/[lng]/publish/videoPage/video.module.scss b/src/app/[lng]/publish/videoPage/video.module.scss
new file mode 100644
index 00000000..be612c14
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/video.module.scss
@@ -0,0 +1,414 @@
+.video {
+ width: 100%;
+ height: 100%;
+ min-width: 0;
+ display: flex;
+ :global {
+ .ant-spin-nested-loading {
+ width: 100%;
+ .ant-spin-container {
+ height: 100%;
+ }
+ }
+ .video-pubBefore {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ width: 100%;
+ height: 100%;
+ &-con {
+ display: flex;
+ }
+ h1 {
+ font-size: 24px;
+ }
+ &-tip {
+ font-size: var(--fs-sm);
+ color: var(--grayColor10);
+ margin: 20px 0;
+ }
+ }
+
+ .video-pubAfter {
+ display: flex;
+ flex-direction: column;
+ flex: 1;
+ height: 100%;
+ min-height: 0;
+ box-sizing: border-box;
+ &-con {
+ height: 100%;
+ min-height: 0;
+ padding: 15px 15px 0 15px;
+ display: flex;
+ box-sizing: border-box;
+ }
+ &-left {
+ width: 70%;
+ display: flex;
+ flex-direction: column;
+ flex: 1;
+ &-list {
+ flex: 1;
+ overflow-y: auto;
+ padding-right: 10px;
+ }
+ &-options {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 15px;
+ h1 {
+ font-weight: 400;
+ font-size: var(--fs-lg);
+ margin-right: 10px;
+ }
+ &-account, &-video {
+ align-items: center;
+ display: flex;
+
+ button {
+ margin-right: 10px;
+ }
+ }
+ }
+ }
+ &-right {
+ width: 30%;
+ margin-left: 20px;
+ padding-left: 10px;
+ border-left: 1px solid rgb(232, 232, 232);
+ overflow: auto;
+ }
+ &-footer {
+ text-align: center;
+ border-top: 1px solid var(--grayColor3);
+ padding: 15px;
+ button {
+ margin-right: 20px;
+ &:last-of-type {
+ margin-right: 0;
+ }
+ }
+ }
+ }
+
+ .videoChooseItem {
+ text-align: left;
+ margin-bottom: 20px;
+ height: 90px;
+ display: flex;
+ &-noAccount {
+ width: 100%;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ cursor: pointer;
+ font-size: var(--fs-sm);
+ &-icon {
+ background: rgba(172, 182, 182);
+ display: flex;
+ width: 40px;
+ height: 40px;
+ align-items: center;
+ justify-content: center;
+ border-radius: 50%;
+ font-size: 20px;
+ color: #fff;
+ margin-bottom: 4px;
+ transition: 0.3s;
+ }
+ & > span {
+ color: #444;
+ }
+
+ &:hover {
+ & > span {
+ color: var(--colorPrimary5) !important;
+ }
+ .videoChooseItem-noAccount-icon {
+ background: var(--colorPrimary5);
+ }
+ }
+ }
+ &-options {
+ flex-shrink: 0;
+ margin-left: 5px;
+ border: 1px solid rgb(232, 232, 232);
+ height: calc(100% - 2px);
+ border-radius: 6px;
+ padding: 0 15px 0 20px;
+ box-sizing: border-box;
+ position: relative;
+ display: flex;
+ align-items: baseline;
+ justify-content: center;
+ flex-direction: column;
+ button {
+ &:nth-of-type(1) {
+ margin-bottom: 5px;
+ }
+ }
+ &:after, &:before {
+ content: "";
+ display: block;
+ position: absolute;
+ border: 1px solid rgb(196, 196, 196);
+ width: 20px;
+ height: 6px;
+ border-radius: 20px;
+ left: 0;
+ transform: translateX(-70%);
+ }
+ &:after {
+ top: 25%;
+ }
+ &:before {
+ top: 65%;
+ }
+ }
+ &-core {
+ display: flex;
+ background: rgb(247, 250, 250);
+ padding: 10px;
+ box-sizing: border-box;
+ border: 1px solid transparent;
+ transition: 0.3s;
+ border-radius: 8px;
+ height: 100%;
+ width: 100%;
+ min-width: 0;
+ &:hover {
+ border-color: var(--colorPrimary5);
+ .videoChooseItem-video-close {
+ display: flex !important;
+ z-index: 10;
+ }
+ }
+ }
+ &-left {
+ display: flex;
+ width: 100%;
+ min-width: 0;
+ &-chooseVideo {
+ width: 100%;
+ cursor: pointer;
+ .videoChoose {
+ width: 100%;
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ }
+ .anticon {
+ color: rgb(172, 182, 182);
+ font-size: 30px;
+ }
+ &-name {
+ font-size: var(--fs-sm);
+ color: rgb(121, 121, 121);
+ }
+ &:hover {
+ .anticon, .videoChooseItem-left-chooseVideo-name {
+ color: var(--colorPrimary5);
+ }
+ }
+ }
+ &-info {
+ display: flex;
+ flex-direction: column;
+ margin-left: 15px;
+ justify-content: center;
+ overflow: hidden;
+ }
+ &-bottom {
+ display: flex;
+ font-size: var(--fs-sm);
+ margin-top: 14px;
+ &-item {
+ margin-right: 30px;
+ label {
+ margin-right: 10px;
+ color: var(--grayColor7);
+ }
+ &--warning {
+ color: var(--errerColor);
+ label {
+ color: var(--errerColor);
+ }
+ & > span {
+ margin-right: 5px;
+ }
+ }
+ }
+ }
+ &-title {
+ font-size: var(--fs-sm);
+ font-weight: 900;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow: hidden;
+ }
+ }
+ &-right {
+ width: 200px;
+ flex-shrink: 0;
+ display: flex;
+ align-items: center;
+ border-left: 1px solid #e5e5e5;
+ padding-left: 20px;
+ box-sizing: border-box;
+ }
+ &-account {
+ width: 100%;
+ display: flex;
+ align-items: center;
+ &:hover {
+ .videoChooseItem-account-avatar-replace {
+ display: flex !important;
+ }
+ }
+ &-avatar {
+ position: relative;
+ .ant-avatar {
+ flex-shrink: 0;
+ }
+ &-replace {
+ display: none;
+ position: absolute;
+ cursor: pointer;
+ color: #fff;
+ background: var(--colorPrimary5);
+ width: 16px;
+ height: 16px;
+ bottom: -2px;
+ right: -2px;
+ align-items: center;
+ justify-content: center;
+ font-size: 10px;
+ border-radius: 50%;
+ }
+ }
+ &-con {
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ margin-left: 5px;
+ font-size: var(--fs-sm);
+
+ .ant-alert {
+ padding: 0 3px;
+ width: 80px;
+ font-size: var(--fs-xs);
+ margin-top: 5px;
+ color: #ff4d4f;
+ cursor: pointer;
+ .anticon {
+ margin-right: 4px;
+ }
+ }
+ }
+ &-top {
+ width: 100%;
+ display: flex;
+ align-items: center;
+ &-name {
+ display: block;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ max-width: 80%;
+ }
+ img {
+ width: 15px;
+ margin-left: 5px;
+ }
+ }
+ }
+ &-video {
+ width: 50px;
+ height: 100%;
+ position: relative;
+ flex-shrink: 0;
+ &-close {
+ border-radius: 50%;
+ position: absolute;
+ right: -4px;
+ top: -4px;
+ background: red;
+ display: none;
+ justify-content: center;
+ align-items: center;
+ width: 15px;
+ height: 15px;
+ cursor: pointer;
+ }
+ &-play {
+ width: 100%;
+ height: 100%;
+ position: relative;
+ img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ border-radius: 4px;
+ }
+ &-click {
+ position: absolute;
+ display: none;
+ align-items: center;
+ justify-content: center;
+ border-radius: 50%;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ color: #fff;
+ font-size: 24px;
+ width: 30px;
+ height: 30px;
+ background: var(--colorPrimary5);
+ }
+ &:hover {
+ .videoChooseItem-video-play-click {
+ display: flex !important;
+ cursor: pointer;
+ }
+ }
+ }
+ }
+ }
+
+ .commonPubSetting {
+ text-align: left;
+ .ant-input-data-count {
+ bottom: 0;
+ }
+
+ h1 {
+ font-weight: 400;
+ font-size: var(--fs-lg);
+ margin-bottom: 5px;
+ }
+ h2 {
+ font-weight: 400;
+ font-size: var(--fs-md);
+ margin-bottom: 5px;
+ margin-top: 20px;
+ .anticon {
+ margin-left: 3px;
+ }
+ }
+ &-tip {
+ font-size: var(--fs-sm);
+ color: var(--grayColor7);
+ margin-top: 5px;
+ }
+ }
+ }
+}
+
diff --git a/src/app/[lng]/publish/videoPage/videoPage.d.ts b/src/app/[lng]/publish/videoPage/videoPage.d.ts
new file mode 100644
index 00000000..9cc85436
--- /dev/null
+++ b/src/app/[lng]/publish/videoPage/videoPage.d.ts
@@ -0,0 +1,112 @@
+import { SocialAccount } from "@/api/types/account.type";
+import { PlatType } from "@/app/config/platConfig";
+import { IImgFile } from "@/app/[lng]/publish/imagePage/imagePage.type";
+import { VisibleTypeEnum } from "@/app/config/publishConfig";
+import { IVideoFile } from "@/app/[lng]/publish/components/Choose/VideoChoose";
+
+// 微信视频号活动
+export interface WxSphEvent {
+ eventCreatorNickname: string;
+ eventTopicId: string;
+ eventName: string;
+}
+
+/**
+ * 不同平台的差异化参数
+ * 每个平台有相同点,有不同点,这不同点都在这个参数下集合
+ */
+export type DiffParmasType = {
+ [PlatType.Xhs]?: {};
+ [PlatType.Douyin]?: {
+ // 申请关联的热点
+ hotPoint?: ILableValue;
+ // 申请关联的活动
+ activitys?: ILableValue[];
+ // 自主声明
+ selfDeclare?: DeclarationDouyin;
+ };
+ [PlatType.WxSph]?: {
+ // 是否为原创
+ isOriginal?: boolean;
+ // 扩展链接
+ extLink?: string;
+ // 活动
+ activity?: WxSphEvent;
+ };
+ [PlatType.KWAI]?: {};
+};
+
+// 自主声明
+export enum DeclarationDouyin {
+ // 内容由AI生成
+ AIGC = "aigc",
+ // 可能会引人不适
+ MaybeUnsuitable = "maybe_unsuitable",
+ // 虚拟作品。仅供娱乐
+ OnlyFunNew = "only_fun_new",
+ // 危险行为,请勿模仿
+ DangerousBehavior = "dangerous_behavior",
+ // 内容自行拍摄
+ SelfShoot = "self_shoot",
+ // 内容取材网络
+ FromNetV3 = "from_net_v3",
+}
+
+// 包含一个name和一个value的对象
+export interface ILableValue {
+ label: string;
+ value: string | number;
+}
+
+// 地点数据
+export interface ILocationDataItem {
+ // 地点名称
+ name: string;
+ // 简单地址简介
+ simpleAddress: string;
+ // 地址ID
+ id: string;
+ // 小红书特有
+ poi_type?: number;
+ latitude: number;
+ longitude: number;
+ // 市
+ city: string;
+}
+
+export interface IPubParams {
+ // 视频标题
+ title?: string;
+ // 视频描述
+ describe?: string;
+ // 视频封面
+ cover?: IImgFile;
+ // 查看权限
+ visibleType?: VisibleTypeEnum;
+ // 视频话题
+ topics?: string[];
+ // 每个平台的差异性参数
+ diffParams?: DiffParmasType;
+ // 位置
+ location?: ILocationDataItem;
+ // 定时发布日期
+ timingTime?: Date;
+ // @用户
+ mentionedUserInfo?: ILableValue[];
+ // 合集
+ mixInfo?: ILableValue;
+}
+
+// 选择视频的每项数据
+export interface IVideoChooseItem {
+ // 选择的视频
+ video?: IVideoFile;
+ // 选择的账户
+ account?: SocialAccount;
+ // 发布参数
+ pubParams: IPubParams;
+ // 唯一id
+ id: string;
+}
+
+export type AccountInfo = SocialAccount;
diff --git a/src/app/[lng]/youtube/page.tsx b/src/app/[lng]/youtube/page.tsx
index 730c04d9..fc3b1a14 100644
--- a/src/app/[lng]/youtube/page.tsx
+++ b/src/app/[lng]/youtube/page.tsx
@@ -1,15 +1,24 @@
-'use client';
-
-import React, { useState } from 'react';
-import { useTransClient } from '@/app/i18n/client';
-import { Button, Input, message, Card, Upload } from 'antd';
-import { MailOutlined, YoutubeOutlined, CheckOutlined, UploadOutlined } from '@ant-design/icons';
-import { getYouTubeAuthUrlApi, checkYouTubeAuthApi, uploadYouTubeVideoApi } from '@/api/youtube';
-import styles from './youtube.module.css';
+"use client";
+
+import React, { useState } from "react";
+import { useTransClient } from "@/app/i18n/client";
+import { Button, Input, message, Card, Upload } from "antd";
+import {
+ MailOutlined,
+ YoutubeOutlined,
+ CheckOutlined,
+ UploadOutlined,
+} from "@ant-design/icons";
+import {
+ getYouTubeAuthUrlApi,
+ checkYouTubeAuthApi,
+ uploadYouTubeVideoApi,
+} 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);
@@ -17,7 +26,7 @@ const YouTubeAuth: React.FC = () => {
const handleCheck = async () => {
if (!email) {
- message.error(t('pleaseEnterEmail'));
+ message.error(t("pleaseEnterEmail"));
return;
}
@@ -26,13 +35,13 @@ const YouTubeAuth: React.FC = () => {
const response = await checkYouTubeAuthApi(email);
setIsAuthorized(response?.data?.authorized || false);
if (response?.data?.authorized) {
- message.success(t('alreadyAuthorized'));
+ message.success(t("alreadyAuthorized"));
} 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);
}
@@ -40,12 +49,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;
}
@@ -53,11 +62,11 @@ const YouTubeAuth: React.FC = () => {
try {
const response = await getYouTubeAuthUrlApi(email);
if (response?.data) {
- window.open(response.data, '_blank', 'noopener,noreferrer');
+ window.open(response.data, "_blank", "noopener,noreferrer");
}
} catch (error) {
- console.error('获取授权 URL 失败:', error);
- message.error(t('authFailed'));
+ console.error("获取授权 URL 失败:", error);
+ message.error(t("authFailed"));
} finally {
setLoading(false);
}
@@ -65,28 +74,28 @@ const YouTubeAuth: React.FC = () => {
const handleUpload = async (file: File) => {
if (!email) {
- message.error(t('pleaseEnterEmail'));
+ message.error(t("pleaseEnterEmail"));
return;
}
if (!isAuthorized) {
- message.error(t('notAuthorized'));
+ message.error(t("notAuthorized"));
return;
}
setUploadLoading(true);
try {
const formData = new FormData();
- formData.append('video', file);
- formData.append('email', email);
-
+ formData.append("video", file);
+ formData.append("email", email);
+
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);
}
@@ -95,24 +104,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"
@@ -121,7 +123,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} />}
@@ -137,7 +139,7 @@ const YouTubeAuth: React.FC = () => {
className={styles.checkButton}
icon={<CheckOutlined />}
>
- {t('checkAuth')}
+ {t("checkAuth")}
</Button>
<Button
@@ -148,7 +150,7 @@ const YouTubeAuth: React.FC = () => {
className={styles.button}
icon={<YoutubeOutlined />}
>
- {t('authorize')}
+ {t("authorize")}
</Button>
</div>
@@ -167,13 +169,11 @@ const YouTubeAuth: React.FC = () => {
icon={<UploadOutlined />}
disabled={!isAuthorized}
>
- {t('uploadVideo')}
+ {t("uploadVideo")}
</Button>
</Upload>
{!isAuthorized && (
- <p className={styles.uploadTip}>
- {t('needAuthFirst')}
- </p>
+ <p className={styles.uploadTip}>{t("needAuthFirst")}</p>
)}
</div>
</div>
@@ -182,4 +182,4 @@ const YouTubeAuth: React.FC = () => {
);
};
-export default YouTubeAuth;
\ No newline at end of file
+export default YouTubeAuth;
diff --git a/src/app/i18n/locales/zh-CN/youtube.json b/src/app/i18n/locales/zh-CN/youtube.json
index e838a38f..27727283 100644
--- a/src/app/i18n/locales/zh-CN/youtube.json
+++ b/src/app/i18n/locales/zh-CN/youtube.json
@@ -7,5 +7,6 @@
"pleaseEnterEmail": "请输入邮箱地址",
"invalidEmail": "请输入有效的邮箱地址",
"authFailed": "授权失败,请稍后重试",
- "checkAuth": "检查授权"
+ "checkAuth": "检查授权",
+ "notAuthorized": "未授权"
}
\ No newline at end of file
diff --git a/src/app/layout/layoutNav.tsx b/src/app/layout/layoutNav.tsx
index 2d5111af..a55132aa 100644
--- a/src/app/layout/layoutNav.tsx
+++ b/src/app/layout/layoutNav.tsx
@@ -26,10 +26,12 @@ function getNameTag(child: IRouterDataItem, iconLoca: number = 1) {
<>
{!child.children ? (
<Link href={path || "/"} target={path[0] === "/" ? "_self" : "_blank"}>
+ {/*@ts-ignore*/}
{t(child.translationKey)}
</Link>
) : (
<span>
+ {/*@ts-ignore*/}
{t(child.translationKey)}
{child.children &&
(iconLoca === 0 ? <UpOutlined /> : <RightOutlined />)}
@@ -211,9 +213,10 @@ function NavPE() {
const router = useRouter();
const { t } = useTransClient("route");
- const translatedMenuItems = peRouterData?.map(item => ({
+ const translatedMenuItems = peRouterData?.map((item) => ({
...item,
- label: t(item.key as string)
+ // @ts-ignore
+ label: t(item.key as string),
}));
return (
@@ -237,6 +240,7 @@ function NavPE() {
}}
style={{ width: "100%" }}
mode="inline"
+ // @ts-ignore
items={translatedMenuItems}
/>
</Drawer>
diff --git a/src/app/plat/plat.type.ts b/src/app/plat/plat.type.ts
index 12ab9a5f..1e3dee8d 100644
--- a/src/app/plat/plat.type.ts
+++ b/src/app/plat/plat.type.ts
@@ -1,5 +1,6 @@
// plat构造器参数
import { Cookie } from "undici-types";
+import { SocialAccount } from "@/api/types/account.type";
export interface IPlatConstrParams {
// cookie
@@ -7,3 +8,30 @@ export interface IPlatConstrParams {
// 代理
proxy?: string;
}
+
+export interface IMixItem {
+ id: string;
+ name: string;
+ coverImg: string;
+ // 作品数量
+ feedCount: number;
+}
+
+// 用户数据
+export interface IUsersItem {
+ image: string;
+ id: string;
+ name: string;
+ des?: string;
+ unique_id?: string;
+ follower_count?: number;
+}
+
+// 视频发布进度返回值
+export interface PublishProgressRes {
+ // 为 -1 表示失败
+ progress: number;
+ msg: string;
+ account: SocialAccount;
+ id: number;
+}
diff --git a/src/app/plat/platChildren/douyin/douyin.type.ts b/src/app/plat/platChildren/douyin/douyin.type.ts
new file mode 100644
index 00000000..9b445b57
--- /dev/null
+++ b/src/app/plat/platChildren/douyin/douyin.type.ts
@@ -0,0 +1,771 @@
+interface TopicSug {
+ cha_name: string;
+ view_count: number;
+ cid: string;
+ group_id: string;
+ tag: number;
+}
+
+interface WordsQueryRecord {
+ info: string;
+ words_source: string;
+ query_id: string;
+}
+
+interface Extra {
+ now: number;
+ logid: string;
+ fatal_item_ids: any[];
+ search_request_id: string;
+}
+
+interface LogPb {
+ impr_id: string;
+}
+
+interface AddressInfo {
+ ad_code_v2: string;
+ addr_with_extra_info: string;
+ address: string;
+ city: string;
+ city_code: string;
+ district: string;
+ im_addr: string;
+ province: string;
+ simple_addr: string;
+}
+
+interface Cover {
+ uri: string;
+ url_list: string[];
+}
+
+interface Icon {
+ uri: string;
+ url_list: string[];
+}
+
+interface LifeCommerceInfo {
+ simple_addr_str: string;
+}
+
+interface PoiBackendType {
+ code: string;
+ content: string;
+ l1_name: string;
+ l2_name: string;
+ l3_name: string;
+ name: string;
+}
+
+interface PoiFrontendType {
+ code: string;
+ name: string;
+}
+
+interface ShareInfo {
+ bool_persist: number;
+ share_title: string;
+ share_url: string;
+ share_weibo_desc: string;
+}
+
+interface Poi {
+ Staturated_tags: any;
+ address_info: AddressInfo;
+ anchor_post_ext: {
+ is_recommend: boolean;
+ };
+ business_area_name: string;
+ channel_exclusive: any;
+ collect_stat: number;
+ collected_count: string;
+ cost: number;
+ cover_hd: Cover;
+ cover_item: Cover;
+ cover_large: Cover;
+ cover_medium: Cover;
+ cover_thumb: Cover;
+ cps_commission_rate_range: any;
+ cps_commission_value_range: any;
+ distance: string;
+ effect_ids: string[];
+ expand_type: number;
+ fulfill_task_list: any;
+ icon_on_entry: Icon;
+ icon_on_info: Icon;
+ icon_on_map: Icon;
+ icon_service_type_list: any;
+ icon_type: number;
+ is_admin_area: boolean;
+ is_commerce_intention: boolean;
+ item_count: number;
+ life_commerce_info: LifeCommerceInfo;
+ poi_backend_type: PoiBackendType;
+ poi_detail_tags: any;
+ poi_frontend_type: PoiFrontendType[];
+ poi_id: string;
+ poi_latitude: number;
+ poi_latitude_gcj02: number;
+ poi_longitude: number;
+ poi_longitude_gcj02: number;
+ poi_name: string;
+ poi_ranks: any;
+ poi_search_tags: any;
+ poi_search_tags_v2: any;
+ poi_type: number;
+ poi_voucher: string;
+ service_type_list: any;
+ share_info: ShareInfo;
+ show_type: number;
+ simple_address_str: string;
+ type_code: string;
+ user_count: number;
+ view_count: string;
+ voucher_release_areas: any[];
+ with_recommend_tag: number;
+}
+
+interface ContentTab {
+ default_tab: number;
+ tab_list: number[];
+}
+
+interface GuideInfo {
+ guide_text_after: string;
+ guide_text_before: string;
+ guide_url: string;
+}
+
+interface DriftInfo {
+ score: number;
+ timestamp: number;
+}
+
+interface Cover {
+ uri: string;
+ url_list: string[];
+}
+
+export interface DouyinActivity {
+ 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;
+ display_style: number;
+ drift_info: DriftInfo[];
+ event_time: number;
+ group_id: string;
+ hot_value: number;
+ hotlist_param: string;
+ label: number;
+ related_words: any;
+ sentence_id: string;
+ video_count: number;
+ word: string;
+ word_cover: Cover;
+ word_sub_board: any;
+ 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;
+}
+
+interface DouyinUser {
+ avatar_larger: Avatar;
+ avatar_medium: Avatar;
+ avatar_thumb: Avatar;
+ aweme_count: number;
+ card_entries: any;
+ custom_verify: string;
+ enterprise_verify_reason: string;
+ favoriting_count: number;
+ follow_status: number;
+ follower_count: number;
+ follower_status: number;
+ followers_detail: any;
+ following_count: number;
+ geofencing: any;
+ has_orders: boolean;
+ is_ad_fake: boolean;
+ is_gov_media_vip: boolean;
+ mix_info: any;
+ nickname: string;
+ original_musician: OriginalMusician;
+ platform_sync_info: any;
+ policy_version: any;
+ rate: number;
+ region: string;
+ sec_uid: string;
+ secret: number;
+ short_id: string;
+ signature: string;
+ status: number;
+ story_open: boolean;
+ total_favorited: string;
+ type_label: any[];
+ uid: string;
+ unique_id: string;
+ user_canceled: boolean;
+ verification_type: number;
+ video_icon: VideoIcon;
+ with_commerce_entry: boolean;
+ with_fusion_shop_entry: boolean;
+ with_shop_entry: boolean;
+}
+
+interface Avatar {
+ uri: string;
+ url_list: string[];
+}
+
+interface OriginalMusician {
+ music_count: number;
+ music_used_count: number;
+}
+
+interface VideoIcon {
+ uri: string;
+ url_list: 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[];
+}
+
+// 抖音活动标签item
+export interface DouyinQueryTags {
+ id: number;
+ name: string;
+}
+
+// 抖音活动标签返回数据
+export interface DouyinActivityTagsResponse {
+ status_code: number;
+ extra: Extra;
+ query_tags: DouyinQueryTags[];
+}
+
+// 抖音活动列表
+export interface DouyinActivityListResponse {
+ activity_list: DouyinActivity[];
+ extra: Extra;
+ status_code: number;
+}
+
+// 抖音的热点数据
+export interface DouyinHotDataResponse {
+ extra: Extra;
+ log_pb: LogPb;
+ sentences: DouyinHotSentence[];
+ status_code: number;
+}
+
+// 抖音的所有热点数据
+export interface DouyinAllHotDataResponse {
+ extra: Extra;
+ log_pb: LogPb;
+ all_sentences: DouyinHotSentence[];
+ status_code: number;
+}
+
+// 抖音的话题数据
+export interface DouyinTopicsSugResponse {
+ sug_list: TopicSug[];
+ status_code: number;
+ status_msg: string;
+ rid: string;
+ words_query_record: WordsQueryRecord;
+ extra: Extra;
+ log_pb: LogPb;
+}
+
+// 抖音的位置数据
+export interface DouyinLocationDataResponse {
+ ab_param_extra: string;
+ content_tab: ContentTab;
+ current_locs: any[];
+ extra: Extra;
+ guide_info: GuideInfo;
+ has_keyuser_combo_entrance: boolean;
+ has_more: number;
+ has_promote_auth: boolean;
+ log_pb: LogPb;
+ page: number;
+ poi_activity: any;
+ poi_list: Poi[];
+ poi_search_range: number[];
+ post_role: number;
+ show_filter_option: boolean;
+ show_guide: boolean;
+ show_new_merchant_guide: boolean;
+ status_code: number;
+ status_msg: string;
+ user_interest_city_code_list: any;
+}
+
+// 抖音用户数据
+export interface DouyinUserListResponse {
+ challenge_list: any[];
+ cursor: number;
+ extra: Extra;
+ has_more: boolean;
+ scene: number;
+ status_code: number;
+ user_list: DouyinUser[];
+}
+
+// 抖音作品列表
+export interface DouyinCreatorListResponse {
+ extra: Extra;
+ status_code: number; // 0
+ status_msg: string;
+ has_more: boolean;
+ item_info_list: {
+ anchor_user_id: string;
+ cursor: string;
+ comment_count: number; // 回复数量
+ cover_image_url: string; // 'https://p3-sign.douyinpic.com/c5d200033ae82940b280~tplv-dy-resize-walign-adapt-aq:540:q75.jpeg?lk3s=138a59ce&x-expires=1742889600&x-signature=jcYpgxENZDa38hHUHNFfpcAPUDs%3D&from=327834062&s=PackSourceEnum_PUBLISH&se=false&sc=cover&biz_tag=aweme_video&l=20250311165957E85797DDC3B0DA04AEBA';
+ create_time: string; // '发布于2018年09月23日 17:51';
+ creator_item_setting: {
+ charge_comment_audit: boolean; // 收费评论审计
+ };
+ duration: number;
+ item_id: string; // '@j/do779EQE//uctS8r3tvsx9pyuRYyn/J6krPKNgjq9hkia+W5A7RJEoPQpq6PZlQedr6LX3XaKU0Yc8jcykog==';
+ item_id_plain: string; // '6604355150884637966';
+ item_link: string; // 'https://www.iesdouyin.com/share/video/6604355150884637966/?region=CN&mid=6568746752824380174&u_code=16b4ji55k&did=MS4wLjABAAAANwkJuWIRFOzg5uCpDRpMj4OX-QryoDgn-yYlXQnRwQQ&iid=MS4wLjABAAAANwkJuWIRFOzg5uCpDRpMj4OX-QryoDgn-yYlXQnRwQQ&with_sec_did=1&video_share_track_ver=&titleType=&share_sign=qwbHwbUn9.rqVOBIpmIak8F4W9CXvvE18GzpMaAUfyU-&share_version=210100&ts=1741683597&from_aid=1128&from_ssr=1';
+ media_type: number; // 4;
+ title: string; // '';
+ }[];
+ total_count: number;
+}
+
+// 抖音作品评论列表
+export interface DouyinCreatorCommentListResponse {
+ comment_info_list: {
+ comment_id: string; // '@j/do779EQE//uctS8rzvtsh7oymVZyz/K6UlPqVrj61hkia+W5A7RJEoPQpq6PZl0KYgJ8TOofuQDOgXI12wCA==';
+ create_time: string; // '1741694473';
+ digg_count: string; // '0';
+ followed: boolean; // false;
+ following: boolean; // false;
+ is_author: boolean; // true;
+ level: number; // 1;
+ reply_count: string; // '0';
+ reply_to_user_info: {
+ avatar_url: string; // '';
+ screen_name: string; // '';
+ user_id: string; // '@j/do779EQE//uctS8rvZjLtLqeE8MOypT/Xro3hVZaE=';
+ };
+ status: number; // 1;
+ text: string; // '不知道在哪里学的';
+ user_bury: boolean; // false;
+ user_digg: boolean; // false;
+ user_info: {
+ avatar_url: string; // 'https://p3.douyinpic.com/aweme/100x100/aweme-avatar/mosaic-legacy_9bae0021f45bb7d411b0.jpeg?from=2956013662';
+ screen_name: string; // '沐墨人';
+ user_id: string; // '@j/do779EQE//uctS8rrrvst3qyiRYCHwJpoaCJNev56Vc+YwAlekyGOU0vO5C292';
+ };
+ }[];
+ cursor: number; // 3;
+ extra: { now: number }; // 1741874549000 };
+ has_more: boolean; // false;
+ has_vcd_filter: boolean; // false;
+ status_code: number; // 0;
+ status_msg: string; // '';
+ total_count: number; // 3;
+}
+
+// 抖音评论回复列表
+export interface DouyinCommentReplyListResponse {
+ status_code: 0;
+ comments: {
+ cid: string; // '7484226055910605622';
+ text: string; // ''哈哈哈,[捂脸],留不长,发质太差了';
+ aweme_id: string; // ''7484154434176568630';
+ create_time: number; // 1742557174;
+ digg_count: number; // 0;
+ status: number; // 1;
+ user: {
+ uid: string; // ''153519948306846';
+ short_id: string; // ''2308542007';
+ nickname: string; // ''海宝💃';
+ signature: string; // ''';
+ avatar_larger: {
+ uri: string; // ''';
+ url_list: string[]; // [];
+ width: number; // 720;
+ height: number; // 720;
+ };
+ avatar_thumb: {
+ uri: string; // ''100x100/aweme-avatar/tos-cn-i-0813c001_oUDEAA5qhfAx5dAgIewzNvptBoNAuByobAvNC1';
+ url_list: string[]; // 'https://p3.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-i-0813c001_oUDEAA5qhfAx5dAgIewzNvptBoNAuByobAvNC1.jpeg?from=2956013662',
+ width: number; // 720;
+ height: number; // 720;
+ };
+ avatar_medium: {
+ uri: string; // '720x720/aweme-avatar/tos-cn-i-0813c001_oUDEAA5qhfAx5dAgIewzNvptBoNAuByobAvNC1';
+ url_list: string[]; // 'https://p3.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-i-0813c001_oUDEAA5qhfAx5dAgIewzNvptBoNAuByobAvNC1.jpeg?from=2956013662',
+ width: number; // 720;
+ height: number; // 720;
+ };
+ is_verified: boolean; // true;
+ follow_status: number; // 0;
+ aweme_count: number; // 0;
+ following_count: number; // 0;
+ follower_count: number; // 0;
+ favoriting_count: number; // 0;
+ total_favorited: number; // 0;
+ is_block: boolean; // false;
+ hide_search: boolean; // true;
+ constellation: number; // 9;
+ location: string; // '';
+ hide_location: boolean; // false;
+ weibo_verify: string; // '';
+ custom_verify: string; // '';
+ unique_id: string; // 'dyehawbhyehm';
+ bind_phone: string; // '';
+ special_lock: number; // 1;
+ need_recommend: number; // 1;
+ is_binded_weibo: boolean; // false;
+ weibo_name: string; // '';
+ weibo_schema: string; // '';
+ weibo_url: string; // '';
+ story_open: boolean; // false;
+ story_count: number; // 0;
+ has_facebook_token: boolean; // false;
+ has_twitter_token: boolean; // false;
+ fb_expire_time: number; // 0;
+ tw_expire_time: number; // 0;
+ has_youtube_token: boolean; // false;
+ youtube_expire_time: number; // 0;
+ room_id: number; // 0;
+ live_verify: number; // 2;
+ authority_status: number; // 0;
+ verify_info: string; // '';
+ shield_follow_notice: number; // 0;
+ shield_digg_notice: number; // 0;
+ shield_comment_notice: number; // 0;
+ school_name: string; // '';
+ school_poi_id: string; // '';
+ school_type: number; // 0;
+ with_commerce_entry: boolean; // false;
+ verification_type: number; // 1;
+ enterprise_verify_reason: string; // '';
+ is_ad_fake: boolean; // false;
+ followers_detail: null;
+ region: string; // 'CN';
+ account_region: string; // '';
+ sync_to_toutiao: number; // 0;
+ live_agreement: number; // 0;
+ platform_sync_info: null;
+ with_shop_entry: boolean; // false;
+ secret: number; // 0;
+ has_orders: boolean; // true;
+ prevent_download: boolean; // false;
+ show_image_bubble: boolean; // false;
+ geofencing: any[]; // [];
+ unique_id_modify_time: number; // 1742631181;
+ video_icon: {
+ uri: string; // '';
+ url_list: string[];
+ width: number; // 720;
+ height: number; // 720;
+ };
+ ins_id: string; // '';
+ google_account: string; // '';
+ youtube_channel_id: string; // '';
+ youtube_channel_title: string; // '';
+ apple_account: number; // 0;
+ with_dou_entry: boolean; // false;
+ with_fusion_shop_entry: boolean; // false;
+ is_phone_binded: boolean; // false;
+ accept_private_policy: boolean; // false;
+ twitter_id: string; // '';
+ twitter_name: string; // '';
+ user_canceled: boolean; // false;
+ has_email: boolean; // false;
+ is_gov_media_vip: boolean; // false;
+ live_agreement_time: number; // 0;
+ status: number; // 1;
+ avatar_uri: string; // 'aweme-avatar/tos-cn-i-0813c001_oUDEAA5qhfAx5dAgIewzNvptBoNAuByobAvNC1';
+ follower_status: number; // 0;
+ neiguang_shield: number; // 0;
+ comment_setting: number; // 0;
+ duet_setting: number; // 0;
+ reflow_page_gid: number; // 0;
+ reflow_page_uid: number; // 0;
+ user_rate: number; // 1;
+ download_setting: number; // -1;
+ download_prompt_ts: number; // 0;
+ react_setting: number; // 0;
+ live_commerce: boolean; // false;
+ cover_url: string[]; // [];
+ show_gender_strategy: number; // 0;
+ language: string; // 'zh-Hans';
+ has_insights: boolean; // false;
+ item_list: null;
+ user_mode: number; // 0;
+ user_period: number; // 0;
+ has_unread_story: boolean; // false;
+ new_story_cover: null;
+ is_star: boolean; // false;
+ cv_level: string; // '';
+ type_label: any; // null;
+ ad_cover_url: any; // null;
+ comment_filter_status: number; // 0;
+ avatar_168x168: {
+ uri: string; // '';
+ url_list: string[]; // [];
+ width: number; // 720;
+ height: number; // 720;
+ };
+ avatar_300x300: {
+ uri: string; // '';
+ url_list: string[]; //[];
+ width: number; // 720;
+ height: number; // 720;
+ };
+ relative_users: any; // null;
+ cha_list: any; // null;
+ sec_uid: string; // 'MS4wLjABAAAAh24q23iMa0OxvuFitRcT13v6lQJpYWVp7TEZGcuX908';
+ urge_detail: {
+ user_urged: number; // 0;
+ };
+ need_points: any; // null;
+ homepage_bottom_toast: any; // null;
+ can_set_geofencing: any; // null;
+ room_id_str: string; // '0';
+ white_cover_url: any; // null;
+ user_tags: any; // null;
+ stitch_setting: number; // 0;
+ is_mix_user: boolean; // false;
+ enable_nearby_visible: boolean; // true;
+ ban_user_functions: any[]; // [];
+ aweme_control: {
+ can_forward: boolean; // true;
+ can_share: boolean; // true;
+ can_comment: boolean; // true;
+ can_show_comment: boolean; // true;
+ };
+ user_not_show: number; // 1;
+ ky_only_predict: number; // 0;
+ user_not_see: number; // 0;
+ card_entries: any; // null;
+ signature_display_lines: number; // 5;
+ display_info: any; // null;
+ follower_request_status: number; // 0;
+ live_status: number; // 0;
+ is_not_show: boolean; // false;
+ card_entries_not_display: any; // null;
+ card_sort_priority: any; // null;
+ show_nearby_active: boolean; // false;
+ interest_tags: any; // null;
+ school_category: number; // 0;
+ search_impr: {
+ entity_id: string; // '153519948306846';
+ };
+ link_item_list: any; // null;
+ user_permissions: any; // null;
+ offline_info_list: any; // null;
+ is_cf: number; // 0;
+ is_blocking_v2: boolean; // false;
+ is_blocked_v2: boolean; // false;
+ close_friend_type: number; // 0;
+ signature_extra: any; // null;
+ max_follower_count: number; // 0;
+ personal_tag_list: any; // null;
+ cf_list: any; // null;
+ im_role_ids: any; // null;
+ not_seen_item_id_list: any; // null;
+ user_age: number; // 32;
+ contacts_status: number; // 1;
+ risk_notice_text: string; // '';
+ follower_list_secondary_information_struct: any; // null;
+ endorsement_info_list: any; // null;
+ text_extra: any; // null;
+ contrail_list: any; // null;
+ data_label_list: any; // null;
+ not_seen_item_id_list_v2: any; // null;
+ is_ban: boolean; // false;
+ special_people_labels: any; // null;
+ special_follow_status: number; // 0;
+ familiar_visitor_user: any; // null;
+ live_high_value: number; // 0;
+ avatar_schema_list: any; // null;
+ profile_mob_params: any; // null;
+ disable_image_comment_saved: number; // 0;
+ verification_permission_ids: any; // null;
+ batch_unfollow_relation_desc: any; // null;
+ batch_unfollow_contain_tabs: any; // null;
+ creator_tag_list: any; // null;
+ private_relation_list: any; // null;
+ mate_add_permission: number; // 0;
+ familiar_confidence: number; // 0;
+ mate_count: number; // 0;
+ follower_count_str: string; // '';
+ social_real_relation_type: number; // 0;
+ };
+ reply_id: string; // '7484209708376032050';
+ user_digged: number; // 0;
+ reply_comment: any; // null;
+ text_extra: string[];
+ label_text: string; // '作者';
+ label_type: number; // 1;
+ reply_to_reply_id: string; // '0';
+ is_author_digged: boolean; // false;
+ user_buried: boolean; // false;
+ label_list: any; // null;
+ is_hot: boolean; // false;
+ text_music_info: any; // null;
+ image_list: any; // null;
+ is_note_comment: number; // 0;
+ root_comment_id: string; // '7484226055910605622';
+ can_share: boolean; // true;
+ level: number; // 2;
+ comment_reply_total: number; // 1;
+ video_list: any; // null;
+ content_type: number; // 1;
+ is_folded: boolean; // false;
+ }[];
+ cursor: number; // 10;
+ has_more: number; // 0;
+ total: number; // 1;
+ extra: {
+ now: number; // 1742631181000;
+ fatal_item_ids: any; // null;
+ };
+ log_pb: {
+ impr_id: string; // '20250322161300615408A9FEC29A97BD28';
+ };
+}
+
+export interface DouyinNewCommentResponse {
+ comment_info: {
+ comment_id: string; // '@j/Jr6bdET0rxssxd57/to896qi+WZSz3LqQlN6Nuja9BugWjRo0mWYw1IBd39et4ggwDVwRptqsgeUQSJiFcAg==';
+ create_time: string; // '1741955069';
+ digg_count: string; // '0';
+ followed: boolean; // false;
+ following: boolean; // false;
+ is_author: boolean; // true;
+ level: number; // 1 | 2; // 第几层
+ reply_count: string; // '0';
+ status: number; // 7;
+ text: string; // '天真蓝';
+ user_digg: boolean; // false;
+ user_info: {
+ avatar_url: string; // 'https://p11.douyinpic.com/aweme/720x720/aweme-avatar/tos-cn-i-0813c001_oUDEAA5qhfAx5dAgIewzNvptBoNAuByobAvNC1.jpeg?from=4010531038';
+ screen_name: string; // '海宝💃';
+ user_id: string; // '@j/Jr6bdET0rxssxd57/to8l7oSuRbyDzJ64tOaxtjpj2c9bt4zgRjBU4l2s/OnM0';
+ };
+ };
+ extra: {
+ now: number; // 1741955069000;
+ };
+ status_code: number; // 0;
+ status_msg: string; // '';
+}
+
+// 合集数据
+export interface DouyinGetMixListResponse {
+ total: number;
+ status_code: number;
+ mix_list: {
+ author: DouyinUser;
+ cover_url: {
+ uri: string;
+ url_list: string[];
+ };
+ statis: {
+ collect_vv: number;
+ current_episode: number;
+ play_vv: number;
+ updated_to_episode: number;
+ };
+ status: {
+ is_collected: number;
+ status: number;
+ };
+ mix_name: string;
+ mix_id: string;
+ ban_episode_count: number;
+ }[];
+}
diff --git a/src/app/plat/platChildren/kwai/kwai.type.ts b/src/app/plat/platChildren/kwai/kwai.type.ts
new file mode 100644
index 00000000..e69de29b
diff --git a/src/app/plat/platChildren/wxSph/wxShp.type.ts b/src/app/plat/platChildren/wxSph/wxShp.type.ts
new file mode 100644
index 00000000..63347b91
--- /dev/null
+++ b/src/app/plat/platChildren/wxSph/wxShp.type.ts
@@ -0,0 +1,214 @@
+interface Location {
+ longitude: number;
+ latitude: number;
+ country: string;
+ countryCode: string;
+ province: string;
+ city: string;
+ region: string;
+ poiCheckSum: string;
+}
+
+interface POI {
+ uid: string;
+ name: string;
+ longitude: number;
+ latitude: number;
+ address: string;
+ province: string;
+ city: string;
+ region: string;
+ fullAddress: string;
+ source: number;
+ poiCheckSum: string;
+}
+
+interface Data {
+ eventList: WxSphEventList[];
+ lastBuff: string;
+ continueFlag: boolean;
+}
+
+export interface WxSphEventList {
+ eventTopicId: string;
+ eventName: string;
+ eventCreatorNickname: string;
+}
+
+export interface WeChatVideoApiResponse {
+ errCode: number;
+ errMsg: string;
+ data: Data;
+}
+
+export interface WeChatLocationData {
+ errCode: number;
+ errMsg: string;
+ data: {
+ list: POI[];
+ cookies: string;
+ address: Location;
+ continueFlag: number;
+ };
+}
+
+interface WeChatVideoUser {
+ username: string;
+ headImgUrl: string;
+ nickName: string;
+ authImgUrl: string;
+ authCompanyName: string;
+}
+
+export interface WeChatVideoUserData {
+ errCode: number;
+ errMsg: string;
+ data: {
+ list: WeChatVideoUser[];
+ totalCount: number;
+ };
+}
+
+export interface SphGetPostListResponse {
+ errCode: number; // 0;
+ errMsg: string; // 'request successful';
+ data: {
+ list: {
+ commentList: any[]; // []
+ objectId: string; //'export/UzFfAgtgekIEAQAAAAAAOhIpzVxlAQAAAAstQy6ubaLX4KHWvLEZgBPExKFQKCowfoSJzNPgMJrD53jJrD_NBzgU3Ncr3usg';
+ createTime: number; // 1741695600;
+ likeCount: number; // 0;
+ commentCount: number; // 2;
+ readCount: number; // 179;
+ forwardCount: number; // 0;
+ favCount: number; // 1;
+ commentClose: number; // 0;
+ visibleType: number; // 1;
+ status: number; // 1;
+ desc: {
+ media: {
+ spec: any[];
+ url: string; // 'https://finder.video.qq.com/251/20302/stodownload?encfilekey=Cvvj5Ix3eewK0tHtibORqcsqchXNh0Gf3sJcaYqC2rQDU5W1jYgILickxkJbjKjCA0skc49CeUbEks0sibuZiaibwQtatVH36DrA4RMiahjHkvAnuexRR8PIU1aUV21WSwOPRd&token=Cvvj5Ix3eewUo13ia09jtLw4nzPEZ0ias6WossfHM76uPFlClLIfTfsFxHS4QJJg4M52GoRJJVV1apGUpUDXaL1XrLckI8PmvWrNpyzDp5Kkpmdjaibb8VLdpj9tlO1icudZ9rgSqhevAB8OxZjUr5UNTk75rEDAv9cADibb2Wx3cGyyTRAjPdUs679Mho6aAkV7r&idx=1&bizid=1023&dotrans=0&hy=SH&m=&uzid=1&web=1';
+ thumbUrl: string; // 'https://finder.video.qq.com/251/20304/stodownload?encfilekey=S7s6ianIic0ia4PicKJSfB8EjyjpQibPUAXolPZYpiae6M5FCeWvaib76vAJ6gaDiazGwGHqGF3FfswaNmyszKNzIlo7mOFB4PqcVll7iasQMzLYL7N6GicD6zcfOGww&token=o3K9JoTic9IhZNy9rvFF19YdS0Ej1KlFbPdgZw0k4Xicia8hcnPcxYp5eGVTBeNQ4ZAgoxjlhjjKHaxzg1dib7FAPEQuXvLHdaZuLj91kArMIT8cXmIBHuJY6Zk8HVW0dcyzemUOccm3en5nQ3dwIed3uc2AcezIozkgPDe5pre0tjAwDrtPoTeCVQ&idx=1&bizid=1023&dotrans=0&hy=SH&m=&uzid=1';
+ mediaType: number; // 4;
+ videoPlayLen: number; // 17;
+ width: number; // 720;
+ height: number; // 1280;
+ md5sum: string; // '6bc1da4fb3224c28c19e9dfd1e077c19';
+ fileSize: string; // '10132537';
+ bitrate: number; // 4613120;
+ coverUrl: string; // 'https://finder.video.qq.com/251/20304/stodownload?encfilekey=rjD5jyTuFrIpZ2ibE8T7YmwgiahniaXswqzmBbTGWBbgZKiaUl56F8wcYSPDRlQqZmtSct3JYHtJHl0Eal0qkCbP2NEFkepZYeh5VnibDXhuvE7dy0jCNa96ZVw&token=2lt8WBSnjTmtsqoH1VcEvDTFaR2SnFUYmDhrIsRVhu6HhdyGOls5ibYXnWXqib9bcXvehgEic5JO6RP96bG3P6WPyyHe5VEyg54PrM6WP4sRqLtNkIUzNAHicc6xmwL8UOtwyeq37Lcf3ic1icMibSXKc6g2ZOZXgdnyE9diaKt3WazBHMRD8c0icInmtOQ&idx=1&hy=SH&m=&scene=2';
+ fullThumbUrl: string; // '';
+ fullUrl: string; // '';
+ fullWidth: number; // 0;
+ fullHeight: number; // 0;
+ fullMd5sum: string; // '';
+ fullFileSize: string; // '0';
+ fullBitrate: number; // 0;
+ halfRect: any; // {};
+ fullCoverUrl: string; // 'https://finder.video.qq.com/251/20304/stodownload?encfilekey=rjD5jyTuFrIpZ2ibE8T7YmwgiahniaXswqzmBbTGWBbgZKiaUl56F8wcYSPDRlQqZmtSct3JYHtJHl0Eal0qkCbP2NEFkepZYeh5VnibDXhuvE7dy0jCNa96ZVw&token=o3K9JoTic9IhZNy9rvFF19exicGwXO43K38lOWeKkiaONWmIf7iaZlVef8hOBfFvB1f6yUJruuNI2EEFicrRfIOgYEh9v7MQ58ibMLbQxDN56eL7T2c8BtKAVmUib3pKGU87JmPjfR9jpnSXSPibsc9PaznwHyNJfldyhQ3Tn6z7V1b1RAWKjHpq27UI2Q&idx=1&hy=SH&m=&scene=2';
+ cardShowStyle: number; // 0;
+ }[];
+ mentionedMusics: any[];
+ shortTitle: {
+ shortTitle: string; // '我家的干饭宝宝';
+ }[];
+ description: string; // '#干饭宝宝';
+ mediaType: number; // 4;
+ location: {
+ longitude: number; // 117.07821655273438;
+ latitude: number; // 39.982460021972656;
+ city: string; // '廊坊市';
+ poiClassifyId: string; // '';
+ };
+ extReading: any; // {};
+ topic: any; // {};
+ feedLocation: any; // {};
+ event: {
+ eventTopicId: string; // '';
+ eventName: string; // '';
+ eventCreatorNickname: string; // '';
+ eventAttendCount: number; // 0;
+ };
+ audio: any; // {};
+ member: any; // {};
+ finderNewlifeDesc: any; // {};
+ };
+ objectType: number; // 0;
+ attachList: { attachments: any[] };
+ flag: number; // 0;
+ objectNonce: string; // '12188256280973362673';
+ permissionFlag: number; // 0;
+ canSetOriginalsoundTitle: true;
+ fullPlayRate: number; // 0.0782122905027933;
+ avgPlayTimeSec: number; // 6.877094972067039;
+ disableInfo: { isDisabled: false };
+ showOriginal: false;
+ exportId: string; // 'export/UzFfAgtgekIEAQAAAAAAOhIpzVxlAQAAAAstQy6ubaLX4KHWvLEZgBPExKFQKCowfoSJzNPgMJrD53jJrD_NBzgU3Ncr3usg';
+ ringsetCount: number; // 0;
+ snscoverCount: number; // 0;
+ statusrefCount: number; // 0;
+ forwardAggregationCount: number; // 0;
+ originalInfo: {
+ auditOriginalFlag: number; // 0;
+ isDeclared: number; // 0;
+ isOriginalUpgrad: number; // 0;
+ };
+ followCount: number; // 1;
+ fastFlipRate: number; // 0.49162011173184356;
+ forwardSnsCount: number; // 0;
+ forwardAllChatCount: number; // 0;
+ argsInfo: {
+ poiCheckSum: string; // '99b069319e6b279e8aff6ec656879f25' };
+ }[];
+ yesterdayReadCount: number; // 143
+ }[];
+ bindInfo: any[];
+ totalCount: number;
+ };
+}
+
+export interface CommentInfo {
+ levelTwoComment: CommentInfo[]; // 二级评论
+ commentId: string; // '14610404657143548189';
+ commentNickname: string; // '义务之后是金钱';
+ commentContent: string; // '可爱吧';
+ commentHeadurl: string; // 'http://wx.qlogo.cn/finderhead/Q3auHgzwzM5OEKzc5UdzOUJUbOsaCtSkcCctCb9ddrCKiag4ZibQ73oA/0';
+ commentCreatetime: string; // '1741695959';
+ commentLikeCount: number; // 0;
+ lastBuff: string; // '';
+ downContinueFlag: number; // 0;
+ visibleFlag: number; // 0;
+ readFlag: true;
+ displayFlag: number; // 514;
+ blacklistFlag: number; // 0;
+ likeFlag: number; // 0;
+ replyCommentId?: string; // '14610404657143548189';
+ replyContent?: string; // '可爱吧';
+}
+
+export interface SphGetCommentListResponse {
+ errCode: number;
+ errMsg: string;
+ data: {
+ comment: CommentInfo[];
+ lastBuff: string; // 'AATVfYAEAAABAAAAAADWiCo0vu4ltcc8lXzRZyAAAADzrBEppsryM1QLZ+dDmBLm9XwcA0exd+eEMM5e+lsrR+oHHo2NIZY18J6IkJAbntQxZiEBkXZ24Y1hrnqW334ItvllglnXoA==',
+ commentCount: number; // 2;
+ downContinueFlag: number; // 0;
+ };
+}
+
+// 微信视频号的合集
+export interface WxSPHGetMixListResponse {
+ errCode: number;
+ data: {
+ collectionList: {
+ id: string;
+ name: string;
+ desc: string;
+ coverImgUrl?: string;
+ feedCount: number;
+ }[];
+ collectionListCount: number;
+ };
+}
diff --git a/src/store/bellMessageStroe.ts b/src/store/bellMessageStroe.ts
new file mode 100644
index 00000000..82ff1564
--- /dev/null
+++ b/src/store/bellMessageStroe.ts
@@ -0,0 +1,77 @@
+import { create } from "zustand";
+import { combine } from "zustand/middleware";
+import lodash from "lodash";
+// import { PublishProgressRes } from "../../electron/main/plat/pub/PubItemVideo";
+// import { onVideoPublishProgress } from "../icp/receiveMsg";
+import { PubStatus } from "@/app/config/publishConfig";
+
+export interface NoticeItem {
+ title: string;
+ time: Date;
+ // 以下为不同类型通知独有的字段
+ // 发布
+ pub?: {
+ // 发布状态
+ status: PubStatus;
+ // TODO 发布记录进度类型
+ // progressList: PublishProgressRes[];
+ progressList: any[];
+ };
+ id: string | number;
+}
+
+export enum NoticeType {
+ // 发布通知
+ PubNotice = "1",
+}
+
+export interface IBellMessageStroe {
+ noticeMap: Map<NoticeType, NoticeItem[]>;
+}
+
+const store: IBellMessageStroe = {
+ noticeMap: new Map<NoticeType, NoticeItem[]>(),
+};
+
+const getStore = () => {
+ return lodash.cloneDeep(store);
+};
+
+// 视频发布所有组件的共享状态和方法
+export const useBellMessageStroe = create(
+ combine(
+ {
+ ...getStore(),
+ },
+ (set, get, storeApi) => {
+ const methods = {
+ // 添加数据
+ addNotice(type: NoticeType, data: NoticeItem[]) {
+ const noticeMap = new Map(get().noticeMap);
+ noticeMap.set(type, data);
+
+ set({ noticeMap });
+ },
+
+ // 发布进度监听
+ videoPublishProgressInit() {
+ // onVideoPublishProgress((progressData) => {
+ // const noticeMap = new Map(get().noticeMap);
+ // const noticeList = noticeMap.get(NoticeType.PubNotice) || [];
+ // const noticeItem = noticeList.find((v) => v.id === progressData.id);
+ //
+ // noticeItem?.pub?.progressList.find((v, i) => {
+ // if (v.account.id === progressData.account.id) {
+ // noticeItem!.pub!.progressList[i] = progressData;
+ // return true;
+ // }
+ // });
+ //
+ // set({ noticeMap });
+ // });
+ },
+ };
+ return methods;
+ },
+ ),
+);
diff --git a/src/store/commont.ts b/src/store/commont.ts
new file mode 100644
index 00000000..ea602776
--- /dev/null
+++ b/src/store/commont.ts
@@ -0,0 +1,31 @@
+import { create } from "zustand";
+import { combine } from "zustand/middleware";
+import { NotificationInstance } from "antd/es/notification/interface";
+
+export interface ICommontStore {
+ // 全局通知api
+ notification?: NotificationInstance;
+}
+
+const store: ICommontStore = {
+ notification: undefined,
+};
+
+// 项目中的通用的、全局的状态和方法
+export const useCommontStore = create(
+ combine(
+ {
+ ...store,
+ },
+ (set, get, storeApi) => {
+ const methods = {
+ setNotification(notification: NotificationInstance) {
+ set({
+ notification,
+ });
+ },
+ };
+ return methods;
+ },
+ ),
+);
diff --git a/src/store/system.ts b/src/store/system.ts
new file mode 100644
index 00000000..df7521dc
--- /dev/null
+++ b/src/store/system.ts
@@ -0,0 +1,30 @@
+import { createPersistStore } from "@/utils/createPersistStore";
+
+export interface ISystemStore {
+ // 视频发布是否开启填写更多参数
+ moreParamsOpen: boolean;
+}
+
+const state: ISystemStore = {
+ moreParamsOpen: false,
+};
+
+export const useSystemStore = createPersistStore(
+ {
+ ...state,
+ },
+ (set, _get) => {
+ const methods = {
+ setMoreParamsOpen(moreParamsOpen: boolean) {
+ set({
+ moreParamsOpen,
+ });
+ },
+ };
+
+ return methods;
+ },
+ {
+ name: "System",
+ },
+);
diff --git a/src/types/publish.ts b/src/types/publish.ts
deleted file mode 100644
index b37d5ef8..00000000
--- a/src/types/publish.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-export enum PubType {
- VIDEO = "video", // 视频
- ARTICLE = "article", // 文章
- IMAGE_TEXT = "image-text", // 图文
-}
-
-export enum PubStatus {
- UNPUBLISH = 0, // 未发布/草稿
- RELEASED = 1, // 已发布
- FAIL = 2, // 发布失败
- PART_SUCCESS = 3, // 部分成功
-}
-
-export type PublishType = `${PubType}`;
-export type PublishStatus = `${PubStatus}`;
diff --git a/src/utils/index.ts b/src/utils/index.ts
new file mode 100644
index 00000000..fbbf5d20
--- /dev/null
+++ b/src/utils/index.ts
@@ -0,0 +1,121 @@
+import dayjs from "dayjs";
+import { message } from "antd";
+/**
+ * 生成唯一ID
+ */
+export function generateUUID(): string {
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
+ const r = (Math.random() * 16) | 0;
+ const v = c === "x" ? r : (r & 0x3) | 0x8;
+ return v.toString(16);
+ });
+}
+
+// 等待n毫秒
+export function sleep(ms: number) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+}
+
+// 获取文件路径中的文件名和后缀
+export const getFilePathName = (path: string) => {
+ if (!path)
+ return {
+ filename: "",
+ suffix: "",
+ };
+ const path1 = path.split("\\")[path.split("\\").length - 1];
+ const filename = path1.split("/")[path1.split("/").length - 1];
+ return {
+ filename,
+ suffix: filename.split(".")[filename.split(".").length - 1],
+ };
+};
+
+// 格式化时间
+export function formatTime(
+ time: string | number | Date,
+ format: string = "YYYY-MM-DD HH:mm:ss",
+) {
+ return dayjs(time).format(format);
+}
+
+/**
+ * 将数值转换为 hh:mm:ss 格式的字符串
+ * 7 -> 00:00:07
+ * @param seconds - 要转换的秒数
+ * @returns 格式化后的时间字符串
+ */
+export function formatSeconds(seconds: number): string {
+ const hours = Math.floor(seconds / 3600);
+ const minutes = Math.floor((seconds % 3600) / 60);
+ const secs = seconds % 60;
+
+ const pad = (num: number) => num.toString().padStart(2, "0");
+
+ return `${pad(hours)}:${pad(minutes)}:${pad(secs)}`;
+}
+
+/**
+ * 根据输入数值返回中文描述
+ * @param value 输入的数值
+ * @returns 如果数值超过1000返回'n千',超过10000返回'n万'
+ */
+export function describeNumber(value: number): string {
+ if (value > 10000) {
+ // 数值超过10000,返回'n万'
+ const wan = Math.floor(value / 10000);
+ return `${wan}万`;
+ } else if (value > 1000) {
+ // 数值超过1000,返回'n千'
+ const qian = Math.floor(value / 1000);
+ return `${qian}千`;
+ } else {
+ // 数值不超过1000,直接返回数值的字符串形式
+ return value.toString();
+ }
+}
+
+// 去除字符串中的话题
+export function parseTopicString(input: string): {
+ topics: string[];
+ cleanedString: string;
+} {
+ // 使用正则表达式提取字符串中的部分
+ const extractedParts = input.match(/#(\S+)/g) || [];
+
+ // 在原始输入中用空字符串替换提取的部分
+ let cleanedString = input;
+ extractedParts.forEach((part) => {
+ cleanedString = cleanedString.replace(part, "").trim();
+ });
+
+ // 创建提取的话题数组
+ const topics = extractedParts.map((part) => {
+ const match = part.match(/#(\S+)/);
+ return match ? match[1] : "";
+ });
+
+ return { topics, cleanedString };
+}
+
+// 敏感词检测-多余检测动画
+export async function sensitivityLoading() {
+ const key = generateUUID();
+ const msgs = [
+ "敏感词检测中",
+ "色情检测中",
+ "abuse检测中",
+ "广告法检测中",
+ "Error检测中",
+ ];
+
+ for (const msg of msgs) {
+ message.open({
+ key,
+ type: "loading",
+ content: `${msg} ...`,
+ });
+ await sleep(200);
+ }
+ message.destroy(key);
+}
diff --git a/src/utils/otherRequest.ts b/src/utils/otherRequest.ts
index 298ce94a..ab474aaf 100644
--- a/src/utils/otherRequest.ts
+++ b/src/utils/otherRequest.ts
@@ -1,5 +1,6 @@
import FetchService from "@/utils/FetchService/FetchService";
import { RequestParams } from "@/utils/FetchService/types";
+import { request } from "@/utils/request";
class OtherRequest {
fetchService;
@@ -20,6 +21,38 @@ class OtherRequest {
const res = await this.fetchService.request(params);
return (await res.json()) as T;
}
+
+ get<T>(url: string, data?: any) {
+ return request<T>({
+ url,
+ params: data,
+ method: "GET",
+ });
+ }
+
+ post<T>(url: string, data?: any) {
+ return request<T>({
+ url,
+ data: data,
+ method: "POST",
+ });
+ }
+
+ put<T>(url: string, data?: any) {
+ return request<T>({
+ url,
+ data: data,
+ method: "PUT",
+ });
+ }
+
+ delete<T>(url: string, data?: any) {
+ return request<T>({
+ url,
+ data: data,
+ method: "DELETE",
+ });
+ }
}
const requestPlatapi = new OtherRequest("https://platapi.yikart.cn/api/");
diff --git a/src/utils/request.ts b/src/utils/request.ts
index 64f86cdb..bd492285 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -25,7 +25,7 @@ const fetchService = new FetchService({
const lng = useUserStore.getState().lang;
requestParams.headers = {
...requestParams.headers,
- 'Accept-Language': lng
+ "Accept-Language": lng,
};
}
diff --git a/tsconfig.json b/tsconfig.json
index 7b285893..af055914 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,5 +1,6 @@
{
"compilerOptions": {
+ "target": "ESNext",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,