Skip to content

Let's use AI to Earn!

facebook1

daoyian419d99260960
diff --git a/.env b/.env
index 4d7cfa6c..54caeda5 100644
--- a/.env
+++ b/.env
@@ -2,4 +2,4 @@
NEXT_PUBLIC_API_URL_PROXY="/baseUrlProxy/"
# OSS URL
-NEXT_PUBLIC_OSS_URL="https://ai-to-earn.oss-cn-beijing.aliyuncs.com/"
\ No newline at end of file
+NEXT_PUBLIC_OSS_URL="https://aitoearn.s3.ap-southeast-1.amazonaws.com/"
\ No newline at end of file
diff --git a/src/api/plat/facebook.ts b/src/api/plat/facebook.ts
index 182d62c8..19f1e56d 100644
--- a/src/api/plat/facebook.ts
+++ b/src/api/plat/facebook.ts
@@ -22,4 +22,15 @@ export const apiGetFacebookPages = (accountId: string) => {
return http.get<FacebookPagesResponse>(
`plat/meta/facebook/pages`,
);
+};
+
+/**
+ * 提交Facebook页面选择
+ * @param pageIds 选择的页面ID数组
+ * @returns
+ */
+export const apiSubmitFacebookPages = (pageIds: string[]) => {
+ return http.post(`plat/meta/facebook/pages`, {
+ pageIds,
+ });
};
\ No newline at end of file
diff --git a/src/api/platAuth.ts b/src/api/platAuth.ts
index 6d707175..7a69a632 100644
--- a/src/api/platAuth.ts
+++ b/src/api/platAuth.ts
@@ -79,6 +79,8 @@ export const getFacebookAuthUrlApi = (mail: string) => {
};
+
+
export const checkMetaAuthApi = ( taskId:any ) => {
return request({
url: `plat/meta/auth/info/${taskId}`,
diff --git a/src/api/tools.ts b/src/api/tools.ts
index 279d3740..3e04c1d8 100644
--- a/src/api/tools.ts
+++ b/src/api/tools.ts
@@ -101,7 +101,7 @@ export const toolsApi = {
formData.append("file", file);
const res = await axios({
- url: `${process.env.NEXT_PUBLIC_API_URL_PROXY}/oss/upload`,
+ url: `${process.env.NEXT_PUBLIC_API_URL_PROXY}/file/upload`,
method: "POST",
data: formData,
headers: {
@@ -114,7 +114,7 @@ export const toolsApi = {
if (onProgress) onProgress(prog);
},
});
- return res.data.data.name;
+ return res.data.data.key;
},
/**
diff --git a/src/app/[lng]/accounts/components/AddAccountModal/index.tsx b/src/app/[lng]/accounts/components/AddAccountModal/index.tsx
index 291d681f..11f0b365 100644
--- a/src/app/[lng]/accounts/components/AddAccountModal/index.tsx
+++ b/src/app/[lng]/accounts/components/AddAccountModal/index.tsx
@@ -1,4 +1,4 @@
-import { ForwardedRef, forwardRef, memo } from "react";
+import { ForwardedRef, forwardRef, memo, useState } from "react";
import styles from "./AddAccountModal.module.scss";
import { Button, Modal, Tooltip } from "antd";
import { AccountPlatInfoArr, PlatType } from "@/app/config/platConfig";
@@ -8,7 +8,7 @@ import { bilibiliSkip } from "../../plat/BilibiliLogin";
import { youtubeSkip } from "../../plat/YoutubeLogin";
import { twitterSkip } from "../../plat/TwtterLogin";
import { tiktokSkip } from "../../plat/TiktokLogin";
-import { facebookSkip } from "../../plat/FacebookLogin";
+import { facebookSkip, FacebookPagesModal } from "../../plat/FacebookLogin";
import { instagramSkip } from "../../plat/InstagramLogin";
import { threadsSkip } from "../../plat/ThreadsLogin";
import { wxGzhSkip } from "../../plat/WxGzh";
@@ -28,6 +28,8 @@ const AddAccountModal = memo(
{ open, onClose, onAddSuccess }: IAddAccountModalProps,
ref: ForwardedRef<IAddAccountModalRef>,
) => {
+ const [showFacebookPagesModal, setShowFacebookPagesModal] = useState(false);
+
const handleOk = () => {
onClose();
};
@@ -36,6 +38,18 @@ const AddAccountModal = memo(
onClose();
};
+ // 处理Facebook授权成功后的页面选择
+ const handleFacebookAuthSuccess = () => {
+ setShowFacebookPagesModal(true);
+ };
+
+ // 处理Facebook页面选择成功
+ const handleFacebookPagesSuccess = () => {
+ setShowFacebookPagesModal(false);
+ onClose();
+ // 可以在这里添加成功提示或其他逻辑
+ };
+
return (
<>
<Modal
@@ -73,7 +87,13 @@ const AddAccountModal = memo(
await tiktokSkip(key);
break;
case PlatType.Facebook:
- await facebookSkip(key);
+ try {
+ await facebookSkip(key);
+ // Facebook授权成功后显示页面选择弹窗
+ handleFacebookAuthSuccess();
+ } catch (error) {
+ console.error('Facebook授权失败:', error);
+ }
break;
case PlatType.Instagram:
await instagramSkip(key);
@@ -102,6 +122,13 @@ const AddAccountModal = memo(
</div>
</div>
</Modal>
+
+ {/* Facebook页面选择弹窗 */}
+ <FacebookPagesModal
+ open={showFacebookPagesModal}
+ onClose={() => setShowFacebookPagesModal(false)}
+ onSuccess={handleFacebookPagesSuccess}
+ />
</>
);
},
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx
index 5d4b8340..683f30ab 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx
+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx
@@ -186,15 +186,17 @@ const RecordCore = memo(
</div>
</div>
<div className="recordDetails-bottom">
- <Button
- icon={<SendOutlined />}
- onClick={async () => {
- await nowPubTaskApi(publishRecord.id);
- getPubRecord();
- }}
- >
- {t("buttons.publishNow")}
- </Button>
+ {publishRecord.status !== PublishStatus.RELEASED && (
+ <Button
+ icon={<SendOutlined />}
+ onClick={async () => {
+ await nowPubTaskApi(publishRecord.id);
+ getPubRecord();
+ }}
+ >
+ {t("buttons.publishNow")}
+ </Button>
+ )}
<Dropdown menu={{ items: dropdownItems }} placement="top">
<Button icon={<MoreOutlined />} />
</Dropdown>
diff --git a/src/app/[lng]/accounts/plat/FacebookLogin.ts b/src/app/[lng]/accounts/plat/FacebookLogin.ts
index 1de63a95..bb4281e1 100644
--- a/src/app/[lng]/accounts/plat/FacebookLogin.ts
+++ b/src/app/[lng]/accounts/plat/FacebookLogin.ts
@@ -3,10 +3,11 @@ import { PlatType } from "@/app/config/platConfig";
import { getFacebookAuthUrlApi, checkMetaAuthApi } from "@/api/platAuth";
import { useAccountStore } from "@/store/account";
-
+// 导入Facebook页面选择弹窗
+import FacebookPagesModal from "@/components/FacebookPagesModal";
/**
- * b站被点击
+ * Facebook被点击
* @param platType
*/
export async function facebookSkip(platType: PlatType) {
@@ -21,47 +22,48 @@ export async function facebookSkip(platType: PlatType) {
}
-export function facebookLogin(taskId:any): Promise<any> {
+export function facebookLogin(taskId: any): Promise<any> {
return new Promise(async (resolve, reject) => {
try {
- // 开始轮询检查授权状态
- const checkAuthStatus = async () => {
- try {
- const authRess:any = await checkMetaAuthApi(taskId);
- let authRes = authRess;
- console.log('authRes', authRes)
- if (authRes?.code === 0 && authRes?.data.status == 1) {
- // message.success('授权成功');
- // useAccountStore
- const accountStore = useAccountStore.getState();
- await accountStore.getAccountList();
- resolve(authRes);
- return true;
- }
- // return false;
- } catch (error) {
- console.error('检查授权状态失败:', error);
- return false;
- }
- };
-
- // 设置轮询间隔
- const interval = setInterval(async () => {
- const isSuccess = await checkAuthStatus();
- if (isSuccess) {
- clearInterval(interval);
+ // 开始轮询检查授权状态
+ const checkAuthStatus = async () => {
+ try {
+ const authRess: any = await checkMetaAuthApi(taskId);
+ let authRes = authRess;
+ console.log('authRes', authRes)
+ if (authRes?.code === 0 && authRes?.data.status == 1) {
+ // 授权成功,不再直接刷新账户列表
+ // 而是触发页面选择弹窗
+ resolve(authRes);
+ return true;
}
- }, 2000);
+ // return false;
+ } catch (error) {
+ console.error('检查授权状态失败:', error);
+ return false;
+ }
+ };
- // 5分钟后自动停止轮询
- setTimeout(() => {
+ // 设置轮询间隔
+ const interval = setInterval(async () => {
+ const isSuccess = await checkAuthStatus();
+ if (isSuccess) {
clearInterval(interval);
- // message.error('授权超时,请重试');
- reject(new Error('授权超时'));
- }, 5 * 60 * 1000);
+ }
+ }, 2000);
+
+ // 5分钟后自动停止轮询
+ setTimeout(() => {
+ clearInterval(interval);
+ // message.error('授权超时,请重试');
+ reject(new Error('授权超时'));
+ }, 5 * 60 * 1000);
} catch (e) {
reject(e);
}
});
}
+
+// 导出Facebook页面选择弹窗组件,供外部使用
+export { FacebookPagesModal };
diff --git a/src/app/i18n/locales/en/publish.json b/src/app/i18n/locales/en/publish.json
index 06bdbc07..adf64182 100644
--- a/src/app/i18n/locales/en/publish.json
+++ b/src/app/i18n/locales/en/publish.json
@@ -7,7 +7,7 @@
"buttons": {
"customizePerAccount": "Customize per account",
"cancelPublish": "Cancel",
- "schedulePublish": "Schedule",
+ "schedulePublish": "Publish now",
"publishNow": "Publish now",
"copyLink": "Copy link",
"delete": "Delete"
diff --git a/src/app/i18n/locales/zh-CN/publish.json b/src/app/i18n/locales/zh-CN/publish.json
index b9d97e2d..adce179c 100644
--- a/src/app/i18n/locales/zh-CN/publish.json
+++ b/src/app/i18n/locales/zh-CN/publish.json
@@ -7,7 +7,7 @@
"buttons": {
"customizePerAccount": "针对每个账户进行定制",
"cancelPublish": "取消发布",
- "schedulePublish": "计划发布",
+ "schedulePublish": "立即发布",
"publishNow": "立即发布",
"copyLink": "复制链接",
"delete": "删除"
diff --git a/src/components/FacebookPagesModal/index.module.scss b/src/components/FacebookPagesModal/index.module.scss
new file mode 100644
index 00000000..1d17ae9d
--- /dev/null
+++ b/src/components/FacebookPagesModal/index.module.scss
@@ -0,0 +1,21 @@
+.facebookPagesModal {
+ .pageList {
+ max-height: 400px;
+ overflow-y: auto;
+ }
+
+ .pageItem {
+ padding: 8px 0;
+ border-bottom: 1px solid #f0f0f0;
+
+ &:last-child {
+ border-bottom: none;
+ }
+ }
+
+ .selectAll {
+ margin-bottom: 16px;
+ padding-bottom: 12px;
+ border-bottom: 1px solid #f0f0f0;
+ }
+}
\ No newline at end of file
diff --git a/src/components/FacebookPagesModal/index.tsx b/src/components/FacebookPagesModal/index.tsx
new file mode 100644
index 00000000..4ebdc05d
--- /dev/null
+++ b/src/components/FacebookPagesModal/index.tsx
@@ -0,0 +1,153 @@
+import React, { useState, useEffect } from 'react';
+import { Modal, Checkbox, List, Button, message, Spin } from 'antd';
+import { apiGetFacebookPages, apiSubmitFacebookPages } from '@/api/plat/facebook';
+import { useAccountStore } from '@/store/account';
+import styles from './index.module.scss';
+
+export interface FacebookPageItem {
+ id: string;
+ name: string;
+}
+
+interface FacebookPagesModalProps {
+ open: boolean;
+ onClose: () => void;
+ onSuccess: () => void;
+}
+
+const FacebookPagesModal: React.FC<FacebookPagesModalProps> = ({
+ open,
+ onClose,
+ onSuccess,
+}) => {
+ const [pages, setPages] = useState<FacebookPageItem[]>([]);
+ const [selectedPageIds, setSelectedPageIds] = useState<string[]>([]);
+ const [loading, setLoading] = useState(false);
+ const [submitting, setSubmitting] = useState(false);
+ const accountStore = useAccountStore();
+
+ // 获取Facebook页面列表
+ const fetchPages = async () => {
+ setLoading(true);
+ try {
+ const res: any = await apiGetFacebookPages('');
+ if (res?.code === 0) {
+ setPages(res.data || []);
+ } else {
+ message.error('获取页面列表失败');
+ }
+ } catch (error) {
+ console.error('获取Facebook页面列表失败:', error);
+ message.error('获取页面列表失败');
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ // 提交选择的页面
+ const handleSubmit = async () => {
+ if (selectedPageIds.length === 0) {
+ message.warning('请至少选择一个页面');
+ return;
+ }
+
+ setSubmitting(true);
+ try {
+ const res = await apiSubmitFacebookPages(selectedPageIds);
+ if (res?.code === 0) {
+ message.success('页面选择成功');
+ // 刷新账户列表
+ await accountStore.getAccountList();
+ onSuccess();
+ onClose();
+ } else {
+ message.error('页面选择失败');
+ }
+ } catch (error) {
+ console.error('提交页面选择失败:', error);
+ message.error('页面选择失败');
+ } finally {
+ setSubmitting(false);
+ }
+ };
+
+ // 处理页面选择变化
+ const handlePageChange = (pageId: string, checked: boolean) => {
+ if (checked) {
+ setSelectedPageIds(prev => [...prev, pageId]);
+ } else {
+ setSelectedPageIds(prev => prev.filter(id => id !== pageId));
+ }
+ };
+
+ // 全选/取消全选
+ const handleSelectAll = (checked: boolean) => {
+ if (checked) {
+ setSelectedPageIds(pages.map(page => page.id));
+ } else {
+ setSelectedPageIds([]);
+ }
+ };
+
+ useEffect(() => {
+ if (open) {
+ fetchPages();
+ setSelectedPageIds([]);
+ }
+ }, [open]);
+
+ return (
+ <Modal
+ title="选择Facebook页面"
+ open={open}
+ onCancel={onClose}
+ footer={[
+ <Button key="cancel" onClick={onClose}>
+ 取消
+ </Button>,
+ <Button
+ key="submit"
+ type="primary"
+ loading={submitting}
+ onClick={handleSubmit}
+ >
+ 确认选择
+ </Button>,
+ ]}
+ width={600}
+ className={styles.facebookPagesModal}
+ >
+ <div className={styles.selectAll}>
+ <Checkbox
+ checked={selectedPageIds.length === pages.length && pages.length > 0}
+ indeterminate={selectedPageIds.length > 0 && selectedPageIds.length < pages.length}
+ onChange={(e) => handleSelectAll(e.target.checked)}
+ >
+ 全选
+ </Checkbox>
+ </div>
+
+ <Spin spinning={loading}>
+ <List
+ className={styles.pageList}
+ dataSource={pages}
+ renderItem={(page) => (
+ <List.Item className={styles.pageItem}>
+ <Checkbox
+ checked={selectedPageIds.includes(page.id)}
+ onChange={(e) => handlePageChange(page.id, e.target.checked)}
+ >
+ {page.name}
+ </Checkbox>
+ </List.Item>
+ )}
+ locale={{
+ emptyText: loading ? '加载中...' : '暂无可用页面',
+ }}
+ />
+ </Spin>
+ </Modal>
+ );
+};
+
+export default FacebookPagesModal;
\ No newline at end of file
diff --git a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/FacebookParams.tsx b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/FacebookParams.tsx
index 70fab763..bb3ef236 100644
--- a/src/components/PublishDialog/compoents/PlatParamsSetting/plats/FacebookParams.tsx
+++ b/src/components/PublishDialog/compoents/PlatParamsSetting/plats/FacebookParams.tsx
@@ -1,4 +1,4 @@
-import { ForwardedRef, forwardRef, memo, useEffect } from "react";
+import { ForwardedRef, forwardRef, memo } from "react";
import {
IPlatsParamsProps,
IPlatsParamsRef,
@@ -6,10 +6,8 @@ import {
import PubParmasTextarea from "@/components/PublishDialog/compoents/PubParmasTextarea";
import usePlatParamsCommon from "@/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon";
import CommonTitleInput from "@/components/PublishDialog/compoents/PlatParamsSetting/common/CommonTitleInput";
-import { usePublishDialogData } from "@/components/PublishDialog/usePublishDialogData";
-import { useShallow } from "zustand/react/shallow";
import styles from "../platParamsSetting.module.scss";
-import { Select } from "antd";
+import { Radio } from "antd";
import { useTransClient } from "@/app/i18n/client";
const FacebookParams = memo(
@@ -18,17 +16,6 @@ const FacebookParams = memo(
const { t } = useTransClient("publish");
const { pubParmasTextareaCommonParams, setOnePubParams } =
usePlatParamsCommon(pubItem);
- const { getFacebookPages, facebookPages } =
- usePublishDialogData(
- useShallow((state) => ({
- getFacebookPages: state.getFacebookPages,
- facebookPages: state.facebookPages,
- })),
- );
-
- useEffect(() => {
- getFacebookPages();
- }, [getFacebookPages]);
return (
<>
@@ -41,17 +28,15 @@ const FacebookParams = memo(
className={styles.commonTitleInput}
style={{ marginTop: "10px" }}
>
- <div className="platParamsSetting-label">{t("form.page")}</div>
- <Select
- style={{ width: "100%" }}
- options={facebookPages}
- value={pubItem.params.option.facebook?.page_id}
- onChange={(value) => {
+ <div className="platParamsSetting-label">{t("form.type")}</div>
+ <Radio.Group
+ value={pubItem.params.option.facebook?.content_category || 'video'}
+ onChange={(e) => {
const option = pubItem.params.option;
if (!option.facebook) {
option.facebook = {};
}
- option.facebook.page_id = value;
+ option.facebook.content_category = e.target.value;
setOnePubParams(
{
option,
@@ -59,13 +44,11 @@ const FacebookParams = memo(
pubItem.account.id,
);
}}
- showSearch={true}
- placeholder={t("form.pagePlaceholder")}
- fieldNames={{
- label: "name",
- value: "id",
- }}
- />
+ >
+ <Radio value="video">Post</Radio>
+ <Radio value="reel">Reel</Radio>
+ <Radio value="story">Story</Radio>
+ </Radio.Group>
</div>
</>
}
diff --git a/src/components/PublishDialog/publishDialog.type.ts b/src/components/PublishDialog/publishDialog.type.ts
index b06082ad..2c3bd902 100644
--- a/src/components/PublishDialog/publishDialog.type.ts
+++ b/src/components/PublishDialog/publishDialog.type.ts
@@ -48,6 +48,8 @@ export interface IPlatOption {
facebook?: {
// 页面ID,由获取Facebook页面信息接口得到
page_id?: string;
+ // 内容类型:video(Post)、reel(Reel)、story(Story)
+ content_category?: string;
};
youtube?: {
// 隐私状态:public、unlisted、private