enhance(frontend): MFMでUNIX時間を指定して日時を表示できるように

Resolve #12294
This commit is contained in:
syuilo
2023-11-17 15:05:37 +09:00
parent 4d1a2bad17
commit a9a743dab9
6 changed files with 44 additions and 2 deletions

View File

@@ -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), ']']);