From 1fd26dcf1a6f7289cfd580cd3d5529b729c8bcf4 Mon Sep 17 00:00:00 2001 From: wangys <3401275564@qq.com> Date: Tue, 23 Dec 2025 19:15:00 +0800 Subject: [PATCH] =?UTF-8?q?web=E7=AB=AF=E8=81=8A=E5=A4=A9=E5=AE=A4?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chatRoom/chatRoom/ChatRoom.scss | 24 +++ .../components/chatRoom/chatRoom/ChatRoom.vue | 31 ++- .../views/public/ChatRoom/ChatRoomView.scss | 134 +++++++++++- .../views/public/ChatRoom/ChatRoomView.vue | 192 +++++++++++++----- 4 files changed, 324 insertions(+), 57 deletions(-) diff --git a/urbanLifelineWeb/packages/workcase/src/components/chatRoom/chatRoom/ChatRoom.scss b/urbanLifelineWeb/packages/workcase/src/components/chatRoom/chatRoom/ChatRoom.scss index 606a4e26..2e2c6327 100644 --- a/urbanLifelineWeb/packages/workcase/src/components/chatRoom/chatRoom/ChatRoom.scss +++ b/urbanLifelineWeb/packages/workcase/src/components/chatRoom/chatRoom/ChatRoom.scss @@ -10,6 +10,14 @@ $brand-color-hover: #004488; background: #fff; } +// ==================== 加载更多 ==================== +.loading-more { + text-align: center; + padding: 12px; + font-size: 13px; + color: #94a3b8; +} + // ==================== 聊天室头部 ==================== .chat-header { height: 64px; @@ -96,12 +104,28 @@ $brand-color-hover: #004488; border-radius: 50%; flex-shrink: 0; overflow: hidden; + background: $brand-color-light; + display: flex; + align-items: center; + justify-content: center; img { width: 100%; height: 100%; object-fit: cover; } + + .avatar-text { + font-size: 14px; + font-weight: 600; + color: $brand-color; + } + } + + .sender-name { + font-size: 12px; + color: #64748b; + margin-bottom: 4px; } .message-content-wrapper { diff --git a/urbanLifelineWeb/packages/workcase/src/components/chatRoom/chatRoom/ChatRoom.vue b/urbanLifelineWeb/packages/workcase/src/components/chatRoom/chatRoom/ChatRoom.vue index e69d1628..f6e1ee31 100644 --- a/urbanLifelineWeb/packages/workcase/src/components/chatRoom/chatRoom/ChatRoom.vue +++ b/urbanLifelineWeb/packages/workcase/src/components/chatRoom/chatRoom/ChatRoom.vue @@ -10,7 +10,11 @@ -
+
+ +
加载中...
+
没有更多消息了
+
@@ -24,9 +28,13 @@ class="message-row" :class="message.senderId === currentUserId ? 'is-me' : 'other'" > - -
- +
+ +
+ + {{ message.senderName?.charAt(0) || '?' }} +
+
{{ message.senderName || '未知用户' }}
@@ -126,12 +134,16 @@ interface Props { meetingUrl?: string showMeeting?: boolean fileDownloadUrl?: string + hasMore?: boolean + loadingMore?: boolean } const props = withDefaults(defineProps(), { roomName: '聊天室', showMeeting: false, - fileDownloadUrl: '' + fileDownloadUrl: '', + hasMore: true, + loadingMore: false }) const FILE_DOWNLOAD_URL = props.fileDownloadUrl @@ -140,8 +152,17 @@ const emit = defineEmits<{ 'send-message': [content: string, files: File[]] 'start-meeting': [] 'download-file': [fileId: string] + 'load-more': [] }>() +// 滚动到顶部加载更多 +const handleScroll = (e: Event) => { + const target = e.target as HTMLElement + if (target.scrollTop < 50 && props.hasMore && !props.loadingMore) { + emit('load-more') + } +} + defineSlots<{ header?: () => any 'action-area'?: () => any diff --git a/urbanLifelineWeb/packages/workcase/src/views/public/ChatRoom/ChatRoomView.scss b/urbanLifelineWeb/packages/workcase/src/views/public/ChatRoom/ChatRoomView.scss index d4f8c028..aebf3adc 100644 --- a/urbanLifelineWeb/packages/workcase/src/views/public/ChatRoom/ChatRoomView.scss +++ b/urbanLifelineWeb/packages/workcase/src/views/public/ChatRoom/ChatRoomView.scss @@ -12,15 +12,135 @@ $brand-color-hover: #004488; font-family: 'Inter', 'Noto Sans SC', sans-serif; } -// ==================== 聊天室列表侧边栏 ==================== -.room-list-sidebar { - width: 320px; +// ==================== 折叠状态的侧边栏 ==================== +.sidebar-collapsed { + position: absolute; + left: 0; + top: 0; height: 100%; + width: 48px; background: #fff; border-right: 1px solid #e2e8f0; display: flex; flex-direction: column; - flex-shrink: 0; + align-items: center; + padding: 16px 0; + z-index: 10; + + .sidebar-toggle-btn { + padding: 8px; + color: #64748b; + background: transparent; + border: none; + border-radius: 8px; + cursor: pointer; + transition: all 0.2s; + margin-bottom: 8px; + + &:hover { + color: $brand-color; + background: $brand-color-light; + } + } + + .sidebar-icons { + flex: 1; + overflow-y: auto; + width: 100%; + display: flex; + flex-direction: column; + align-items: center; + gap: 4px; + padding: 8px 0; + } + + .sidebar-icon-btn { + width: 32px; + height: 32px; + display: flex; + align-items: center; + justify-content: center; + color: #fff; + background: linear-gradient(135deg, $brand-color 0%, $brand-color-hover 100%); + border: none; + border-radius: 50%; + cursor: pointer; + transition: all 0.2s; + font-size: 12px; + font-weight: 600; + + &:hover { + transform: scale(1.1); + } + + &.active { + box-shadow: 0 0 0 2px $brand-color-light; + } + } + + .expand-btn { + padding: 8px; + color: #94a3b8; + background: transparent; + border: none; + border-radius: 8px; + cursor: pointer; + transition: all 0.2s; + + &:hover { + color: #64748b; + background: #f1f5f9; + } + } +} + +// ==================== 展开时的关闭按钮 ==================== +.sidebar-close-btn { + position: absolute; + left: 256px; + top: 50%; + transform: translateY(-50%); + z-index: 20; + background: #fff; + border: 1px solid #e2e8f0; + border-left: none; + border-radius: 0 8px 8px 0; + padding: 8px; + cursor: pointer; + box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05); + transition: all 0.2s; + color: #64748b; + + &:hover { + background: #f8fafc; + box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1); + } +} + +// ==================== 聊天室列表侧边栏 ==================== +.room-list-sidebar { + position: absolute; + left: 0; + top: 0; + height: 100%; + width: 0; + background: #fff; + border-right: 1px solid #e2e8f0; + z-index: 10; + transition: all 0.3s ease; + overflow: hidden; + box-shadow: 4px 0 16px rgba(0, 0, 0, 0.08); + + &.open { + width: 256px; + } + + .sidebar-inner { + width: 256px; + height: 100%; + display: flex; + flex-direction: column; + } .sidebar-header { height: 56px; @@ -156,6 +276,12 @@ $brand-color-hover: #004488; flex-direction: column; height: 100%; background: #fff; + margin-left: 48px; + transition: margin-left 0.3s ease; + + &.sidebar-open { + margin-left: 256px; + } } // ==================== 聊天室头部 ==================== diff --git a/urbanLifelineWeb/packages/workcase/src/views/public/ChatRoom/ChatRoomView.vue b/urbanLifelineWeb/packages/workcase/src/views/public/ChatRoom/ChatRoomView.vue index 6cb95373..a046770e 100644 --- a/urbanLifelineWeb/packages/workcase/src/views/public/ChatRoom/ChatRoomView.vue +++ b/urbanLifelineWeb/packages/workcase/src/views/public/ChatRoom/ChatRoomView.vue @@ -1,69 +1,102 @@