feat: 实现挂机修仙、排行榜、大厅重构与全站留言板系统

- (Phase 8) 后台各维度管理与配置
- (Phase 9) 全自动静默挂机修仙升级
- (Phase 9) 四大维度风云排行榜页面
- (Phase 10) 全站留言板与悄悄话私信功能
- 运行 Pint 代码格式化
This commit is contained in:
2026-02-26 13:35:38 +08:00
parent 7d6423902d
commit 50fc804402
85 changed files with 5776 additions and 30 deletions

View File

@@ -0,0 +1,50 @@
<?php
/**
* 文件功能:异步持久化聊天记录队列
* 承接高频聊天缓存,防堵塞 MySQL 进程。
*
* @author ChatRoom Laravel
*
* @version 1.0.0
*/
namespace App\Jobs;
use App\Models\Message;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Carbon;
class SaveMessageJob implements ShouldQueue
{
use Queueable;
/**
* Create a new job instance.
*
* @param array $messageData 包装好的消息数组
*/
public function __construct(
public readonly array $messageData
) {}
/**
* Execute the job.
* 将缓存在 Redis 刚广播出去的消息,真实映射写入到 `messages` 数据表。
*/
public function handle(): void
{
Message::create([
'room_id' => $this->messageData['room_id'],
'from_user' => $this->messageData['from_user'],
'to_user' => $this->messageData['to_user'] ?? '大家',
'content' => $this->messageData['content'],
'is_secret' => $this->messageData['is_secret'] ?? false,
'font_color' => $this->messageData['font_color'] ?? '',
'action' => $this->messageData['action'] ?? '',
// 恢复 Carbon 时间对象
'sent_at' => Carbon::parse($this->messageData['sent_at']),
]);
}
}