parent
d06ed1b477
commit
2fda83c321
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="hpaizdrt" :style="bg">
|
||||
<img v-if="instance.faviconUrl" class="icon" :src="instance.faviconUrl" aria-hidden="true"/>
|
||||
<img class="icon" :src="getInstanceIcon(instance)" aria-hidden="true"/>
|
||||
<span class="name">{{ instance.name }}</span>
|
||||
</div>
|
||||
</template>
|
||||
@ -8,6 +8,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { instanceName } from '@/config';
|
||||
import { instance as Instance } from '@/instance';
|
||||
import { getProxiedImageUrlNullable } from '@/scripts/media-proxy';
|
||||
|
||||
const props = defineProps<{
|
||||
instance?: {
|
||||
@ -29,6 +30,10 @@ const themeColor = instance.themeColor ?? '#777777';
|
||||
const bg = {
|
||||
background: `linear-gradient(90deg, ${themeColor}, ${themeColor}11)`,
|
||||
};
|
||||
|
||||
function getInstanceIcon(instance): string {
|
||||
return getProxiedImageUrlNullable(instance.iconUrl, 'preview') ?? getProxiedImageUrlNullable(instance.faviconUrl, 'preview') ?? '/client-assets/dummy.png';
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
15
packages/client/src/scripts/media-proxy.ts
Normal file
15
packages/client/src/scripts/media-proxy.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { query } from '@/scripts/url';
|
||||
import { url } from '@/config';
|
||||
|
||||
export function getProxiedImageUrl(imageUrl: string, type?: 'preview'): string {
|
||||
return `${url}/proxy/image.webp?${query({
|
||||
url: imageUrl,
|
||||
fallback: '1',
|
||||
...(type ? { [type]: '1' } : {}),
|
||||
})}`;
|
||||
}
|
||||
|
||||
export function getProxiedImageUrlNullable(imageUrl: string | null | undefined, type?: 'preview'): string | null {
|
||||
if (imageUrl == null) return null;
|
||||
return getProxiedImageUrl(imageUrl, type);
|
||||
}
|
Loading…
Reference in New Issue
Block a user