Skip to content

Commit

Permalink
feat: add local time display
Browse files Browse the repository at this point in the history
  • Loading branch information
orangelckc committed Mar 20, 2023
1 parent 06be6cd commit 3380725
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/Session/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import MarkdownItCodeCopy from 'markdown-it-code-copy'
import { IconImage } from '@arco-design/web-vue/es/icon'
import { saveImage } from '@/utils'
import { useSettingsStore, useSessionStore, useRoleStore } from '@/stores'
import dayjs from 'dayjs'
import utc from 'dayjs/plugin/utc'
dayjs.extend(utc)
const marked = new MarkdownIt().use(MarkdownItHighlight).use(MarkdownItCodeCopy)
Expand All @@ -14,6 +18,9 @@ const { currentRole } = storeToRefs(useRoleStore())
const sessionElement = ref<HTMLDivElement | null>(null)
const localTime = (time: string) =>
dayjs.utc(time).local().format('YYYY-MM-DD HH:mm:ss')
watchEffect(() => {
if (!sessionElement.value) return
Expand Down Expand Up @@ -44,7 +51,9 @@ watchEffect(() => {
class="flex w-[calc(100%-8rem)] flex-col gap-2"
:class="item.is_ask && 'items-end'"
>
<span>{{ item.time }}</span>
<span class="text-true-gray text-xs">{{
localTime(item.time!)
}}</span>
<div class="blink-block" v-if="!item.message.content"></div>
<div
Expand Down

0 comments on commit 3380725

Please sign in to comment.