UNPKG

create-iking-admin

Version:

金合技术中台脚手架

28 lines (25 loc) 907 B
import type { TDate } from 'timeago.js' /* * @Author : wfl * @LastEditors : wfl * @description : * @updateInfo : * @Date : 2023-03-06 11:43:58 * @LastEditTime : 2023-03-06 11:44:45 */ const timeAgo = { name: 'time-ago', mounted: (el: { innerText: string; __timeagoSetInterval__: NodeJS.Timer; }, binding: { value: TDate; modifiers: { interval: any; }; }) => { el.innerText = useTimeago().format(binding.value) if (binding.modifiers.interval) { el.__timeagoSetInterval__ = setInterval(() => { el.innerText = useTimeago().format(binding.value) }, 1000) } }, beforeUnmount: (el: { __timeagoSetInterval__: string | number | NodeJS.Timeout | undefined; }, binding: { modifiers: { interval: any; }; }) => { if (binding.modifiers.interval) clearInterval(el.__timeagoSetInterval__) } } export default timeAgo