【操盘手】 自动点赞展示点赞数

This commit is contained in:
wong
2025-05-14 17:28:05 +08:00
parent 57a3caa4d5
commit 04df295d62
2 changed files with 57 additions and 23 deletions

View File

@@ -45,6 +45,9 @@ interface TaskConfig {
tagOperator: number
createTime: string
updateTime: string
todayLikeCount?: number
totalLikeCount?: number
friends?: string[]
}
interface Task {
@@ -291,35 +294,33 @@ export default function AutoLikePage() {
</div>
</div>
<div className="grid grid-cols-2 gap-4 mb-4">
<div className="grid grid-cols-2 gap-4 mb-6">
<div className="text-sm text-gray-500">
<div>{task.config.devices.length} </div>
<div>{
task.config.targetGroups.length > 2
? `${task.config.targetGroups[0]}${task.config.targetGroups.length - 1}个标签`
: task.config.targetGroups.join(', ')
}</div>
<div className="mb-1">{task.config.devices.length} </div>
<div className="mb-1">{task.config.friends?.length || 0} </div>
<div>{task.updateTime}</div>
</div>
<div className="text-sm text-gray-500">
<div>{task.config.interval} </div>
<div>{task.config.maxLikes} </div>
<div className="mb-1">{task.config.interval} </div>
<div className="mb-1">{task.config.maxLikes} </div>
<div>{task.createTime}</div>
</div>
</div>
<div className="flex items-center justify-between text-xs text-gray-500 border-t pt-4">
<div className="flex items-center">
<Clock className="w-4 h-4 mr-1" />
{task.updateTime}
<div className="grid grid-cols-2 gap-4 border-t pt-4">
<div className="text-sm">
<div className="flex items-center">
<ThumbsUp className="h-4 w-4 mr-2 text-blue-500" />
<span className="text-gray-500"></span>
<span className="ml-1 font-medium">{task.config.todayLikeCount || 0} </span>
</div>
</div>
<div className="flex items-center">
<span>{task.createTime}</span>
<Button variant="ghost" size="sm" className="ml-2 p-0 h-6 w-6" onClick={() => toggleExpand(task.id)}>
{expandedTaskId === task.id ? (
<ChevronUp className="h-4 w-4" />
) : (
<ChevronDown className="h-4 w-4" />
)}
</Button>
<div className="text-sm">
<div className="flex items-center">
<ThumbsUp className="h-4 w-4 mr-2 text-green-500" />
<span className="text-gray-500"></span>
<span className="ml-1 font-medium">{task.config.totalLikeCount || 0} </span>
</div>
</div>
</div>

View File

@@ -183,6 +183,22 @@ class WorkbenchController extends Controller
//$item->config->targetGroups = json_decode($item->config->targetGroups, true);
$item->config->contentTypes = json_decode($item->config->contentTypes, true);
$item->config->friends = json_decode($item->config->friends, true);
// 添加今日点赞数
$startTime = strtotime(date('Y-m-d') . ' 00:00:00');
$endTime = strtotime(date('Y-m-d') . ' 23:59:59');
$todayLikeCount = Db::name('workbench_auto_like_item')
->where('workbenchId', $item->id)
->whereTime('createTime', 'between', [$startTime, $endTime])
->count();
// 添加总点赞数
$totalLikeCount = Db::name('workbench_auto_like_item')
->where('workbenchId', $item->id)
->count();
$item->config->todayLikeCount = $todayLikeCount;
$item->config->totalLikeCount = $totalLikeCount;
}
unset($item->autoLike,$item->auto_like);
break;
@@ -293,6 +309,23 @@ class WorkbenchController extends Controller
$workbench->config->friends = json_decode($workbench->config->friends, true);
//$workbench->config->targetGroups = json_decode($workbench->config->targetGroups, true);
$workbench->config->contentTypes = json_decode($workbench->config->contentTypes, true);
// 添加今日点赞数
$startTime = strtotime(date('Y-m-d') . ' 00:00:00');
$endTime = strtotime(date('Y-m-d') . ' 23:59:59');
$todayLikeCount = Db::name('workbench_auto_like_item')
->where('workbenchId', $workbench->id)
->whereTime('createTime', 'between', [$startTime, $endTime])
->count();
// 添加总点赞数
$totalLikeCount = Db::name('workbench_auto_like_item')
->where('workbenchId', $workbench->id)
->count();
$workbench->config->todayLikeCount = $todayLikeCount;
$workbench->config->totalLikeCount = $totalLikeCount;
unset($workbench->autoLike,$workbench->auto_like);
}
break;