Skip to content

Let's use AI to Earn!

任务状态和完成任务

DESKTOP-ZTS2NQJNAbaa1c7c95ea3
diff --git a/commont/types/task.ts b/commont/types/task.ts
index b0bf2aae..b9967412 100644
--- a/commont/types/task.ts
+++ b/commont/types/task.ts
@@ -27,7 +27,7 @@ export enum TaskStatus {
CANCELLED = 'cancelled', // 取消
}
export const TaskStatusName = new Map([
- [TaskStatus.ACTIVE, '激活'],
+ [TaskStatus.ACTIVE, '进行中'],
[TaskStatus.COMPLETED, '完成'],
[TaskStatus.CANCELLED, '取消'],
]);
diff --git a/electron/main/index.ts b/electron/main/index.ts
index f7761169..fbcb7b2b 100644
--- a/electron/main/index.ts
+++ b/electron/main/index.ts
@@ -53,8 +53,8 @@ async function createWindow() {
win = new BrowserWindow({
title: '爱团团AiToEarn',
icon: path.join(getAssetPath('favicon.ico')),
- width: 1280,
- height: 800,
+ width: 2350,
+ height: 1280,
minWidth: 1280,
minHeight: 800,
titleBarStyle: 'hidden',
diff --git a/src/views/statistics/index.tsx b/src/views/statistics/index.tsx
index de33edfc..e32ba1f6 100644
--- a/src/views/statistics/index.tsx
+++ b/src/views/statistics/index.tsx
@@ -21,6 +21,7 @@ import { Dayjs } from 'dayjs';
import * as echarts from 'echarts';
import dayjs from 'dayjs';
import { message } from 'antd';
+import WebView from '@/components/WebView';
import douyinIcon from '@/assets/svgs/account/douyin.svg';
import xhsIcon from '@/assets/svgs/account/xhs.svg';
@@ -415,8 +416,26 @@ const Statistics = () => {
}
};
+ const examineVideo = () => {
+ console.log('检查视频');
+ // 实现检查视频的逻辑
+ };
+
return (
<div className="min-h-screen page-container bg-gray-50">
+{/*
+{ open ? (
+ <WebView
+ url={examineVideo.url}
+ cookieParams={{
+ cookies: JSON.parse(examineVideo.account.loginCookie),
+ }}
+ key={examineVideo.url + examineVideo.open}
+ />
+ ) : (
+ ''
+ )} */}
+
<div className="px-6 py-6">
{/* 顶部标题区域 */}
<div className="flex items-center justify-between mb-6">
diff --git a/src/views/task/components/popInfo.tsx b/src/views/task/components/popInfo.tsx
index 0219baa4..0ebffae4 100644
--- a/src/views/task/components/popInfo.tsx
+++ b/src/views/task/components/popInfo.tsx
@@ -201,7 +201,7 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
<div className={styles.taskInfoFooter}>
<div className={styles.taskStatus}>
<span className={styles.statusLabel}>任务状态:</span>
- <Tag color="#87d068">
+ <Tag color="#a66ae4">
{TaskStatusName.get(taskInfo.status) || '进行中'}
</Tag>
</div>
diff --git a/src/views/task/components/videoInfo.module.scss b/src/views/task/components/videoInfo.module.scss
index 86fc06ac..a461baa1 100644
--- a/src/views/task/components/videoInfo.module.scss
+++ b/src/views/task/components/videoInfo.module.scss
@@ -244,12 +244,10 @@
.applyButton {
min-width: 100px;
- background-color: #52c41a;
- border-color: #52c41a;
&:hover {
- background-color: #73d13d;
- border-color: #73d13d;
+ background-color: #9559d1 !important;
+ border-color: #9559d1 !important;
}
}
diff --git a/src/views/task/components/videoInfo.tsx b/src/views/task/components/videoInfo.tsx
index 219145de..d8c0b1b9 100644
--- a/src/views/task/components/videoInfo.tsx
+++ b/src/views/task/components/videoInfo.tsx
@@ -28,6 +28,7 @@ import {
import ChooseAccountModule from '@/views/publish/components/ChooseAccountModule/ChooseAccountModule';
import { ipcDownFile } from '@/icp/tools';
import { AccountType } from '@@/AccountEnum';
+import VideoPlayer from '@/components/VideoPlayer';
const FILE_BASE_URL = import.meta.env.VITE_APP_FILE_HOST;
@@ -39,6 +40,24 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
const [isModalOpen, setIsModalOpen] = useState(false);
const [taskInfo, setTaskInfo] = useState<Task<TaskVideo> | null>();
const [downloading, setDownloading] = useState(false);
+ const [videoPlayback, setVideoPlayback] = useState<{
+ visible: boolean;
+ url: string;
+ title: string;
+ }>({
+ visible: false,
+ url: '',
+ title: '',
+ });
+
+ // 在组件内添加一个新的状态来存储任务记录
+ const [taskRecord, setTaskRecord] = useState<{
+ _id: string;
+ createTime: string;
+ isFirstTimeSubmission: boolean;
+ status: string;
+ taskId: string;
+ } | null>(null);
async function init(inTaskInfo: Task<TaskVideo>) {
setTaskInfo(inTaskInfo);
@@ -53,38 +72,46 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
* 接受任务
*/
async function taskApply() {
- console.log('接受任务', taskInfo);
if (!taskInfo) return;
try {
- const res = await taskApi.taskApply<TaskVideo>(taskInfo?._id);
- // setTaskInfo(res);
- message.success('任务接受成功!');
- setIsModalOpen(false);
- setChooseAccountOpen(true);
+ const res:any = await taskApi.taskApply<TaskVideo>(taskInfo?._id);
+ // 存储任务记录信息
+ if (res.code === 0 && res.data) {
+ setTaskRecord(res.data);
+ message.success('任务接受成功!');
+ setIsModalOpen(false);
+ setChooseAccountOpen(true);
+ } else {
+ message.error(res.msg || '接受任务失败,请稍后再试?');
+ }
} catch (error) {
message.error('接受任务失败,请稍后再试');
}
}
-
- /**
- * 接受任务
+ /**
+ * 完成任务
*/
- async function taskDone() {
- console.log('接受任务', taskInfo);
- if (!taskInfo) return;
- try {
- const res = await taskApi.taskDone(taskInfo?._id, {
- submissionUrl: taskInfo.title,
- screenshotUrls: [taskInfo.imageUrl],
- qrCodeScanResult: taskInfo.title,
- });
- message.success('任务发布成功!');
- } catch (error) {
- message.error('接受任务失败,请稍后再试');
- }
+ async function taskDone() {
+ console.log('完成任务', taskInfo, taskRecord);
+ if (!taskInfo || !taskRecord) {
+ message.error('任务信息不完整,无法完成任务');
+ return;
+ }
+
+ try {
+ // 使用任务记录的 ID 而不是任务 ID
+ const res = await taskApi.taskDone(taskRecord._id, {
+ submissionUrl: taskInfo.title,
+ screenshotUrls: [taskInfo.imageUrl],
+ qrCodeScanResult: taskInfo.title,
+ });
+ message.success('任务发布成功!');
+ } catch (error) {
+ message.error('完成任务失败,请稍后再试');
}
+ }
const handleCancel = () => {
setIsModalOpen(false);
@@ -190,8 +217,34 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
}
};
+ // 打开视频播放器
+ const openVideoPlayer = (e: React.MouseEvent) => {
+ e.stopPropagation();
+ if (taskInfo?.dataInfo?.videoUrl) {
+ setVideoPlayback({
+ visible: true,
+ url: `${FILE_BASE_URL}${taskInfo.dataInfo.videoUrl}`,
+ title: taskInfo.title || '视频播放',
+ });
+ } else {
+ message.info('该任务暂无视频');
+ }
+ };
+
+ // 关闭视频播放器
+ const closeVideoPlayer = () => {
+ setVideoPlayback((prev) => ({ ...prev, visible: false }));
+ };
+
return (
<>
+ <VideoPlayer
+ videoUrl={videoPlayback.url}
+ visible={videoPlayback.visible}
+ onClose={closeVideoPlayer}
+ title={videoPlayback.title}
+ />
+
<ChooseAccountModule
open={chooseAccountOpen}
onClose={() => !downloading && setChooseAccountOpen(false)}
@@ -222,14 +275,14 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
<h2 className={styles.taskTitle}>
{taskInfo.title}
<span className={styles.taskId}>
- ID: {taskInfo.id}
+ ID: {taskInfo._id}
<CopyOutlined
className={styles.copyIcon}
- onClick={() => copyTaskId(taskInfo.id)}
+ onClick={() => copyTaskId(taskInfo._id)}
/>
</span>
</h2>
- <Tag color="#f50" className={styles.taskTag}>
+ <Tag color="#a66ae4" className={styles.taskTag}>
{(taskInfo.dataInfo as any)?.type || '视频任务'}
</Tag>
</div>
@@ -238,7 +291,10 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
<Row gutter={24}>
<Col span={12}>
<div className={styles.videoContainer}>
- <div className={styles.taskImageContainer}>
+ <div
+ className={styles.taskImageContainer}
+ onClick={openVideoPlayer}
+ >
<img
src={`${FILE_BASE_URL}${taskInfo.imageUrl}`}
alt={taskInfo.title}
@@ -336,7 +392,7 @@ const Com = forwardRef<TaskInfoRef>((props: any, ref) => {
<div className={styles.taskInfoFooter}>
<div className={styles.taskStatus}>
<span className={styles.statusLabel}>任务状态:</span>
- <Tag color="#87d068">
+ <Tag color="#a66ae4">
{TaskStatusName.get(taskInfo.status) || '进行中'}
</Tag>
</div>
diff --git a/src/views/task/popTask.tsx b/src/views/task/popTask.tsx
index 856742c3..30a00310 100644
--- a/src/views/task/popTask.tsx
+++ b/src/views/task/popTask.tsx
@@ -163,7 +163,7 @@ export default function Page() {
<div className={styles.taskAction}>
<div className={styles.taskStatus}>
- <Tag color="#87d068">进行中</Tag>
+ <Tag color="#a66ae4">进行中</Tag>
</div>
<div className={styles.taskReward}>
diff --git a/src/views/task/videoTask.module.scss b/src/views/task/videoTask.module.scss
index da9c60d8..e1dc5fac 100644
--- a/src/views/task/videoTask.module.scss
+++ b/src/views/task/videoTask.module.scss
@@ -215,12 +215,10 @@
.viewButton {
width: 100%;
- background-color: #52c41a;
- border-color: #52c41a;
&:hover {
- background-color: #73d13d;
- border-color: #73d13d;
+ background-color: #9559d1;
+ border-color: #9559d1;
}
}
diff --git a/src/views/task/videoTask.tsx b/src/views/task/videoTask.tsx
index 477edfa6..39b0f94d 100644
--- a/src/views/task/videoTask.tsx
+++ b/src/views/task/videoTask.tsx
@@ -257,7 +257,7 @@ export default function Page() {
<div className={styles.taskAction}>
<div className={styles.taskStatus}>
- <Tag color="#87d068">进行中</Tag>
+ <Tag color="#a66ae4">进行中</Tag>
</div>
<div className={styles.taskReward}>