chat-pc/src/views/message/inner/TalkItem.vue

259 lines
6.5 KiB
Vue
Raw Normal View History

<script setup>
2024-12-24 08:14:21 +00:00
import { ArrowUp, ArrowDown, CloseRemind } from '@icon-park/vue-next'
import Xtime from '@/components/base/Xtime.vue'
import avatarModule from '@/components/avatar-module/index.vue'
2024-12-24 08:14:21 +00:00
const emit = defineEmits(['tab-talk', 'top-talk'])
defineProps({
data: Object,
avatar: String,
username: String,
2024-12-24 08:14:21 +00:00
active: Boolean
})
//群类型1=普通群2=部门群3=项目群4=总群/公司群
const labelColor=[
{group_type:2,color:'#377EC6',label:'部门'},
{group_type:3,color:'#C1691C',label:'项目'},
{group_type:4,color:'#7A58DE',label:'公司'},
]
2024-12-24 08:14:21 +00:00
</script>
<template>
<div :class="`talk pointer ${data.is_top === 1 ? 'bg-#F3F3F3' : ''} ${active ? 'actived' : ''}`" @click="emit('tab-talk', data)">
<div class="avatar-box relative">
<avatarModule showGroupType :mode="data?.group_type === 0 ? 1 : 2"
:avatar="data?.avatar"
:groupType="data?.group_type"
:userName="data?.name" :customStyle="{width:'42px',height:'42px'}"></avatarModule>
<!-- <div v-if="[2,3,4].includes(data.group_type)" class="absolute w-32px h-18px border-2px border-solid rounded-3px top-28px bg-#fff text-10px flex justify-center items-center leading-none" :style="`color:${labelColor.find(x=>x.group_type===data.group_type)?.color};border-color:${labelColor.find(x=>x.group_type===data.group_type)?.color}`">{{ labelColor.find(x=>x.group_type===data.group_type)?.label }}</div> -->
<!-- <im-avatar :src="avatar" :size="34" :username="data.name" /> -->
<!-- <div class="top-mask" @click.stop="emit('top-talk', data)">
2024-12-24 08:14:21 +00:00
<n-icon :component="data.is_top == 1 ? ArrowDown : ArrowUp" />
</div> -->
2024-12-24 08:14:21 +00:00
</div>
<div class="content-box">
<div class="header">
<div class="title">
<span class="nickname">{{ username }}</span>
<!-- <span class="badge top" v-show="data.is_top"></span>
2024-12-24 08:14:21 +00:00
<span class="badge roboot" v-show="data.is_robot"></span>
<span class="badge group" v-show="data.talk_type == 2"></span> -->
2024-12-24 08:14:21 +00:00
</div>
<div class="datetime"><Xtime :time="data.updated_at" /></div>
</div>
<div class="content">
<div class="text">
<template v-if="!active && data.draft_text">
<span class="draft">[草稿]</span>
<span class="detail" v-html="data.draft_text" />
</template>
<template v-else>
<span class="online" v-show="data.talk_type == 1 && data.is_online == 1"> [在线] </span>
<span class="detail" v-html="data.msg_text" />
</template>
</div>
<div class="tip">
<div v-if="data.is_disturb" class="disturb flex justify-center items-center">
2024-12-24 08:14:21 +00:00
<!-- <n-icon :component="CloseRemind" /> -->
<span class="badge w-50px">
<!-- {{ data.unread_num > 99 ? '99+' : data.unread_num }} -->
<img src="@/assets/image/xxxx@2x.png" class="w-11.1px h-13px mr-6px" alt="">
<span v-if="data.unread_num>0" class="w-10px h-10px bg-#D03050 rounded-50%"></span>
2024-12-24 08:14:21 +00:00
</span>
</div>
<div v-else class="unread" v-show="data.unread_num">
<span class="badge">
{{ data.unread_num > 99 ? '99+' : data.unread_num }}
</span>
</div>
</div>
</div>
</div>
</div>
</template>
<style lang="less" scoped>
.talk {
padding: 8px 10px 8px 5px;
height: 64px;
2024-12-24 08:14:21 +00:00
display: flex;
align-items: center;
transition: 0.2s ease-in;
margin: 0px 2px 5px 5px;
border-radius: 5px;
.avatar-box {
height: 42px;
width: 42px;
2024-12-24 08:14:21 +00:00
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
font-size: 14px;
user-select: none;
transition: ease 1s;
position: relative;
2024-12-24 08:14:21 +00:00
.top-mask {
width: 100%;
height: 100%;
background-color: rgba(22, 25, 29, 0.6);
position: absolute;
top: 0;
left: 0;
color: #ffffff;
display: none;
align-items: center;
justify-content: center;
}
&:hover .top-mask {
display: flex;
}
}
.content-box {
height: 40px;
display: flex;
align-content: center;
flex-direction: column;
flex: 1 1;
margin-left: 10px;
overflow: hidden;
.header {
width: 100%;
height: 20px;
display: flex;
align-items: center;
.title {
color: #1f2329;
font-size: 14px;
line-height: 20px;
flex: 1 1;
display: flex;
overflow: hidden;
.nickname {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-right: 5px;
}
}
.datetime {
color: #8f959e;
font-size: 12px;
margin-left: 10px;
user-select: none;
}
}
.content {
width: 100%;
height: 20px;
display: flex;
align-items: center;
justify-content: space-between;
.text {
overflow: hidden;
font-weight: 300;
font-size: 12px;
color: #8f959e;
display: flex;
.draft {
color: red;
padding-right: 3px;
flex-shrink: 0;
}
.online {
color: #8bc34a;
padding-right: 3px;
flex-shrink: 0;
}
.detail {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.tip {
height: inherit;
display: flex;
padding-left: 5px;
align-items: center;
.unread {
color: #8f959e;
font-size: 12px;
user-select: none;
.badge {
background-color: #D03050;
2024-12-24 08:14:21 +00:00
color: #ffffff;
border-radius: 50%;
2024-12-24 08:14:21 +00:00
transform-origin: right;
}
}
.disturb {
color: #8f959e;
font-size: 12px;
user-select: none;
}
}
}
}
--actived-bg: #EEE9F8;
2024-12-24 08:14:21 +00:00
&:hover,
&.actived {
background-color: var(--actived-bg);
}
}
.badge {
&.top {
color: red !important;
background-color: #ffdddd !important;
}
&.roboot {
color: #dc9b04 !important;
background-color: #faf1d1 !important;
}
&.group {
color: #3370ff !important;
background-color: #e1eaff !important;
}
}
html[theme-mode='dark'] {
.talk {
--actived-bg: rgb(44, 44, 50);
.nickname {
color: #ffffff;
}
}
.disturb {
color: #ffffff;
}
}
</style>