121 lines
2.4 KiB
Vue
121 lines
2.4 KiB
Vue
<script setup lang="ts">
|
|
import type { Message, MessageType } from '@/types/business/message'
|
|
|
|
interface Props {
|
|
message: Message
|
|
}
|
|
|
|
defineProps<Props>()
|
|
|
|
const emit = defineEmits<{ view: [id: string] }>()
|
|
|
|
const emojiMap: Record<MessageType, string> = {
|
|
在线客服: '💬',
|
|
状态通知: '📢',
|
|
系统通知: '🔔',
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div
|
|
class="message-item"
|
|
:class="{ 'is-unread': !message.isRead }"
|
|
role="button"
|
|
tabindex="0"
|
|
@click="emit('view', message.id)"
|
|
@keydown.enter="emit('view', message.id)"
|
|
>
|
|
<span class="message-item__emoji">{{ emojiMap[message.type] }}</span>
|
|
<div class="message-item__body">
|
|
<div class="message-item__head">
|
|
<span class="message-item__title">{{ message.title }}</span>
|
|
<span class="message-item__time">{{ message.publishTime }}</span>
|
|
</div>
|
|
<p class="message-item__summary">
|
|
{{ message.summary }}
|
|
</p>
|
|
</div>
|
|
<span v-if="!message.isRead" class="message-item__dot" aria-label="未读" />
|
|
</div>
|
|
</template>
|
|
|
|
<style lang="less" scoped>
|
|
.message-item {
|
|
position: relative;
|
|
.flex(row, flex-start, flex-start);
|
|
gap: 16px;
|
|
min-height: 86px;
|
|
padding: 19px 29px;
|
|
background: @white;
|
|
cursor: pointer;
|
|
box-sizing: border-box;
|
|
transition: background 0.2s;
|
|
|
|
&:hover {
|
|
background: @bg-color-light;
|
|
}
|
|
|
|
&__emoji {
|
|
flex-shrink: 0;
|
|
.flex(row, center);
|
|
width: 42px;
|
|
height: 42px;
|
|
border-radius: @radius-round;
|
|
background: @message-item-icon;
|
|
font-size: 20px;
|
|
line-height: 1;
|
|
}
|
|
|
|
&__body {
|
|
.flex(column, flex-start, stretch);
|
|
gap: 8px;
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
|
|
&__head {
|
|
.flex(row, space-between, flex-start);
|
|
gap: @spacing-base;
|
|
width: 100%;
|
|
}
|
|
|
|
&__title {
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
line-height: 20px;
|
|
color: @finance-ink;
|
|
.ellipsis();
|
|
}
|
|
|
|
&__time {
|
|
flex-shrink: 0;
|
|
font-size: 12px;
|
|
line-height: 20px;
|
|
color: @message-tabs-text;
|
|
}
|
|
|
|
&__summary {
|
|
font-size: 12px;
|
|
line-height: 18px;
|
|
color: @message-tabs-text;
|
|
.ellipsis();
|
|
}
|
|
|
|
&__dot {
|
|
position: absolute;
|
|
top: 21px;
|
|
left: 60px;
|
|
width: 14px;
|
|
height: 14px;
|
|
border: 2px solid @white;
|
|
border-radius: @radius-round;
|
|
background: @message-tabs-badge;
|
|
box-sizing: content-box;
|
|
}
|
|
|
|
&.is-unread .message-item__title {
|
|
font-weight: 600;
|
|
}
|
|
}
|
|
</style>
|