From 707398b1d9084480868f05f7d9d8b3f0cdd25a14 Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 27 Nov 2022 08:57:11 +0900 Subject: [PATCH] enhance: Modify MkInstanceTicker (#9236) * fix and enhance MkNoteDetailed * change instanceticker * :art: * fix * :art: * fix * :art: * revert MkNoteDetailed --- .../src/components/MkInstanceTicker.vue | 38 ++++++++++--------- packages/client/src/scripts/media-proxy.ts | 7 ++-- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/packages/client/src/components/MkInstanceTicker.vue b/packages/client/src/components/MkInstanceTicker.vue index a5ff656f6d..d8228b2c0f 100644 --- a/packages/client/src/components/MkInstanceTicker.vue +++ b/packages/client/src/components/MkInstanceTicker.vue @@ -1,7 +1,7 @@ @@ -21,11 +21,12 @@ const props = defineProps<{ // if no instance data is given, this is for the local instance const instance = props.instance ?? { - faviconUrl: getProxiedImageUrlNullable(Instance.iconUrl) ?? getProxiedImageUrlNullable(Instance.faviconUrl) ?? '/favicon.ico', name: instanceName, themeColor: (document.querySelector('meta[name="theme-color-orig"]') as HTMLMetaElement).content, }; +const faviconUrl = $computed(() => props.instance ? getProxiedImageUrlNullable(props.instance.faviconUrl, 'preview') : getProxiedImageUrlNullable(Instance.iconUrl, 'preview') ?? getProxiedImageUrlNullable(Instance.faviconUrl, 'preview') ?? '/favicon.ico'); + const themeColor = instance.themeColor ?? '#777777'; const bg = { @@ -33,13 +34,15 @@ const bg = { }; - diff --git a/packages/client/src/scripts/media-proxy.ts b/packages/client/src/scripts/media-proxy.ts index 76e20786f4..506cb78291 100644 --- a/packages/client/src/scripts/media-proxy.ts +++ b/packages/client/src/scripts/media-proxy.ts @@ -1,13 +1,14 @@ import { query } from '@/scripts/url'; import { url } from '@/config'; -export function getProxiedImageUrl(imageUrl: string): string { +export function getProxiedImageUrl(imageUrl: string, type?: 'preview'): string { return `${url}/proxy/image.webp?${query({ url: imageUrl, + ...(type ? { [type]: "1" } : {}), })}`; } -export function getProxiedImageUrlNullable(imageUrl: string | null | undefined): string | null { +export function getProxiedImageUrlNullable(imageUrl: string | null | undefined, type?: 'preview'): string | null { if (imageUrl == null) return null; - return getProxiedImageUrl(imageUrl); + return getProxiedImageUrl(imageUrl, type); }