diff --git a/locales/index.d.ts b/locales/index.d.ts index fb010d9353..df248301af 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -5190,6 +5190,10 @@ export interface Locale extends ILocale { * 名前に禁止されている文字列が含まれています。この名前を使用したい場合は、サーバー管理者にお問い合わせください。 */ "yourNameContainsProhibitedWordsDescription": string; + /** + * 常に絶対時刻で表示する + */ + "alwaysUseAbsoluteTime": string; "_abuseUserReport": { /** * 転送 diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index c241a9e560..ac3c07826c 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1293,6 +1293,7 @@ prohibitedWordsForNameOfUser: "禁止ワード(ユーザーの名前)" prohibitedWordsForNameOfUserDescription: "このリストに含まれる文字列がユーザーの名前に含まれる場合、ユーザーの名前の変更を拒否します。モデレーター権限を持つユーザーはこの制限の影響を受けません。" yourNameContainsProhibitedWords: "変更しようとした名前に禁止された文字列が含まれています" yourNameContainsProhibitedWordsDescription: "名前に禁止されている文字列が含まれています。この名前を使用したい場合は、サーバー管理者にお問い合わせください。" +alwaysUseAbsoluteTime: "常に絶対時刻で表示する" _abuseUserReport: forward: "転送" diff --git a/packages/frontend/src/components/global/MkTime.vue b/packages/frontend/src/components/global/MkTime.vue index f600f7eed2..92cfdcba08 100644 --- a/packages/frontend/src/components/global/MkTime.vue +++ b/packages/frontend/src/components/global/MkTime.vue @@ -6,9 +6,9 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -16,6 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-only import isChromatic from 'chromatic/isChromatic'; import { onMounted, onUnmounted, ref, computed } from 'vue'; import { i18n } from '@/i18n.js'; +import { defaultStore } from '@/store.js'; import { dateTimeFormat } from '@@/js/intl-const.js'; const props = withDefaults(defineProps<{ @@ -23,9 +24,21 @@ const props = withDefaults(defineProps<{ origin?: Date | null; mode?: 'relative' | 'absolute' | 'detail'; colored?: boolean; + allowOverrideByUser?: boolean; }>(), { origin: isChromatic() ? () => new Date('2023-04-01T00:00:00Z') : null, mode: 'relative', + allowOverrideByUser: true, +}); + +const _mode = computed(() => { + if (props.mode === 'detail') return 'detail'; + + if (props.allowOverrideByUser && defaultStore.state.alwaysUseAbsoluteTime) { + return 'absolute'; + } else { + return props.mode; + } }); function getDateSafe(n: Date | string | number) { @@ -51,7 +64,7 @@ const now = ref(props.origin?.getTime() ?? Date.now()); const ago = computed(() => (now.value - _time) / 1000/*ms*/); const relative = computed(() => { - if (props.mode === 'absolute') return ''; // absoluteではrelativeを使わないので計算しない + if (_mode.value === 'absolute') return ''; // absoluteではrelativeを使わないので計算しない if (invalid) return i18n.ts._ago.invalid; return ( @@ -87,7 +100,7 @@ function tick() { } } -if (!invalid && props.origin === null && (props.mode === 'relative' || props.mode === 'detail')) { +if (!invalid && props.origin === null && (_mode.value === 'relative' || _mode.value === 'detail')) { onMounted(() => { tick(); }); diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index 1bfdfd0e76..5dd8337618 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -170,6 +170,7 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.enableHorizontalSwipe }} {{ i18n.ts.alwaysConfirmFollow }} {{ i18n.ts.confirmWhenRevealingSensitiveMedia }} + {{ i18n.ts.alwaysUseAbsoluteTime }} @@ -319,6 +320,7 @@ const enableHorizontalSwipe = computed(defaultStore.makeGetterSetter('enableHori const useNativeUIForVideoAudioPlayer = computed(defaultStore.makeGetterSetter('useNativeUIForVideoAudioPlayer')); const alwaysConfirmFollow = computed(defaultStore.makeGetterSetter('alwaysConfirmFollow')); const confirmWhenRevealingSensitiveMedia = computed(defaultStore.makeGetterSetter('confirmWhenRevealingSensitiveMedia')); +const alwaysUseAbsoluteTime = computed(defaultStore.makeGetterSetter('alwaysUseAbsoluteTime')); const contextMenu = computed(defaultStore.makeGetterSetter('contextMenu')); watch(lang, () => { @@ -363,6 +365,7 @@ watch([ enableSeasonalScreenEffect, alwaysConfirmFollow, confirmWhenRevealingSensitiveMedia, + alwaysUseAbsoluteTime, contextMenu, ], async () => { await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true }); diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts index aab67e0b5c..4dbd72d835 100644 --- a/packages/frontend/src/store.ts +++ b/packages/frontend/src/store.ts @@ -472,6 +472,10 @@ export const defaultStore = markRaw(new Storage('base', { where: 'device', default: true, }, + alwaysUseAbsoluteTime: { + where: 'device', + default: false, + }, sound_masterVolume: { where: 'device',