|
|
@@ -57,8 +57,14 @@ const renderedHtml = computed(() => renderReportMarkdown(props.markdown))
|
|
|
// 「刚刚生成」/「N 秒前生成」/「N 分钟前生成」 — 每秒重算
|
|
|
const now = ref(Date.now())
|
|
|
let timer: number | null = null
|
|
|
-onMounted(() => { timer = window.setInterval(() => { now.value = Date.now() }, 1000) })
|
|
|
-onUnmounted(() => { if (timer) clearInterval(timer) })
|
|
|
+onMounted(() => {
|
|
|
+ timer = window.setInterval(() => {
|
|
|
+ now.value = Date.now()
|
|
|
+ }, 1000)
|
|
|
+})
|
|
|
+onUnmounted(() => {
|
|
|
+ if (timer) clearInterval(timer)
|
|
|
+})
|
|
|
|
|
|
function formatTpl(tpl: string, vars: Record<string, string | number>): string {
|
|
|
return tpl.replace(/\{(\w+)\}/g, (_, k) => String(vars[k] ?? ''))
|
|
|
@@ -69,7 +75,7 @@ const generatedAtLabel = computed(() => {
|
|
|
const ts = new Date(props.generatedAt).getTime()
|
|
|
if (isNaN(ts)) return ''
|
|
|
const elapsed = Math.max(0, Math.floor((now.value - ts) / 1000))
|
|
|
- if (elapsed < 5) return (lang as any).ssSpkJustNow
|
|
|
+ if (elapsed < 5) return (lang as any).ssSpkJustNow
|
|
|
if (elapsed < 60) return formatTpl((lang as any).ssSpkSecondsAgoTpl, { n: elapsed })
|
|
|
return formatTpl((lang as any).ssSpkMinutesAgoTpl, { n: Math.floor(elapsed / 60) })
|
|
|
})
|