perf: 优化消息

This commit is contained in:
kuaifan 2025-01-02 14:54:22 +08:00
parent ab2b29f267
commit 64b10e3060
3 changed files with 12 additions and 2 deletions

View File

@ -26,7 +26,7 @@
<!--详情--> <!--详情-->
<div ref="content" class="dialog-content" :class="contentClass"> <div ref="content" class="dialog-content" :class="contentClass">
<!--文本--> <!--文本-->
<TextMsg v-if="msgData.type === 'text'" :msgId="msgData.id" :msg="msgData.msg" @viewText="viewText"/> <TextMsg v-if="msgData.type === 'text'" :msgId="msgData.id" :msg="msgData.msg" :createdAt="msgData.created_at" @viewText="viewText"/>
<!--长文本--> <!--长文本-->
<LongTextMsg v-else-if="msgData.type === 'longtext'" :msgId="msgData.id" :msg="msgData.msg" @viewText="viewText" @downFile="downFile"/> <LongTextMsg v-else-if="msgData.type === 'longtext'" :msgId="msgData.id" :msg="msgData.msg" @viewText="viewText" @downFile="downFile"/>
<!--文件--> <!--文件-->

View File

@ -1,6 +1,7 @@
<template> <template>
<div class="content-text no-dark-content"> <div class="content-text no-dark-content">
<DialogMarkdown v-if="msg.type === 'md'" @click="viewText" :text="msg.text"/> <div v-if="isOverdueMsg" class="content-overdue">{{$L('此消息已经过期')}}</div>
<DialogMarkdown v-else-if="msg.type === 'md'" @click="viewText" :text="msg.text"/>
<pre v-else @click="viewText" v-html="$A.formatTextMsg(msg.text, userId)"></pre> <pre v-else @click="viewText" v-html="$A.formatTextMsg(msg.text, userId)"></pre>
<template v-if="translation"> <template v-if="translation">
@ -24,6 +25,7 @@ export default {
props: { props: {
msgId: Number, msgId: Number,
msg: Object, msg: Object,
createdAt: String,
}, },
computed: { computed: {
...mapState(['cacheTranslations', 'cacheTranslationLanguage']), ...mapState(['cacheTranslations', 'cacheTranslationLanguage']),
@ -34,6 +36,10 @@ export default {
}); });
return translation ? translation : null; return translation ? translation : null;
}, },
isOverdueMsg({msg, createdAt}) {
return msg.text === '...' && $A.daytz(createdAt).isBefore($A.daytz().subtract(10, 'minute'));
},
}, },
methods: { methods: {
viewText(e) { viewText(e) {

View File

@ -1437,6 +1437,10 @@
} }
} }
.content-overdue {
opacity: 0.6;
}
.content-divider { .content-divider {
width: 100%; width: 100%;
display: flex; display: flex;