Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
all s
I5bijibned19dac7c88f0
diff --git a/src/api/account.ts b/src/api/account.tsindex d25219a8..624b4883 100644--- a/src/api/account.ts+++ b/src/api/account.ts@@ -69,6 +69,20 @@ export const deleteAccountGroupApi = (ids: string[]) => {};// 获取所有账户组-export const getAccountGroupApi = () => {- return http.get<AccountGroupItem[]>("accountGroup/getList");+export const getAccountGroupApi = async () => {+ const res:any = await http.get<AccountGroupItem[]>("accountGroup/getList");+ console.log(res.data);+ // res.data.push({+ // id: "68a6d3e5861d0b23ca010123",+ // ip: "188.166.188.86",+ // isDefault: false,+ // location: "AU",+ // name: "测试外网",+ // proxyIp: "188.166.188.86",+ // rank: 1,+ // userId: "689aea2a2b50f147c09f01bc",+ // _id: "68a6d3e5861d0b23ca010123",+ // });++ return res;};diff --git a/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsx b/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsxindex aa52295a..e9489f07 100644--- a/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsx+++ b/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsx@@ -255,6 +255,7 @@ const UserManageModal = memo(const [deleteLoading, setDeleteLoading] = useState(false);const [cutLoading, setCutLoading] = useState(false);const [isAddAccountOpen, setIsAddAccountOpen] = useState(false);+ const [targetGroupIdForModal, setTargetGroupIdForModal] = useState<string | undefined>(undefined);const [chooseGroupOpen, setChooseGroupOpen] = useState(false);const [chosenGroupId, setChosenGroupId] = useState<string | undefined>(undefined);const preAccountIds = useRef<Set<string>>(new Set());@@ -417,6 +418,7 @@ const UserManageModal = memo(setChooseGroupOpen(true);} else {pendingGroupIdRef.current = currentGroupId;+ setTargetGroupIdForModal(currentGroupId);if ((useAccountStore.getState().accountList || []).length === 0) {await getAccountList();}@@ -591,6 +593,7 @@ const UserManageModal = memo(onOk={async () => {if (!chosenGroupId) return message.warning(t("pleaseChooseSpace" as any));pendingGroupIdRef.current = chosenGroupId;+ setTargetGroupIdForModal(chosenGroupId);if ((useAccountStore.getState().accountList || []).length === 0) {await getAccountList();}@@ -616,6 +619,7 @@ const UserManageModal = memo(open={isAddAccountOpen}onClose={async () => {setIsAddAccountOpen(false);+ setTargetGroupIdForModal(undefined);}}onAddSuccess={async (acc) => {try {@@ -628,6 +632,7 @@ const UserManageModal = memo(await getAccountList();}}}+ targetGroupId={targetGroupIdForModal}/></>);diff --git a/src/app/[lng]/accounts/components/AddAccountModal/index.tsx b/src/app/[lng]/accounts/components/AddAccountModal/index.tsxindex 8d4e5f7d..c7678380 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, useState } from "react";+import { ForwardedRef, forwardRef, memo, useEffect, useMemo, useState } from "react";import styles from "./AddAccountModal.module.scss";import { Button, Modal, Tooltip } from "antd";import { AccountPlatInfoArr, PlatType } from "@/app/config/platConfig";@@ -14,6 +14,9 @@ import { instagramSkip } from "../../plat/InstagramLogin";import { threadsSkip } from "../../plat/ThreadsLogin";import { wxGzhSkip } from "../../plat/WxGzh";import { pinterestSkip } from "../../plat/PinterestLogin";+import { useAccountStore } from "@/store/account";+import { getIpLocation, IpLocationInfo } from "@/utils/ipLocation";+import DownloadAppModal from "@/components/common/DownloadAppModal";export interface IAddAccountModalRef {}@@ -21,16 +24,97 @@ export interface IAddAccountModalProps {open: boolean;onClose: () => void;onAddSuccess: (accountInfo: SocialAccount) => void;+ // 目标空间ID,用于根据空间属地(CN)过滤可添加平台+ targetGroupId?: string;}const AddAccountModal = memo(forwardRef((- { open, onClose, onAddSuccess }: IAddAccountModalProps,+ { open, onClose, onAddSuccess, targetGroupId }: IAddAccountModalProps,ref: ForwardedRef<IAddAccountModalRef>,) => {const { t } = useTransClient('account');const [showFacebookPagesModal, setShowFacebookPagesModal] = useState(false);+ const accountGroupList = useAccountStore((state) => state.accountGroupList);+ const [downloadVisible, setDownloadVisible] = useState(false);+ const [downloadPlatform, setDownloadPlatform] = useState<string>("");+ const aitoearnDownloadUrl = process.env.NEXT_PUBLIC_AITOEARN_APP_DOWNLOAD_URL || "";++ // 判断location是否属于中国(CN)+ const isLocationCN = (location?: string | null): boolean => {+ if (!location) return false;+ const upper = location.toUpperCase();+ return upper.startsWith('CN') || upper.includes('CHINA') || location.includes('中国');+ };++ // 当前目标空间是否视为中国属地+ const [isCnSpace, setIsCnSpace] = useState<boolean | null>(null);+ const [isLocLoading, setIsLocLoading] = useState(false);++ useEffect(() => {+ if (!open || !targetGroupId) {+ setIsCnSpace(null);+ setIsLocLoading(false);+ return;+ }++ const currentSpace = (accountGroupList || []).find((g: any) => g.id === targetGroupId);+ if (!currentSpace) {+ setIsCnSpace(null);+ return;+ }++ const shouldUseLocal = !currentSpace.proxyIp || currentSpace.proxyIp === '';+ if (!shouldUseLocal && currentSpace.ip && currentSpace.location) {+ setIsCnSpace(isLocationCN(currentSpace.location));+ return;+ }++ let cancelled = false;+ const fetchLocal = async () => {+ try {+ setIsLocLoading(true);+ const info: IpLocationInfo = await getIpLocation();+ if (!cancelled) setIsCnSpace(isLocationCN(info.location));+ } catch {+ if (!cancelled) setIsCnSpace(null);+ } finally {+ if (!cancelled) setIsLocLoading(false);+ }+ };+ fetchLocal();++ return () => {+ cancelled = true;+ };+ }, [open, targetGroupId, accountGroupList]);++ // 根据是否CN过滤可添加平台+ const displayPlatInfoArr = useMemo(() => {+ if (isCnSpace === true) {+ const allowSet = new Set<PlatType>([+ PlatType.KWAI,+ PlatType.BILIBILI,+ PlatType.WxGzh,+ PlatType.Douyin,+ PlatType.Xhs,+ ]);+ return AccountPlatInfoArr.filter(([key]) => allowSet.has(key as PlatType));+ }+ if (isCnSpace === false) {+ // 非中国属地时隐藏国内平台:小红书、抖音、快手、公众号+ const disallowSet = new Set<PlatType>([+ PlatType.Xhs,+ PlatType.Douyin,+ PlatType.KWAI,+ PlatType.WxGzh,+ PlatType.BILIBILI,+ ]);+ return AccountPlatInfoArr.filter(([key]) => !disallowSet.has(key as PlatType));+ }+ return AccountPlatInfoArr;+ }, [isCnSpace]);const handleOk = () => {onClose();@@ -65,15 +149,21 @@ const AddAccountModal = memo(<div className={styles.addAccountModal}><h1>{t('addAccountModal.subtitle')}</h1><div className="addAccountModal_plats">- {AccountPlatInfoArr.map(([key, value]) => {+ {displayPlatInfoArr.map(([key, value]) => {return (- !value.pcNoThis &&+ // !value.pcNoThis &&<Tooltip title={value.tips?.account} key={key}>-+<Buttontype="text"className="addAccountModal_plats-item"onClick={async () => {+ // 如果该平台在PC端不可用,则提示下载Aitoearn App+ if (value.pcNoThis) {+ setDownloadPlatform(value.name);+ setDownloadVisible(true);+ return;+ }switch (key) {case PlatType.KWAI:await kwaiSkip(key);@@ -137,6 +227,15 @@ const AddAccountModal = memo(onClose={() => setShowFacebookPagesModal(false)}onSuccess={handleFacebookPagesSuccess}/>++ {/* 下载Aitoearn App提示弹窗 */}+ <DownloadAppModal+ visible={downloadVisible}+ onClose={() => setDownloadVisible(false)}+ platform={downloadPlatform}+ appName={"Aitoearn App"}+ downloadUrl={aitoearnDownloadUrl}+ /></>);},diff --git a/src/app/config/platConfig.ts b/src/app/config/platConfig.tsindex a6e87cb7..dcc9d907 100644--- a/src/app/config/platConfig.ts+++ b/src/app/config/platConfig.ts@@ -11,6 +11,7 @@ import threadsSvg from "@/assets/svgs/plat/xiancheng.svg";import wxGzhSvg from "@/assets/svgs/plat/wx-gzh.svg";import gongzhonghaoSvg from "@/assets/svgs/plat/gongzhonghao.png";import pinterestSvg from "@/assets/svgs/plat/pinterest.svg";+import xhsSvg from "@/assets/svgs/plat/xhs.svg";// 平台类型export enum PlatType {@@ -68,19 +69,21 @@ export interface IAccountPlatInfo {// 各个平台的信息export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([+[- PlatType.Tiktok,+ PlatType.Xhs,{- name: "TikTok",- icon: tiktokSvg.src,- url: "https://www.tiktok.com/",- pubTypes: new Set([PubType.VIDEO, PubType.ImageText]),+ name: "小红书",+ icon: xhsSvg.src,+ url: "https://www.xiaohongshu.com/",+ themeColor: "red",+ pubTypes: new Set([]),commonPubParamsConfig: {+ titleMax: 100,topicMax: 100,- desMax: 4000,- imagesMax: 10,+ desMax: 1000,},- themeColor: "black",+ pcNoThis: true,},],[@@ -89,7 +92,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([name: "抖音",icon: douyinSvg.src,url: "https://www.douyin.com/",- pubTypes: new Set([PubType.VIDEO]),+ pubTypes: new Set([]),commonPubParamsConfig: {titleMax: 30,topicMax: 5,@@ -128,6 +131,36 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([themeColor: "blue",},],+ [+ PlatType.WxGzh,+ {+ name: "微信公众号",+ icon: gongzhonghaoSvg.src,+ url: "https://mp.weixin.qq.com/",+ pubTypes: new Set([PubType.ImageText, PubType.Article]),+ commonPubParamsConfig: {+ topicMax: 10,+ desMax: 2200,+ imagesMax: 20,+ },+ themeColor: "green",+ },+ ],+ [+ PlatType.Tiktok,+ {+ name: "TikTok",+ icon: tiktokSvg.src,+ url: "https://www.tiktok.com/",+ pubTypes: new Set([PubType.VIDEO, PubType.ImageText]),+ commonPubParamsConfig: {+ topicMax: 100,+ desMax: 4000,+ imagesMax: 10,+ },+ themeColor: "black",+ },+ ],[PlatType.YouTube,{@@ -174,21 +207,6 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([themeColor: "blue",},],- [- PlatType.WxGzh,- {- name: "微信公众号",- icon: gongzhonghaoSvg.src,- url: "https://mp.weixin.qq.com/",- pubTypes: new Set([PubType.ImageText, PubType.Article]),- commonPubParamsConfig: {- topicMax: 10,- desMax: 2200,- imagesMax: 20,- },- themeColor: "green",- },- ],[PlatType.Instagram,{diff --git a/src/components/ChooseAccountModule/components/SimpleAccountChoose.tsx b/src/components/ChooseAccountModule/components/SimpleAccountChoose.tsxindex a233173c..e600c956 100644--- a/src/components/ChooseAccountModule/components/SimpleAccountChoose.tsx+++ b/src/components/ChooseAccountModule/components/SimpleAccountChoose.tsx@@ -94,9 +94,9 @@ const SimpleAccountChoose = memo(// key=组ID,val=账户组const accountGroupMap = new Map<string, AccountGroup>();- const defaultGroup = groupList.find((v) => v.isDefault)!;+ const defaultGroup = groupList.find((v:any) => v.isDefault)!;- groupList.map((v) => {+ groupList.map((v:any) => {const accountGroupItem = {...v,children: [],diff --git a/src/components/common/DownloadAppModal.tsx b/src/components/common/DownloadAppModal.tsxindex f641f28e..1da4d79d 100644--- a/src/components/common/DownloadAppModal.tsx+++ b/src/components/common/DownloadAppModal.tsx@@ -1,7 +1,8 @@import React from 'react';import { Modal, Button, Space, Typography } from 'antd';-import { DownloadOutlined, MobileOutlined, QrcodeOutlined } from '@ant-design/icons';+import { DownloadOutlined, QrcodeOutlined } from '@ant-design/icons';import { useTransClient } from '@/app/i18n/client';+import logo from '@/assets/images/logo.png';const { Text, Paragraph } = Typography;@@ -21,8 +22,8 @@ interface DownloadAppModalProps {const DownloadAppModal: React.FC<DownloadAppModalProps> = ({visible,onClose,- platform = "小红书",- appName = "小红书App",+ platform = "",+ appName = "Aitoearn App",downloadUrl,qrCodeUrl}) => {@@ -46,7 +47,7 @@ const DownloadAppModal: React.FC<DownloadAppModalProps> = ({<Modaltitle={<Space>- <MobileOutlined style={{ color: '#1890ff' }} />+ <img src={logo.src} alt="Aitoearn" style={{ width: 20, height: 20, borderRadius: 4 }} /><span>下载{appName}</span></Space>}@@ -73,16 +74,16 @@ const DownloadAppModal: React.FC<DownloadAppModalProps> = ({><div style={{ textAlign: 'center', padding: '20px 0' }}><div style={{ marginBottom: '24px' }}>- <MobileOutlined style={{ fontSize: '48px', color: '#1890ff' }} />+ <img src={logo.src} alt="Aitoearn" style={{ width: 56, height: 56, borderRadius: 12 }} /></div><Typography.Title level={4} style={{ marginBottom: '16px' }}>- 请在{platform}App中操作+ 请在{appName}中操作添加</Typography.Title><Paragraph style={{ color: '#666', marginBottom: '24px' }}>- 为了更好的用户体验和功能完整性,{platform}相关操作需要在移动端App中进行。- 请下载并安装{appName}后继续操作。+ 为了更好的用户体验和功能完整性,该操作需要在 {appName} 中完成账号添加。+ 请下载并安装 {appName} 后继续操作。</Paragraph>{qrCodeUrl && (