Skip to content

Let's use AI to Earn!

feat: 删除不需要的主进程接口

牛文政ef41a437019f
diff --git a/.env b/.env
index df2c816e..aea7f5ae 100644
--- a/.env
+++ b/.env
@@ -5,7 +5,7 @@ VITE_APP_FILE_HOST = 'https://ai-to-earn.oss-cn-beijing.aliyuncs.com/'
# VITE_APP_URL = 'https://attapi.yikart.cn/api'
# 测试
-VITE_APP_URL = 'https://wkknliyjrzzn.sealosbja.site/api'
+# VITE_APP_URL = 'https://wkknliyjrzzn.sealosbja.site/api'
# 调试
-# VITE_APP_URL = 'http://127.0.0.1:3000/api'
+VITE_APP_URL = 'http://127.0.0.1:3000/api'
diff --git a/electron/main/api/platform.ts b/electron/main/api/platform.ts
deleted file mode 100644
index 6d52153e..00000000
--- a/electron/main/api/platform.ts
+++ /dev/null
@@ -1,257 +0,0 @@
-import { net } from 'electron';
-import { ResOp } from './types';
-import {
- Platform,
- PlatformAccount,
- PlatformAccountGroup,
- CreatePlatformDto,
- UpdatePlatformDto,
- CreatePlatformAccountDto,
- UpdatePlatformAccountDto,
- CreatePlatformAccountGroupDto,
- UpdatePlatformAccountGroupDto,
-} from './types/platform';
-
-class PlatformApi {
- private async request<T>(
- method: string,
- path: string,
- data?: any,
- token?: string,
- ): Promise<ResOp<T>> {
- return new Promise((resolve, reject) => {
- const request = net.request({
- method,
- url: `https://ttgufwxxqyow.sealosbja.site`,
- headers: token
- ? {
- Authorization: `Bearer ${token}`,
- }
- : {},
- });
-
- request.on('response', (response) => {
- let data = '';
- response.on('data', (chunk) => {
- data += chunk;
- });
- response.on('end', () => {
- try {
- resolve(JSON.parse(data));
- } catch (e) {
- reject(e);
- }
- });
- });
-
- request.on('error', reject);
-
- if (data) {
- request.write(JSON.stringify(data));
- }
- request.end();
- });
- }
-
- // 获取所有平台
- async getAllPlatforms(token: string): Promise<Platform[]> {
- const response = await this.request<Platform[]>(
- 'GET',
- '/api/platform',
- null,
- token,
- );
- return response.data;
- }
-
- // 创建平台
- async createPlatform(
- data: CreatePlatformDto,
- token: string,
- ): Promise<Platform> {
- const response = await this.request<Platform>(
- 'POST',
- '/api/platform',
- data,
- token,
- );
- return response.data;
- }
-
- // 获取平台详情
- async getPlatform(id: string, token: string): Promise<Platform> {
- const response = await this.request<Platform>(
- 'GET',
- `/api/platform/${id}`,
- null,
- token,
- );
- return response.data;
- }
-
- // 更新平台
- async updatePlatform(
- id: string,
- data: UpdatePlatformDto,
- token: string,
- ): Promise<Platform> {
- const response = await this.request<Platform>(
- 'PUT',
- `/api/platform/${id}`,
- data,
- token,
- );
- return response.data;
- }
-
- // 删除平台
- async deletePlatform(id: string, token: string): Promise<void> {
- await this.request<void>('DELETE', `/api/platform/${id}`, null, token);
- }
-
- // 获取所有平台账号
- async getAllPlatformAccounts(token: string): Promise<PlatformAccount[]> {
- const response = await this.request<PlatformAccount[]>(
- 'GET',
- '/api/platform-account',
- null,
- token,
- );
- return response.data;
- }
-
- // 创建平台账号
- async createPlatformAccount(
- data: CreatePlatformAccountDto,
- token: string,
- ): Promise<PlatformAccount> {
- const response = await this.request<PlatformAccount>(
- 'POST',
- '/api/platform-account',
- data,
- token,
- );
- return response.data;
- }
-
- // 获取平台账号详情
- async getPlatformAccount(
- id: string,
- token: string,
- ): Promise<PlatformAccount> {
- const response = await this.request<PlatformAccount>(
- 'GET',
- `/api/platform-account/${id}`,
- null,
- token,
- );
- return response.data;
- }
-
- // 更新平台账号
- async updatePlatformAccount(
- id: string,
- data: UpdatePlatformAccountDto,
- token: string,
- ): Promise<PlatformAccount> {
- const response = await this.request<PlatformAccount>(
- 'PUT',
- `/api/platform-account/${id}`,
- data,
- token,
- );
- return response.data;
- }
-
- // 删除平台账号
- async deletePlatformAccount(id: string, token: string): Promise<void> {
- await this.request<void>(
- 'DELETE',
- `/api/platform-account/${id}`,
- null,
- token,
- );
- }
-
- // 获取指定平台的所有账号
- async getPlatformAccountsByPlatformId(
- platformId: string,
- token: string,
- ): Promise<PlatformAccount[]> {
- const response = await this.request<PlatformAccount[]>(
- 'GET',
- `/api/platform-account/platform/${platformId}`,
- null,
- token,
- );
- return response.data;
- }
-
- // 获取所有平台账号分组
- async getAllPlatformAccountGroups(
- token: string,
- ): Promise<PlatformAccountGroup[]> {
- const response = await this.request<PlatformAccountGroup[]>(
- 'GET',
- '/api/platform-account-group',
- null,
- token,
- );
- return response.data;
- }
-
- // 创建平台账号分组
- async createPlatformAccountGroup(
- data: CreatePlatformAccountGroupDto,
- token: string,
- ): Promise<PlatformAccountGroup> {
- const response = await this.request<PlatformAccountGroup>(
- 'POST',
- '/api/platform-account-group',
- data,
- token,
- );
- return response.data;
- }
-
- // 获取平台账号分组详情
- async getPlatformAccountGroup(
- id: string,
- token: string,
- ): Promise<PlatformAccountGroup> {
- const response = await this.request<PlatformAccountGroup>(
- 'GET',
- `/api/platform-account-group/${id}`,
- null,
- token,
- );
- return response.data;
- }
-
- // 更新平台账号分组
- async updatePlatformAccountGroup(
- id: string,
- data: UpdatePlatformAccountGroupDto,
- token: string,
- ): Promise<PlatformAccountGroup> {
- const response = await this.request<PlatformAccountGroup>(
- 'PUT',
- `/api/platform-account-group/${id}`,
- data,
- token,
- );
- return response.data;
- }
-
- // 删除平台账号分组
- async deletePlatformAccountGroup(id: string, token: string): Promise<void> {
- await this.request<void>(
- 'DELETE',
- `/api/platform-account-group/${id}`,
- null,
- token,
- );
- }
-}
-
-export const platformApi = new PlatformApi();
diff --git a/electron/main/api/ranking.ts b/electron/main/api/ranking.ts
deleted file mode 100644
index 6c005ae4..00000000
--- a/electron/main/api/ranking.ts
+++ /dev/null
@@ -1,171 +0,0 @@
-import { net } from 'electron';
-import { ResOp, PaginationMeta } from './types';
-import {
- Ranking,
- RankingContent,
- CreateRankingDto,
- UpdateRankingDto,
- RankingStatus,
-} from './types/ranking';
-
-interface RankingContentResponse {
- items: RankingContent[];
- meta: PaginationMeta;
-}
-
-class RankingApi {
- private async request<T>(
- method: string,
- path: string,
- data?: any,
- token?: string,
- ): Promise<ResOp<T>> {
- return new Promise((resolve, reject) => {
- const request = net.request({
- method,
- url: `https://ttgufwxxqyow.sealosbja.site`,
- headers: token
- ? {
- Authorization: `Bearer ${token}`,
- }
- : {},
- });
-
- request.on('response', (response) => {
- let data = '';
- response.on('data', (chunk) => {
- data += chunk;
- });
- response.on('end', () => {
- try {
- resolve(JSON.parse(data));
- } catch (e) {
- reject(e);
- }
- });
- });
-
- request.on('error', reject);
-
- if (data) {
- request.write(JSON.stringify(data));
- }
- request.end();
- });
- }
-
- // 根据平台获取榜单
- async getRankingsByPlatform(
- platformId: string,
- status?: RankingStatus,
- token?: string,
- ): Promise<Ranking[]> {
- const params = new URLSearchParams();
- params.append('platformId', platformId);
- if (status !== undefined) {
- params.append('status', status.toString());
- }
- const response = await this.request<Ranking[]>(
- 'GET',
- `/api/ranking/platform?${params.toString()}`,
- null,
- token,
- );
- return response.data;
- }
-
- // 获取所有榜单
- async getAllRankings(token: string): Promise<Ranking[]> {
- const response = await this.request<Ranking[]>(
- 'GET',
- '/api/ranking',
- null,
- token,
- );
- return response.data;
- }
-
- // 创建榜单
- async createRanking(data: CreateRankingDto, token: string): Promise<Ranking> {
- const response = await this.request<Ranking>(
- 'POST',
- '/api/ranking',
- data,
- token,
- );
- return response.data;
- }
-
- // 获取榜单详情
- async getRanking(id: string, token: string): Promise<Ranking> {
- const response = await this.request<Ranking>(
- 'GET',
- `/api/ranking/${id}/detail`,
- null,
- token,
- );
- return response.data;
- }
-
- // 更新榜单
- async updateRanking(
- id: string,
- data: UpdateRankingDto,
- token: string,
- ): Promise<Ranking> {
- const response = await this.request<Ranking>(
- 'PUT',
- `/api/ranking/${id}`,
- data,
- token,
- );
- return response.data;
- }
-
- // 删除榜单
- async deleteRanking(id: string, token: string): Promise<void> {
- await this.request<void>('DELETE', `/api/ranking/${id}`, null, token);
- }
-
- // 获取榜单内容
- async getRankingContents(
- id: string,
- params: {
- page: number;
- pageSize: number;
- field?: string;
- order?: 'ASC' | 'DESC';
- category?: string;
- type?: 'article' | 'video' | 'live' | 'short_video';
- date?: string;
- },
- token: string,
- ): Promise<RankingContentResponse> {
- const queryParams = new URLSearchParams();
- Object.entries(params).forEach(([key, value]) => {
- if (value !== undefined) {
- queryParams.append(key, value.toString());
- }
- });
- const response = await this.request<RankingContentResponse>(
- 'GET',
- `/api/ranking/${id}/contents?${queryParams.toString()}`,
- null,
- token,
- );
- return response.data;
- }
-
- // 获取榜单内容分类
- async getRankingCategories(id: string, token: string): Promise<string[]> {
- const response = await this.request<string[]>(
- 'GET',
- `/api/ranking/${id}/categories`,
- null,
- token,
- );
- return response.data;
- }
-}
-
-export const rankingApi = new RankingApi();
diff --git a/electron/main/api/tools.ts b/electron/main/api/tools.ts
index ea72bc02..055692d2 100644
--- a/electron/main/api/tools.ts
+++ b/electron/main/api/tools.ts
@@ -1,6 +1,4 @@
import { net } from 'electron';
-import { ResOp } from './types';
-import { Ranking, CreateRankingDto } from './types/ranking';
class ToolsApi {
private async request<T>(
@@ -8,7 +6,7 @@ class ToolsApi {
path: string,
data?: any,
token?: string,
- ): Promise<ResOp<T>> {
+ ): Promise<any> {
return new Promise((resolve, reject) => {
const request = net.request({
method,
@@ -44,8 +42,8 @@ class ToolsApi {
}
// 获取AI的评论回复
- async createRanking(data: CreateRankingDto, token: string): Promise<Ranking> {
- const response = await this.request<Ranking>(
+ async createRanking(data: any, token: string): Promise<any> {
+ const response = await this.request<any>(
'POST',
'tools/ai/recover/review',
data,
diff --git a/electron/main/api/types/platform.ts b/electron/main/api/types/platform.ts
deleted file mode 100644
index 66d8c9c4..00000000
--- a/electron/main/api/types/platform.ts
+++ /dev/null
@@ -1,104 +0,0 @@
-// 平台类型
-export type PlatformType =
- | 'xiaohongshu'
- | 'wechat'
- | 'douyin'
- | 'bilibili'
- | 'shipinhao'
- | 'kuaishou';
-
-// 平台状态
-export type PlatformStatus = 0 | 1 | -1;
-
-// 平台信息
-export interface Platform {
- id: string;
- name: string;
- type: PlatformType;
- description?: string;
- icon?: string;
- status: PlatformStatus;
- sort?: number;
- config?: Record<string, any>;
-}
-
-// 创建平台DTO
-export interface CreatePlatformDto {
- name: string;
- type: PlatformType;
- description?: string;
- icon?: string;
- sort?: number;
- config?: Record<string, any>;
- status: PlatformStatus;
-}
-
-// 更新平台DTO
-export interface UpdatePlatformDto {
- name?: string;
- description?: string;
- icon?: string;
- sort?: number;
- config?: Record<string, any>;
- status?: PlatformStatus;
-}
-
-// 平台账号
-export interface PlatformAccount {
- id: string;
- platformId: string;
- name: string;
- type: PlatformType;
- description?: string;
- avatar?: string;
- status: PlatformStatus;
- sort?: number;
- config?: Record<string, any>;
-}
-
-// 创建平台账号DTO
-export interface CreatePlatformAccountDto {
- platformId: string;
- name: string;
- type: PlatformType;
- description?: string;
- avatar?: string;
- sort?: number;
- config?: Record<string, any>;
- status: PlatformStatus;
-}
-
-// 更新平台账号DTO
-export interface UpdatePlatformAccountDto {
- name?: string;
- description?: string;
- avatar?: string;
- sort?: number;
- config?: Record<string, any>;
- status?: PlatformStatus;
-}
-
-// 平台账号分组
-export interface PlatformAccountGroup {
- id: string;
- name: string;
- description?: string;
- status: PlatformStatus;
- sort?: number;
-}
-
-// 创建平台账号分组DTO
-export interface CreatePlatformAccountGroupDto {
- name: string;
- description?: string;
- sort?: number;
- status: PlatformStatus;
-}
-
-// 更新平台账号分组DTO
-export interface UpdatePlatformAccountGroupDto {
- name?: string;
- description?: string;
- sort?: number;
- status?: PlatformStatus;
-}
diff --git a/electron/main/api/types/ranking.ts b/electron/main/api/types/ranking.ts
deleted file mode 100644
index 31b71300..00000000
--- a/electron/main/api/types/ranking.ts
+++ /dev/null
@@ -1,117 +0,0 @@
-import { Platform } from './platform';
-
-// 榜单类型
-export type RankingType = 'daily' | 'week' | 'month';
-
-// 内容类型
-export type ContentType = 'article' | 'video' | 'live' | 'short_video';
-
-// 榜单状态
-export type RankingStatus = 0 | 1 | -1;
-
-// 作者信息
-export interface Author {
- id: string;
- name: string;
- avatar?: string;
- description?: string;
-}
-
-// 统计信息
-export interface Stats {
- readCount: number;
- likeCount: number;
- collectCount: number;
- forwardCount: number;
- commentCount: number;
-}
-
-// 榜单信息
-export interface Ranking {
- id: string;
- name: string;
- platformId: string;
- type: RankingType;
- description?: string;
- icon?: string;
- status: RankingStatus;
- rules?: string;
- config?: Record<string, any>;
- sort?: number;
- platform?: Platform;
-}
-
-// 创建榜单DTO
-export interface CreateRankingDto {
- name: string;
- platformId: string;
- type: RankingType;
- description?: string;
- icon?: string;
- rules?: string;
- config?: Record<string, any>;
- sort?: number;
- status: RankingStatus;
-}
-
-// 更新榜单DTO
-export interface UpdateRankingDto {
- name?: string;
- description?: string;
- icon?: string;
- rules?: string;
- config?: Record<string, any>;
- sort?: number;
- status?: RankingStatus;
-}
-
-// 榜单内容
-export interface RankingContent {
- id: string;
- rankingId: string;
- platformId: string;
- type: ContentType;
- title: string;
- cover?: string;
- url: string;
- description?: string;
- author?: Author;
- stats?: Stats;
- status: RankingStatus;
- publishTime?: Date;
- sort?: number;
- rankingPosition?: number;
- platform?: Platform;
- ranking?: Ranking;
-}
-
-// 创建榜单内容DTO
-export interface CreateRankingContentDto {
- rankingId: string;
- platformId: string;
- type: ContentType;
- title: string;
- cover?: string;
- url: string;
- description?: string;
- author?: Author;
- stats?: Stats;
- publishTime?: Date;
- sort?: number;
- rankingPosition?: number;
- status: RankingStatus;
-}
-
-// 更新榜单内容DTO
-export interface UpdateRankingContentDto {
- title?: string;
- cover?: string;
- url?: string;
- description?: string;
- author?: Author;
- stats?: Stats;
- publishTime?: Date;
- sort?: number;
- rankingPosition?: number;
- status?: RankingStatus;
-}
diff --git a/electron/main/api/types/user.ts b/electron/main/api/types/user.ts
deleted file mode 100644
index efc3ad80..00000000
--- a/electron/main/api/types/user.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-// 用户状态
-export type UserStatus = 0 | 1 | -1;
-
-// 用户信息
-export interface UserInfo {
- id: string;
- name: string;
- phone: string;
- avatar?: string;
- desc?: string;
- status: UserStatus;
- createTime: Date;
- updateTime: Date;
-}
-
-// 用户登录返回
-export interface LoginResponse {
- userInfo: UserInfo;
- token: string;
-}
-
-// 手机号验证码登录DTO
-export interface PhoneLoginByCodeDto {
- phone: string;
- code: string;
- inviteCode?: string;
-}
-
-// 密码登录DTO
-export interface LoginByPasswordDto {
- phone: string;
- password: string;
- inviteCode?: string;
-}
-
-// 修改密码DTO
-export interface ChangePasswordDto {
- oldPassword: string;
- newPassword: string;
-}
-
-// 更新用户信息DTO
-export interface UpdateUserInfoDto {
- name?: string;
- avatar?: string;
- desc?: string;
-}
-
-// 获取验证码DTO
-export interface GetRegisterCodeDto {
- phone: string;
-}
-
-// 手机号注册DTO
-export interface PhoneRegisterDto {
- code: string;
- phone: string;
- password: string;
- inviteCode?: string;
-}
diff --git a/electron/main/api/user.ts b/electron/main/api/user.ts
deleted file mode 100644
index c867e6c1..00000000
--- a/electron/main/api/user.ts
+++ /dev/null
@@ -1,143 +0,0 @@
-import { net } from 'electron';
-import { ResOp } from './types';
-import {
- UserInfo,
- LoginResponse,
- PhoneLoginByCodeDto,
- LoginByPasswordDto,
- ChangePasswordDto,
- UpdateUserInfoDto,
- GetRegisterCodeDto,
- PhoneRegisterDto,
-} from './types/user';
-
-class UserApi {
- private async request<T>(
- method: string,
- path: string,
- data?: any,
- token?: string,
- ): Promise<ResOp<T>> {
- return new Promise((resolve, reject) => {
- const request = net.request({
- method,
- url: `https://ttgufwxxqyow.sealosbja.site`,
- headers: token
- ? {
- Authorization: `Bearer ${token}`,
- }
- : {},
- });
-
- request.on('response', (response) => {
- let data = '';
- response.on('data', (chunk) => {
- data += chunk;
- });
- response.on('end', () => {
- try {
- resolve(JSON.parse(data));
- } catch (e) {
- reject(e);
- }
- });
- });
-
- request.on('error', reject);
-
- if (data) {
- request.write(JSON.stringify(data));
- }
- request.end();
- });
- }
-
- // 发送手机验证码
- async sendCode(data: GetRegisterCodeDto): Promise<void> {
- await this.request<void>('POST', '/api/user/code', data);
- }
-
- // 手机号注册
- async register(data: PhoneRegisterDto): Promise<LoginResponse> {
- const response = await this.request<LoginResponse>(
- 'POST',
- '/api/user/add',
- data,
- );
- return response.data;
- }
-
- // 手机验证码登录
- async loginByCode(data: PhoneLoginByCodeDto): Promise<LoginResponse> {
- const response = await this.request<LoginResponse>(
- 'POST',
- '/api/user/login/code/phone',
- data,
- );
- return response.data;
- }
-
- // 密码登录
- async loginByPassword(data: LoginByPasswordDto): Promise<LoginResponse> {
- const response = await this.request<LoginResponse>(
- 'POST',
- '/api/user/login/password',
- data,
- );
- return response.data;
- }
-
- // 修改密码
- async changePassword(data: ChangePasswordDto, token: string): Promise<void> {
- await this.request<void>('POST', '/api/user/password/change', data, token);
- }
-
- // 刷新token
- async refreshToken(token: string): Promise<string> {
- const response = await this.request<{ token: string }>(
- 'POST',
- '/api/user/token/refresh',
- null,
- token,
- );
- return response.data.token;
- }
-
- // 获取用户信息
- async getUserInfo(token: string): Promise<UserInfo> {
- const response = await this.request<UserInfo>(
- 'GET',
- '/api/user/mine',
- null,
- token,
- );
- return response.data;
- }
-
- // 更新用户信息
- async updateUserInfo(
- data: UpdateUserInfoDto,
- token: string,
- ): Promise<UserInfo> {
- const response = await this.request<UserInfo>(
- 'PUT',
- '/api/user/info/update',
- data,
- token,
- );
- return response.data;
- }
-
- // 注销用户
- async deleteUser(token: string): Promise<UserInfo> {
- const response = await this.request<UserInfo>(
- 'DELETE',
- '/api/user/del',
- null,
- token,
- );
- return response.data;
- }
-}
-
-export const userApi = new UserApi();