116 lines
2.2 KiB
Vue
116 lines
2.2 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 text-secondary">{{ message.publishTime }}</span>
|
|
</div>
|
|
<p class="message-item__summary text-secondary">
|
|
{{ 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);
|
|
gap: @spacing-base;
|
|
padding: 14px 17px;
|
|
background: @white;
|
|
cursor: pointer;
|
|
transition: background 0.2s;
|
|
|
|
&:hover {
|
|
background: @bg-color-light;
|
|
}
|
|
|
|
&__emoji {
|
|
flex-shrink: 0;
|
|
.flex(row, center);
|
|
width: 31px;
|
|
height: 31px;
|
|
border-radius: @radius-round;
|
|
background: @message-icon-bg;
|
|
font-size: 15px;
|
|
line-height: 1;
|
|
}
|
|
|
|
&__body {
|
|
.flex(column, flex-start, stretch);
|
|
gap: 5px;
|
|
flex: 1;
|
|
min-width: 0;
|
|
margin-top: 6px;
|
|
}
|
|
|
|
&__head {
|
|
.flex(row, space-between);
|
|
gap: @spacing-base;
|
|
width: 100%;
|
|
}
|
|
|
|
&__title {
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
color: @heading-color;
|
|
.ellipsis();
|
|
}
|
|
|
|
&__time {
|
|
flex-shrink: 0;
|
|
font-size: 11px;
|
|
color: @text-color-disabled;
|
|
}
|
|
|
|
&__summary {
|
|
font-size: 11px;
|
|
.ellipsis();
|
|
}
|
|
|
|
&__dot {
|
|
position: absolute;
|
|
top: 12px;
|
|
left: 42px;
|
|
width: 15px;
|
|
height: 15px;
|
|
border-radius: @radius-round;
|
|
background: @danger-color;
|
|
}
|
|
|
|
&.is-unread {
|
|
.message-item__title {
|
|
font-weight: 600;
|
|
}
|
|
}
|
|
}
|
|
</style>
|