ff-admin/src/components/AppIcon.vue

39 lines
883 B
Vue

<template>
<img v-if="useFallback" ref="fallback" src="/icon.png" alt="LOGO" class="h-full w-auto" />
<img
v-else
ref="icon"
:src="url + '/api/public/icon.png'"
alt="LOGO"
class="h-full w-auto"
@error="useFallback = true"
/>
</template>
<script setup lang="ts">
import { url } from "@/serverCom";
import { useSettingStore } from "@/stores/admin/management/setting";
import { mapState } from "pinia";
import { defineComponent } from "vue";
</script>
<script lang="ts">
export default defineComponent({
watch: {
icon() {
(this.$refs.icon as HTMLImageElement).src = url + "/api/public/icon.png?" + new Date().getTime();
},
},
data() {
return {
useFallback: false,
};
},
computed: {
...mapState(useSettingStore, ["readSetting"]),
icon() {
return this.readSetting("club.icon");
},
},
});
</script>