Skip to content

Commit

Permalink
feat: 群图标边上显示发言者小头像
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Dec 6, 2023
1 parent a97f514 commit ea54405
Show file tree
Hide file tree
Showing 5 changed files with 2,261 additions and 2,266 deletions.
11 changes: 11 additions & 0 deletions icalingua-bridge-oicq/adapters/oicqAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ const eventHandlers = {
content: '',
timestamp: formatDate('hh:mm', now),
username: senderName,
userId: senderId,
}
////process message////
await processMessage(data.message, message, lastMessage, roomId)
Expand Down Expand Up @@ -263,6 +264,7 @@ const eventHandlers = {
content: msg,
username: null,
timestamp: formatDate('hh:mm'),
userId: data.operator_id,
}
const message: Message = {
username: '',
Expand Down Expand Up @@ -306,6 +308,7 @@ const eventHandlers = {
content: msg,
username: null,
timestamp: formatDate('hh:mm'),
userId: data.operator_id,
}
const message: Message = {
username: '',
Expand Down Expand Up @@ -335,6 +338,7 @@ const eventHandlers = {
content: msg,
username: null,
timestamp: formatDate('hh:mm'),
userId: data.user_id,
}
const message: Message = {
username: '',
Expand Down Expand Up @@ -386,6 +390,7 @@ const eventHandlers = {
content: message.content,
username: '',
timestamp: formatDate('hh:mm', now),
userId: senderId,
}
clients.addMessage(roomId, message)
clients.updateRoom(room)
Expand Down Expand Up @@ -437,6 +442,7 @@ const eventHandlers = {
content: message.content,
username: '',
timestamp: formatDate('hh:mm', now),
userId: data.operator_id,
}
clients.addMessage(roomId, message)
clients.updateRoom(room)
Expand Down Expand Up @@ -489,6 +495,7 @@ const eventHandlers = {
content: message.content,
username: '',
timestamp: formatDate('hh:mm', new Date(data.time)),
userId: data.operator_id,
}
clients.addMessage(roomId, message)
clients.updateRoom(room)
Expand Down Expand Up @@ -687,6 +694,7 @@ const eventHandlers = {
content: message.content,
username: '',
timestamp: formatDate('hh:mm', new Date(data.time)),
userId: data.operator_id,
}
clients.addMessage(roomId, message)
clients.updateRoom(room)
Expand Down Expand Up @@ -749,6 +757,7 @@ const eventHandlers = {
content: message.content,
username: '',
timestamp: formatDate('hh:mm', now),
userId: senderId,
}
clients.addMessage(roomId, message)
clients.updateRoom(room)
Expand Down Expand Up @@ -782,6 +791,7 @@ const eventHandlers = {
content: message.content,
username: '',
timestamp: formatDate('hh:mm', now),
userId: senderId,
}
clients.addMessage(roomId, message)
clients.updateRoom(room)
Expand Down Expand Up @@ -1460,6 +1470,7 @@ const adapter = {
content: '',
timestamp: formatDate('hh:mm'),
username: 'You',
userId: bot.uin,
}
try {
await processMessage(message, _message, lastMessage, user_id)
Expand Down
11 changes: 11 additions & 0 deletions icalingua/src/main/adapters/oicqAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ const eventHandlers = {
content: '',
timestamp: formatDate('hh:mm', now),
username: senderName,
userId: senderId,
}
////process message////
await processMessage(data.message, message, lastMessage, roomId)
Expand Down Expand Up @@ -384,6 +385,7 @@ const eventHandlers = {
content: msg,
username: null,
timestamp: formatDate('hh:mm'),
userId: data.operator_id,
}
const message: Message = {
username: '',
Expand Down Expand Up @@ -428,6 +430,7 @@ const eventHandlers = {
content: msg,
username: null,
timestamp: formatDate('hh:mm'),
userId: data.operator_id,
}
const message: Message = {
username: '',
Expand Down Expand Up @@ -457,6 +460,7 @@ const eventHandlers = {
content: msg,
username: null,
timestamp: formatDate('hh:mm'),
userId: data.user_id,
}
const message: Message = {
username: '',
Expand Down Expand Up @@ -509,6 +513,7 @@ const eventHandlers = {
content: message.content,
username: '',
timestamp: formatDate('hh:mm', now),
userId: senderId,
}
ui.addMessage(roomId, message)
ui.updateRoom(room)
Expand Down Expand Up @@ -561,6 +566,7 @@ const eventHandlers = {
content: message.content,
username: '',
timestamp: formatDate('hh:mm', now),
userId: data.operator_id,
}
ui.addMessage(roomId, message)
ui.updateRoom(room)
Expand Down Expand Up @@ -613,6 +619,7 @@ const eventHandlers = {
content: message.content,
username: '',
timestamp: formatDate('hh:mm', now),
userId: data.operator_id,
}
ui.addMessage(roomId, message)
ui.updateRoom(room)
Expand Down Expand Up @@ -811,6 +818,7 @@ const eventHandlers = {
content: message.content,
username: '',
timestamp: formatDate('hh:mm', now),
userId: data.operator_id,
}
ui.addMessage(roomId, message)
ui.updateRoom(room)
Expand Down Expand Up @@ -900,6 +908,7 @@ const eventHandlers = {
content: message.content,
username: '',
timestamp: formatDate('hh:mm', now),
userId: senderId,
}
ui.addMessage(roomId, message)
ui.updateRoom(room)
Expand Down Expand Up @@ -933,6 +942,7 @@ const eventHandlers = {
content: message.content,
username: '',
timestamp: formatDate('hh:mm', now),
userId: senderId,
}
ui.addMessage(roomId, message)
ui.updateRoom(room)
Expand Down Expand Up @@ -1712,6 +1722,7 @@ const adapter: OicqAdapter = {
content: '',
timestamp: formatDate('hh:mm'),
username: 'You',
userId: bot.uin,
}
try {
await processMessage(message, _message, lastMessage, user_id)
Expand Down
29 changes: 28 additions & 1 deletion icalingua/src/renderer/components/RoomEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
<div class="entry">
<div class="left">
<el-badge value="@" :type="room.at === 'all' ? 'warning' : undefined" :hidden="!room.at">
<el-avatar size="large" :src="roomAvatar" />
<div class="avatar-container">
<el-avatar size="large" :src="roomAvatar" />
<el-avatar
class="sub-avatar"
:size="20"
:src="roomSubAvatar"
v-if="room.users.length > 2 && room.lastMessage && room.lastMessage.userId"
/>
</div>
<el-badge
class="avatar-only-unread"
:value="room.unreadCount"
Expand Down Expand Up @@ -79,6 +87,9 @@ export default {
roomAvatar() {
return getAvatarUrl(this.room.roomId)
},
roomSubAvatar() {
return getAvatarUrl(this.room.lastMessage.userId)
},
roomName() {
return this.removeEmotes ? removeGroupNameEmotes(this.room.roomName) : this.room.roomName
},
Expand Down Expand Up @@ -203,4 +214,20 @@ a {
top: 30px;
left: 24px;
}
.avatar-container {
position: relative;
}
.sub-avatar {
position: absolute;
bottom: -2px;
right: -2px;
}
@container (max-width: 80px) {
.sub-avatar {
display: none;
}
}
</style>
1 change: 1 addition & 0 deletions packages/types/LastMessage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export default interface LastMessage {
content?: string
timestamp?: string
username?: string
userId?: number
}
Loading

0 comments on commit ea54405

Please sign in to comment.