feat: 集成菜单栏伸缩功能

This commit is contained in:
张传龙
2022-05-08 11:59:01 +08:00
parent f88820b727
commit f15e21b0a0
5 changed files with 51 additions and 16 deletions

View File

@@ -1,21 +1,36 @@
<template>
<header class="header">
<BreadCrumb />
<div class="h-left">
<n-icon size="20" style="cursor: pointer" @click="appStore.switchCollapsed">
<IconMenuExpand v-if="appStore.collapsed" />
<IconMenuCollapse v-else />
</n-icon>
<BreadCrumb ml-15 />
</div>
<HeaderAction />
</header>
</template>
<script setup>
import { useAppStore } from '@/store/modules/app'
import BreadCrumb from './BreadCrumb.vue'
import HeaderAction from './HeaderAction.vue'
import { IconMenuCollapse, IconMenuExpand } from '@/components/AppIcons'
const appStore = useAppStore()
</script>
<style lang="scss" scoped>
.header {
padding: 0 24px;
padding: 0 15px;
height: 100%;
display: flex;
justify-content: space-between;
align-items: center;
justify-content: space-between;
.h-left {
display: flex;
align-items: center;
}
}
</style>

View File

@@ -1,31 +1,33 @@
<template>
<div class="logo">
<router-link to="/" class="logo">
<n-icon size="36" color="#316c72">
<IconLogo />
</n-icon>
<router-link to="/">
<n-gradient-text type="primary">{{ title }}</n-gradient-text>
</router-link>
</div>
<n-gradient-text v-show="!appStore.collapsed" type="primary">{{ title }}</n-gradient-text>
</router-link>
</template>
<script setup>
import { IconLogo } from '@/components/AppIcons'
import { useAppStore } from '@/store/modules/app'
const title = import.meta.env.VITE_APP_TITLE
const appStore = useAppStore()
</script>
<style lang="scss" scoped>
.logo {
height: 64px;
padding: 15px;
display: flex;
align-items: center;
justify-content: center;
a {
margin-left: 5px;
.n-gradient-text {
font-size: 14px;
font-weight: bold;
}
.n-gradient-text {
margin-left: 15px;
font-size: 16px;
font-weight: bold;
max-width: 140px;
flex-shrink: 0;
white-space: normal;
}
}
</style>

View File

@@ -1,6 +1,13 @@
<template>
<n-layout has-sider style="height: 100%">
<n-layout-sider bordered :width="200" :collapsed-width="0" :native-scrollbar="false">
<n-layout-sider
bordered
collapse-mode="width"
:collapsed-width="64"
:width="220"
:native-scrollbar="false"
:collapsed="appStore.collapsed"
>
<SideBar />
</n-layout-sider>
<n-layout>
@@ -27,8 +34,10 @@ import SideBar from './components/sidebar/index.vue'
import AppMain from './components/AppMain.vue'
import AppTags from './components/tags/index.vue'
import { useThemeStore } from '@/store/modules/theme'
import { useAppStore } from '@/store/modules/app'
const useTheme = useThemeStore()
const appStore = useAppStore()
</script>
<style lang="scss" scoped>