-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
281 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { MsgEnum } from '@/enums' | ||
|
||
// 消息回复映射表 | ||
export const MSG_REPLY_TEXT_MAP: Record<number, string> = { | ||
[MsgEnum.UNKNOWN]: '[未知]', | ||
[MsgEnum.RECALL]: '[撤回消息]', | ||
[MsgEnum.IMAGE]: '[图片]', | ||
[MsgEnum.FILE]: '[文件]', | ||
[MsgEnum.VOICE]: '[语音]', | ||
[MsgEnum.VIDEO]: '[音频]', | ||
[MsgEnum.EMOJI]: '[表情]', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/views/Home/Chat/components/ChatList/MsgItem/components/UserCard/UserCard.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<script setup lang="ts"> | ||
import { onMounted, ref } from 'vue' | ||
import type { CacheUserItem } from '@/services/types' | ||
import apis from '@/services/apis' | ||
import { RoomTypeEnum } from '@/enums' | ||
import { useChatStore } from '@/stores/chat' | ||
import { useGlobalStore } from '@/stores/global' | ||
import { useCachedStore } from '@/stores/cached' | ||
import { useUserStore } from '@/stores/user' | ||
const chatStore = useChatStore() | ||
const globalStore = useGlobalStore() | ||
const cacheStore = useCachedStore() | ||
const userStore = useUserStore() | ||
const props = defineProps<{ | ||
user: CacheUserItem | ||
}>() | ||
const userCard = ref<HTMLDivElement>() | ||
const sendMsg = async () => { | ||
const result = await apis.sessionDetailWithFriends({ uid: props.user.uid }).send() | ||
globalStore.currentSession.roomId = result.roomId | ||
globalStore.currentSession.type = RoomTypeEnum.Single | ||
chatStore.updateSessionLastActiveTime(result.roomId, result) | ||
} | ||
onMounted(() => { | ||
cacheStore.getBatchBadgeInfo(props.user.itemIds) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div ref="userCard" class="user-card"> | ||
<div class="user-card_top"> | ||
<div class="user-card_top-avatar"> | ||
<el-avatar shape="square" :size="55" :src="user.avatar" /> | ||
</div> | ||
<div class="user-card_top-info"> | ||
<el-tooltip effect="dark" :content="user.name" placement="top-start"> | ||
<div class="user-card_top-info_name">昵称:{{ user.name }}</div> | ||
</el-tooltip> | ||
<div class="user-card_top-info_id">uid:{{ user.uid }}</div> | ||
<div class="user-card_top-info_place">地区:{{ user.locPlace }}</div> | ||
</div> | ||
</div> | ||
<div class="user-card_badge" v-if="user.itemIds?.length"> | ||
<div class="user-card_badge-item" v-for="itemId in user.itemIds" :key="itemId"> | ||
<el-badge v-if="user.wearingItemId === itemId" is-dot> | ||
<img | ||
class="user-card_badge-item" | ||
:src="cacheStore.badgeCachedList[itemId]?.img" | ||
:alt="cacheStore.badgeCachedList[itemId]?.describe" | ||
:title="cacheStore.badgeCachedList[itemId]?.describe" | ||
/> | ||
</el-badge> | ||
<img | ||
v-else | ||
class="user-card_badge-item" | ||
:src="cacheStore.badgeCachedList[itemId]?.img" | ||
:alt="cacheStore.badgeCachedList[itemId]?.describe" | ||
:title="cacheStore.badgeCachedList[itemId]?.describe" | ||
/> | ||
</div> | ||
</div> | ||
<div class="user-card_other"> | ||
<div | ||
class="user-card_other-item user-card_other_send" | ||
@click="sendMsg" | ||
v-if="userStore.isSign" | ||
> | ||
<Icon class="tool-icon" icon="chat" :size="28" /> | ||
<span>发消息</span> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped lang="scss" src="./styles.scss"></style> |
60 changes: 60 additions & 0 deletions
60
src/views/Home/Chat/components/ChatList/MsgItem/components/UserCard/styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
.user-card { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 200px; | ||
padding: 10px; | ||
background-color: var(--background-wrapper); | ||
border-radius: 8px; | ||
box-shadow: 1px 1px 5px 1px var(--background-2); | ||
|
||
&_top { | ||
display: flex; | ||
padding-bottom: 10px; | ||
border-bottom: 1px solid var(--background-secondary); | ||
|
||
&-avatar { | ||
width: 35%; | ||
} | ||
|
||
&-info { | ||
width: 65%; | ||
font-size: 13px; | ||
|
||
&_name { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
} | ||
} | ||
|
||
&_badge { | ||
display: flex; | ||
justify-content: space-between; | ||
padding: 5px 0; | ||
|
||
&-item { | ||
width: 25px; | ||
height: 25px; | ||
} | ||
} | ||
|
||
&_other { | ||
display: flex; | ||
align-items: center; | ||
|
||
&-item { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
min-height: 60px; | ||
font-size: 10px; | ||
cursor: pointer; | ||
|
||
&:hover { | ||
color: var(--hover-primary); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script setup lang="ts"> | ||
import { MSG_REPLY_TEXT_MAP } from '@/constant/message' | ||
import type { MessageType, SessionItem } from '@/services/types' | ||
defineProps<{ | ||
session: SessionItem | ||
message: MessageType | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<div class="post-confirm_box"> | ||
<div class="contact-info"> | ||
<img | ||
:src="session.avatar" | ||
alt="${session.avatar}" | ||
:title="session.name" | ||
class="session-avatar" | ||
/> | ||
<span>{{ session.name }}</span> | ||
</div> | ||
<div class="msg-body"> | ||
{{ MSG_REPLY_TEXT_MAP[message.message.type] ?? message.message.body?.content }} | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped lang="scss" src="./styles.scss"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.post-confirm_box { | ||
padding: 0 10px 10px; | ||
|
||
.contact-info { | ||
display: flex; | ||
align-items: center; | ||
|
||
.session-avatar { | ||
width: 40px; | ||
height: 40px; | ||
margin-right: 10px; | ||
border-radius: 10px; | ||
} | ||
} | ||
|
||
.msg-body { | ||
display: -webkit-box; | ||
width: 100%; | ||
height: 70px; | ||
padding: 5px 10px; | ||
margin-top: 10px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
word-break: break-word; | ||
background-color: var(--background-dark); | ||
-webkit-line-clamp: 3; | ||
-webkit-box-orient: vertical; | ||
} | ||
} |
Oops, something went wrong.