From 4db6747d60d5c8583fbe45e1e15848ef757ec4ed Mon Sep 17 00:00:00 2001 From: KUN1007 Date: Fri, 25 Aug 2023 17:27:27 +0800 Subject: [PATCH] fix: format time --- src/language/zh.ts | 20 +++++++++---------- src/utils/formatTime.ts | 13 ++++++++---- .../content/article/components/TopicPart.vue | 2 +- .../Home/content/aside/components/Topic.vue | 2 -- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/language/zh.ts b/src/language/zh.ts index 38d7a7b5..dad83e6c 100644 --- a/src/language/zh.ts +++ b/src/language/zh.ts @@ -1,6 +1,6 @@ export default { header: { - name: '鲲Galgame', + name: '鲲 Galgame', pool: '所有话题', create: '发布话题', technique: '技术交流', @@ -46,22 +46,22 @@ export default { item: { daily: '日常交流', chat: '闲聊灌水', - execute: 'galgame运行相关', - globalization: 'galgame汉化相关', - make: 'galgame制作相关', + execute: 'Galgame 运行相关', + globalization: 'Galgame 汉化相关', + make: 'Galgame 制作相关', privacy: '隐私政策', principle: '运营理念', balance: '收支公示', acgngame: 'ACGNGAME', shinnku: '失落的小站', - ymgal: '月幕galgame', + ymgal: '月幕 galgame', }, describe: { - title: '鲲Galgame', - kun1: '世界上最萌的 galgame 论坛!', - kun2: '鲲galgame以营造最良好的氛围为理念', - kun3: '鲲galgame永远不会有广告', - kun4: '鲲galgame永远不会收费', + title: '鲲 Galgame', + kun1: '世界上最萌的 Galgame 论坛!', + kun2: '鲲 Galgame 以营造最良好的氛围为理念', + kun3: '鲲 Galgame 永远不会有广告', + kun4: '鲲 Galgame 永远不会收费', }, contact: '联系我们', }, diff --git a/src/utils/formatTime.ts b/src/utils/formatTime.ts index 1c685fa2..b1054135 100644 --- a/src/utils/formatTime.ts +++ b/src/utils/formatTime.ts @@ -4,10 +4,10 @@ dayjs.extend(relativeTime) const languageOptions = { en: { - second: 'second', - seconds: 'seconds', - minute: 'minute', - minutes: 'minutes', + second: 'sec', + seconds: 'secs', + minute: 'min', + minutes: 'mins', hour: 'hour', hours: 'hours', day: 'day', @@ -42,6 +42,7 @@ function replaceTimeUnits(input: string, language: string) { (languageOptions as Record)[language] || languageOptions.en const replacements: Record = { + a: '1', // 将 "a" 替换为 "1" second: languageOption.second, seconds: languageOption.seconds, minute: languageOption.minute, @@ -86,6 +87,10 @@ export function formatTimeDifference(pastTime: number, language: string) { } } + if (time() === 'a few seconds') { + return language === 'en' ? 'a few secs ago' : '几秒前' + } + const cnTime = replaceTimeUnits(time(), language).replace(/s\b/g, '') + hint const enTime = replaceTimeUnits(time(), language) + hint diff --git a/src/views/Home/content/article/components/TopicPart.vue b/src/views/Home/content/article/components/TopicPart.vue index fef0b199..e467d3c6 100644 --- a/src/views/Home/content/article/components/TopicPart.vue +++ b/src/views/Home/content/article/components/TopicPart.vue @@ -134,7 +134,7 @@ const plainText = getPlainText(props.data.content) } /* 发帖日期 */ .topic-post-date { - width: 55px; + width: 60px; font-size: x-small; color: var(--kungalgame-font-color-0); /* 居中 */ diff --git a/src/views/Home/content/aside/components/Topic.vue b/src/views/Home/content/aside/components/Topic.vue index f8b41be3..3a585d15 100644 --- a/src/views/Home/content/aside/components/Topic.vue +++ b/src/views/Home/content/aside/components/Topic.vue @@ -162,7 +162,6 @@ onMounted(async () => { /* 设置 fa 图标字体的颜色 */ color: var(--kungalgame-purple-4); span { - width: 38px; font-size: xx-small; /* 右侧区域距离最右侧的距离 */ margin-left: 5px; @@ -179,7 +178,6 @@ onMounted(async () => { align-items: center; color: var(--kungalgame-red-4); span { - width: 38px; font-size: small; margin-left: 5px; color: var(--kungalgame-font-color-3);