refactor: treat formatTimeFromNow as helper not signal

This commit is contained in:
kunish 2024-10-12 23:13:14 +08:00
parent 2bc5c78d91
commit c397ed4dda
No known key found for this signature in database
GPG Key ID: 67D3ACD788F3A7CD
6 changed files with 6 additions and 7 deletions

View File

@ -1,2 +1,3 @@
export * from './global' export * from './global'
export * from './proxies' export * from './proxies'
export * from './time'

View File

@ -1,5 +1,4 @@
import dayjs from 'dayjs' import dayjs, { locale } from 'dayjs'
import { locale } from '~/i18n'
export const formatTimeFromNow = (time: number | string) => export const formatTimeFromNow = (time: number | string) =>
dayjs(time).locale(locale()).fromNow() dayjs(time).locale(locale()).fromNow()

View File

@ -37,6 +37,7 @@ import {
} from '~/components' } from '~/components'
import DocumentTitle from '~/components/DocumentTitle' import DocumentTitle from '~/components/DocumentTitle'
import { CONNECTIONS_TABLE_ACCESSOR_KEY } from '~/constants' import { CONNECTIONS_TABLE_ACCESSOR_KEY } from '~/constants'
import { formatTimeFromNow } from '~/helpers'
import { useI18n } from '~/i18n' import { useI18n } from '~/i18n'
import { import {
allConnections, allConnections,
@ -45,7 +46,6 @@ import {
connectionsTableColumnVisibility, connectionsTableColumnVisibility,
connectionsTableSize, connectionsTableSize,
endpoint, endpoint,
formatTimeFromNow,
quickFilterRegex, quickFilterRegex,
setConnectionsTableColumnOrder, setConnectionsTableColumnOrder,
setConnectionsTableColumnVisibility, setConnectionsTableColumnVisibility,

View File

@ -17,12 +17,12 @@ import {
import DocumentTitle from '~/components/DocumentTitle' import DocumentTitle from '~/components/DocumentTitle'
import { import {
filterProxiesByAvailability, filterProxiesByAvailability,
formatTimeFromNow,
sortProxiesByOrderingType, sortProxiesByOrderingType,
} from '~/helpers' } from '~/helpers'
import { useI18n } from '~/i18n' import { useI18n } from '~/i18n'
import { import {
endpoint, endpoint,
formatTimeFromNow,
hideUnAvailableProxies, hideUnAvailableProxies,
iconHeight, iconHeight,
iconMarginRight, iconMarginRight,

View File

@ -4,9 +4,9 @@ import { matchSorter } from 'match-sorter'
import { twMerge } from 'tailwind-merge' import { twMerge } from 'tailwind-merge'
import { Button } from '~/components' import { Button } from '~/components'
import DocumentTitle from '~/components/DocumentTitle' import DocumentTitle from '~/components/DocumentTitle'
import { useStringBooleanMap } from '~/helpers' import { formatTimeFromNow, useStringBooleanMap } from '~/helpers'
import { useI18n } from '~/i18n' import { useI18n } from '~/i18n'
import { endpoint, formatTimeFromNow, useRules } from '~/signals' import { endpoint, useRules } from '~/signals'
import { Rule, RuleProvider } from '~/types' import { Rule, RuleProvider } from '~/types'
enum ActiveTab { enum ActiveTab {

View File

@ -1,6 +1,5 @@
export * from './config' export * from './config'
export * from './connections' export * from './connections'
export * from './global'
export * from './proxies' export * from './proxies'
export * from './request' export * from './request'
export * from './rules' export * from './rules'