wujingjing
2024-04-22 f106e4dffb8279cb90726e83e7edd631f4c77699
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<template>
    <div class="layout-logo" v-if="setShowLogo" @click="onThemeConfigChange">
        <img :src="logoSrc" class="layout-logo-medium-img" />
        <span>{{ themeConfig.globalTitle }}</span>
    </div>
    <div class="layout-logo-size" v-else @click="onThemeConfigChange">
        <img :src="logoSrc" class="layout-logo-size-img" />
    </div>
</template>
 
<script setup lang="ts" name="layoutLogo">
import { computed, onMounted, ref } from 'vue';
import { storeToRefs } from 'pinia';
import { useThemeConfig } from '/@/stores/themeConfig';
 
// 定义变量内容
const storesThemeConfig = useThemeConfig();
const { themeConfig } = storeToRefs(storesThemeConfig);
 
// 设置 logo 的显示。classic 经典布局默认显示 logo
const setShowLogo = computed(() => {
    let { isCollapse, layout } = themeConfig.value;
    return !isCollapse || layout === 'classic' || document.body.clientWidth < 1000;
});
// logo 点击实现菜单展开/收起
const onThemeConfigChange = () => {
    if (themeConfig.value.layout === 'transverse') return false;
    themeConfig.value.isCollapse = !themeConfig.value.isCollapse;
};
 
const logoSrc = window.globalConfig.SoftWareInfo.logoTopMenu;
</script>
 
<style scoped lang="scss">
.layout-logo {
    width: var(--yw-columns-menu-width);
    height: var(--yw-horizontal-menu-height);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: rgb(0 21 41 / 2%) 0px 1px 4px;
    color: var(--next-bg-topBarColor);
    font-size: 16px;
    cursor: pointer;
    animation: logoAnimation 0.3s ease-in-out;
    span {
        white-space: nowrap;
        display: inline-block;
    }
    &:hover {
        span {
            color: var(--color-primary-light-2);
        }
    }
    &-medium-img {
        width: 25px;
        margin-right: 15px;
    }
}
.layout-logo-size {
    width: 100%;
    height: 50px;
    display: flex;
    cursor: pointer;
    animation: logoAnimation 0.3s ease-in-out;
    &-img {
        width: 20px;
        margin: auto;
    }
    &:hover {
        img {
            animation: logoAnimation 0.3s ease-in-out;
        }
    }
}
</style>