mirror of https://github.com/langgenius/dify.git
feat(app-publisher): add relative time formatting for timestamps
This commit is contained in:
parent
cd1ec65286
commit
ce619287b3
|
|
@ -6,6 +6,7 @@ import {
|
|||
} from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import dayjs from 'dayjs'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
import {
|
||||
RiArrowDownSLine,
|
||||
RiArrowRightSLine,
|
||||
|
|
@ -48,6 +49,7 @@ import { useAppWhiteListSubjects, useGetUserCanAccessApp } from '@/service/acces
|
|||
import { AccessMode } from '@/models/access-control'
|
||||
import { fetchAppDetail } from '@/service/apps'
|
||||
import { useGlobalPublicStore } from '@/context/global-public-context'
|
||||
dayjs.extend(relativeTime)
|
||||
|
||||
export type AppPublisherProps = {
|
||||
disabled?: boolean
|
||||
|
|
@ -116,7 +118,7 @@ const AppPublisher = ({
|
|||
}
|
||||
}, [appAccessSubjects, appDetail])
|
||||
const language = useGetLanguage()
|
||||
const formatTimeFromNow = useCallback((time: number) => {
|
||||
const formatTimeFromNow = useCallback(async (time: number) => {
|
||||
return dayjs(time).locale(language === 'zh_Hans' ? 'zh-cn' : language.replace('_', '-')).fromNow()
|
||||
}, [language])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue