Skip to content

Let's use AI to Earn!

赚钱模式和任务

DESKTOP-EMF2SH4\Administrator99823c7506f6
diff --git a/src/views/task/task.tsx b/src/views/task/task.tsx
index e819f540..7dcaa420 100644
--- a/src/views/task/task.tsx
+++ b/src/views/task/task.tsx
@@ -302,7 +302,7 @@ export default function Task() {
// 根据任务类型选择不同的处理逻辑
if (selectedTask.type === TaskType.ARTICLE) {
- // 文章任务使用 pubCore 逻辑
+ // 文章任务使用 逻辑
setChooseAccountOpen(true);
} else {
// 其他任务使用原有的互动任务逻辑
@@ -333,6 +333,7 @@ export default function Task() {
if (!selectedTask) return;
try {
+ // 00.00 测试
// const res: any = await taskApi.taskApply<TaskVideo>(selectedTask?._id, {
// account: params.account,
// accountType: params.accountType,
@@ -354,6 +355,9 @@ export default function Task() {
// handleCompleteTask();
// console.log('selectedTask.dataInfo', selectedTask.dataInfo);
+
+ // pubCore(params);
+
let imageList = [];
for (let index = 0; index < sucai.imageList.length; index++) {
let element = sucai.imageList[index];
@@ -456,7 +460,10 @@ export default function Task() {
// 文章任务的发布核心逻辑
const pubCore = async (account: any) => {
+ const sucai: any = await taskApi.getFristTaskMaterial(selectedTask?._id);
+ console.log('sucai:', sucai);
if (!selectedTask) return;
+ // return;
setPubProgressModuleOpen(true);
setLoading(true);
@@ -466,43 +473,50 @@ export default function Task() {
};
// 00.00 测试
- // console.log('pubCore', selectedTask);
+ // console.log('1', selectedTask);
// return;
+ // topics: selectedTask.dataInfo?.topicList || [],
+
// 创建一级记录
const recordRes = await icpCreatePubRecord({
- title: selectedTask.title,
- desc: selectedTask.description,
+ title: sucai.title || selectedTask.dataInfo?.title,
+ desc: sucai.desc || selectedTask.dataInfo?.desc,
type: PubType.ImageText,
- coverPath: FILE_BASE_URL + (selectedTask.dataInfo?.imageList?.[0] || ''),
+ coverPath: FILE_BASE_URL + (sucai.coverUrl || ''),
});
if (!recordRes) return err();
let pubList = [];
- if (selectedTask.dataInfo?.imageList?.length > 1) {
- pubList = selectedTask.dataInfo?.imageList.map(
- (v: string) => FILE_BASE_URL + v,
+ console.log('sucai.imageList', sucai.imageList);
+ if (sucai.imageList.length) {
+ pubList = sucai.imageList.map(
+ (v: any) => {
+ console.log('v', v);
+ return FILE_BASE_URL + v.imageUrl
+ },
);
+
}
console.log('pubList', pubList);
- console.log(accountListChoose);
+ console.log('accountListChoose', accountListChoose);
+
const allAccount = accountListChoose?.length
? accountListChoose
: [account];
- console.log(allAccount);
+ console.log('allAccount', allAccount);
for (const account of allAccount) {
// 创建二级记录
await icpCreateImgTextPubRecord({
- title: selectedTask.title,
- desc: selectedTask.description,
+ title: sucai.title || selectedTask.dataInfo?.title,
+ desc: sucai.desc || selectedTask.dataInfo?.desc,
type: account.type,
accountId: account.id,
pubRecordId: recordRes.id,
publishTime: new Date(),
- coverPath:
- FILE_BASE_URL + (selectedTask.dataInfo?.imageList?.[0] || ''),
+ coverPath: FILE_BASE_URL + (sucai.coverUrl || ''),
imagesPath: pubList,
});
}
@@ -611,8 +625,8 @@ export default function Task() {
// 根据任务类型选择不同的处理逻辑
if (selectedTask?.type === TaskType.ARTICLE) {
- // 文章任务使用 pubCore 逻辑
- console.log('文章任务使用 pubCore 逻辑');
+ // 文章任务使用逻辑
+ console.log('文章任务使用逻辑');
if (isOne) {
for (const account of aList) {
taskApplyoney({
@@ -623,14 +637,16 @@ export default function Task() {
}
}else{
for (const account of aList) {
- taskApply({
- account: account.account,
- accountType: account.type,
- uid: account.uid,
- });
+ // taskApply({
+ // account: account.account,
+ // accountType: account.type,
+ // uid: account.uid,
+ // });
+ await pubCore(account);
}
}
- // await pubCore(aList[0]);
+ // 00.00 测试
+
} else {
// 其他任务使用原有的互动任务逻辑
await handleInteraction(aList[0]);
diff --git a/src/views/user/mine/UserProfile.tsx b/src/views/user/mine/UserProfile.tsx
index 15500636..77911628 100644
--- a/src/views/user/mine/UserProfile.tsx
+++ b/src/views/user/mine/UserProfile.tsx
@@ -1,11 +1,11 @@
import { useEffect, useState } from 'react';
-import { Card, Descriptions, Spin, Typography, Space, Avatar, Switch, Slider, Button, Alert } from 'antd';
+import { Card, Descriptions, Spin, Typography, Space, Avatar, Switch, Slider, Button, Alert, InputNumber, Form, Tooltip } from 'antd';
import { userApi } from '@/api/user';
import styles from './userProfile.module.scss';
-import { UserOutlined, PhoneOutlined, IdcardOutlined, QrcodeOutlined, ClockCircleOutlined, SafetyOutlined, WechatOutlined } from '@ant-design/icons';
+import { UserOutlined, PhoneOutlined, IdcardOutlined, QrcodeOutlined, ClockCircleOutlined, SafetyOutlined, WechatOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import { message } from 'antd';
-const { Title } = Typography;
+const { Title, Text } = Typography;
interface UserInfo {
createTime: string;
@@ -30,6 +30,7 @@ const UserProfile = () => {
const [earnStatus, setEarnStatus] = useState<boolean>(false);
const [cycleInterval, setCycleInterval] = useState<number>(30);
const [earnLoading, setEarnLoading] = useState<boolean>(false);
+ const [form] = Form.useForm();
const fetchUserInfo = async () => {
try {
@@ -46,6 +47,9 @@ const UserProfile = () => {
if (res.earnInfo) {
setEarnStatus(res.earnInfo.status === 1);
setCycleInterval(res.earnInfo.cycleInterval || 30);
+ form.setFieldsValue({
+ cycleInterval: res.earnInfo.cycleInterval || 30
+ });
} else {
setEarnStatus(false);
setCycleInterval(30);
@@ -79,6 +83,49 @@ const UserProfile = () => {
}
};
+ const handleEarnStatusChange = async (checked: boolean) => {
+ setLoading(true);
+ try {
+ await userApi.setUserEarnInfo({
+ status: checked ? 1 : 0,
+ cycleInterval: cycleInterval
+ });
+ setEarnStatus(checked);
+ message.success(`赚钱模式已${checked ? '开启' : '关闭'}`);
+ } catch (error) {
+ console.error('更新赚钱模式状态失败:', error);
+ message.error('操作失败,请稍后重试');
+ // 恢复原状态
+ setEarnStatus(!checked);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ const handleCycleIntervalChange = async (value: number) => {
+ setCycleInterval(value);
+ };
+
+ const handleAfterChangeInterval = async (value: number) => {
+ if (!value || value < 5) return;
+
+ setLoading(true);
+ try {
+ await userApi.setUserEarnInfo({
+ status: earnStatus ? 1 : 0,
+ cycleInterval: value
+ });
+ message.success('检查频率已更新');
+ } catch (error) {
+ console.error('更新检查频率失败:', error);
+ message.error('操作失败,请稍后重试');
+ // 恢复原值
+ setCycleInterval(cycleInterval);
+ } finally {
+ setLoading(false);
+ }
+ };
+
const getIntervalLabel = (val: number) => {
if (val < 60) return `${val} 分钟`;
if (val % 60 === 0) return `${val / 60} 小时`;
@@ -181,22 +228,33 @@ const UserProfile = () => {
<Card className={styles.profileCard} style={{ marginTop: 24 }}>
<Title level={5} style={{ marginBottom: 16 }}>赚钱模式设置</Title>
- <div style={{ marginBottom: 16, display: 'flex', alignItems: 'center', gap: 16 }}>
- <span>赚钱模式</span>
- <Switch checked={earnStatus} onChange={setEarnStatus} />
- </div>
- <div style={{ marginBottom: 8, display: 'flex', alignItems: 'center', gap: 16 }}>
- <span>检查频率</span>
- <Slider
- min={5}
- max={1440}
- step={1}
- value={cycleInterval}
- onChange={setCycleInterval}
- style={{ flex: 1, marginRight: 16 }}
- disabled={!earnStatus}
- />
- <span style={{ minWidth: 70, textAlign: 'right' }}>{getIntervalLabel(cycleInterval)}</span>
+ <div style={{ marginBottom: 16 }}>
+ <div style={{ marginBottom: 16, display: 'flex', alignItems: 'center', gap: 16 }}>
+ <span>赚钱模式</span>
+ <Switch
+ checked={earnStatus}
+ onChange={handleEarnStatusChange}
+ loading={loading}
+ />
+ <Tooltip title="开启后系统将自动为您寻找并完成任务">
+ <QuestionCircleOutlined style={{ color: '#999' }} />
+ </Tooltip>
+ </div>
+
+ <div style={{ marginBottom: 8, display: 'flex', alignItems: 'center', gap: 16 }}>
+ <span>检查频率</span>
+ <Slider
+ min={5}
+ max={120}
+ step={1}
+ value={cycleInterval}
+ onChange={handleCycleIntervalChange}
+ onAfterChange={handleAfterChangeInterval}
+ style={{ flex: 1, marginRight: 16 }}
+ disabled={!earnStatus || loading}
+ />
+ <span style={{ minWidth: 70, textAlign: 'right' }}>{getIntervalLabel(cycleInterval)}</span>
+ </div>
</div>
<div style={{ color: '#999', fontSize: 12, marginBottom: 12 }}>
可设置 5分钟~24小时 区间