Skip to content

Let's use AI to Earn!

授权

daoyian923c08c0f1dc
diff --git a/src/api/platAuth.ts b/src/api/platAuth.ts
index bbe02b70..6f3cb30c 100644
--- a/src/api/platAuth.ts
+++ b/src/api/platAuth.ts
@@ -79,7 +79,7 @@ export const getFacebookAuthUrlApi = (mail: string) => {
};
-export const checkFacebookAuthApi = ( taskId:any ) => {
+export const checkMetaAuthApi = ( taskId:any ) => {
return request({
url: `plat/meta/auth/info/${taskId}`,
method: 'GET',
@@ -87,6 +87,41 @@ export const checkFacebookAuthApi = ( taskId:any ) => {
};
+/**
+ * 获取instagram授权状态
+ * @param taskId 任务ID
+ * @returns
+ */
+export const getInstagramAuthUrlApi = (mail: string) => {
+ return request({
+ url: 'plat/meta/auth/url',
+ method: 'POST',
+ data: {
+ platform: 'instagram',
+ },
+ });
+};
+
+
+
+/**
+ * 获取threads授权状态
+ * @param taskId 任务ID
+ * @returns
+ */
+export const getThreadsAuthUrlApi = (mail: string) => {
+ return request({
+ url: 'plat/meta/auth/url',
+ method: 'POST',
+ data: {
+ platform: 'threads',
+ },
+ });
+};
+
+
+
+
/**
* 获取tiktok授权状态
* @param taskId 任务ID
diff --git a/src/app/[lng]/accounts/components/AddAccountModal/index.tsx b/src/app/[lng]/accounts/components/AddAccountModal/index.tsx
index b4c37d96..38065508 100644
--- a/src/app/[lng]/accounts/components/AddAccountModal/index.tsx
+++ b/src/app/[lng]/accounts/components/AddAccountModal/index.tsx
@@ -9,6 +9,8 @@ import { youtubeSkip } from "../../plat/YoutubeLogin";
import { twitterSkip } from "../../plat/TwtterLogin";
import { tiktokSkip } from "../../plat/TiktokLogin";
import { facebookSkip } from "../../plat/FacebookLogin";
+import { instagramSkip } from "../../plat/InstagramLogin";
+import { threadsSkip } from "../../plat/ThreadsLogin";
import { wxGzhSkip } from "../../plat/WxGzh";
export interface IAddAccountModalRef {}
@@ -72,6 +74,12 @@ const AddAccountModal = memo(
case PlatType.Facebook:
await facebookSkip(key);
break;
+ case PlatType.Instagram:
+ await instagramSkip(key);
+ break;
+ case PlatType.Threads:
+ await threadsSkip(key);
+ break;
case PlatType.WxGzh:
await wxGzhSkip(key);
break;
diff --git a/src/app/[lng]/accounts/plat/FacebookLogin.ts b/src/app/[lng]/accounts/plat/FacebookLogin.ts
index a1e1c65c..1de63a95 100644
--- a/src/app/[lng]/accounts/plat/FacebookLogin.ts
+++ b/src/app/[lng]/accounts/plat/FacebookLogin.ts
@@ -1,6 +1,6 @@
import qs from "qs";
import { PlatType } from "@/app/config/platConfig";
-import { getFacebookAuthUrlApi, checkFacebookAuthApi } from "@/api/platAuth";
+import { getFacebookAuthUrlApi, checkMetaAuthApi } from "@/api/platAuth";
import { useAccountStore } from "@/store/account";
@@ -27,7 +27,7 @@ export function facebookLogin(taskId:any): Promise<any> {
// 开始轮询检查授权状态
const checkAuthStatus = async () => {
try {
- const authRess:any = await checkFacebookAuthApi(taskId);
+ const authRess:any = await checkMetaAuthApi(taskId);
let authRes = authRess;
console.log('authRes', authRes)
if (authRes?.code === 0 && authRes?.data.status == 1) {
diff --git a/src/app/[lng]/accounts/plat/InstagramLogin.ts b/src/app/[lng]/accounts/plat/InstagramLogin.ts
new file mode 100644
index 00000000..fd635ae3
--- /dev/null
+++ b/src/app/[lng]/accounts/plat/InstagramLogin.ts
@@ -0,0 +1,67 @@
+import qs from "qs";
+import { PlatType } from "@/app/config/platConfig";
+import { getInstagramAuthUrlApi, checkMetaAuthApi } from "@/api/platAuth";
+import { useAccountStore } from "@/store/account";
+
+
+
+/**
+ * b站被点击
+ * @param platType
+ */
+export async function instagramSkip(platType: PlatType) {
+ if (platType !== PlatType.Instagram) return;
+
+ const res: any = await getInstagramAuthUrlApi('pc');
+ if (res?.code !== 0) return;
+ const url = res.data.url;
+ window.open(`${url}`);
+
+ const instagramLoginRes = await instagramLogin(res.data.taskId);
+
+}
+
+export function instagramLogin(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);
+ }
+ }, 2000);
+
+ // 5分钟后自动停止轮询
+ setTimeout(() => {
+ clearInterval(interval);
+ // message.error('授权超时,请重试');
+ reject(new Error('授权超时'));
+ }, 5 * 60 * 1000);
+
+ } catch (e) {
+ reject(e);
+ }
+ });
+}
diff --git a/src/app/[lng]/accounts/plat/ThreadsLogin.ts b/src/app/[lng]/accounts/plat/ThreadsLogin.ts
new file mode 100644
index 00000000..3eb834d5
--- /dev/null
+++ b/src/app/[lng]/accounts/plat/ThreadsLogin.ts
@@ -0,0 +1,67 @@
+import qs from "qs";
+import { PlatType } from "@/app/config/platConfig";
+import { getThreadsAuthUrlApi, checkMetaAuthApi } from "@/api/platAuth";
+import { useAccountStore } from "@/store/account";
+
+
+
+/**
+ * b站被点击
+ * @param platType
+ */
+export async function threadsSkip(platType: PlatType) {
+ if (platType !== PlatType.Threads) return;
+
+ const res: any = await getThreadsAuthUrlApi('pc');
+ if (res?.code !== 0) return;
+ const url = res.data.url;
+ window.open(`${url}`);
+
+ const threadsLoginRes = await threadsLogin(res.data.taskId);
+
+}
+
+export function threadsLogin(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);
+ }
+ }, 2000);
+
+ // 5分钟后自动停止轮询
+ setTimeout(() => {
+ clearInterval(interval);
+ // message.error('授权超时,请重试');
+ reject(new Error('授权超时'));
+ }, 5 * 60 * 1000);
+
+ } catch (e) {
+ reject(e);
+ }
+ });
+}
diff --git a/src/app/[lng]/cgmaterial/cgmaterialPageCore.tsx b/src/app/[lng]/cgmaterial/cgmaterialPageCore.tsx
index e1613482..2dd1f692 100644
--- a/src/app/[lng]/cgmaterial/cgmaterialPageCore.tsx
+++ b/src/app/[lng]/cgmaterial/cgmaterialPageCore.tsx
@@ -494,6 +494,8 @@ export default function CgMaterialPageCore() {
'wxSph': '微信视频号',
'wxGzh': '微信公众号',
'facebook': 'Facebook',
+ 'instagram': 'Instagram',
+ 'threads': 'Threads',
};
return platformNames[type] || type;
}
diff --git a/src/app/config/platConfig.ts b/src/app/config/platConfig.ts
index f2478a6e..213e0f46 100644
--- a/src/app/config/platConfig.ts
+++ b/src/app/config/platConfig.ts
@@ -6,6 +6,8 @@ import douyinSvg from "@/assets/svgs/plat/douyin.svg";
import tiktokSvg from "@/assets/svgs/plat/tiktok.svg";
import twitterSvg from "@/assets/svgs/plat/twtter.svg";
import facebookSvg from "@/assets/svgs/plat/facebook.svg";
+import instagramSvg from "@/assets/svgs/plat/instagram.svg";
+import threadsSvg from "@/assets/svgs/plat/xiancheng.svg";
import wxGzhSvg from "@/assets/svgs/plat/wx-gzh.svg";
import wxSphSvg from "@/assets/svgs/plat/wx-sph.svg";
@@ -21,6 +23,8 @@ export enum PlatType {
Twitter = "twitter", // Twitter
WxGzh = "wxGzh", // 微信公众号
Facebook = "facebook", // Facebook
+ Instagram = "instagram", // Instagram
+ Threads = "threads", // Threads
}
export interface IAccountPlatInfo {
@@ -170,5 +174,33 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
themeColor: "green",
},
],
+ [
+ PlatType.Instagram,
+ {
+ name: "Instagram",
+ icon: instagramSvg.src,
+ url: "https://www.instagram.com/",
+ pubTypes: new Set([PubType.VIDEO]),
+ commonPubParamsConfig: {
+ titleMax: 16,
+ topicMax: 10,
+ },
+ themeColor: "blue",
+ },
+ ],
+ [
+ PlatType.Threads,
+ {
+ name: "Threads",
+ icon: threadsSvg.src,
+ url: "https://www.threads.net/",
+ pubTypes: new Set([PubType.VIDEO]),
+ commonPubParamsConfig: {
+ titleMax: 16,
+ topicMax: 10,
+ },
+ themeColor: "blue",
+ },
+ ],
]);
export const AccountPlatInfoArr = Array.from(AccountPlatInfoMap);