perf: ttl value will use unit 'day' when above 1 day #122
This commit is contained in:
parent
022ee20eed
commit
42fa24debd
|
@ -11,10 +11,10 @@ import IconButton from '@/components/common/IconButton.vue'
|
||||||
import Copy from '@/components/icons/Copy.vue'
|
import Copy from '@/components/icons/Copy.vue'
|
||||||
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
|
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
|
||||||
import { computed, onUnmounted, reactive, watch } from 'vue'
|
import { computed, onUnmounted, reactive, watch } from 'vue'
|
||||||
import { padStart } from 'lodash'
|
|
||||||
import { NIcon, useThemeVars } from 'naive-ui'
|
import { NIcon, useThemeVars } from 'naive-ui'
|
||||||
import { timeout } from '@/utils/promise.js'
|
import { timeout } from '@/utils/promise.js'
|
||||||
import AutoRefreshForm from '@/components/common/AutoRefreshForm.vue'
|
import AutoRefreshForm from '@/components/common/AutoRefreshForm.vue'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
server: String,
|
server: String,
|
||||||
|
@ -54,20 +54,19 @@ const binaryKey = computed(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const ttlString = computed(() => {
|
const ttlString = computed(() => {
|
||||||
let s = ''
|
|
||||||
if (props.ttl > 0) {
|
if (props.ttl > 0) {
|
||||||
const hours = Math.floor(props.ttl / 3600)
|
const dur = dayjs.duration(props.ttl, 'seconds')
|
||||||
s += padStart(hours + ':', 3, '0')
|
const days = dur.days()
|
||||||
const minutes = Math.floor((props.ttl % 3600) / 60)
|
if (days > 0) {
|
||||||
s += padStart(minutes + ':', 3, '0')
|
return days + i18n.t('common.unit_day') + ' ' + dur.format('HH:mm:ss')
|
||||||
const seconds = Math.floor(props.ttl % 60)
|
|
||||||
s += padStart(seconds + '', 2, '0')
|
|
||||||
} else if (props.ttl < 0) {
|
|
||||||
s = '-1'
|
|
||||||
} else {
|
} else {
|
||||||
s = '00:00:00'
|
return dur.format('HH:mm:ss')
|
||||||
|
}
|
||||||
|
} else if (props.ttl < 0) {
|
||||||
|
return i18n.t('interface.forever')
|
||||||
|
} else {
|
||||||
|
return '00:00:00'
|
||||||
}
|
}
|
||||||
return s
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const startAutoRefresh = async () => {
|
const startAutoRefresh = async () => {
|
||||||
|
@ -165,7 +164,7 @@ const onTTL = () => {
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<n-icon :component="Timer" size="18" />
|
<n-icon :component="Timer" size="18" />
|
||||||
</template>
|
</template>
|
||||||
{{ ttlString === '-1' ? $t('interface.forever') : ttlString }}
|
{{ ttlString }}
|
||||||
</n-button>
|
</n-button>
|
||||||
</template>
|
</template>
|
||||||
TTL{{ `${ttl > 0 ? ': ' + ttl + $t('common.second') : ''}` }}
|
TTL{{ `${ttl > 0 ? ': ' + ttl + $t('common.second') : ''}` }}
|
||||||
|
|
Loading…
Reference in New Issue