import dayjs from 'dayjs' ; import relativeTime from 'dayjs/plugin/relativeTime' ; import 'dayjs/locale/zh-cn' ; import { Lang } from '@i18n' ; dayjs . extend ( relativeTime ) ; export function fromNow ( date , lang ) { const locale = lang === 'en_US' ? 'en' : 'zh-cn' ; return dayjs ( ) . locale ( locale ) . from ( date ) ; }