feat: dayjs

This commit is contained in:
Zephyruso 2023-08-31 11:50:21 +08:00
parent 5d801edb76
commit b4fc1b4c98
4 changed files with 2159 additions and 769 deletions

View File

@ -29,6 +29,7 @@
"byte-size": "^8.1.1", "byte-size": "^8.1.1",
"commitlint": "^17.7.1", "commitlint": "^17.7.1",
"daisyui": "^3.6.4", "daisyui": "^3.6.4",
"dayjs": "^1.11.9",
"husky": "^8.0.3", "husky": "^8.0.3",
"is-ip": "^5.0.1", "is-ip": "^5.0.1",
"ky": "^0.33.3", "ky": "^0.33.3",

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@ import Collapse from '~/components/Collpase'
import ProxyNodeCard from '~/components/ProxyNodeCard' import ProxyNodeCard from '~/components/ProxyNodeCard'
import { useProxies } from '~/signals/proxies' import { useProxies } from '~/signals/proxies'
import type { Proxy } from '~/types' import type { Proxy } from '~/types'
import { formatTimeFromNow } from '~/utils/date'
export default () => { export default () => {
const { const {
@ -106,8 +107,8 @@ export default () => {
<span>{proxyProvider.name}</span> <span>{proxyProvider.name}</span>
<div class="text-sm text-slate-500"> <div class="text-sm text-slate-500">
{proxyProvider.vehicleType} :: Updated at{' '} {proxyProvider.vehicleType} :: Updated{' '}
{new Date(proxyProvider.updatedAt).toLocaleString()} {formatTimeFromNow(proxyProvider.updatedAt)}
</div> </div>
</div> </div>

8
src/utils/date.ts Normal file
View File

@ -0,0 +1,8 @@
import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
dayjs.extend(relativeTime)
export function formatTimeFromNow(time: number | string) {
return dayjs(time).fromNow()
}