feat: 集成菜单栏伸缩功能
This commit is contained in:
parent
f88820b727
commit
f15e21b0a0
@ -14,5 +14,7 @@ export { default as IconExpand } from '~icons/mdi/arrow-expand-horizontal'
|
|||||||
export { default as IconExpandLeft } from '~icons/mdi/arrow-expand-left'
|
export { default as IconExpandLeft } from '~icons/mdi/arrow-expand-left'
|
||||||
export { default as IconExpandRight } from '~icons/mdi/arrow-expand-right'
|
export { default as IconExpandRight } from '~icons/mdi/arrow-expand-right'
|
||||||
export { default as IconMenuTable } from '~icons/mdi/table'
|
export { default as IconMenuTable } from '~icons/mdi/table'
|
||||||
|
export { default as IconMenuCollapse } from '~icons/mdi/format-indent-decrease'
|
||||||
|
export { default as IconMenuExpand } from '~icons/mdi/format-indent-increase'
|
||||||
|
|
||||||
export { default as IconLogo } from './IconLogo.vue'
|
export { default as IconLogo } from './IconLogo.vue'
|
||||||
|
@ -1,21 +1,36 @@
|
|||||||
<template>
|
<template>
|
||||||
<header class="header">
|
<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 />
|
<HeaderAction />
|
||||||
</header>
|
</header>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { useAppStore } from '@/store/modules/app'
|
||||||
import BreadCrumb from './BreadCrumb.vue'
|
import BreadCrumb from './BreadCrumb.vue'
|
||||||
import HeaderAction from './HeaderAction.vue'
|
import HeaderAction from './HeaderAction.vue'
|
||||||
|
import { IconMenuCollapse, IconMenuExpand } from '@/components/AppIcons'
|
||||||
|
|
||||||
|
const appStore = useAppStore()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.header {
|
.header {
|
||||||
padding: 0 24px;
|
padding: 0 15px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
.h-left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,31 +1,33 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="logo">
|
<router-link to="/" class="logo">
|
||||||
<n-icon size="36" color="#316c72">
|
<n-icon size="36" color="#316c72">
|
||||||
<IconLogo />
|
<IconLogo />
|
||||||
</n-icon>
|
</n-icon>
|
||||||
<router-link to="/">
|
<n-gradient-text v-show="!appStore.collapsed" type="primary">{{ title }}</n-gradient-text>
|
||||||
<n-gradient-text type="primary">{{ title }}</n-gradient-text>
|
</router-link>
|
||||||
</router-link>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { IconLogo } from '@/components/AppIcons'
|
import { IconLogo } from '@/components/AppIcons'
|
||||||
|
import { useAppStore } from '@/store/modules/app'
|
||||||
const title = import.meta.env.VITE_APP_TITLE
|
const title = import.meta.env.VITE_APP_TITLE
|
||||||
|
|
||||||
|
const appStore = useAppStore()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.logo {
|
.logo {
|
||||||
height: 64px;
|
padding: 15px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
a {
|
.n-gradient-text {
|
||||||
margin-left: 5px;
|
margin-left: 15px;
|
||||||
.n-gradient-text {
|
font-size: 16px;
|
||||||
font-size: 14px;
|
font-weight: bold;
|
||||||
font-weight: bold;
|
max-width: 140px;
|
||||||
}
|
flex-shrink: 0;
|
||||||
|
white-space: normal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<n-layout has-sider style="height: 100%">
|
<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 />
|
<SideBar />
|
||||||
</n-layout-sider>
|
</n-layout-sider>
|
||||||
<n-layout>
|
<n-layout>
|
||||||
@ -27,8 +34,10 @@ import SideBar from './components/sidebar/index.vue'
|
|||||||
import AppMain from './components/AppMain.vue'
|
import AppMain from './components/AppMain.vue'
|
||||||
import AppTags from './components/tags/index.vue'
|
import AppTags from './components/tags/index.vue'
|
||||||
import { useThemeStore } from '@/store/modules/theme'
|
import { useThemeStore } from '@/store/modules/theme'
|
||||||
|
import { useAppStore } from '@/store/modules/app'
|
||||||
|
|
||||||
const useTheme = useThemeStore()
|
const useTheme = useThemeStore()
|
||||||
|
const appStore = useAppStore()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -5,6 +5,7 @@ export const useAppStore = defineStore('app', {
|
|||||||
state() {
|
state() {
|
||||||
return {
|
return {
|
||||||
reloadFlag: true,
|
reloadFlag: true,
|
||||||
|
collapsed: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@ -19,5 +20,11 @@ export const useAppStore = defineStore('app', {
|
|||||||
$loadingBar.finish()
|
$loadingBar.finish()
|
||||||
}, 100)
|
}, 100)
|
||||||
},
|
},
|
||||||
|
switchCollapsed() {
|
||||||
|
this.collapsed = !this.collapsed
|
||||||
|
},
|
||||||
|
setCollapsed(collapsed) {
|
||||||
|
this.collapsed = collapsed
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user