修复在线名单职务图标显示

This commit is contained in:
2026-04-22 10:10:40 +08:00
parent 73c6674fc4
commit bef797abd5
2 changed files with 32 additions and 0 deletions
+7
View File
@@ -2,6 +2,7 @@
use Illuminate\Support\Facades\Broadcast;
// 用户私有频道:仅允许用户本人订阅自己的通知频道。
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
@@ -19,6 +20,9 @@ Broadcast::channel('room.{roomId}', function ($user, $roomId) {
}
$superLevel = (int) \App\Models\Sysparam::getValue('superlevel', '100');
// 预加载当前在职职务,供右侧在线名单直接显示职务图标与名称。
$activePosition = $user->activePosition()->with('position.department')->first();
$position = $activePosition?->position;
return [
'id' => $user->id,
@@ -30,6 +34,9 @@ Broadcast::channel('room.{roomId}', function ($user, $roomId) {
'vip_name' => $user->vipName(),
'vip_color' => $user->isVip() ? ($user->vipLevel?->color ?? '') : '',
'is_admin' => $user->user_level >= $superLevel,
'position_icon' => $position?->icon ?? '',
'position_name' => $position?->name ?? '',
'department_name' => $position?->department?->name ?? '',
];
});