- 任命/撤销事件增加 type 字段区分类型 - 任命:全屏礼花 + 紫色弹窗 + 紫色系统消息 - 撤销:灰色弹窗 + 灰色系统消息,无礼花 - 消息分发:操作者/被操作者显示在私聊面板,其他人显示在公屏 - 系统消息加随机鼓励语(各5条轮换) - ChatStateService 修复 Redis key 前缀扫描问题(getAllActiveRoomIds) - 用户名片折叠优化:管理员视野、职务履历均可折叠 - 管理操作 + 职务操作合并为「🔧 管理操作」折叠区 - 悄悄话改为「🎁 送礼物」按钮,礼物面板内联展开
103 lines
2.6 KiB
PHP
103 lines
2.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 文件功能:自动事件管理控制器
|
|
* 管理员可在后台增删改随机事件(好运/坏运/经验/金币奖惩等)
|
|
* 复刻原版 ASP 聊天室的 autoact 管理功能
|
|
*
|
|
* @author ChatRoom Laravel
|
|
*
|
|
* @version 1.0.0
|
|
*/
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Autoact;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class AutoactController extends Controller
|
|
{
|
|
/**
|
|
* 显示所有自动事件列表
|
|
*/
|
|
public function index(): View
|
|
{
|
|
$events = Autoact::orderByDesc('id')->get();
|
|
|
|
return view('admin.autoact.index', compact('events'));
|
|
}
|
|
|
|
/**
|
|
* 保存新事件
|
|
*/
|
|
public function store(Request $request): RedirectResponse
|
|
{
|
|
$data = $request->validate([
|
|
'text_body' => 'required|string|max:500',
|
|
'event_type' => 'required|in:good,bad,neutral',
|
|
'exp_change' => 'required|integer',
|
|
'jjb_change' => 'required|integer',
|
|
]);
|
|
|
|
$data['enabled'] = true;
|
|
|
|
Autoact::create($data);
|
|
|
|
return redirect()->route('admin.autoact.index')->with('success', '事件添加成功!');
|
|
}
|
|
|
|
/**
|
|
* 更新事件
|
|
*
|
|
* @param Autoact $autoact 路由模型自动注入
|
|
*/
|
|
public function update(Request $request, Autoact $autoact): RedirectResponse
|
|
{
|
|
$event = $autoact;
|
|
|
|
$data = $request->validate([
|
|
'text_body' => 'required|string|max:500',
|
|
'event_type' => 'required|in:good,bad,neutral',
|
|
'exp_change' => 'required|integer',
|
|
'jjb_change' => 'required|integer',
|
|
]);
|
|
|
|
$event->update($data);
|
|
|
|
return redirect()->route('admin.autoact.index')->with('success', '事件修改成功!');
|
|
}
|
|
|
|
/**
|
|
* 切换事件启用/禁用状态
|
|
*
|
|
* @param Autoact $autoact 路由模型自动注入
|
|
*/
|
|
public function toggle(Autoact $autoact): JsonResponse
|
|
{
|
|
$autoact->enabled = ! $autoact->enabled;
|
|
$autoact->save();
|
|
|
|
return response()->json([
|
|
'status' => 'success',
|
|
'enabled' => $autoact->enabled,
|
|
'message' => $autoact->enabled ? '已启用' : '已禁用',
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 删除事件
|
|
*
|
|
* @param Autoact $autoact 路由模型自动注入
|
|
*/
|
|
public function destroy(Autoact $autoact): RedirectResponse
|
|
{
|
|
$autoact->delete();
|
|
|
|
return redirect()->route('admin.autoact.index')->with('success', '事件已删除!');
|
|
}
|
|
}
|