<template>
	<div class="layout-logo" v-if="setShowLogo" @click="onThemeConfigChange">
		<!-- <img src="./favicon.svg" class="layout-logo-medium-img" /> -->
		<span style="width:180px;">{{ $t('message.layout.title') }}</span>
	</div>
</template>

<script lang="ts">
import { computed, getCurrentInstance } from 'vue';
import { useStore } from '/@/store/index';
export default {
	name: 'layoutLogo',
	setup() {
		const { proxy } = getCurrentInstance() as any;
		const store = useStore();
		// 获取布局配置信息
		const getThemeConfig = computed(() => {
			return store.state.themeConfig.themeConfig;
		});
		// 设置 logo 的显示。classic 经典布局默认显示 logo
		const setShowLogo = computed(() => {
			let { isCollapse, layout } = store.state.themeConfig.themeConfig;
			return !isCollapse || layout === 'classic' || document.body.clientWidth < 1000;
		});
		// logo 点击实现菜单展开/收起
		const onThemeConfigChange = () => {
			if (store.state.themeConfig.themeConfig.layout === 'transverse') return false;
			proxy.mittBus.emit('onMenuClick');
			store.state.themeConfig.themeConfig.isCollapse = !store.state.themeConfig.themeConfig.isCollapse;
		};
		return {
			setShowLogo,
			getThemeConfig,
			onThemeConfigChange,
		};
	},
};
</script>

<style scoped lang="scss">
.layout-logo {
	width: 180px;
	padding: auto;
	height: 50px;
	display: flex;
	align-items: center;
	// justify-content: center;
	// background: red;
	padding-left: 12px;
	letter-spacing: 1px;
	box-shadow: rgb(0 21 41 / 2%) 0px 1px 4px;
	color: var(--color-primary);
	font-size: 20px;
	font-weight: 500;
	border-bottom: 1px solid #f1f2f3;
	// line-height: 150px;
	// color: #333333;
	cursor: pointer;
	color: #333333;
	animation: logoAnimation 0.3s ease-in-out;
	span {
		white-space: nowrap; /* 防止换行 */
   		overflow: hidden; /* 控制元素大小并隐藏超出部分 */
   		text-overflow: ellipsis; /* 显示省略号 */
	}
	&:hover {
		span {
			color: var(--color-primary-light-2);
		}
	}
	&-medium-img {
		width: 40px;
		margin-right: 5px;
		
	}
}
.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>
