fix(frontend): MkInstanceTickerの情報がリアクティブでない問題を修正

This commit is contained in:
kakkokari-gtyih 2024-12-13 13:28:14 +09:00
parent dac3b1f405
commit 1310c9e35d

View File

@ -4,16 +4,16 @@ SPDX-License-Identifier: AGPL-3.0-only
--> -->
<template> <template>
<div :class="$style.root" :style="bg"> <div :class="$style.root" :style="themeColorStyle">
<img v-if="faviconUrl" :class="$style.icon" :src="faviconUrl"/> <img v-if="faviconUrl" :class="$style.icon" :src="faviconUrl"/>
<div :class="$style.name">{{ instance.name }}</div> <div :class="$style.name">{{ instanceName }}</div>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed } from 'vue'; import { computed, type CSSProperties } from 'vue';
import { instanceName } from '@@/js/config.js'; import { instanceName as localInstanceName } from '@@/js/config.js';
import { instance as Instance } from '@/instance.js'; import { instance as localInstance } from '@/instance.js';
import { getProxiedImageUrlNullable } from '@/scripts/media-proxy.js'; import { getProxiedImageUrlNullable } from '@/scripts/media-proxy.js';
const props = defineProps<{ const props = defineProps<{
@ -25,18 +25,16 @@ const props = defineProps<{
}>(); }>();
// if no instance data is given, this is for the local instance // if no instance data is given, this is for the local instance
const instance = props.instance ?? { const instanceName = computed(() => props.instance?.name ?? localInstanceName);
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') ?? '/favicon.ico'); const faviconUrl = computed(() => getProxiedImageUrlNullable(props.instance?.faviconUrl ?? localInstance.iconUrl, 'preview') ?? '/favicon.ico');
const themeColor = instance.themeColor ?? '#777777'; const themeColorStyle = computed<CSSProperties>(() => {
const themeColor = props.instance?.themeColor ?? localInstance.themeColor ?? '#777777';
const bg = { return {
background: `linear-gradient(90deg, ${themeColor}, ${themeColor}00)`, background: `linear-gradient(90deg, ${themeColor}, ${themeColor}00)`,
}; };
});
</script> </script>
<style lang="scss" module> <style lang="scss" module>