|
1
|
<template>
|
vben
authored
|
2
|
<div class="app-logo anticon" @click="handleGoHome" :style="wrapStyle">
|
|
3
|
<img :src="logo" />
|
vben
authored
|
4
|
<div v-if="show" class="logo-title ml-2 ellipsis">{{ globSetting.title }}</div>
|
|
5
6
7
|
</div>
</template>
<script lang="ts">
|
vben
authored
|
8
|
import { computed, defineComponent, PropType, ref, watch } from 'vue';
|
|
9
10
|
// hooks
import { useSetting } from '/@/hooks/core/useSetting';
|
vben
authored
|
11
12
|
import { useTimeout } from '/@/hooks/core/useTimeout';
import { useGo } from '/@/hooks/web/usePage';
|
|
13
14
|
import { PageEnum } from '/@/enums/pageEnum';
|
vben
authored
|
15
16
|
import { MenuTypeEnum } from '../enums/menuEnum';
|
|
17
|
import logo from '/@/assets/images/logo.png';
|
vben
authored
|
18
19
20
|
import { menuStore } from '../store/modules/menu';
import { appStore } from '../store/modules/app';
|
|
21
22
23
24
25
26
27
28
29
30
|
export default defineComponent({
name: 'Logo',
props: {
showTitle: {
type: Boolean as PropType<boolean>,
default: true,
},
},
setup(props) {
|
vben
authored
|
31
|
const showRef = ref<boolean>(!!props.showTitle);
|
|
32
33
|
const { globSetting } = useSetting();
const go = useGo();
|
vben
authored
|
34
|
|
|
35
36
37
|
function handleGoHome() {
go(PageEnum.BASE_HOME);
}
|
vben
authored
|
38
|
|
|
39
40
41
42
43
44
45
46
47
48
49
50
|
watch(
() => props.showTitle,
(show: boolean) => {
if (show) {
useTimeout(() => {
showRef.value = show;
}, 280);
} else {
showRef.value = show;
}
}
);
|
vben
authored
|
51
|
|
vben
authored
|
52
53
54
55
56
57
58
59
60
61
62
63
|
const wrapStyle = computed(() => {
const { getCollapsedState } = menuStore;
const {
menuSetting: { menuWidth, type },
} = appStore.getProjectConfig;
const miniWidth = { minWidth: `${menuWidth}px` };
if (type !== MenuTypeEnum.SIDEBAR) {
return miniWidth;
}
return getCollapsedState ? {} : miniWidth;
});
|
|
64
65
66
67
68
|
return {
handleGoHome,
globSetting,
show: showRef,
logo,
|
vben
authored
|
69
|
wrapStyle,
|
|
70
71
72
73
|
};
},
});
</script>
|
nebv
authored
|
74
75
76
77
78
79
|
<style lang="less" scoped>
@import (reference) '../design/index.less';
.app-logo {
display: flex;
align-items: center;
|
vben
authored
|
80
|
padding-left: 16px;
|
nebv
authored
|
81
|
cursor: pointer;
|
vben
authored
|
82
|
// justify-content: center;
|
nebv
authored
|
83
84
|
.logo-title {
|
vben
authored
|
85
|
font-size: 18px;
|
vben
authored
|
86
|
font-weight: 400;
|
vben
authored
|
87
88
|
opacity: 0;
transition: all 0.5s;
|
nebv
authored
|
89
|
.respond-to(medium,{
|
vben
authored
|
90
|
opacity: 1;
|
nebv
authored
|
91
92
93
94
|
});
}
}
</style>
|