smart-power-ui/src/layout/components/Sidebar/Logo.vue

140 lines
3.2 KiB
Vue

<template>
<div :class="{'collapse':collapse}" class="sidebar-logo-container" @click="toggleSideBar">
<transition name="sidebarLogoFade">
<div v-if="collapse" key="collapse" class="sidebar-logo-link">
<img v-if="logo" :src="logo" class="sidebar-logo">
<h1 class="sidebar-title">{{ attribute }} </h1>
</div>
<div v-else key="expand" class="sidebar-logo-link">
<img v-if="logo" :src="logo" class="sidebar-logo">
<h1 class="sidebar-title">{{ attribute }} </h1>
</div>
</transition>
</div>
</template>
<script>
// import logoImg from '@/assets/logo/logo.png'
import variables from '@/assets/styles/variables.scss'
// import defaultConfig from '@/settings.js'
export default {
name: 'SidebarLogo',
props: {
collapse: {
type: Boolean,
required: true
}
},
computed: {
variables() {
return variables;
},
sideTheme() {
return this.$store.state.settings.sideTheme
},
attribute() {
// return this.$store.getters.attributeInfo['logoTitle'] || this.title;
return process.env.VUE_APP_SYSTEM_NAME || this.title;
}
},
data() {
return {
title: '数字用电管理系统',
logo: ''
}
},
created() {
this.logo = '/images/' + process.env.VUE_APP_ICO_URL;
},
methods: {
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')
},
themeMenuBg() {
// switch (this.sideTheme) {
// case "theme-dark":
// return variables["menuBg"];
// case "theme-light":
// return variables["menuLightBg"];
// case "theme-N1":
// return variables["menuN1Bg"];
// case "theme-Green":
// return variables["menuGreenBg"];
// }
return variables[`menu${this.sideTheme.substring(6)}Bg`];
},
themeTextColor() {
// switch (this.sideTheme) {
// case "theme-dark":
// return variables["sidebarTitle"];
// case "theme-light":
// return variables['sidebarLightTitle'];
// case "theme-N1":
// return variables["sidebarN1Title"];
// case "theme-Green":
// return variables["sidebarGreenTitle"];
// }
return variables[`sidebar${this.sideTheme.substring(6)}Title`];
},
},
}
</script>
<style lang="scss" scoped>
@import "~@/assets/styles/variables.scss";
.sidebarLogoFade-enter-active {
transition: opacity 1.5s;
}
.sidebarLogoFade-enter,
.sidebarLogoFade-leave-to {
opacity: 0;
}
.sidebar-logo-container {
position: relative;
width: 100%;
height: 50px;
line-height: 50px;
//background: $menuGreenLogoBg;
text-align: center;
overflow: hidden;
cursor: pointer;
& .sidebar-logo-link {
height: 100%;
width: 100%;
& .sidebar-logo {
width: 32px;
height: 32px;
vertical-align: middle;
margin-right: 12px;
}
& .sidebar-title {
display: inline-block;
margin: 0;
//color: $menuGreenLogoColor;
font-weight: 600;
line-height: 50px;
font-size: 16px;
font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
vertical-align: middle;
}
}
&.collapse {
.sidebar-logo {
margin-right: 0px;
}
}
}
</style>
<style>
</style>