Skip to content

Let's use AI to Earn!

点赞问题

DESKTOP-ZTS2NQJNAec693c01c743
diff --git a/electron/main/plat/PlatformBase.ts b/electron/main/plat/PlatformBase.ts
index 404c3e6a..6317741d 100644
--- a/electron/main/plat/PlatformBase.ts
+++ b/electron/main/plat/PlatformBase.ts
@@ -74,6 +74,30 @@ export abstract class PlatformBase {
time: string[],
): Promise<DashboardData[]>;
+
+
+
+ /**
+ * 获取作品列表
+ * @param account 账户
+ * @param pcursor 分页游标
+ */
+ abstract dianzanDyOther(
+ account: AccountModel,
+ pcursor?: string,
+ ): Promise<any>;
+
+
+ /**
+ * 获取作品列表
+ * @param account 账户
+ * @param pcursor 分页游标
+ */
+ abstract shoucangDyOther(
+ account: AccountModel,
+ pcursor?: string,
+ ): Promise<any>;
+
/**
* 获取作品列表
* @param account 账户
diff --git a/electron/main/plat/index.ts b/electron/main/plat/index.ts
index be003f7d..d7f0acad 100644
--- a/electron/main/plat/index.ts
+++ b/electron/main/plat/index.ts
@@ -176,6 +176,28 @@ class PlatController {
return await platform.getUsers(params);
}
+
+
+ /**
+ * 获取作品列表
+ * @param account
+ * @param pcursor
+ */
+ public async dianzanDyOther(account: AccountModel, pcursor?: string) {
+ const platform = this.platforms.get(account.type)!;
+ return await platform.dianzanDyOther(account, pcursor);
+ }
+
+ /**
+ * 获取作品列表
+ * @param account
+ * @param pcursor
+ */
+ public async shoucangDyOther(account: AccountModel, pcursor?: string) {
+ const platform = this.platforms.get(account.type)!;
+ return await platform.shoucangDyOther(account, pcursor);
+ }
+
/**
* 获取作品列表
* @param account
diff --git a/electron/main/plat/platforms/douyin/index.ts b/electron/main/plat/platforms/douyin/index.ts
index 2472d6aa..ec6f7ae8 100644
--- a/electron/main/plat/platforms/douyin/index.ts
+++ b/electron/main/plat/platforms/douyin/index.ts
@@ -297,19 +297,53 @@ export class Douyin extends PlatformBase {
};
}
+
+
+
+ async dianzanDyOther(
+ account: AccountModel,
+ dataId: string, // 作品ID
+ ) {
+ console.log('------ dianzanDyOther3333', dataId);
+ const cookie: CookiesType = JSON.parse(account.loginCookie);
+ const res = await douyinService.creatorDianzanOther(cookie, {
+ aweme_id: dataId,
+ item_type: 0,
+ type: 1,
+ });
+
+ console.log('------ res', res);
+
+ return res;
+ }
+
+
+
+ async shoucangDyOther(
+ account: AccountModel,
+ dataId: string, // 作品ID
+ ) {
+
+ const cookie: CookiesType = JSON.parse(account.loginCookie);
+ const res = await douyinService.creatorShoucangOther(cookie, {
+ aweme_id: dataId,
+ action: 1,
+ aweme_type: 0
+ });
+
+ console.log('------ res', res);
+
+ return res;
+ }
+
+
+
+
async createCommentByOther(
account: AccountModel,
dataId: string, // 作品ID
content: string,
) {
- // const cookie: CookiesType = JSON.parse(account.loginCookie);
- // const res = await douyinService.creatorCommentReply(cookie, {
- // comment_Id: '',
- // item_id: dataId,
- // text: content,
- // });
-
- // return res.status === 200 && res.data.status_code === 0;
const cookie: CookiesType = JSON.parse(account.loginCookie);
const res = await douyinService.creatorCommentReplyOther(cookie, {
diff --git a/electron/main/reply/controller.ts b/electron/main/reply/controller.ts
index 904fb6a2..2b995b02 100644
--- a/electron/main/reply/controller.ts
+++ b/electron/main/reply/controller.ts
@@ -46,7 +46,7 @@ export class ReplyController {
count: 0,
};
- const res = await platController.getWorkList(account, pcursor);
+ const res = await platController.dianzanDyOther(account, pcursor);
return res;
}
@@ -69,7 +69,7 @@ export class ReplyController {
count: 0,
};
- const res = await platController.getWorkList(account, pcursor);
+ const res = await platController.shoucangDyOther(account, pcursor);
return res;
}
diff --git a/electron/plat/douyin/index.ts b/electron/plat/douyin/index.ts
index c6d74a2f..7be3814a 100644
--- a/electron/plat/douyin/index.ts
+++ b/electron/plat/douyin/index.ts
@@ -2375,6 +2375,198 @@ export class DouyinService {
return res;
}
+ /**
+ * 发送表单数据请求
+ * @param url 请求URL
+ * @param options 请求选项
+ * @param retryOptions 重试选项
+ */
+ private async postFormData(
+ url: string,
+ options: any,
+ retryOptions: { maxRetries?: number, retryDelay?: number } = {}
+ ): Promise<any> {
+ console.log(`[${new Date().toLocaleString()}] 开始发起表单数据请求...`);
+ console.log(`[${new Date().toLocaleString()}] 请求URL:`, url);
+ console.log(`[${new Date().toLocaleString()}] 请求参数:`, options);
+
+ const maxRetries = retryOptions.maxRetries || 3;
+ const retryDelay = retryOptions.retryDelay || 2000;
+ let retryCount = 0;
+
+ while (retryCount < maxRetries) {
+ try {
+ // 创建 FormData 对象
+ const formData = new FormData();
+ const postData = options.data;
+
+ // 将数据添加到 FormData
+ Object.keys(postData).forEach((key) => {
+ if (typeof postData[key] === 'object') {
+ formData.append(key, JSON.stringify(postData[key]));
+ } else {
+ formData.append(key, postData[key]);
+ }
+ });
+
+ console.log(
+ `[${new Date().toLocaleString()}] 请求体数据:`,
+ Object.fromEntries(formData.entries()),
+ );
+
+ const response = await fetch(url, {
+ method: options.method || 'POST',
+ headers: {
+ ...options.headers,
+ },
+ body: formData,
+ });
+
+ console.log(
+ `[${new Date().toLocaleString()}] 收到响应,状态码:`,
+ response.status,
+ );
+ console.log(
+ `[${new Date().toLocaleString()}] 响应头:`,
+ Object.fromEntries(response.headers.entries()),
+ );
+
+ // 检查HTTP状态码
+ if (!response.ok) {
+ console.error(`[${new Date().toLocaleString()}] HTTP错误状态码: ${response.status}`);
+ if (retryCount < maxRetries - 1) {
+ retryCount++;
+ console.log(`[${new Date().toLocaleString()}] 状态码错误,${retryDelay/1000}秒后进行第${retryCount}次重试...`);
+ await new Promise(resolve => setTimeout(resolve, retryDelay));
+ continue;
+ }
+ throw new Error(`服务器返回错误状态码: ${response.status}`);
+ }
+
+ const responseText = await response.text();
+ console.log(
+ `[${new Date().toLocaleString()}] 原始响应数据长度:`,
+ responseText.length,
+ );
+ console.log(
+ `[${new Date().toLocaleString()}] 原始响应数据:`,
+ responseText,
+ );
+
+ // 检查响应数据是否为空
+ if (!responseText || responseText.trim() === '') {
+ console.error(`[${new Date().toLocaleString()}] 响应数据为空,尝试次数: ${retryCount + 1}/${maxRetries}`);
+
+ if (retryCount < maxRetries - 1) {
+ retryCount++;
+ console.log(`[${new Date().toLocaleString()}] 等待${retryDelay/1000}秒后重试...`);
+ await new Promise(resolve => setTimeout(resolve, retryDelay));
+ continue;
+ }
+
+ throw new Error('服务器多次返回空数据,请检查网络连接或抖音服务器状态');
+ }
+
+ try {
+ const result = JSON.parse(responseText);
+ console.log(
+ `[${new Date().toLocaleString()}] 解析后的响应数据:`,
+ result,
+ );
+
+ if (!result) {
+ console.error(`[${new Date().toLocaleString()}] 解析后的数据为空`);
+ throw new Error('解析后的数据为空');
+ }
+
+ return result;
+ } catch (err) {
+ console.error(
+ `[${new Date().toLocaleString()}] 解析响应数据失败:`,
+ err,
+ );
+ console.error(
+ `[${new Date().toLocaleString()}] 导致错误的原始数据:`,
+ responseText,
+ );
+ throw new Error(
+ `解析响应数据失败: ${err instanceof Error ? err.message : String(err)}`,
+ );
+ }
+ } catch (error) {
+ if (retryCount < maxRetries - 1) {
+ retryCount++;
+ console.log(`[${new Date().toLocaleString()}] 请求失败,${retryDelay/1000}秒后进行第${retryCount}次重试...`);
+ await new Promise(resolve => setTimeout(resolve, retryDelay));
+ continue;
+ }
+
+ console.error(`[${new Date().toLocaleString()}] 请求发生错误:`, error);
+ throw new Error(
+ `请求失败: ${error instanceof Error ? error.message : String(error)}`,
+ );
+ }
+ }
+
+ // 这里不应该被执行到,但为了类型安全添加
+ throw new Error('请求失败: 超过最大重试次数');
+ }
+
+ // 点赞
+ async creatorDianzanOther(cookie: Electron.Cookie[], data: any) {
+ console.log('------ creatorDianzanOther-data@@@@@');
+ const thisUri = `https://www.douyin.com/aweme/v1/web/commit/item/digg/?${jsonToQueryString(
+ {
+ aid: '6383',
+ },
+ )}`;
+ console.log('------ creatorDianzanOther-data', data);
+ console.log('------ creatorDianzanOther-thisUri', thisUri);
+ const cookieString = CommonUtils.convertCookieToJson(cookie);
+ const csrfToken = await this.getSecsdkCsrfToken(cookieString);
+
+ // 使用新的 postRequest 方法替代 makePublishRequest
+ 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}`,
+ 'user-agent': this.defaultUserAgent,
+ },
+ data: data,
+ }, { maxRetries: 0, retryDelay: 2000 });
+
+ return res;
+ }
+
+ // 收藏
+ async creatorShoucangOther(cookie: Electron.Cookie[], data: any) {
+ console.log('------ creatorShoucangOther-data@@@@@');
+ const thisUri = `https://www.douyin.com/aweme/v1/web/aweme/collect/?${jsonToQueryString(
+ {
+ aid: '6383',
+ },
+ )}`;
+ console.log('------ creatorCommentReplyOther-data', data);
+ console.log('------ creatorCommentReplyOther-thisUri', thisUri);
+ const cookieString = CommonUtils.convertCookieToJson(cookie);
+ const csrfToken = await this.getSecsdkCsrfToken(cookieString);
+
+ // 使用新的 postRequest 方法替代 makePublishRequest
+ 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,
+ }, { maxRetries: 1, retryDelay: 2000 });
+
+ return res;
+ }
+
// 回复其他人的评论
async creatorCommentReplyOther(cookie: Electron.Cookie[], data: any) {
const thisUri = `https://www.douyin.com/aweme/v1/web/comment/publish/?${jsonToQueryString(
@@ -2421,6 +2613,131 @@ export class DouyinService {
});
return res;
}
+
+ /**
+ * 发送POST请求
+ * @param url 请求URL
+ * @param options 请求选项
+ * @param retryOptions 重试选项
+ */
+ private async postRequest(
+ url: string,
+ options: any,
+ retryOptions: { maxRetries?: number, retryDelay?: number } = {}
+ ): Promise<any> {
+ console.log(`[${new Date().toLocaleString()}] 开始发起POST请求...`);
+ console.log(`[${new Date().toLocaleString()}] 请求URL:`, url);
+ console.log(`[${new Date().toLocaleString()}] 请求参数:`, options);
+
+ const maxRetries = retryOptions.maxRetries || 3;
+ const retryDelay = retryOptions.retryDelay || 2000;
+ let retryCount = 0;
+
+ while (retryCount < maxRetries) {
+ try {
+ console.log(
+ `[${new Date().toLocaleString()}] 请求体数据:`,
+ options.data,
+ );
+
+ const response = await fetch(url, {
+ method: options.method || 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ ...options.headers,
+ },
+ body: JSON.stringify(options.data),
+ });
+
+ console.log(
+ `[${new Date().toLocaleString()}] 收到响应,状态码:`,
+ response.status,
+ );
+ console.log(
+ `[${new Date().toLocaleString()}] 响应头:`,
+ Object.fromEntries(response.headers.entries()),
+ );
+
+ // 检查HTTP状态码
+ if (!response.ok) {
+ console.error(`[${new Date().toLocaleString()}] HTTP错误状态码: ${response.status}`);
+ if (retryCount < maxRetries - 1) {
+ retryCount++;
+ console.log(`[${new Date().toLocaleString()}] 状态码错误,${retryDelay/1000}秒后进行第${retryCount}次重试...`);
+ await new Promise(resolve => setTimeout(resolve, retryDelay));
+ continue;
+ }
+ throw new Error(`服务器返回错误状态码: ${response.status}`);
+ }
+
+ const responseText = await response.text();
+ console.log(
+ `[${new Date().toLocaleString()}] 原始响应数据长度:`,
+ responseText.length,
+ );
+ console.log(
+ `[${new Date().toLocaleString()}] 原始响应数据:`,
+ responseText,
+ );
+
+ // 检查响应数据是否为空
+ if (!responseText || responseText.trim() === '') {
+ console.error(`[${new Date().toLocaleString()}] 响应数据为空,尝试次数: ${retryCount + 1}/${maxRetries}`);
+
+ if (retryCount < maxRetries - 1) {
+ retryCount++;
+ console.log(`[${new Date().toLocaleString()}] 等待${retryDelay/1000}秒后重试...`);
+ await new Promise(resolve => setTimeout(resolve, retryDelay));
+ continue;
+ }
+
+ throw new Error('服务器多次返回空数据,请检查网络连接或抖音服务器状态');
+ }
+
+ try {
+ const result = JSON.parse(responseText);
+ console.log(
+ `[${new Date().toLocaleString()}] 解析后的响应数据:`,
+ result,
+ );
+
+ if (!result) {
+ console.error(`[${new Date().toLocaleString()}] 解析后的数据为空`);
+ throw new Error('解析后的数据为空');
+ }
+
+ return result;
+ } catch (err) {
+ console.error(
+ `[${new Date().toLocaleString()}] 解析响应数据失败:`,
+ err,
+ );
+ console.error(
+ `[${new Date().toLocaleString()}] 导致错误的原始数据:`,
+ responseText,
+ );
+ throw new Error(
+ `解析响应数据失败: ${err instanceof Error ? err.message : String(err)}`,
+ );
+ }
+ } catch (error) {
+ if (retryCount < maxRetries - 1) {
+ retryCount++;
+ console.log(`[${new Date().toLocaleString()}] 请求失败,${retryDelay/1000}秒后进行第${retryCount}次重试...`);
+ await new Promise(resolve => setTimeout(resolve, retryDelay));
+ continue;
+ }
+
+ console.error(`[${new Date().toLocaleString()}] 请求发生错误:`, error);
+ throw new Error(
+ `请求失败: ${error instanceof Error ? error.message : String(error)}`,
+ );
+ }
+ }
+
+ // 这里不应该被执行到,但为了类型安全添加
+ throw new Error('请求失败: 超过最大重试次数');
+ }
}
// 导出服务实例
diff --git a/package-lock.json b/package-lock.json
index f3533217..1dc190eb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -23,6 +23,7 @@
"dayjs": "^1.11.13",
"dotenv": "^16.4.7",
"echarts": "^5.6.0",
+ "electron": "^35.0.3",
"electron-log": "^5.3.0",
"electron-serve": "^2.1.1",
"electron-store": "^10.0.0",
@@ -48,6 +49,7 @@
"typeorm": "^0.3.20",
"uninstall": "^0.0.0",
"uuid": "^11.0.5",
+ "vite": "^6.2.3",
"xml2js": "^0.6.2",
"zustand": "^5.0.3"
},
diff --git a/package.json b/package.json
index 2ff348ee..5c9a416f 100644
--- a/package.json
+++ b/package.json
@@ -44,6 +44,7 @@
"dayjs": "^1.11.13",
"dotenv": "^16.4.7",
"echarts": "^5.6.0",
+ "electron": "^35.0.3",
"electron-log": "^5.3.0",
"electron-serve": "^2.1.1",
"electron-store": "^10.0.0",
@@ -69,6 +70,7 @@
"typeorm": "^0.3.20",
"uninstall": "^0.0.0",
"uuid": "^11.0.5",
+ "vite": "^6.2.3",
"xml2js": "^0.6.2",
"zustand": "^5.0.3"
},
diff --git a/src/views/replyother/index.tsx b/src/views/replyother/index.tsx
index a6185af6..8e7e126c 100644
--- a/src/views/replyother/index.tsx
+++ b/src/views/replyother/index.tsx
@@ -92,12 +92,12 @@ export default function Page() {
*/
async function dianzanFunc(data: WorkData) {
console.log('------ dianzanFunc', data);
- const res = await icpDianzanDyOther(activeAccountId, '7484585415068880139');
+ const res = await icpDianzanDyOther(activeAccountId, '7485806097282993419');
console.log('----- res', res);
if (res.status_code == 0) {
- message.success('评论成功');
+ message.success('点赞成功');
} else {
- message.error('评论失败');
+ message.error('点赞失败');
}
}
@@ -106,7 +106,7 @@ export default function Page() {
*/
async function shoucangFunc(data: WorkData) {
console.log('------ shoucangFunc', data);
- const res = await icpShoucangDyOther(activeAccountId, '7484585415068880139');
+ const res = await icpShoucangDyOther(activeAccountId, '7485806097282993419');
console.log('----- res', res);
if (res.status_code == 0) {
message.success('收藏成功');