From 2654f6013d9a8d7fc09029f82937089fa03ec593 Mon Sep 17 00:00:00 2001 From: NoriDev Date: Wed, 21 Jun 2023 16:39:41 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=83=8E=E3=83=BC=E3=83=88=E3=81=AE?= =?UTF-8?q?=E6=99=82=E5=88=BB=E3=82=92=E6=97=A5=E4=BB=98=E3=81=A7=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=99=E3=82=8B=E6=A9=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG_CHERRYPICK.md | 1 + locales/en-US.yml | 1 + locales/index.d.ts | 1 + locales/ja-JP.yml | 1 + locales/ko-KR.yml | 1 + .../frontend/src/components/global/MkTime.vue | 32 +++++++++++++------ .../frontend/src/pages/settings/general.vue | 3 ++ packages/frontend/src/store.ts | 4 +++ 8 files changed, 34 insertions(+), 10 deletions(-) diff --git a/CHANGELOG_CHERRYPICK.md b/CHANGELOG_CHERRYPICK.md index b67c35cddb..a70f09f162 100644 --- a/CHANGELOG_CHERRYPICK.md +++ b/CHANGELOG_CHERRYPICK.md @@ -29,6 +29,7 @@ ### General - 리액션 수신의 기본값을 전체로 설정 - 제어판 메인 화면에 서버 통계 추가 +- 노트의 시간을 일자로 표시하는 기능 ### Client - 리노트 전 확인 팝업을 띄움 diff --git a/locales/en-US.yml b/locales/en-US.yml index d2e9887774..646008b724 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1,5 +1,6 @@ --- _lang_: "English" +enableMarkByDate: "Show note times as dates" renoteConfirm: "Do you want to Renote?" inviteRevoke: "Revoke All Invitation Codes" inviteRevokeConfirm: "Are you sure that you want to revoke all invitation codes?" diff --git a/locales/index.d.ts b/locales/index.d.ts index 43396a1033..f589e817c9 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -3,6 +3,7 @@ // Do not edit this file directly. export interface Locale { "_lang_": string; + "enableMarkByDate": string; "renoteConfirm": string; "inviteRevoke": string; "inviteRevokeConfirm": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 2a865412e3..600bf70eca 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1,5 +1,6 @@ _lang_: "日本語" +enableMarkByDate: "ノート時刻を日付で表示" renoteConfirm: "Renoteしますか?" inviteRevoke: "全ての招待コードを失効する" inviteRevokeConfirm: "本当に全ての招待コードを失効させますか?" diff --git a/locales/ko-KR.yml b/locales/ko-KR.yml index 53486e7314..7bc7ed9af0 100644 --- a/locales/ko-KR.yml +++ b/locales/ko-KR.yml @@ -1,5 +1,6 @@ --- _lang_: "한국어" +enableMarkByDate: "노트 시간을 일자로 표시" renoteConfirm: "리노트 할까요?" inviteRevoke: "모든 초대 코드 무효화" inviteRevokeConfirm: "정말로 모든 초대 코드를 무효화 할까요?" diff --git a/packages/frontend/src/components/global/MkTime.vue b/packages/frontend/src/components/global/MkTime.vue index c4acb52c84..ff9014a9a4 100644 --- a/packages/frontend/src/components/global/MkTime.vue +++ b/packages/frontend/src/components/global/MkTime.vue @@ -12,6 +12,7 @@ import isChromatic from 'chromatic/isChromatic'; import { onUnmounted } from 'vue'; import { i18n } from '@/i18n'; import { dateTimeFormat } from '@/scripts/intl-const'; +import {defaultStore} from "@/store"; const props = withDefaults(defineProps<{ time: Date | string | number | null; @@ -34,16 +35,27 @@ const relative = $computed(() => { if (invalid) return i18n.ts._ago.invalid; const ago = (now - _time) / 1000/*ms*/; - return ( - ago >= 31536000 ? i18n.t('_ago.yearsAgo', { n: Math.round(ago / 31536000).toString() }) : - ago >= 2592000 ? i18n.t('_ago.monthsAgo', { n: Math.round(ago / 2592000).toString() }) : - ago >= 604800 ? i18n.t('_ago.weeksAgo', { n: Math.round(ago / 604800).toString() }) : - ago >= 86400 ? i18n.t('_ago.daysAgo', { n: Math.round(ago / 86400).toString() }) : - ago >= 3600 ? i18n.t('_ago.hoursAgo', { n: Math.round(ago / 3600).toString() }) : - ago >= 60 ? i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() }) : - ago >= 10 ? i18n.t('_ago.secondsAgo', { n: (~~(ago % 60)).toString() }) : - ago >= -1 ? i18n.ts._ago.justNow : - i18n.ts._ago.future); + + if (defaultStore.state.enableMarkByDate) { + return ( + ago >= 86400 ? i18n.t('_ago.daysAgo', { n: Math.round(ago / 86400).toString() }) : + ago >= 3600 ? i18n.t('_ago.hoursAgo', { n: Math.round(ago / 3600).toString() }) : + ago >= 60 ? i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() }) : + ago >= 10 ? i18n.t('_ago.secondsAgo', { n: (~~(ago % 60)).toString() }) : + ago >= -1 ? i18n.ts._ago.justNow : + i18n.ts._ago.future); + } else { + return ( + ago >= 31536000 ? i18n.t('_ago.yearsAgo', { n: Math.round(ago / 31536000).toString() }) : + ago >= 2592000 ? i18n.t('_ago.monthsAgo', { n: Math.round(ago / 2592000).toString() }) : + ago >= 604800 ? i18n.t('_ago.weeksAgo', { n: Math.round(ago / 604800).toString() }) : + ago >= 86400 ? i18n.t('_ago.daysAgo', { n: Math.round(ago / 86400).toString() }) : + ago >= 3600 ? i18n.t('_ago.hoursAgo', { n: Math.round(ago / 3600).toString() }) : + ago >= 60 ? i18n.t('_ago.minutesAgo', { n: (~~(ago / 60)).toString() }) : + ago >= 10 ? i18n.t('_ago.secondsAgo', { n: (~~(ago % 60)).toString() }) : + ago >= -1 ? i18n.ts._ago.justNow : + i18n.ts._ago.future); + } }); let tickId: number; diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index bec3a8eb3b..eaee5174c0 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -61,6 +61,7 @@ {{ i18n.ts.enableAbsoluteTime }} CherryPick + {{ i18n.ts.enableMarkByDate }} CherryPick @@ -334,6 +335,7 @@ const requireRefreshBehavior = computed(defaultStore.makeGetterSetter('requireRe const hideAvatarsInNote = computed(defaultStore.makeGetterSetter('hideAvatarsInNote')); const showTranslateButtonInNote = computed(defaultStore.makeGetterSetter('showTranslateButtonInNote')); const enableAbsoluteTime = computed(defaultStore.makeGetterSetter('enableAbsoluteTime')); +const enableMarkByDate = computed(defaultStore.makeGetterSetter('enableMarkByDate')); watch(lang, () => { miLocalStorage.setItem('lang', lang.value as string); @@ -379,6 +381,7 @@ watch([ overridedDeviceKind, enableDataSaverMode, enableAbsoluteTime, + enableMarkByDate, ], async () => { await reloadAsk(); }); diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts index 9927c80ace..bb24dff9fa 100644 --- a/packages/frontend/src/store.ts +++ b/packages/frontend/src/store.ts @@ -387,6 +387,10 @@ export const defaultStore = markRaw(new Storage('base', { where: 'device', default: false, }, + enableMarkByDate: { + where: 'device', + default: false, + }, // - Settings/CherryPick nicknameEnabled: {