diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-11-17 15:05:37 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2023-11-17 15:05:37 +0900 |
| commit | a9a743dab98d6547cef7c9f5285a4615b6feb245 (patch) | |
| tree | 0ef3c2c34d2badb7e7a3ffbbc6838ca4da452bb2 /packages/frontend | |
| parent | typo (diff) | |
| download | misskey-a9a743dab98d6547cef7c9f5285a4615b6feb245.tar.gz misskey-a9a743dab98d6547cef7c9f5285a4615b6feb245.tar.bz2 misskey-a9a743dab98d6547cef7c9f5285a4615b6feb245.zip | |
enhance(frontend): MFMでUNIX時間を指定して日時を表示できるように
Resolve #12294
Diffstat (limited to 'packages/frontend')
| -rw-r--r-- | packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts | 14 | ||||
| -rw-r--r-- | packages/frontend/src/components/global/MkTime.vue | 10 | ||||
| -rw-r--r-- | packages/frontend/src/const.ts | 2 |
3 files changed, 24 insertions, 2 deletions
diff --git a/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts b/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts index 163724a386..b10a12b504 100644 --- a/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts +++ b/packages/frontend/src/components/global/MkMisskeyFlavoredMarkdown.ts @@ -7,6 +7,7 @@ import { VNode, h } from 'vue'; import * as mfm from 'mfm-js'; import * as Misskey from 'misskey-js'; import MkUrl from '@/components/global/MkUrl.vue'; +import MkTime from '@/components/global/MkTime.vue'; import MkLink from '@/components/MkLink.vue'; import MkMention from '@/components/MkMention.vue'; import MkEmoji from '@/components/global/MkEmoji.vue'; @@ -249,6 +250,19 @@ export default function(props: MfmProps) { return h('ruby', {}, [...genEl(token.children.slice(0, token.children.length - 1), scale), h('rt', text.trim())]); } } + case 'unixtime': { + const child = token.children[0]; + const unixtime = parseInt(child.type === 'text' ? child.props.text : ''); + return h('span', { + style: 'display: inline-block; font-size: 90%; border: solid 1px var(--divider); border-radius: 999px; padding: 4px 10px 4px 6px;', + }, [ + h('i', { + class: 'ti ti-clock', + style: 'margin-right: 0.25em;', + }), + h(MkTime, { time: unixtime * 1000, mode: 'detail' }), + ]); + } } if (style == null) { return h('span', {}, ['$[', token.props.name, ' ', ...genEl(token.children, scale), ']']); diff --git a/packages/frontend/src/components/global/MkTime.vue b/packages/frontend/src/components/global/MkTime.vue index 5ba13ca3f3..61e65a8dcf 100644 --- a/packages/frontend/src/components/global/MkTime.vue +++ b/packages/frontend/src/components/global/MkTime.vue @@ -50,7 +50,15 @@ const relative = $computed<string>(() => { 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); + ago < -31536000 ? i18n.t('_timeIn.years', { n: Math.round(-ago / 31536000).toString() }) : + ago < -2592000 ? i18n.t('_timeIn.months', { n: Math.round(-ago / 2592000).toString() }) : + ago < -604800 ? i18n.t('_timeIn.weeks', { n: Math.round(-ago / 604800).toString() }) : + ago < -86400 ? i18n.t('_timeIn.days', { n: Math.round(-ago / 86400).toString() }) : + ago < -3600 ? i18n.t('_timeIn.hours', { n: Math.round(-ago / 3600).toString() }) : + ago < -60 ? i18n.t('_timeIn.minutes', { n: (~~(-ago / 60)).toString() }) : + ago < -10 ? i18n.t('_timeIn.seconds', { n: (~~(-ago % 60)).toString() }) : + '?' + ); }); let tickId: number; diff --git a/packages/frontend/src/const.ts b/packages/frontend/src/const.ts index 002c198b4d..397f804822 100644 --- a/packages/frontend/src/const.ts +++ b/packages/frontend/src/const.ts @@ -93,4 +93,4 @@ export const DEFAULT_SERVER_ERROR_IMAGE_URL = 'https://xn--931a.moe/assets/error export const DEFAULT_NOT_FOUND_IMAGE_URL = 'https://xn--931a.moe/assets/not-found.jpg'; export const DEFAULT_INFO_IMAGE_URL = 'https://xn--931a.moe/assets/info.jpg'; -export const MFM_TAGS = ['tada', 'jelly', 'twitch', 'shake', 'spin', 'jump', 'bounce', 'flip', 'x2', 'x3', 'x4', 'scale', 'position', 'fg', 'bg', 'font', 'blur', 'rainbow', 'sparkle', 'rotate', 'ruby']; +export const MFM_TAGS = ['tada', 'jelly', 'twitch', 'shake', 'spin', 'jump', 'bounce', 'flip', 'x2', 'x3', 'x4', 'scale', 'position', 'fg', 'bg', 'font', 'blur', 'rainbow', 'sparkle', 'rotate', 'ruby', 'unixtime']; |