-
+
-
{friend.nickname}
+
{friend.friendName}
{friend.wechatId}
{!readonly && (
diff --git a/Cunkebao/src/pages/mobile/workspace/auto-like/list/index.tsx b/Cunkebao/src/pages/mobile/workspace/auto-like/list/index.tsx
index a967f725..22ff25dc 100644
--- a/Cunkebao/src/pages/mobile/workspace/auto-like/list/index.tsx
+++ b/Cunkebao/src/pages/mobile/workspace/auto-like/list/index.tsx
@@ -116,20 +116,38 @@ const AutoLike: React.FC = () => {
setLoading(true);
try {
const Res: any = await fetchAutoLikeTasks();
- // 直接就是任务数组,无需再解包
- const mappedTasks = Res?.list?.map((task: any) => ({
- ...task,
- status: task.status || 2, // 默认为关闭状态
- deviceCount: task.deviceCount || 0,
- targetGroup: task.targetGroup || "全部好友",
- likeInterval: task.likeInterval || 60,
- maxLikesPerDay: task.maxLikesPerDay || 100,
- lastLikeTime: task.lastLikeTime || "暂无",
- createTime: task.createTime || "",
- updateTime: task.updateTime || "",
- todayLikeCount: task.todayLikeCount || 0,
- totalLikeCount: task.totalLikeCount || 0,
- }));
+ // 数据在 data.list 中
+ const taskList = Res?.data?.list || Res?.list || [];
+ const mappedTasks = taskList.map((task: any) => {
+ const config = task.config || {};
+ const friends = config.friends || [];
+ const devices = config.devices || [];
+
+ // 判断目标人群:如果 friends 为空或未设置,表示选择全部好友
+ let targetGroup = "全部好友";
+ if (friends.length > 0) {
+ targetGroup = `${friends.length} 个好友`;
+ }
+
+ return {
+ id: task.id?.toString() || "",
+ name: task.name || "",
+ status: task.status === 1 ? 1 : 2, // 1: 开启, 2: 关闭
+ deviceCount: devices.length,
+ targetGroup: targetGroup,
+ likeInterval: config.interval || 60,
+ maxLikesPerDay: config.maxLikes || 100,
+ lastLikeTime: task.lastLikeTime || "暂无",
+ createTime: task.createTime || "",
+ updateTime: task.updateTime || "",
+ todayLikeCount: config.todayLikeCount || 0,
+ totalLikeCount: config.totalLikeCount || 0,
+ // 保留原始数据
+ config: config,
+ devices: devices,
+ friends: friends,
+ };
+ });
setTasks(mappedTasks);
} catch (error) {
console.error("获取自动点赞任务失败:", error);
@@ -355,7 +373,7 @@ const AutoLike: React.FC = () => {
/>
今日点赞:
- {task.lastLikeTime}
+ {task.todayLikeCount || 0}
diff --git a/Cunkebao/src/pages/mobile/workspace/auto-like/new/index.tsx b/Cunkebao/src/pages/mobile/workspace/auto-like/new/index.tsx
index 779aecea..b02e5e61 100644
--- a/Cunkebao/src/pages/mobile/workspace/auto-like/new/index.tsx
+++ b/Cunkebao/src/pages/mobile/workspace/auto-like/new/index.tsx
@@ -36,6 +36,7 @@ const NewAutoLike: React.FC = () => {
const [isSubmitting, setIsSubmitting] = useState(false);
const [isLoading, setIsLoading] = useState(isEditMode);
const [autoEnabled, setAutoEnabled] = useState(false);
+ const [selectAllFriends, setSelectAllFriends] = useState(false);
const [formData, setFormData] = useState
({
name: "",
interval: 5,
@@ -45,8 +46,8 @@ const NewAutoLike: React.FC = () => {
contentTypes: ["text", "image", "video"],
deviceGroups: [],
deviceGroupsOptions: [],
- friendsGroups: [],
- friendsGroupsOptions: [],
+ wechatFriends: [],
+ wechatFriendsOptions: [],
targetTags: [],
friendMaxLikes: 10,
enableFriendTags: false,
@@ -74,8 +75,8 @@ const NewAutoLike: React.FC = () => {
contentTypes: config.contentTypes || ["text", "image", "video"],
deviceGroups: config.deviceGroups || [],
deviceGroupsOptions: config.deviceGroupsOptions || [],
- friendsGroups: config.friendsgroups || [],
- friendsGroupsOptions: config.friendsGroupsOptions || [],
+ wechatFriends: config.wechatFriends || [],
+ wechatFriendsOptions: config.wechatFriendsOptions || [],
targetTags: config.targetTags || [],
friendMaxLikes: config.friendMaxLikes || 10,
enableFriendTags: config.enableFriendTags || false,
@@ -85,6 +86,10 @@ const NewAutoLike: React.FC = () => {
(taskDetail as any).status === 1 ||
(taskDetail as any).status === "running",
);
+ // 如果 wechatFriends 为空或未设置,可能表示选择了全部好友
+ setSelectAllFriends(
+ !config.wechatFriends || config.wechatFriends.length === 0
+ );
}
} catch (error) {
message.error("获取任务详情失败");
@@ -127,11 +132,19 @@ const NewAutoLike: React.FC = () => {
}
setIsSubmitting(true);
try {
+ // 如果选择了全部好友,提交时传空数组或特殊标识
+ const submitData = {
+ ...formData,
+ wechatFriends: selectAllFriends ? [] : formData.wechatFriends,
+ wechatFriendsOptions: selectAllFriends ? [] : formData.wechatFriendsOptions,
+ selectAllFriends: selectAllFriends, // 添加标识字段
+ };
+
if (isEditMode) {
- await updateAutoLikeTask({ ...formData, id });
+ await updateAutoLikeTask({ ...submitData, id });
message.success("更新成功");
} else {
- await createAutoLikeTask(formData);
+ await createAutoLikeTask(submitData);
message.success("创建成功");
}
navigate("/workspace/auto-like");
@@ -142,6 +155,28 @@ const NewAutoLike: React.FC = () => {
}
};
+ // 选择全部好友(仅设置标识)
+ const handleSelectAllFriends = () => {
+ if (!formData.deviceGroups || formData.deviceGroups.length === 0) {
+ message.warning("请先选择执行设备");
+ return;
+ }
+
+ if (selectAllFriends) {
+ // 取消全选标识
+ setSelectAllFriends(false);
+ // 清空已选好友
+ handleUpdateFormData({
+ wechatFriends: [],
+ wechatFriendsOptions: [],
+ });
+ } else {
+ // 设置全选标识
+ setSelectAllFriends(true);
+ message.success("已标记为选择全部好友");
+ }
+ };
+
// 步骤器
const renderStepIndicator = () => (
@@ -364,16 +399,39 @@ const NewAutoLike: React.FC = () => {
const renderFriendSettings = () => (
-
- handleUpdateFormData({
- friendsGroups: friends.map(f => f.id),
- friendsGroupsOptions: friends,
- })
- }
- deviceIds={formData.deviceGroups}
- />
+
+
选择好友
+
+
+ {selectAllFriends ? (
+
+ ✓
+ 已标记为选择全部好友
+
+ ) : (
+ {
+ handleUpdateFormData({
+ wechatFriends: friends.map(f => f.id),
+ wechatFriendsOptions: friends,
+ });
+ // 如果手动选择了好友,取消全选标识
+ if (selectAllFriends) {
+ setSelectAllFriends(false);
+ }
+ }}
+ deviceIds={formData.deviceGroups}
+ />
+ )}