Skip to content

Let's use AI to Earn!

授权登录

daoyian5b2e6cf8962a
diff --git a/src/api/platAuth.ts b/src/api/platAuth.ts
index 6f3cb30c..725d8f2f 100644
--- a/src/api/platAuth.ts
+++ b/src/api/platAuth.ts
@@ -120,8 +120,6 @@ export const getThreadsAuthUrlApi = (mail: string) => {
};
-
-
/**
* 获取tiktok授权状态
* @param taskId 任务ID
@@ -158,3 +156,24 @@ export const checkWxGzAuthApi = ( taskId:any ) => {
method: 'GET',
});
};
+
+
+/**
+ * 获取facebook授权状态
+ * @param taskId 任务ID
+ * @returns
+ */
+export const getPinterestAuthUrlApi = (mail: string) => {
+ return request({
+ url: 'plat/pinterest/getAuth',
+ method: 'GET',
+ });
+};
+
+
+export const checkPinterestAuthApi = ( taskId:any ) => {
+ return request({
+ url: `plat/pinterest/checkAuth`,
+ method: 'GET',
+ });
+};
diff --git a/src/app/[lng]/accounts/components/AddAccountModal/index.tsx b/src/app/[lng]/accounts/components/AddAccountModal/index.tsx
index 38065508..291d681f 100644
--- a/src/app/[lng]/accounts/components/AddAccountModal/index.tsx
+++ b/src/app/[lng]/accounts/components/AddAccountModal/index.tsx
@@ -12,6 +12,7 @@ import { facebookSkip } from "../../plat/FacebookLogin";
import { instagramSkip } from "../../plat/InstagramLogin";
import { threadsSkip } from "../../plat/ThreadsLogin";
import { wxGzhSkip } from "../../plat/WxGzh";
+import { pinterestSkip } from "../../plat/PinterestLogin";
export interface IAddAccountModalRef {}
@@ -83,6 +84,9 @@ const AddAccountModal = memo(
case PlatType.WxGzh:
await wxGzhSkip(key);
break;
+ case PlatType.Pinterest:
+ await pinterestSkip(key);
+ break;
}
}}
>
diff --git a/src/app/[lng]/accounts/plat/PinterestLogin.ts b/src/app/[lng]/accounts/plat/PinterestLogin.ts
new file mode 100644
index 00000000..3fcba867
--- /dev/null
+++ b/src/app/[lng]/accounts/plat/PinterestLogin.ts
@@ -0,0 +1,67 @@
+import qs from "qs";
+import { PlatType } from "@/app/config/platConfig";
+import { getPinterestAuthUrlApi, checkPinterestAuthApi } from "@/api/platAuth";
+import { useAccountStore } from "@/store/account";
+
+
+
+/**
+ * b站被点击
+ * @param platType
+ */
+export async function pinterestSkip(platType: PlatType) {
+ if (platType !== PlatType.Pinterest) return;
+
+ const res: any = await getPinterestAuthUrlApi('pc');
+ if (res?.code !== 0) return;
+ const url = res.data.url;
+ window.open(`${url}`);
+
+ const pinterestLoginRes = await pinterestLogin(res.data.taskId);
+
+}
+
+export function pinterestLogin(taskId:any): Promise<any> {
+ return new Promise(async (resolve, reject) => {
+ try {
+ // 开始轮询检查授权状态
+ const checkAuthStatus = async () => {
+ try {
+ const authRess:any = await checkPinterestAuthApi(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/config/platConfig.ts b/src/app/config/platConfig.ts
index 213e0f46..468750d0 100644
--- a/src/app/config/platConfig.ts
+++ b/src/app/config/platConfig.ts
@@ -10,6 +10,7 @@ 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";
+import pinterestSvg from "@/assets/svgs/plat/pinterest.svg";
// 平台类型
export enum PlatType {
@@ -25,6 +26,7 @@ export enum PlatType {
Facebook = "facebook", // Facebook
Instagram = "instagram", // Instagram
Threads = "threads", // Threads
+ Pinterest = "pinterest", // Pinterest
}
export interface IAccountPlatInfo {
@@ -63,7 +65,7 @@ export interface IAccountPlatInfo {
}
// 各个平台的信息
-export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
+export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
[
PlatType.Douyin,
{
@@ -202,5 +204,19 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
themeColor: "blue",
},
],
+ [
+ PlatType.Pinterest,
+ {
+ name: "Pinterest",
+ icon: pinterestSvg.src,
+ url: "https://www.pinterest.com/",
+ pubTypes: new Set([PubType.VIDEO]),
+ commonPubParamsConfig: {
+ titleMax: 16,
+ topicMax: 10,
+ },
+ themeColor: "#CC2025",
+ },
+ ],
]);
export const AccountPlatInfoArr = Array.from(AccountPlatInfoMap);