"use client" import { useState } from "react" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Label } from "@/components/ui/label" import { Switch } from "@/components/ui/switch" import { Slider } from "@/components/ui/slider" import { Input } from "@/components/ui/input" import { Button } from "@/components/ui/button" import { Checkbox } from "@/components/ui/checkbox" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip" import { Info, Plus, Trash2 } from "lucide-react" import { Badge } from "@/components/ui/badge" export interface TimeRange { id: string start: string end: string } export interface LikeRulesData { enableAutoLike: boolean likeInterval: number maxLikesPerDay: number likeOldContent: boolean contentTypes: string[] keywordFilters: string[] friendGroups: string[] excludedGroups: string[] timeRanges: TimeRange[] randomizeInterval: boolean minInterval?: number maxInterval?: number } interface LikeRulesProps { initialData?: Partial onSave: (data: LikeRulesData) => void } export function LikeRules({ initialData, onSave }: LikeRulesProps) { const [formData, setFormData] = useState({ enableAutoLike: initialData?.enableAutoLike ?? true, likeInterval: initialData?.likeInterval ?? 15, maxLikesPerDay: initialData?.maxLikesPerDay ?? 50, likeOldContent: initialData?.likeOldContent ?? false, contentTypes: initialData?.contentTypes ?? ["text", "image", "video"], keywordFilters: initialData?.keywordFilters ?? [], friendGroups: initialData?.friendGroups ?? ["all"], excludedGroups: initialData?.excludedGroups ?? [], timeRanges: initialData?.timeRanges ?? [{ id: "1", start: "09:00", end: "11:00" }], randomizeInterval: initialData?.randomizeInterval ?? false, minInterval: initialData?.minInterval ?? 5, maxInterval: initialData?.maxInterval ?? 30, }) const [newKeyword, setNewKeyword] = useState("") // 内容类型选项 const contentTypeOptions = [ { id: "text", label: "纯文字动态" }, { id: "image", label: "图片动态" }, { id: "video", label: "视频动态" }, { id: "link", label: "链接分享" }, { id: "original", label: "仅原创内容" }, ] // 好友分组选项(模拟数据) const friendGroupOptions = [ { id: "all", label: "所有好友" }, { id: "work", label: "工作相关" }, { id: "family", label: "亲友" }, { id: "clients", label: "客户" }, { id: "potential", label: "潜在客户" }, ] // 添加时间范围 const addTimeRange = () => { const newId = String(formData.timeRanges.length + 1) setFormData({ ...formData, timeRanges: [...formData.timeRanges, { id: newId, start: "12:00", end: "14:00" }], }) } // 删除时间范围 const removeTimeRange = (id: string) => { setFormData({ ...formData, timeRanges: formData.timeRanges.filter((range) => range.id !== id), }) } // 更新时间范围 const updateTimeRange = (id: string, field: "start" | "end", value: string) => { setFormData({ ...formData, timeRanges: formData.timeRanges.map((range) => (range.id === id ? { ...range, [field]: value } : range)), }) } // 添加关键词 const addKeyword = () => { if (newKeyword.trim() && !formData.keywordFilters.includes(newKeyword.trim())) { setFormData({ ...formData, keywordFilters: [...formData.keywordFilters, newKeyword.trim()], }) setNewKeyword("") } } // 删除关键词 const removeKeyword = (keyword: string) => { setFormData({ ...formData, keywordFilters: formData.keywordFilters.filter((k) => k !== keyword), }) } // 切换内容类型 const toggleContentType = (typeId: string) => { setFormData({ ...formData, contentTypes: formData.contentTypes.includes(typeId) ? formData.contentTypes.filter((id) => id !== typeId) : [...formData.contentTypes, typeId], }) } // 切换好友分组 const toggleFriendGroup = (groupId: string) => { if (groupId === "all") { setFormData({ ...formData, friendGroups: ["all"], excludedGroups: [], }) return } // 如果当前包含"all",则移除它 let newGroups = formData.friendGroups.filter((id) => id !== "all") if (formData.friendGroups.includes(groupId)) { newGroups = newGroups.filter((id) => id !== groupId) // 如果没有选择任何组,默认回到"all" if (newGroups.length === 0) { newGroups = ["all"] } } else { newGroups.push(groupId) } setFormData({ ...formData, friendGroups: newGroups, }) } // 切换排除分组 const toggleExcludedGroup = (groupId: string) => { setFormData({ ...formData, excludedGroups: formData.excludedGroups.includes(groupId) ? formData.excludedGroups.filter((id) => id !== groupId) : [...formData.excludedGroups, groupId], }) } // 处理表单提交 const handleSubmit = () => { onSave(formData) } return (
点赞规则设置 设定自动点赞的规则和时间间隔 {/* 基本设置 */}

开启后系统将根据设置自动为朋友圈点赞

setFormData({ ...formData, enableAutoLike: checked })} />
{formData.randomizeInterval ? (
{formData.minInterval}分钟
setFormData({ ...formData, minInterval: value[0] })} disabled={!formData.enableAutoLike} />
{formData.maxInterval}分钟
setFormData({ ...formData, maxInterval: value[0] })} disabled={!formData.enableAutoLike} />
) : (
{formData.likeInterval}分钟
setFormData({ ...formData, likeInterval: value[0] })} disabled={!formData.enableAutoLike} />
)}
{formData.maxLikesPerDay}个
setFormData({ ...formData, maxLikesPerDay: value[0] })} disabled={!formData.enableAutoLike} />

开启后系统将点赞好友的历史朋友圈内容

setFormData({ ...formData, likeOldContent: checked })} disabled={!formData.enableAutoLike} />
{/* 内容类型设置 */}
{contentTypeOptions.map((type) => (
toggleContentType(type.id)} disabled={!formData.enableAutoLike} />
))}
{/* 关键词过滤 */}
setNewKeyword(e.target.value)} className="flex-1" disabled={!formData.enableAutoLike} />
{formData.keywordFilters.length > 0 && (
{formData.keywordFilters.map((keyword) => ( {keyword} ))}
)}

添加关键词后,系统将只对包含这些关键词的内容进行点赞

{/* 好友分组设置 */}
{friendGroupOptions.map((group) => (
toggleFriendGroup(group.id)} disabled={!formData.enableAutoLike || (group.id !== "all" && formData.friendGroups.includes("all"))} />
))}
{!formData.friendGroups.includes("all") && (
{friendGroupOptions .filter((group) => group.id !== "all" && !formData.friendGroups.includes(group.id)) .map((group) => (
toggleExcludedGroup(group.id)} disabled={!formData.enableAutoLike} />
))}
)}
{/* 时间范围设置 */}
{formData.timeRanges.map((range) => (
updateTimeRange(range.id, "start", e.target.value)} className="w-32" disabled={!formData.enableAutoLike} /> updateTimeRange(range.id, "end", e.target.value)} className="w-32" disabled={!formData.enableAutoLike} /> {formData.timeRanges.length > 1 && ( )}
))}

设置点赞的时间段,系统将在这些时间段内执行点赞任务

) }