parent
d06ed1b477
commit
2fda83c321
2 changed files with 21 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="hpaizdrt" :style="bg">
|
<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>
|
<span class="name">{{ instance.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { instanceName } from '@/config';
|
import { instanceName } from '@/config';
|
||||||
import { instance as Instance } from '@/instance';
|
import { instance as Instance } from '@/instance';
|
||||||
|
import { getProxiedImageUrlNullable } from '@/scripts/media-proxy';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
instance?: {
|
instance?: {
|
||||||
|
@ -29,6 +30,10 @@ const themeColor = instance.themeColor ?? '#777777';
|
||||||
const bg = {
|
const bg = {
|
||||||
background: `linear-gradient(90deg, ${themeColor}, ${themeColor}11)`,
|
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>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<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 a new issue