Logo.vue
1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<template>
<div class="flex justify-items-center items-center cursor-pointer" @click="handleGoHome">
<img :src="logo" />
<div v-if="show" class="logo-title ml-2 text-xl hidden md:block font-logo ellipsis">{{
globSetting.title
}}</div>
</div>
</template>
<script lang="ts">
import { defineComponent, PropType, ref, watch } from 'vue';
// hooks
import { useSetting } from '/@/hooks/core/useSetting';
import { PageEnum } from '/@/enums/pageEnum';
import logo from '/@/assets/images/logo.png';
import { useTimeout } from '/@/hooks/core/useTimeout';
import { useGo } from '/@/hooks/web/usePage';
export default defineComponent({
name: 'Logo',
props: {
showTitle: {
type: Boolean as PropType<boolean>,
default: true,
},
},
setup(props) {
const { globSetting } = useSetting();
const go = useGo();
function handleGoHome() {
go(PageEnum.BASE_HOME);
}
const showRef = ref<boolean>(!!props.showTitle);
watch(
() => props.showTitle,
(show: boolean) => {
if (show) {
useTimeout(() => {
showRef.value = show;
}, 280);
} else {
showRef.value = show;
}
}
);
return {
handleGoHome,
globSetting,
show: showRef,
logo,
};
},
});
</script>