Skip to content

Let's use AI to Earn!

feat: 添加首次进入系统和每天检测账户登录的逻辑

gaoSir16df6a4c85a7
diff --git a/electron/main/app.ts b/electron/main/app.ts
index e20a9e6b..efdad929 100644
--- a/electron/main/app.ts
+++ b/electron/main/app.ts
@@ -19,7 +19,6 @@ 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: [
@@ -45,19 +44,6 @@ export class App {
async _init() {
// 初始化数据库
await initSqlite3Db();
- this.timeingCheckAccount();
- }
-
- // 轮询检测账户有效性
- async timeingCheckAccount() {
- return new Promise(async () => {
- while (true) {
- // TODO : 轮询检测账户有效性
-
- // 等待24小时执行,如果用户没有关闭应用
- await sleep(3600000 * 24);
- }
- });
}
}
diff --git a/electron/plat/douyin/index.ts b/electron/plat/douyin/index.ts
index 9e14c351..fafbd91d 100644
--- a/electron/plat/douyin/index.ts
+++ b/electron/plat/douyin/index.ts
@@ -1933,7 +1933,7 @@ export class DouyinService {
* 发布专用请求方法
*/
private async makePublishRequest(
- url: string,
+ url: string,
options: any,
proxy: string,
): Promise<any> {
@@ -2415,29 +2415,26 @@ export class DouyinService {
// 回复其他人的评论
async creatorCommentReplyOther(cookie: Electron.Cookie[], data: any) {
- console.log('wentipaicha1')
+ console.log('wentipaicha1');
const thisUri = `https://www.douyin.com/aweme/v1/web/comment/publish/?${jsonToQueryString(
{
aid: '6383',
},
)}`;
- console.log('wentipaicha2')
+ console.log('wentipaicha2');
const cookieString = CommonUtils.convertCookieToJson(cookie);
- console.log('wentipaicha3')
+ console.log('wentipaicha3');
const csrfToken = await this.getSecsdkCsrfToken(cookieString);
- console.log('wentipaicha4')
- const res = await this.postFormData(
- thisUri,
- {
- method: 'POST',
- headers: {
- Cookie: cookieString,
- 'X-Secsdk-Csrf-Token': csrfToken,
- referer: `https://www.douyin.com/video/${data.aweme_id}`,
- },
- data: data,
- }
- );
+ console.log('wentipaicha4');
+ const res = await this.postFormData(thisUri, {
+ method: 'POST',
+ headers: {
+ Cookie: cookieString,
+ 'X-Secsdk-Csrf-Token': csrfToken,
+ referer: `https://www.douyin.com/video/${data.aweme_id}`,
+ },
+ data: data,
+ });
console.log('douyin index ------ res', res);
return res;
}
diff --git a/src/store/account.ts b/src/store/account.ts
index 395c091a..4b6a0e57 100644
--- a/src/store/account.ts
+++ b/src/store/account.ts
@@ -1,13 +1,16 @@
import { create } from 'zustand';
import { combine } from 'zustand/middleware';
import lodash from 'lodash';
-import { AccountInfo } from '../views/account/comment';
+import { AccountInfo } from '@/views/account/comment';
import {
AccountGroup,
+ acpAccountLoginCheck,
icpGetAccountGroup,
icpGetAccountList,
-} from '../icp/account';
-import { onAccountLoginFinish } from '../icp/receiveMsg';
+} from '@/icp/account';
+import { onAccountLoginFinish } from '@/icp/receiveMsg';
+import { sleep } from '@@/utils';
+import { AccountModel } from '../../electron/db/models/account';
export interface AccountGroupItem extends AccountGroup {
children: AccountInfo[];
@@ -100,8 +103,6 @@ export const useAccountStore = create(
},
async init() {
- methods.getAccountList();
-
const unBindFn = onAccountLoginFinish(() => {
methods.getAccountList();
});
@@ -109,6 +110,31 @@ export const useAccountStore = create(
set({
unBindFn,
});
+
+ await methods.getAccountList();
+ methods.timeingCheckAccount();
+ },
+
+ // 轮询检测账户有效性 core
+ async checkAccountCore(account: AccountModel) {
+ await acpAccountLoginCheck(account.type, account.uid);
+ },
+ // 轮询检测账户有效性
+ async timeingCheckAccount() {
+ return new Promise(async () => {
+ while (true) {
+ const { accountList } = get();
+ const tasks: Promise<void>[] = [];
+ for (let i = 0; i < accountList.length; i++) {
+ const account = accountList[i];
+ tasks.push(methods.checkAccountCore(account));
+ }
+ await Promise.all(tasks);
+
+ // 等待24小时执行,如果用户没有关闭应用
+ await sleep(3600000 * 24);
+ }
+ });
},
};
return methods;