加载中...
';
fetch('{{ route('chat.rooms-online-status') }}')
.then(r => r.json())
.then(data => {
- if (!data.rooms || !data.rooms.length) {
- container.innerHTML = ' {
+ const roomId = Number.parseInt(room.id, 10);
+ if (!Number.isInteger(roomId)) {
+ return '';
+ }
+
+ const isCurrent = roomId === currentRoomId;
+ const bg = isCurrent ? '#ecf4ff' : '#fff';
+ const nameColor = isCurrent ? '#336699' : (room.door_open ? '#444' : '#bbb');
+ const safeRoomName = escapeMobileDrawerHtml(String(room.name ?? ''));
+ const safeOnlineCount = Math.max(Number.parseInt(room.online, 10) || 0, 0);
+ const badge = safeOnlineCount > 0
+ ? `
${safeOnlineCount}人`
+ : `
空`;
+ const currentTag = isCurrent ? `
当前` : '';
+ const clickAttr = isCurrent ? '' : `onclick="location.href='/room/${roomId}'"`;
+
+ return `
@@ -270,13 +319,9 @@
${safeRoomName}${currentTag}
${badge}
`;
- }).filter(Boolean).join('');
+ }).filter(Boolean).join('');
- container.innerHTML = roomRows || '
暂无房间
';
- })
- .catch(() => {
- container.innerHTML = '
加载失败
';
- });
+ container.innerHTML = roomRows || '
暂无房间
';
}
/**
diff --git a/resources/views/chat/partials/layout/right-panel.blade.php b/resources/views/chat/partials/layout/right-panel.blade.php
index 4b3a3c4..7ffa8e2 100644
--- a/resources/views/chat/partials/layout/right-panel.blade.php
+++ b/resources/views/chat/partials/layout/right-panel.blade.php
@@ -37,7 +37,7 @@