fix(client): use proxied image for instance icon

This commit is contained in:
syuilo 2022-12-08 17:33:04 +09:00
parent d73cc8f9b8
commit e4c2bba89a
4 changed files with 18 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View file

@ -4,7 +4,7 @@
<transition name="change" mode="default"> <transition name="change" mode="default">
<MarqueeText :key="key" :duration="marqueeDuration" :reverse="marqueeReverse"> <MarqueeText :key="key" :duration="marqueeDuration" :reverse="marqueeReverse">
<span v-for="instance in instances" :key="instance.id" class="item" :class="{ colored }" :style="{ background: colored ? instance.themeColor : null }"> <span v-for="instance in instances" :key="instance.id" class="item" :class="{ colored }" :style="{ background: colored ? instance.themeColor : null }">
<img v-if="instance.iconUrl" class="icon" :src="instance.iconUrl" alt=""/> <img class="icon" :src="getInstanceIcon(instance)" alt=""/>
<MkA :to="`/instance-info/${instance.host}`" class="host _monospace"> <MkA :to="`/instance-info/${instance.host}`" class="host _monospace">
{{ instance.host }} {{ instance.host }}
</MkA> </MkA>
@ -27,6 +27,7 @@ import * as os from '@/os';
import { useInterval } from '@/scripts/use-interval'; import { useInterval } from '@/scripts/use-interval';
import { getNoteSummary } from '@/scripts/get-note-summary'; import { getNoteSummary } from '@/scripts/get-note-summary';
import { notePage } from '@/filters/note'; import { notePage } from '@/filters/note';
import { getProxiedImageUrlNullable } from '@/scripts/media-proxy';
const props = defineProps<{ const props = defineProps<{
display?: 'marquee' | 'oneByOne'; display?: 'marquee' | 'oneByOne';
@ -56,6 +57,10 @@ useInterval(tick, Math.max(5000, props.refreshIntervalSec * 1000), {
immediate: true, immediate: true,
afterMounted: true, afterMounted: true,
}); });
function getInstanceIcon(instance): string {
return getProxiedImageUrlNullable(instance.iconUrl, 'preview') ?? getProxiedImageUrlNullable(instance.faviconUrl, 'preview') ?? '/client-assets/dummy.png';
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View file

@ -6,7 +6,7 @@
<MkLoading v-if="fetching"/> <MkLoading v-if="fetching"/>
<transition-group v-else tag="div" :name="$store.state.animation ? 'chart' : ''" class="instances"> <transition-group v-else tag="div" :name="$store.state.animation ? 'chart' : ''" class="instances">
<div v-for="(instance, i) in instances" :key="instance.id" class="instance"> <div v-for="(instance, i) in instances" :key="instance.id" class="instance">
<img v-if="instance.iconUrl" :src="instance.iconUrl" alt=""/> <img :src="getInstanceIcon(instance)" alt=""/>
<div class="body"> <div class="body">
<a class="a" :href="'https://' + instance.host" target="_blank" :title="instance.host">{{ instance.host }}</a> <a class="a" :href="'https://' + instance.host" target="_blank" :title="instance.host">{{ instance.host }}</a>
<p>{{ instance.softwareName || '?' }} {{ instance.softwareVersion }}</p> <p>{{ instance.softwareName || '?' }} {{ instance.softwareVersion }}</p>
@ -27,6 +27,7 @@ import MkMiniChart from '@/components/MkMiniChart.vue';
import * as os from '@/os'; import * as os from '@/os';
import { useInterval } from '@/scripts/use-interval'; import { useInterval } from '@/scripts/use-interval';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { getProxiedImageUrlNullable } from '@/scripts/media-proxy';
const name = 'federation'; const name = 'federation';
@ -71,6 +72,10 @@ useInterval(fetch, 1000 * 60, {
afterMounted: true, afterMounted: true,
}); });
function getInstanceIcon(instance): string {
return getProxiedImageUrlNullable(instance.iconUrl, 'preview') ?? getProxiedImageUrlNullable(instance.faviconUrl, 'preview') ?? '/client-assets/dummy.png';
}
defineExpose<WidgetComponentExpose>({ defineExpose<WidgetComponentExpose>({
name, name,
configure, configure,

View file

@ -4,7 +4,7 @@
<MkTagCloud v-if="activeInstances"> <MkTagCloud v-if="activeInstances">
<li v-for="instance in activeInstances" :key="instance.id"> <li v-for="instance in activeInstances" :key="instance.id">
<a @click.prevent="onInstanceClick(instance)"> <a @click.prevent="onInstanceClick(instance)">
<img style="width: 32px;" :src="instance.iconUrl"> <img style="width: 32px;" :src="getInstanceIcon(instance)">
</a> </a>
</li> </li>
</MkTagCloud> </MkTagCloud>
@ -20,6 +20,7 @@ import MkContainer from '@/components/MkContainer.vue';
import MkTagCloud from '@/components/MkTagCloud.vue'; import MkTagCloud from '@/components/MkTagCloud.vue';
import * as os from '@/os'; import * as os from '@/os';
import { useInterval } from '@/scripts/use-interval'; import { useInterval } from '@/scripts/use-interval';
import { getProxiedImageUrlNullable } from '@/scripts/media-proxy';
const name = 'instanceCloud'; const name = 'instanceCloud';
@ -64,6 +65,10 @@ useInterval(() => {
afterMounted: true, afterMounted: true,
}); });
function getInstanceIcon(instance): string {
return getProxiedImageUrlNullable(instance.iconUrl, 'preview') ?? getProxiedImageUrlNullable(instance.faviconUrl, 'preview') ?? '/client-assets/dummy.png';
}
defineExpose<WidgetComponentExpose>({ defineExpose<WidgetComponentExpose>({
name, name,
configure, configure,