Skip to content

Let's use AI to Earn!

feat: 添加ip管理

gaoSir4d33176dbee2
diff --git a/electron/db/models/account.ts b/electron/db/models/account.ts
index 883a4766..bc3fe15a 100644
--- a/electron/db/models/account.ts
+++ b/electron/db/models/account.ts
@@ -109,5 +109,5 @@ export class AccountModel extends TempModel {
comment: '关联组,与 AccountGroupModel表 id关联',
default: 1,
})
- groupId?: number;
+ groupId!: number;
}
diff --git a/electron/main/account/controller.ts b/electron/main/account/controller.ts
index fa9167ad..d01801fe 100644
--- a/electron/main/account/controller.ts
+++ b/electron/main/account/controller.ts
@@ -16,6 +16,7 @@ import { AccountModel } from '../../db/models/account';
import windowOperate from '../../util/windowOperate';
import { SendChannelEnum } from '../../../commont/UtilsEnum';
import { AccountGroupModel } from '../../db/models/accountGroup';
+import { proxyCheck } from '../../plat/coomont';
@Controller()
export class AccountController {
@@ -246,6 +247,15 @@ export class AccountController {
return this.accountService.editAccountGroup(data);
}
+ // 代理地址有效性检测
+ @Icp('ICP_ACCOUNTS_PROXY_CHECK')
+ async proxyCheck(
+ event: Electron.IpcMainInvokeEvent,
+ proxy: string,
+ ): Promise<any> {
+ return await proxyCheck(proxy);
+ }
+
@Et('ET_UP_ALL_ACCOUNT_STATISTICS') // 更新所有的账户的统计信息
async updateAllAccountStatistics(id: number, status: number) {
const userInfo = getUserInfo();
diff --git a/electron/main/app.ts b/electron/main/app.ts
index e7188381..e20a9e6b 100644
--- a/electron/main/app.ts
+++ b/electron/main/app.ts
@@ -19,6 +19,7 @@ import { ReplyModule } from './reply/module';
import { AutoRunModule } from './autoRun/module';
import { InteractionModule } from './interaction/module';
import { TracingModule } from './tracing/module';
+import { sleep } from '../../commont/utils';
@Module({
imports: [
@@ -38,7 +39,25 @@ import { TracingModule } from './tracing/module';
})
export class App {
constructor() {
- initSqlite3Db();
+ this._init();
+ }
+
+ async _init() {
+ // 初始化数据库
+ await initSqlite3Db();
+ this.timeingCheckAccount();
+ }
+
+ // 轮询检测账户有效性
+ async timeingCheckAccount() {
+ return new Promise(async () => {
+ while (true) {
+ // TODO : 轮询检测账户有效性
+
+ // 等待24小时执行,如果用户没有关闭应用
+ await sleep(3600000 * 24);
+ }
+ });
}
}
diff --git a/electron/main/index.ts b/electron/main/index.ts
index efb1c9b8..d43a604e 100644
--- a/electron/main/index.ts
+++ b/electron/main/index.ts
@@ -103,10 +103,10 @@ async function createWindow() {
if (splashWindow) {
win?.show();
// 在主窗口显示后再打开开发者工具
- win?.webContents.openDevTools({ mode: 'bottom' });
+ win?.webContents.openDevTools({ mode: 'right' });
// if (process.env.NODE_ENV === 'development') {
- // win?.webContents.openDevTools({ mode: 'bottom' });
+ // win?.webContents.openDevTools({ mode: 'right' });
// }
// if (VITE_DEV_SERVER_URL) {
diff --git a/electron/main/plat/platforms/Kwai/index.ts b/electron/main/plat/platforms/Kwai/index.ts
index 04f7bd17..d6b1c7c0 100644
--- a/electron/main/plat/platforms/Kwai/index.ts
+++ b/electron/main/plat/platforms/Kwai/index.ts
@@ -151,7 +151,6 @@ export class Kwai extends PlatformBase {
res?.data?.data?.basicData?.map((v1, i1) => {
v1.trendData.map((v2, i2) => {
const currTime = dayjs(v2.date, 'YYYYMMDD').valueOf();
- console.log('currTime', currTime);
if (currTime >= startTime && currTime <= endTime) {
if (!dashboard[i2])
dashboard[i2] = {
diff --git a/electron/plat/coomont.ts b/electron/plat/coomont.ts
index e69de29b..938a86d0 100644
--- a/electron/plat/coomont.ts
+++ b/electron/plat/coomont.ts
@@ -0,0 +1,19 @@
+import requestNet from './requestNet';
+
+// 代理地址有效性检测
+export async function proxyCheck(proxy: string) {
+ try {
+ const res = await requestNet({
+ url: 'https://www.baidu.com',
+ method: 'GET',
+ proxy,
+ });
+ if (res.status === 200 || res.status === 201 || res.data.length > 100000) {
+ return true;
+ }
+ return false;
+ } catch (e) {
+ console.log(e);
+ return false;
+ }
+}
diff --git a/electron/plat/requestNet.ts b/electron/plat/requestNet.ts
index ea8c695c..0d43a51e 100644
--- a/electron/plat/requestNet.ts
+++ b/electron/plat/requestNet.ts
@@ -1,11 +1,4 @@
-/*
- * @Author: nevin
- * @Date: 2025-03-24 22:03:35
- * @LastEditTime: 2025-03-24 22:12:34
- * @LastEditors: nevin
- * @Description:
- */
-import { net } from 'electron';
+import { net, session, Session } from 'electron';
import FormData from 'form-data';
export interface IRequestNetResult<T> {
@@ -24,8 +17,26 @@ export interface IRequestNetParams {
// body是否为文件
isFile?: boolean;
formData?: FormData;
+ // 代理配置,例如 "http=proxy1.com:8080"
+ proxy?: string;
}
+const convertToProxyFormat = (url: string): string => {
+ const urlPattern = /^(https?):\/\/([^:\/]+(:\d+)?)(\/.*)?$/; // 匹配协议、域名/IP 和端口号
+ const ipPattern = /^\d{1,3}(\.\d{1,3}){3}(:\d+)?$/; // 匹配 IP 地址格式以及可选端口号
+
+ if (ipPattern.test(url)) {
+ // 如果是 IP 地址(可能带端口号),默认使用 HTTP 协议
+ return `http=${url}`;
+ } else if (urlPattern.test(url)) {
+ // 如果是 URL,提取协议、域名/IP 和端口号
+ const [, protocol, domainWithPort] = url.match(urlPattern)!;
+ return `${protocol}=${domainWithPort}`;
+ } else {
+ return url;
+ }
+};
+
const requestNet = <T = any>({
headers,
body,
@@ -34,83 +45,104 @@ const requestNet = <T = any>({
isFile,
formData,
isReqFile,
+ proxy,
}: IRequestNetParams): Promise<IRequestNetResult<T>> => {
- return new Promise((resolve, reject) => {
- const req = net.request({
- method: method || 'GET',
- url,
- });
+ return new Promise(async (resolve, reject) => {
+ try {
+ const customSession: Session = session.fromPartition(
+ `persist:proxy-session-${Date.now()}`,
+ );
- if (formData) {
- headers = {
- ...(headers ? headers : {}),
- ...formData.getHeaders(),
- };
- }
+ // 如果传入了代理配置,动态设置代理
+ if (proxy) {
+ const proxyFormat = convertToProxyFormat(proxy);
+ console.log('代理地址:', proxyFormat);
+ await customSession.setProxy({ proxyRules: proxyFormat });
+ }
- // 设置请求头
- if (headers) {
- Object.entries(headers).forEach(([key, value]) => {
- // @ts-ignore
- req.setHeader(key, value);
+ const req = net.request({
+ method: method || 'GET',
+ url,
+ // 如果有代理,使用自定义 session
+ session: proxy ? customSession : undefined,
});
- }
- // 处理响应
- req.on('response', (response) => {
- const chunks: Buffer<ArrayBufferLike>[] = [];
- let data = '';
- response.on('data', (chunk) => {
- if (isReqFile) {
- chunks.push(chunk);
- } else {
- data += chunk;
- }
- });
+ if (formData) {
+ headers = {
+ ...(headers ? headers : {}),
+ ...formData.getHeaders(),
+ ...(proxy
+ ? {
+ 'x-forwarded-for': proxy,
+ }
+ : {}),
+ };
+ }
- response.on('end', () => {
- let parsedData: T;
- if (isReqFile) {
- const buffer = Buffer.concat(chunks);
- parsedData = buffer as any;
- } else {
- try {
- parsedData = JSON.parse(data);
- } catch (e) {
- parsedData = undefined as any;
- console.log(e);
+ // 设置请求头
+ if (headers) {
+ Object.entries(headers).forEach(([key, value]) => {
+ req.setHeader(key, value as string);
+ });
+ }
+
+ // 处理响应
+ req.on('response', (response) => {
+ const chunks: Buffer<ArrayBufferLike>[] = [];
+ let data = '';
+ response.on('data', (chunk) => {
+ if (isReqFile) {
+ chunks.push(chunk);
+ } else {
+ data += chunk;
}
- }
- resolve({
- status: response.statusCode,
- headers: response.headers,
- data: parsedData,
});
- });
- });
- // 错误处理
- req.on('error', (error) => {
- reject(error);
- });
+ response.on('end', () => {
+ let parsedData: T;
+ if (isReqFile) {
+ const buffer = Buffer.concat(chunks);
+ parsedData = buffer as any;
+ } else {
+ try {
+ parsedData = JSON.parse(data);
+ } catch (e) {
+ parsedData = data as T;
+ }
+ }
+ resolve({
+ status: response.statusCode,
+ headers: response.headers,
+ data: parsedData,
+ });
+ });
+ });
- if (formData) {
- formData.pipe(req as any);
- const cReq = formData.submit(url!, (err, res) => {
- cReq.end();
+ // 错误处理
+ req.on('error', (error) => {
+ reject(error);
});
- } else {
- if (isFile) {
- req.setHeader('Content-Type', 'application/octet-stream');
- req.write(body);
+
+ if (formData) {
+ formData.pipe(req as any);
+ const cReq = formData.submit(url!, (err, res) => {
+ cReq.end();
+ });
} else {
- // 发送请求体
- if (body) {
- req.setHeader('Content-Type', 'application/json');
- req.write(typeof body === 'string' ? body : JSON.stringify(body));
+ if (isFile) {
+ req.setHeader('Content-Type', 'application/octet-stream');
+ req.write(body);
+ } else {
+ // 发送请求体
+ if (body) {
+ req.setHeader('Content-Type', 'application/json');
+ req.write(typeof body === 'string' ? body : JSON.stringify(body));
+ }
}
+ req.end();
}
- req.end();
+ } catch (error) {
+ reject(error);
}
});
};
diff --git a/src/assets/svgs/proxy.svg b/src/assets/svgs/proxy.svg
new file mode 100644
index 00000000..80d5f4a8
--- /dev/null
+++ b/src/assets/svgs/proxy.svg
@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1745912872708" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4858" xmlns:xlink="http://www.w3.org/1999/xlink" width="300" height="300"><path d="M832 665.6v-164.266667c0-17.066667-14.933333-32-32-32h-256v-128H789.333333c23.466667 0 42.666667-19.2 42.666667-42.666666V149.333333c0-23.466667-19.2-42.666667-42.666667-42.666666H234.666667c-23.466667 0-42.666667 19.2-42.666667 42.666666v149.333334c0 23.466667 19.2 42.666667 42.666667 42.666666h245.333333v128h-256c-17.066667 0-32 14.933333-32 32v164.266667c-55.466667 14.933333-96 64-96 123.733333 0 70.4 57.6 128 128 128s128-57.6 128-128c0-59.733333-40.533333-108.8-96-123.733333V533.333333h224v132.266667c-55.466667 14.933333-96 64-96 123.733333 0 70.4 57.6 128 128 128s128-57.6 128-128c0-59.733333-40.533333-108.8-96-123.733333V533.333333H768v132.266667c-55.466667 14.933333-96 64-96 123.733333 0 70.4 57.6 128 128 128s128-57.6 128-128c0-59.733333-40.533333-108.8-96-123.733333zM256 170.666667h512v106.666666H256V170.666667z m32 618.666666c0 36.266667-27.733333 64-64 64s-64-27.733333-64-64 27.733333-64 64-64 64 27.733333 64 64zM576 789.333333c0 36.266667-27.733333 64-64 64s-64-27.733333-64-64 27.733333-64 64-64 64 27.733333 64 64z m224 64c-36.266667 0-64-27.733333-64-64s27.733333-64 64-64 64 27.733333 64 64-27.733333 64-64 64z" p-id="4859"></path></svg>
\ No newline at end of file
diff --git a/src/icp/account.ts b/src/icp/account.ts
index 40e5f098..6a1753d5 100644
--- a/src/icp/account.ts
+++ b/src/icp/account.ts
@@ -138,3 +138,8 @@ export async function icpAccountEditGroup(id: number, groupId: number) {
groupId,
);
}
+
+// 代理地址有效性检测
+export async function icpProxyCheck(proxy: string) {
+ return await window.ipcRenderer.invoke('ICP_ACCOUNTS_PROXY_CHECK', proxy);
+}
diff --git a/src/store/account.ts b/src/store/account.ts
index 05050dfa..395c091a 100644
--- a/src/store/account.ts
+++ b/src/store/account.ts
@@ -18,6 +18,7 @@ export interface IAccountStore {
accountMap: Map<number, AccountInfo>;
unBindFn?: () => void;
accountGroupList: AccountGroupItem[];
+ accountGroupMap: Map<number, AccountGroupItem>;
}
const store: IAccountStore = {
@@ -25,6 +26,7 @@ const store: IAccountStore = {
accountList: [],
// 分组的账户数据
accountGroupList: [],
+ accountGroupMap: new Map([]),
accountMap: new Map([]),
unBindFn: undefined,
};
@@ -55,7 +57,6 @@ export const useAccountStore = create(
async getAccountList() {
const accountMap = new Map<number, AccountInfo>([]);
const result = await icpGetAccountList();
- console.log(result);
if (!result) return;
for (const item of result) {
@@ -85,14 +86,16 @@ export const useAccountStore = create(
accountGroupMap.set(v.id, accountGroupItem);
});
get().accountList.map((v) => {
- accountGroupMap.get(v.groupId!)!.children.push(v);
+ accountGroupMap.get(v.groupId!)!.children?.push(v);
});
accountGroupList.sort((a, b) => {
return a.rank - b.rank;
});
+
set({
accountGroupList,
+ accountGroupMap,
});
},
diff --git a/src/views/account/components/AccountSidebar/AccountSidebar.module.scss b/src/views/account/components/AccountSidebar/AccountSidebar.module.scss
index 60534f75..4425df08 100644
--- a/src/views/account/components/AccountSidebar/AccountSidebar.module.scss
+++ b/src/views/account/components/AccountSidebar/AccountSidebar.module.scss
@@ -298,6 +298,15 @@
position: relative;
padding: 10px;
+ &-head {
+ display: flex;
+ justify-content: space-between;
+ margin-bottom: 10px;
+ &-proxy {
+
+ }
+ }
+
.ant-drawer-header {
height: 40px;
.ant-drawer-close {
diff --git a/src/views/account/components/AccountSidebar/AccountSidebar.tsx b/src/views/account/components/AccountSidebar/AccountSidebar.tsx
index 9bc00c17..c68646e3 100644
--- a/src/views/account/components/AccountSidebar/AccountSidebar.tsx
+++ b/src/views/account/components/AccountSidebar/AccountSidebar.tsx
@@ -9,13 +9,13 @@ import {
import styles from './AccountSidebar.module.scss';
import { AccountInfo, AccountPlatInfoMap } from '../../comment';
import { Avatar, Button, Collapse, message, Popover, Tooltip } from 'antd';
-import { accountLogin, acpAccountLoginCheck } from '../../../../icp/account';
+import { accountLogin, acpAccountLoginCheck } from '@/icp/account';
import AddAccountModal from '../AddAccountModal';
import {
AccountStatus,
defaultAccountGroupId,
} from '../../../../../commont/AccountEnum';
-import {
+import Icon, {
CheckCircleOutlined,
PlusOutlined,
UserOutlined,
@@ -26,8 +26,10 @@ import PubAccountDetModule, {
IPubAccountDetModuleRef,
} from '../../../publish/components/PubAccountDetModule/PubAccountDetModule';
import { useShallow } from 'zustand/react/shallow';
-import { useAccountStore } from '../../../../store/account';
-import UserManageModal from './UserManageModal';
+import { useAccountStore } from '@/store/account';
+import UserManageModal, { IUserManageModalRef } from './UserManageModal';
+import ProxyManage from '@/views/account/components/AccountSidebar/ProxyManage';
+import ProxyIcon from '@/assets/svgs/proxy.svg?react';
export interface IAccountSidebarRef {}
@@ -138,6 +140,8 @@ const AccountSidebar = memo(
})),
);
const [userManageModalOpen, setUserManageModalOpen] = useState(false);
+ const [proxyManageOpen, setProxyManageOpen] = useState(false);
+ const userManageModalRef = useRef<IUserManageModalRef>(null);
// 在组件内部过滤账号列表,而不是在 useAccountStore 中过滤
const accountList = useMemo(() => {
@@ -148,7 +152,16 @@ const AccountSidebar = memo(
return (
<>
+ <ProxyManage
+ open={proxyManageOpen}
+ onCancel={() => setProxyManageOpen(false)}
+ onExamineAccountClick={(groupId) => {
+ userManageModalRef.current?.setActiveGroup(groupId);
+ setUserManageModalOpen(true);
+ }}
+ />
<UserManageModal
+ ref={userManageModalRef}
open={userManageModalOpen}
onCancel={() => setUserManageModalOpen(false)}
/>
@@ -186,6 +199,16 @@ const AccountSidebar = memo(
></Button>
</Tooltip>
</div>
+ <div className="accountSidebar-top-box">
+ <Button
+ icon={<Icon component={ProxyIcon} />}
+ onClick={() => {
+ setProxyManageOpen(true);
+ }}
+ >
+ 代理管理器
+ </Button>
+ </div>
</div>
<Collapse
@@ -197,9 +220,9 @@ const AccountSidebar = memo(
<>
{v.name}
<span className="accountSidebar-userCount">
- {v.children.length}/
+ {v.children?.length}/
{
- v.children.map(
+ v.children?.map(
(v) => v.status === AccountStatus.USABLE,
).length
}
@@ -208,7 +231,7 @@ const AccountSidebar = memo(
),
children: (
<ul key={v.id} className="accountList">
- {v.children.map((account) => {
+ {v.children?.map((account) => {
const platInfo = AccountPlatInfoMap.get(account.type)!;
return (
<li
diff --git a/src/views/account/components/AccountSidebar/ProxyManage/index.tsx b/src/views/account/components/AccountSidebar/ProxyManage/index.tsx
new file mode 100644
index 00000000..bc475019
--- /dev/null
+++ b/src/views/account/components/AccountSidebar/ProxyManage/index.tsx
@@ -0,0 +1,184 @@
+import {
+ ForwardedRef,
+ forwardRef,
+ memo,
+ useMemo,
+ useRef,
+ useState,
+} from 'react';
+import styles from './proxyManage.module.scss';
+import { Button, Input, message, Modal, Table, TableProps } from 'antd';
+import { AccountGroupItem, useAccountStore } from '@/store/account';
+import { useShallow } from 'zustand/react/shallow';
+import { SearchOutlined } from '@ant-design/icons';
+import accountStyles from '../AccountSidebar.module.scss';
+import { icpEditDeleteAccountGroup, icpProxyCheck } from '@/icp/account';
+
+export interface IProxyManageRef {}
+
+export interface IProxyManageProps {
+ open: boolean;
+ onCancel: () => void;
+ onExamineAccountClick: (groupId: number) => void;
+}
+
+const ProxyManage = memo(
+ forwardRef(
+ (
+ { open, onCancel, onExamineAccountClick }: IProxyManageProps,
+ ref: ForwardedRef<IProxyManageRef>,
+ ) => {
+ const { accountGroupList, getAccountGroup } = useAccountStore(
+ useShallow((state) => ({
+ accountGroupList: state.accountGroupList,
+ getAccountGroup: state.getAccountGroup,
+ })),
+ );
+ const [proxyOpen, setProxyOpen] = useState(false);
+ const [proxyName, setProxyName] = useState('');
+ const [proxyLoading, setProxyLoading] = useState(false);
+ const [submitLoading, setSubmitLoading] = useState(false);
+ const proxyGroupData = useRef<AccountGroupItem>(undefined);
+
+ const columns = useMemo(() => {
+ const columns: TableProps<AccountGroupItem>['columns'] = [
+ {
+ title: '分组名称',
+ key: 'name',
+ dataIndex: 'name',
+ },
+ {
+ title: '代理地址',
+ key: 'proxy',
+ dataIndex: 'proxyIp',
+ },
+ {
+ title: '账号数量',
+ key: 'accountCount',
+ width: 110,
+ sorter: (a, b) => b.children?.length - a.children?.length,
+ render: (_, gri) => {
+ return (
+ <>
+ <div className={styles.accountCount}>
+ <span className="accountCount-count">
+ {gri.children?.length}
+ </span>
+ {(gri.children?.length || 0) > 0 && (
+ <SearchOutlined
+ title="查看账号"
+ onClick={() => {
+ onExamineAccountClick(gri.id);
+ }}
+ />
+ )}
+ </div>
+ </>
+ );
+ },
+ },
+ {
+ title: '操作',
+ width: 100,
+ render: (_, gri) => {
+ return (
+ <>
+ <Button
+ size="small"
+ type="link"
+ onClick={() => {
+ proxyGroupData.current = gri;
+ setProxyName(gri.proxyIp || '');
+ setProxyOpen(true);
+ }}
+ >
+ 设置代理
+ </Button>
+ </>
+ );
+ },
+ },
+ ];
+ return columns;
+ }, []);
+
+ return (
+ <>
+ <Modal
+ title="设置代理"
+ open={proxyOpen}
+ onCancel={() => setProxyOpen(false)}
+ footer={
+ <>
+ <Button onClick={() => setProxyOpen(false)}>取消</Button>
+ <Button
+ type="primary"
+ loading={submitLoading}
+ onClick={async () => {
+ setSubmitLoading(true);
+ const proxyCheckRes = await icpProxyCheck(proxyName);
+ if (!proxyCheckRes) {
+ setSubmitLoading(false);
+ return message.error('代理地址不可用');
+ }
+ await icpEditDeleteAccountGroup({
+ id: proxyGroupData.current!.id,
+ proxyIp: proxyName,
+ });
+ await getAccountGroup();
+ setProxyOpen(false);
+ setSubmitLoading(false);
+ message.success('代理地址添加成功!');
+ }}
+ >
+ 确认
+ </Button>
+ </>
+ }
+ >
+ <div
+ className={`${accountStyles.createGroup} ${styles.proxyInput}`}
+ >
+ <label>代理地址</label>
+ <Input
+ value={proxyName}
+ placeholder="请输入代理地址"
+ onChange={(e) => setProxyName(e.target.value)}
+ />
+ <Button
+ disabled={proxyName.length === 0}
+ loading={proxyLoading}
+ onClick={async () => {
+ setProxyLoading(true);
+ const res = await icpProxyCheck(proxyName);
+ setProxyLoading(false);
+ if (res) {
+ message.success('代理地址可用');
+ } else {
+ message.error('代理地址不可用');
+ }
+ }}
+ >
+ 验证连接
+ </Button>
+ </div>
+ </Modal>
+ <Modal open={open} title="代理管理器" onCancel={onCancel} width={700}>
+ <div className={styles.proxyManage}>
+ <Table<AccountGroupItem>
+ columns={columns}
+ dataSource={accountGroupList}
+ rowKey="id"
+ childrenColumnName="1"
+ scroll={{ y: 500 }}
+ />
+ </div>
+ </Modal>
+ </>
+ );
+ },
+ ),
+);
+ProxyManage.displayName = 'ProxyManage';
+
+export default ProxyManage;
diff --git a/src/views/account/components/AccountSidebar/ProxyManage/proxyManage.module.scss b/src/views/account/components/AccountSidebar/ProxyManage/proxyManage.module.scss
new file mode 100644
index 00000000..13fac5b0
--- /dev/null
+++ b/src/views/account/components/AccountSidebar/ProxyManage/proxyManage.module.scss
@@ -0,0 +1,27 @@
+.proxyManage {
+
+}
+.accountCount {
+ :global {
+ .accountCount-count {
+ display: inline-block;
+ margin-right: 5px;
+ }
+ .anticon {
+ color: var(--grayColor8);
+ cursor: pointer;
+ }
+ }
+}
+
+.proxyInput {
+ input {
+ border-top-right-radius: 0;
+ border-bottom-right-radius: 0;
+ }
+ button {
+ border-top-left-radius: 0;
+ border-bottom-left-radius: 0;
+ border-left: none;
+ }
+}
\ No newline at end of file
diff --git a/src/views/account/components/AccountSidebar/UserManageModal.tsx b/src/views/account/components/AccountSidebar/UserManageModal.tsx
index a6e6dfdc..35417d23 100644
--- a/src/views/account/components/AccountSidebar/UserManageModal.tsx
+++ b/src/views/account/components/AccountSidebar/UserManageModal.tsx
@@ -2,6 +2,7 @@ import {
ForwardedRef,
forwardRef,
memo,
+ useImperativeHandle,
useMemo,
useRef,
useState,
@@ -17,7 +18,7 @@ import {
Tooltip,
} from 'antd';
import styles from './AccountSidebar.module.scss';
-import { useAccountStore } from '../../../../store/account';
+import { useAccountStore } from '@/store/account';
import { useShallow } from 'zustand/react/shallow';
import { AccountModel } from '../../../../../electron/db/models/account';
import { AccountPlatInfoMap } from '../../comment';
@@ -27,15 +28,17 @@ import {
DeleteOutlined,
WarningOutlined,
} from '@ant-design/icons';
-import { AvatarPlat } from '../../../publish/components/PubProgressModule/PubProgressModule';
+import { AvatarPlat } from '@/views/publish/components/PubProgressModule/PubProgressModule';
import {
icpAccountEditGroup,
icpDeleteAccounts,
icpEditDeleteAccountGroup,
-} from '../../../../icp/account';
+} from '@/icp/account';
import UserManageSidebar from './UserManageSidebar';
-export interface IUserManageModalRef {}
+export interface IUserManageModalRef {
+ setActiveGroup: (groupId: number) => void;
+}
export interface IUserManageModalProps {
open: boolean;
@@ -225,6 +228,11 @@ const UserManageModal = memo(
return accountGroupList.find((v) => v.id === activeGroup)?.children;
}, [accountMap, activeGroup, accountGroupList]);
+ const imperativeHandle: IUserManageModalRef = {
+ setActiveGroup,
+ };
+ useImperativeHandle(ref, () => imperativeHandle);
+
return (
<>
<Modal
@@ -264,6 +272,7 @@ const UserManageModal = memo(
<Modal
open={open}
title="账号管理器"
+ zIndex={10001}
footer={null}
width={1000}
onCancel={close}
@@ -280,6 +289,9 @@ const UserManageModal = memo(
/>
<div className="userManage-content">
+ {/*<div className="userManage-content-head">*/}
+ {/* <div></div>*/}
+ {/*</div>*/}
<Table<AccountModel>
columns={columns}
dataSource={accountListLast}
diff --git a/src/views/account/components/AccountSidebar/UserManageSidebar.tsx b/src/views/account/components/AccountSidebar/UserManageSidebar.tsx
index b4151bab..c79c1761 100644
--- a/src/views/account/components/AccountSidebar/UserManageSidebar.tsx
+++ b/src/views/account/components/AccountSidebar/UserManageSidebar.tsx
@@ -5,14 +5,14 @@ import {
PlusOutlined,
UnorderedListOutlined,
} from '@ant-design/icons';
-import { useAccountStore } from '../../../../store/account';
+import { useAccountStore } from '@/store/account';
import { useShallow } from 'zustand/react/shallow';
import styles from './AccountSidebar.module.scss';
import {
icpEditDeleteAccountGroup,
icpAddAccountGroup,
icpDeleteAccountGroup,
-} from '../../../../icp/account';
+} from '@/icp/account';
import { defaultAccountGroupId } from '../../../../../commont/AccountEnum';
import { Menu, MenuItem } from '@electron-uikit/contextmenu/renderer';
import { ReactSortable } from 'react-sortablejs';
diff --git a/src/views/account/components/AddAccountModal.tsx b/src/views/account/components/AddAccountModal.tsx
index 3a861624..772b4be6 100644
--- a/src/views/account/components/AddAccountModal.tsx
+++ b/src/views/account/components/AddAccountModal.tsx
@@ -40,11 +40,10 @@ const AddAccountModal = memo(
<div className="addAccountModal_plats">
{Array.from(AccountPlatInfoMap).map(([key, value]) => {
return (
- <Tooltip title={value.tips?.account}>
+ <Tooltip title={value.tips?.account} key={key}>
<Button
type="text"
className="addAccountModal_plats-item"
- key={key}
onClick={async () => {
const res = await accountLogin(key);
if (!res) return;
diff --git a/src/views/publish/children/imagePage/page.tsx b/src/views/publish/children/imagePage/page.tsx
index e11e9c56..9f9d533a 100644
--- a/src/views/publish/children/imagePage/page.tsx
+++ b/src/views/publish/children/imagePage/page.tsx
@@ -209,6 +209,7 @@ export default function Page() {
onClose={() => setPubProgressModuleOpen(false)}
/>
<PubAccountDetModule
+ isCheckProxy={true}
ref={pubAccountDetModuleRef}
accounts={imageAccounts
.map((v) => v.account)
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
index 3650d2fc..484f934e 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
@@ -334,6 +334,7 @@ const VideoPubSetModal = memo(
/>
<PubAccountDetModule
ref={pubAccountDetModuleRef}
+ isCheckProxy={true}
accounts={videoListChoose
.map((v) => v.account)
.filter((v) => v !== undefined)}
diff --git a/src/views/publish/components/PubAccountDetModule/PubAccountDetModule.tsx b/src/views/publish/components/PubAccountDetModule/PubAccountDetModule.tsx
index 20fd5126..f20084d3 100644
--- a/src/views/publish/components/PubAccountDetModule/PubAccountDetModule.tsx
+++ b/src/views/publish/components/PubAccountDetModule/PubAccountDetModule.tsx
@@ -11,9 +11,15 @@ import { Alert, Button, Checkbox, message, Modal, Tooltip } from 'antd';
import { CheckCircleOutlined, CloseCircleOutlined } from '@ant-design/icons';
import { AccountInfo } from '../../../account/comment';
import { LoadingOutlined } from '@ant-design/icons';
-import { accountLogin, acpAccountLoginCheck } from '../../../../icp/account';
+import {
+ accountLogin,
+ acpAccountLoginCheck,
+ icpProxyCheck,
+} from '../../../../icp/account';
import { AccountStatus } from '../../../../../commont/AccountEnum';
import { AvatarPlat } from '../PubProgressModule/PubProgressModule';
+import { AccountGroupItem, useAccountStore } from '@/store/account';
+import { useShallow } from 'zustand/react/shallow';
export interface IPubAccountDetModuleRef {
// 打开弹框并且开始检测
@@ -38,6 +44,8 @@ export interface IPubAccountDetModuleProps {
tips?: string;
// 是否需要footer操作栏
isFooter?: boolean;
+ // 是否需要校验代理地址
+ isCheckProxy?: boolean;
}
// 发布用户检测
@@ -53,6 +61,7 @@ const PubAccountDetModule = memo(
title = '发布检测',
tips = '以下账号将发布至平台',
isFooter = true,
+ isCheckProxy = false,
}: IPubAccountDetModuleProps,
ref: ForwardedRef<IPubAccountDetModuleRef>,
) => {
@@ -64,6 +73,15 @@ const PubAccountDetModule = memo(
);
const [progress, setProgress] = useState(0);
const [isFilterAccountOl, setIsFilterAccountOl] = useState(false);
+ // 代理失效的账户组Map
+ const [proxyInvalidAccountMap, setProxyInvalidAccountMap] = useState<
+ Map<number, AccountGroupItem>
+ >(new Map());
+ const { accountGroupMap } = useAccountStore(
+ useShallow((state) => ({
+ accountGroupMap: state.accountGroupMap,
+ })),
+ );
useEffect(() => {
if (open) {
@@ -84,34 +102,77 @@ const PubAccountDetModule = memo(
if (onClose) onClose();
};
+ // 检测账户状态
const retLoginStatusCore = async (account: AccountInfo) => {
const res = await acpAccountLoginCheck(account.type, account.uid);
setProgress((prevProgress) => prevProgress + 1);
return res;
};
+ // 检测代理地址有效性
+ const retProxyCheckCore = async (group: AccountGroupItem) => {
+ let status = true;
+ if (group.proxyIp) {
+ status = await icpProxyCheck(group.proxyIp);
+ }
+ return {
+ status,
+ group,
+ };
+ };
+
const imperative: IPubAccountDetModuleRef = {
async startDet() {
+ setProxyInvalidAccountMap(new Map());
setDisabledIdSet(new Set([]));
setOpen(true);
setDetLoading(true);
- const tasks: Promise<AccountInfo>[] = [];
+ // 账户状态
+ 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];
- tasks.push(retLoginStatusCore(account));
+ tasksAccountStatus.push(retLoginStatusCore(account));
+
+ if (isCheckProxy) {
+ if (!proxyGroupSet.has(account.groupId!)) {
+ tasksProxyCheck.push(
+ retProxyCheckCore(accountGroupMap.get(account.groupId!)!),
+ );
+ proxyGroupSet.add(account.groupId!);
+ }
+ }
}
- const res = await Promise.all(tasks);
+
+ const resGroupProxyStatus = await Promise.all(tasksProxyCheck);
+ const resAccountStatus = await Promise.all(tasksAccountStatus);
setTimeout(() => {
- if (onDetFinish) onDetFinish(res);
+ if (onDetFinish) onDetFinish(resAccountStatus);
setDetLoading(false);
const disabledIdSet = new Set<number>([]);
- res.map((v) =>
+ 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;
+ });
+ }
+ });
}, 100);
},
};
@@ -129,27 +190,53 @@ const PubAccountDetModule = memo(
<div className={styles.pubAccountDetModule}>
<div className="pubAccountDetModule-tips">
{!detLoading ? (
- disabledIdSet.size === 0 ? (
- `${tips}`
- ) : (
- <Alert
- message={
- <div className={styles.loginStatusDisable}>
- <span>账号登录状态失效,点击账户重新登录</span>
- <Checkbox
- checked={isFilterAccountOl}
- onChange={(e) =>
- setIsFilterAccountOl(e.target.checked)
- }
- >
- 过滤在线账户
- </Checkbox>
- </div>
- }
- type="error"
- showIcon
- />
- )
+ <>
+ {disabledIdSet.size === 0 ? (
+ proxyInvalidAccountMap.size === 0 && `${tips}`
+ ) : (
+ <Alert
+ 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}>
+ 用户组:{v.name},代理地址:{v.proxyIp}{' '}
+ 不可用
+ </li>
+ );
+ },
+ )}
+ </ul>
+ </div>
+ }
+ type="error"
+ showIcon
+ />
+ )}
+ </>
) : (
<>
正在检测账号状态 {progress} / {accounts.length}
@@ -191,11 +278,13 @@ const PubAccountDetModule = memo(
<div
className={[
'pubAccountDetModule-accounts-name',
- disabledIdSet.has(v.id) &&
- 'pubAccountDetModule-accounts-disable',
- !disabledIdSet.has(v.id) &&
- !detLoading &&
- 'pubAccountDetModule-accounts-ol',
+
+ disabledIdSet.has(v.id) ||
+ proxyInvalidAccountMap.get(v.groupId)
+ ? 'pubAccountDetModule-accounts-disable'
+ : !disabledIdSet.has(v.id) &&
+ !detLoading &&
+ 'pubAccountDetModule-accounts-ol',
].join(' ')}
>
<div className="pubAccountDetModule-accounts-name-wrapper">
@@ -219,7 +308,9 @@ const PubAccountDetModule = memo(
<Button
type="primary"
loading={detLoading}
- disabled={disabledIdSet.size !== 0}
+ disabled={
+ disabledIdSet.size !== 0 || proxyInvalidAccountMap.size !== 0
+ }
onClick={() => {
setOpen(false);
if (onPubClick) onPubClick();