mirror of
https://github.com/MisskeyIO/misskey
synced 2024-12-23 19:18:44 +09:00
81d2c5a4a7
* PackedNoteなどのemojisはプロキシしていないURLを返すように * MFMでx3/x4もしくはscale.x/yが2.5以上に指定されていた場合にはオリジナル品質の絵文字を使用する * update CHANGELOG.md * fix changelog * ?? * wip * fix * merge * Update packages/frontend/src/scripts/media-proxy.ts Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * merge * calc scale --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
79 lines
2.0 KiB
Vue
79 lines
2.0 KiB
Vue
<template>
|
|
<span v-if="errored">:{{ customEmojiName }}:</span>
|
|
<img v-else :class="[$style.root, { [$style.normal]: normal, [$style.noStyle]: noStyle }]" :src="url" :alt="alt" :title="alt" decoding="async" @error="errored = true" @load="errored = false"/>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed } from 'vue';
|
|
import { getProxiedImageUrl, getStaticImageUrl } from '@/scripts/media-proxy';
|
|
import { defaultStore } from '@/store';
|
|
import { customEmojis } from '@/custom-emojis';
|
|
|
|
const props = defineProps<{
|
|
name: string;
|
|
normal?: boolean;
|
|
noStyle?: boolean;
|
|
host?: string | null;
|
|
url?: string;
|
|
useOriginalSize?: boolean;
|
|
}>();
|
|
|
|
const customEmojiName = computed(() => (props.name[0] === ':' ? props.name.substr(1, props.name.length - 2) : props.name).replace('@.', ''));
|
|
const isLocal = computed(() => !props.host && (customEmojiName.value.endsWith('@.') || !customEmojiName.value.includes('@')));
|
|
|
|
const rawUrl = computed(() => {
|
|
if (props.url) {
|
|
return props.url;
|
|
}
|
|
if (isLocal.value) {
|
|
return customEmojis.value.find(x => x.name === customEmojiName.value)?.url ?? null;
|
|
}
|
|
return props.host ? `/emoji/${customEmojiName.value}@${props.host}.webp` : `/emoji/${customEmojiName.value}.webp`;
|
|
});
|
|
|
|
const url = computed(() => {
|
|
if (rawUrl.value == null) return null;
|
|
|
|
const proxied =
|
|
(rawUrl.value.startsWith('/emoji/') || (props.useOriginalSize && isLocal.value))
|
|
? rawUrl.value
|
|
: getProxiedImageUrl(
|
|
rawUrl.value,
|
|
props.useOriginalSize ? undefined : 'emoji',
|
|
false,
|
|
true,
|
|
);
|
|
return defaultStore.reactiveState.disableShowingAnimatedImages.value
|
|
? getStaticImageUrl(proxied)
|
|
: proxied;
|
|
});
|
|
|
|
const alt = computed(() => `:${customEmojiName.value}:`);
|
|
let errored = $ref(url.value == null);
|
|
</script>
|
|
|
|
<style lang="scss" module>
|
|
.root {
|
|
height: 2em;
|
|
vertical-align: middle;
|
|
transition: transform 0.2s ease;
|
|
|
|
&:hover {
|
|
transform: scale(1.2);
|
|
}
|
|
}
|
|
|
|
.normal {
|
|
height: 1.25em;
|
|
vertical-align: -0.25em;
|
|
|
|
&:hover {
|
|
transform: none;
|
|
}
|
|
}
|
|
|
|
.noStyle {
|
|
height: auto !important;
|
|
}
|
|
</style>
|