2025-01-25 02:44:29 +00:00

113 lines
2.4 KiB
Vue

<!--
* @Description:
* @Author: zenghua.wang
* @Date: 2023-06-20 14:29:45
* @LastEditors: zenghua.wang
* @LastEditTime: 2025-01-24 15:11:22
-->
<template>
<div class="layout-header-placeholder" :style="stylePlaceholder()"></div>
<div
class="layout-header"
:class="{
'fixed-header': themeConfig.fixedHeader,
collapse: themeConfig.fixedHeader && isCollapse,
'no-collapse': themeConfig.fixedHeader && !isCollapse,
}"
>
<div class="layout-header-inner">
<div class="layout-header-left">
<Hamburger />
<Breadcrumb />
</div>
<div class="layout-header-right">
<ScreenFull class="layout-header-tool" />
<Avatar class="layout-header-tool" />
</div>
</div>
<TagsView v-if="themeConfig.showTag" />
</div>
</template>
<script setup name="layout-header">
import { computed } from 'vue';
import { useSettingStore } from '@/store/modules/setting';
import { setPx } from '@/utils';
import Hamburger from '../Hamburger';
import Breadcrumb from '../Breadcrumb';
import ScreenFull from '../ScreenFull';
import Avatar from '../Avatar';
import TagsView from '../TagsView';
const SettingStore = useSettingStore();
// 主题配置
const themeConfig = computed(() => SettingStore.themeConfig);
const isCollapse = computed(() => !SettingStore.isCollapse);
const stylePlaceholder = () => {
return { height: themeConfig.value.showTag ? setPx(90) : setPx(50) };
};
</script>
<style lang="scss" scoped>
.layout-header {
width: 100%;
background: white;
transition: width 0.28s;
flex-shrink: 0;
box-sizing: border-box;
box-shadow: 0 1px 4px rgb(0 21 41 / 8%);
&.fixed-header {
position: fixed;
top: 0;
right: 0;
z-index: 9;
}
&.collapse {
width: calc(100% - 60px);
}
&.no-collapse {
width: calc(100% - 210px);
}
&-placeholder {
height: 50px;
}
&-inner {
@include flex-row();
align-items: center;
justify-content: space-between;
height: 50px;
width: 100%;
padding: 0 10px 0 0;
border-bottom: 1px solid #eee;
box-sizing: border-box;
}
&-left {
@include flex-row();
align-items: center;
height: 100%;
}
&-right {
@include flex-row();
align-items: center;
}
&-tool {
padding: 4px;
margin-right: 10px;
cursor: pointer;
:deep(.el-icon) {
font-size: 20px;
color: #333;
}
}
}
</style>