37 lines
987 B
Vue
37 lines
987 B
Vue
<script setup>
|
|
import { computed } from 'vue';
|
|
import { zhCN } from 'date-fns/locale';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { messageTimestamp } from 'shared/helpers/timeHelper';
|
|
import BaseBubble from './Base.vue';
|
|
import { useMessageContext } from '../provider.js';
|
|
|
|
const { content, createdAt } = useMessageContext();
|
|
|
|
const { locale } = useI18n();
|
|
|
|
const readableTime = computed(() => {
|
|
if (locale.value === 'zh_CN') {
|
|
return messageTimestamp(createdAt.value, 'M月d日 aaa h:mm', {
|
|
locale: zhCN,
|
|
fallbackFormat: 'yyyy年M月d日 aaa h:mm',
|
|
});
|
|
}
|
|
return messageTimestamp(createdAt.value, 'LLL d, h:mm a');
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<BaseBubble
|
|
v-tooltip.top="readableTime"
|
|
class="px-3 py-1 !rounded-xl flex min-w-0 max-w-full items-center gap-2"
|
|
data-bubble-name="activity"
|
|
>
|
|
<span
|
|
v-dompurify-html="content"
|
|
:title="content"
|
|
class="min-w-0 max-w-full [overflow-wrap:anywhere]"
|
|
/>
|
|
</BaseBubble>
|
|
</template>
|