183 lines
4.3 KiB
Vue
183 lines
4.3 KiB
Vue
<script setup>
|
|||
|
|
import AvatarBadge from '../AvatarBadge.vue'
|
||
|
|
|
||
|
|
defineProps({
|
||
|
|
conversation: { type: Object, default: null },
|
||
|
|
bindingLabel: { type: String, default: '' },
|
||
|
|
connected: { type: Boolean, default: false },
|
||
|
|
connectionText: { type: String, default: '未连接' },
|
||
|
|
connectionReason: { type: String, default: '' },
|
||
|
|
messageTotal: { type: Number, default: 0 },
|
||
|
|
refreshing: { type: Boolean, default: false }
|
||
|
|
})
|
||
|
|
|
||
|
|
defineEmits(['search', 'refresh'])
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<template>
|
||
|
|
<header class="chat-head">
|
||
|
|
<div v-if="conversation" class="chat-identity">
|
||
|
|
<AvatarBadge
|
||
|
|
:media-uid="conversation.avatarMediaUid"
|
||
|
|
:name="conversation.nickname || conversation.name"
|
||
|
|
:type="conversation.type"
|
||
|
|
size="md"
|
||
|
|
/>
|
||
|
|
<div class="head-text">
|
||
|
|
<div class="head-name">
|
||
|
|
<span :class="{ unknown: !conversation.nickname }">{{ conversation.name }}</span>
|
||
|
|
<span class="head-tag">{{ conversation.typeLabel }}</span>
|
||
|
|
</div>
|
||
|
|
<div class="head-sub">
|
||
|
|
<span>{{ conversation.type === 'GROUP' ? '群号' : '账号' }} {{ conversation.account }}</span>
|
||
|
|
<span v-if="bindingLabel"> · 绑定 {{ bindingLabel }}</span>
|
||
|
|
<span> · 共 {{ messageTotal }} 条</span>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div v-else class="chat-identity empty">
|
||
|
|
<div class="head-text">
|
||
|
|
<div class="head-name">未选择会话</div>
|
||
|
|
<div class="head-sub">从左侧选择一个会话查看已入库消息。</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div v-if="conversation" class="chat-actions">
|
||
|
|
<span class="conn-chip" :class="{ online: connected }" v-tooltip="connectionReason">
|
||
|
|
<i></i>{{ connectionText }}
|
||
|
|
</span>
|
||
|
|
<button class="head-btn" type="button" v-tooltip="'在消息检索中查看该会话'" aria-label="消息检索" @click="$emit('search')">
|
||
|
|
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||
|
|
<circle cx="11" cy="11" r="6.5" />
|
||
|
|
<path d="M20 20l-4-4" />
|
||
|
|
</svg>
|
||
|
|
</button>
|
||
|
|
<button class="head-btn" type="button" v-tooltip="'刷新消息'" aria-label="刷新消息" :disabled="refreshing" @click="$emit('refresh')">
|
||
|
|
<svg viewBox="0 0 24 24" :class="{ spinning: refreshing }" aria-hidden="true">
|
||
|
|
<path d="M20 11a8 8 0 1 0-2.3 5.7" />
|
||
|
|
<path d="M20 4v7h-7" />
|
||
|
|
</svg>
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
</header>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<style scoped>
|
||
|
|
.chat-head {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: space-between;
|
||
|
|
gap: 16px;
|
||
|
|
flex-shrink: 0;
|
||
|
|
padding: 12px 18px;
|
||
|
|
min-height: 62px;
|
||
|
|
border-bottom: 1px solid #ebedef;
|
||
|
|
background: #fff;
|
||
|
|
}
|
||
|
|
.chat-identity {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 11px;
|
||
|
|
min-width: 0;
|
||
|
|
}
|
||
|
|
.head-name .unknown {
|
||
|
|
color: #9aa1b2;
|
||
|
|
font-weight: 400;
|
||
|
|
}
|
||
|
|
.head-text {
|
||
|
|
min-width: 0;
|
||
|
|
}
|
||
|
|
.head-name {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 8px;
|
||
|
|
font-size: 15px;
|
||
|
|
font-weight: 600;
|
||
|
|
color: #1f2329;
|
||
|
|
white-space: nowrap;
|
||
|
|
overflow: hidden;
|
||
|
|
text-overflow: ellipsis;
|
||
|
|
}
|
||
|
|
.head-tag {
|
||
|
|
flex-shrink: 0;
|
||
|
|
padding: 1px 6px;
|
||
|
|
border: 1px solid #e3e5e8;
|
||
|
|
border-radius: 4px;
|
||
|
|
color: #8a8f99;
|
||
|
|
font-size: 10px;
|
||
|
|
font-weight: 400;
|
||
|
|
}
|
||
|
|
.head-sub {
|
||
|
|
margin-top: 3px;
|
||
|
|
font-size: 11px;
|
||
|
|
color: #8a8f99;
|
||
|
|
white-space: nowrap;
|
||
|
|
overflow: hidden;
|
||
|
|
text-overflow: ellipsis;
|
||
|
|
}
|
||
|
|
.chat-actions {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 8px;
|
||
|
|
flex-shrink: 0;
|
||
|
|
}
|
||
|
|
.conn-chip {
|
||
|
|
display: inline-flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 5px;
|
||
|
|
padding: 3px 8px;
|
||
|
|
border-radius: 5px;
|
||
|
|
background: #f3f4f5;
|
||
|
|
color: #8a8f99;
|
||
|
|
font-size: 11px;
|
||
|
|
white-space: nowrap;
|
||
|
|
}
|
||
|
|
.conn-chip i {
|
||
|
|
width: 6px;
|
||
|
|
height: 6px;
|
||
|
|
border-radius: 50%;
|
||
|
|
background: #c0c4ca;
|
||
|
|
}
|
||
|
|
.conn-chip.online {
|
||
|
|
color: #15803d;
|
||
|
|
background: #eefaf2;
|
||
|
|
}
|
||
|
|
.conn-chip.online i {
|
||
|
|
background: #22c55e;
|
||
|
|
}
|
||
|
|
.head-btn {
|
||
|
|
width: 30px;
|
||
|
|
height: 30px;
|
||
|
|
border: 0;
|
||
|
|
border-radius: 7px;
|
||
|
|
background: transparent;
|
||
|
|
color: #6b7078;
|
||
|
|
display: grid;
|
||
|
|
place-items: center;
|
||
|
|
}
|
||
|
|
.head-btn:hover:not(:disabled) {
|
||
|
|
background: #f0f1f3;
|
||
|
|
color: #1f2329;
|
||
|
|
}
|
||
|
|
.head-btn:disabled {
|
||
|
|
cursor: default;
|
||
|
|
opacity: 0.5;
|
||
|
|
}
|
||
|
|
.head-btn svg {
|
||
|
|
width: 17px;
|
||
|
|
height: 17px;
|
||
|
|
fill: none;
|
||
|
|
stroke: currentColor;
|
||
|
|
stroke-width: 1.8;
|
||
|
|
stroke-linecap: round;
|
||
|
|
}
|
||
|
|
.head-btn svg.spinning {
|
||
|
|
animation: head-spin 0.9s linear infinite;
|
||
|
|
}
|
||
|
|
@keyframes head-spin {
|
||
|
|
to {
|
||
|
|
transform: rotate(360deg);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</style>
|