Skip to content

Let's use AI to Earn!

feat: 小红书发布错误捕获、视频发布通知框close改为只关闭弹框、图文发布数据库相关逻辑注册

gaoSirb95212212d20
diff --git a/electron/db/index.ts b/electron/db/index.ts
index 528c68df..41a23151 100644
--- a/electron/db/index.ts
+++ b/electron/db/index.ts
@@ -20,6 +20,7 @@ import { asyData as accountExamine } from './scripts/account';
import { logger } from '../global/log';
import { AutoRunModel } from './models/autoRun';
import { AutoRunRecordModel } from './models/autoRunRecord';
+import { ImgTextModel } from './models/imgText';
const configPath = app.getPath('userData');
const database = path.join(configPath, 'database.sqlite');
@@ -39,6 +40,7 @@ export const AppDataSource = new DataSource({
VideoStatsModel,
AutoRunModel,
AutoRunRecordModel,
+ ImgTextModel,
], // 实体或模型表
migrations: Object.values(migrations), // 迁移类
migrationsRun: true, // 确保在连接时自动运行迁移
diff --git a/electron/main/plat/platforms/xhs/index.ts b/electron/main/plat/platforms/xhs/index.ts
index b88854c7..36af6bcc 100644
--- a/electron/main/plat/platforms/xhs/index.ts
+++ b/electron/main/plat/platforms/xhs/index.ts
@@ -514,6 +514,8 @@ export class Xhs extends PlatformBase {
this.pubParamsParse(params),
)
.catch((err) => {
+ console.log('----------');
+ console.log(err);
resolve({
code: 0,
msg: err,
diff --git a/electron/main/publish/imgText/controller.ts b/electron/main/publish/imgText/controller.ts
index 09aeb563..822050c6 100644
--- a/electron/main/publish/imgText/controller.ts
+++ b/electron/main/publish/imgText/controller.ts
@@ -1,5 +1,4 @@
import { Controller, Et, Icp, Inject } from '../../core/decorators';
-import { VideoPubService } from '../video/service';
import { PublishService } from '../service';
import { AccountService } from '../../account/service';
import { ImgTextPubService } from './service';
@@ -9,7 +8,7 @@ import platController from '../../plat';
@Controller()
export class ImgTextPubController {
- @Inject(VideoPubService)
+ @Inject(ImgTextPubService)
private readonly imgTextService!: ImgTextPubService;
@Inject(PublishService)
diff --git a/electron/main/publish/module.ts b/electron/main/publish/module.ts
index 1d90547a..38f8f7ff 100644
--- a/electron/main/publish/module.ts
+++ b/electron/main/publish/module.ts
@@ -10,9 +10,11 @@ import { PublishController } from './controller';
import { PublishService } from './service';
import { VideoPubController } from './video/controller';
import { VideoPubService } from './video/service';
+import { ImgTextPubController } from './imgText/controller';
+import { ImgTextPubService } from './imgText/service';
@Module({
- controllers: [PublishController, VideoPubController],
- providers: [PublishService, VideoPubService],
+ controllers: [PublishController, VideoPubController, ImgTextPubController],
+ providers: [PublishService, VideoPubService, ImgTextPubService],
})
export class PublishModule {}
diff --git a/electron/plat/xiaohongshu/index.ts b/electron/plat/xiaohongshu/index.ts
index 8874c56b..c4891328 100644
--- a/electron/plat/xiaohongshu/index.ts
+++ b/electron/plat/xiaohongshu/index.ts
@@ -819,46 +819,49 @@ export class XiaohongshuService {
shareLink: string;
}> {
return new Promise(async (resolve, reject) => {
- // try {
- // 初始化cookie
- const cookieString = CommonUtils.convertCookieToJson(cookies);
- console.log('cookieString', cookieString);
- // 上传图片
- const uploadImgRet = [];
- for (const imgUrl of imagePath) {
- // 上传图片, 获取远程Url
- const imgRet = await this.uploadCoverFile(cookieString, imgUrl);
- // 添加到成功列表
- uploadImgRet.push(imgRet);
- }
- // 获取cookie_a1
- const cookieObject = JSON.parse(cookies);
- let cookie_a1 = null;
- for (const cookieItem of cookieObject) {
- if (cookieItem.name === 'a1') {
- cookie_a1 = cookieItem.value;
- break;
+ try {
+ // 初始化cookie
+ const cookieString = CommonUtils.convertCookieToJson(cookies);
+ console.log('cookieString', cookieString);
+ // 上传图片
+ const uploadImgRet = [];
+ for (const imgUrl of imagePath) {
+ // 上传图片, 获取远程Url
+ const imgRet = await this.uploadCoverFile(cookieString, imgUrl);
+ // 添加到成功列表
+ uploadImgRet.push(imgRet);
}
+ // 获取cookie_a1
+ const cookieObject = JSON.parse(cookies);
+ let cookie_a1 = null;
+ for (const cookieItem of cookieObject) {
+ if (cookieItem.name === 'a1') {
+ cookie_a1 = cookieItem.value;
+ break;
+ }
+ }
+ // 创建作品
+ const uploadResult = {
+ imageList: uploadImgRet,
+ };
+ const { shareLink, publishId } = (await this.postCreateVideo(
+ cookieString,
+ cookie_a1,
+ 'image',
+ uploadResult,
+ platformSetting,
+ )) as any;
+ console.log('shareLink', shareLink);
+ console.log('publishId', publishId);
+ // 返回信息
+ resolve({
+ publishTime: Math.floor(Date.now() / 1000),
+ publishId: publishId,
+ shareLink: shareLink,
+ });
+ } catch (e) {
+ reject(e);
}
- // 创建作品
- const uploadResult = {
- imageList: uploadImgRet,
- };
- const { shareLink, publishId } = (await this.postCreateVideo(
- cookieString,
- cookie_a1,
- 'image',
- uploadResult,
- platformSetting,
- )) as any;
- console.log('shareLink', shareLink);
- console.log('publishId', publishId);
- // 返回信息
- resolve({
- publishTime: Math.floor(Date.now() / 1000),
- publishId: publishId,
- shareLink: shareLink,
- });
});
}
@@ -1441,7 +1444,6 @@ export class XiaohongshuService {
return res;
}
-
/**
* 点赞作品
* @param cookie
@@ -1450,10 +1452,7 @@ export class XiaohongshuService {
* @param targetCommentId // 回复的评论ID
* @returns
*/
- async likeNote(
- cookie: Electron.Cookie[],
- noteId: string,
- ) {
+ async likeNote(cookie: Electron.Cookie[], noteId: string) {
const url = `/api/sns/web/v1/note/like`;
const body = {
note_oid: noteId,
@@ -1484,8 +1483,7 @@ export class XiaohongshuService {
return res;
}
-
- /**
+ /**
* 点赞作品
* @param cookie
* @param noteId
@@ -1493,39 +1491,36 @@ export class XiaohongshuService {
* @param targetCommentId // 回复的评论ID
* @returns
*/
- async shoucangNote(
- cookie: Electron.Cookie[],
- noteId: string,
- ) {
- const url = `/api/sns/web/v1/note/collect`;
- const body = {
- note_id: noteId,
- };
- const reverseRes: any = await this.getReverseResult({
- url,
- a1: CookieToString(cookie),
- data: body,
- });
-
- const res = await requestNet<XhsCommentPostResponse>({
- url: `https://edith.xiaohongshu.com${url}`,
- headers: {
- cookie: CookieToString(cookie),
- Referer: 'https://www.xiaohongshu.com/',
- Origin: 'https://www.xiaohongshu.com',
- 'X-S': reverseRes['X-s'],
- 'X-T': reverseRes['X-t'],
- userAgent:
- 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/100.0.1185.36',
- },
- method: 'POST',
- body,
- });
-
- console.log('--- xhs shoucangNote --- res', res);
-
- return res;
- }
+ async shoucangNote(cookie: Electron.Cookie[], noteId: string) {
+ const url = `/api/sns/web/v1/note/collect`;
+ const body = {
+ note_id: noteId,
+ };
+ const reverseRes: any = await this.getReverseResult({
+ url,
+ a1: CookieToString(cookie),
+ data: body,
+ });
+
+ const res = await requestNet<XhsCommentPostResponse>({
+ url: `https://edith.xiaohongshu.com${url}`,
+ headers: {
+ cookie: CookieToString(cookie),
+ Referer: 'https://www.xiaohongshu.com/',
+ Origin: 'https://www.xiaohongshu.com',
+ 'X-S': reverseRes['X-s'],
+ 'X-T': reverseRes['X-t'],
+ userAgent:
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/100.0.1185.36',
+ },
+ method: 'POST',
+ body,
+ });
+
+ console.log('--- xhs shoucangNote --- res', res);
+
+ return res;
+ }
/**
* 评论作品
diff --git a/src/views/publish/children/imagePage/page.tsx b/src/views/publish/children/imagePage/page.tsx
index 42dc540e..b69a8966 100644
--- a/src/views/publish/children/imagePage/page.tsx
+++ b/src/views/publish/children/imagePage/page.tsx
@@ -136,7 +136,6 @@ export default function Page() {
</Space>
),
key: Date.now(),
- onClose: close,
});
};
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
index f0188926..92b82c85 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
@@ -235,7 +235,6 @@ const VideoPubSetModal = memo(
</Space>
),
key: Date.now(),
- onClose: close,
});
}, 10);
};
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx
index 6681cdeb..78efc9b4 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/children/VideoPubSetModal_DouYin.tsx
@@ -34,6 +34,7 @@ const HotspotSelect = ({ currChooseAccount }: IVideoPubSetModalChildProps) => {
return (
<CommonHotspotSelect
+ account={currChooseAccount.account}
value={
currChooseAccount.pubParams!.diffParams![AccountType.Douyin]!.hotPoint
}
@@ -122,10 +123,10 @@ const VideoPubSetModal_DouYin = memo(
title="@好友"
/>
- <LocationSelect currChooseAccount={currChooseAccount} />
-
<HotspotSelect {...props} />
+ <LocationSelect currChooseAccount={currChooseAccount} />
+
<ScheduledTimeSelect currChooseAccount={currChooseAccount} />
<h1>自主声明</h1>