返回 AiToEarn
task.ts
1 /*
2 * @Author: nevin
3 * @Date: 2025-02-22 12:27:40
4 * @LastEditTime: 2025-03-03 17:59:13
5 * @LastEditors: nevin
6 * @Description: 任务
7 */
8 import { PlatType } from '../AccountEnum';
9 import { TimeTemp } from './apiServer';
10
11 export enum TaskType {
12 PRODUCT = 'product', // 挂车市场任务
13 ARTICLE = 'article', // 文章任务
14 PROMOTION = 'promotion', // 推广任务
15 VIDEO = 'video', // 视频任务
16 INTERACTION = 'interaction', // 互动任务
17 }
18
19 export const TaskTypeName = new Map([
20 [TaskType.PRODUCT, '挂车市场任务'],
21 [TaskType.ARTICLE, '文章任务'],
22 [TaskType.PROMOTION, '推广任务'],
23 [TaskType.VIDEO, '视频任务'],
24 [TaskType.INTERACTION, '互动任务'],
25 ]);
26
27 export enum TaskStatus {
28 ACTIVE = 'active', // 激活
29 COMPLETED = 'completed', // 完成
30 CANCELLED = 'cancelled', // 取消
31 }
32 export const TaskStatusName = new Map([
33 [TaskStatus.ACTIVE, '进行中'],
34 [TaskStatus.COMPLETED, '完成'],
35 [TaskStatus.CANCELLED, '取消'],
36 ]);
37
38 interface TaskData {
39 title: string;
40 desc?: string;
41 }
42 export interface TaskVideo extends TaskData {
43 videoUrl: string;
44 }
45
46 export interface TaskArticle extends TaskData {
47 imageList: string[];
48 topicList: string[];
49 }
50
51 export interface TaskPromotion extends TaskData {}
52
53 export interface TaskProduct extends TaskData {
54 price: number;
55 sales?: number;
56 }
57
58 export interface TaskInteraction extends TaskData {
59 accountType: PlatType; // 平台类型
60 worksId: string; // 作品ID
61 authorId?: string; // 作者ID
62 commentContent?: string; // 评论内容,不填则使用AI
63 }
64
65 export type TaskDataInfo =
66 | TaskProduct
67 | TaskPromotion
68 | TaskVideo
69 | TaskArticle
70 | TaskInteraction;
71 export interface Task<T extends TaskDataInfo> extends TimeTemp {
72 _id: string;
73 id: string;
74 screenshotUrls: any;
75 title: string;
76 description: string;
77 type: TaskType;
78 dataInfo: T;
79 imageUrl: string;
80 keepTime: number; // 保持时间(秒)
81 requiresShoppingCart: boolean; // 是否需要挂购物车
82 maxRecruits: number; // 最大招募人数
83 currentRecruits: number; // 当前招募人数
84 deadline: string; // 任务截止时间
85 firstTimeBonus: number; // 首次任务奖励
86 reward: number; // 任务奖励金额
87 status: TaskStatus; // 'active' | 'completed' | 'cancelled'
88 accountTypes: PlatType[];
89 isAccepted?: boolean; // 是否已经接受任务
90 requirement?: string;
91 }
92
92 lines TYPESCRIPT