From 3bceb2d0b22ddb78b771d69c9115bf99a0ba7286 Mon Sep 17 00:00:00 2001 From: Rogee Date: Thu, 6 Aug 2026 11:31:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(conversations):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=97=B6=E9=97=B4=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/components/ui/TimeAgo.vue | 4 +++- .../dashboard/components/ui/specs/TimeAgo.spec.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 frontend/app/javascript/dashboard/components/ui/specs/TimeAgo.spec.js diff --git a/frontend/app/javascript/dashboard/components/ui/TimeAgo.vue b/frontend/app/javascript/dashboard/components/ui/TimeAgo.vue index 5a039320..98a51586 100644 --- a/frontend/app/javascript/dashboard/components/ui/TimeAgo.vue +++ b/frontend/app/javascript/dashboard/components/ui/TimeAgo.vue @@ -13,6 +13,8 @@ const chineseShortTimestamp = timestamp => { .replace(/^(\d+)y$/, '$1年'); }; +export { chineseShortTimestamp }; + import { zhCN } from 'date-fns/locale'; import { dynamicTime, @@ -151,7 +153,7 @@ export default { content: tooltipText, delay: { show: 1000, hide: 0 }, }" - class="ml-auto leading-4 text-xxs text-n-slate-10 hover:text-n-slate-11" + class="ml-auto whitespace-nowrap leading-4 text-xxs text-n-slate-10 hover:text-n-slate-11" > {{ `${createdAtTime} • ${lastActivityTime}` }} diff --git a/frontend/app/javascript/dashboard/components/ui/specs/TimeAgo.spec.js b/frontend/app/javascript/dashboard/components/ui/specs/TimeAgo.spec.js new file mode 100644 index 00000000..5cd4df9f --- /dev/null +++ b/frontend/app/javascript/dashboard/components/ui/specs/TimeAgo.spec.js @@ -0,0 +1,15 @@ +import { chineseShortTimestamp } from '../TimeAgo.vue'; + +describe('chineseShortTimestamp', () => { + it.each([ + ['now', '刚刚'], + ['1m', '1分钟'], + ['1h', '1小时'], + ['12h', '12小时'], + ['1d', '1天'], + ['2mo', '2个月'], + ['1y', '1年'], + ])('formats %s as %s', (timestamp, expected) => { + expect(chineseShortTimestamp(timestamp)).toBe(expected); + }); +}); \ No newline at end of file