refactor(dayjs): Refactor internationalized time formatting feature (#22870) (#22872)

This commit is contained in:
HyaCinth 2025-07-24 10:42:33 +08:00 • committed by GitHub
commit b8504ac7d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 13 additions and 34 deletions

View file

@ -15,7 +15,6 @@ export * from './use-workflow-variables'
export * from './use-shortcuts'
export * from './use-workflow-interactions'
export * from './use-workflow-mode'
export * from './use-format-time-from-now'
export * from './use-workflow-refresh-draft'
export * from './use-inspect-vars-crud'
export * from './use-set-workflow-vars-with-value'

View file

@ -1,12 +0,0 @@
import dayjs from 'dayjs'
import { useCallback } from 'react'
import { useI18N } from '@/context/i18n'
export const useFormatTimeFromNow = () => {
const { locale } = useI18N()
const formatTimeFromNow = useCallback((time: number) => {
return dayjs(time).locale(locale === 'zh-Hans' ? 'zh-cn' : locale).fromNow()
}, [locale])
return { formatTimeFromNow }
}