refactor(layout-sider): 重构侧边栏布局结构并调整折叠模式
1. 将侧边栏折叠模式从transform改为width 2. 简化DOM层级,移除多余的sider-wrapper容器 3. 调整用户区定位使其固定在侧边栏底部 4. 优化图标渲染参数和菜单样式封装
This commit is contained in:
parent
e0087b12a6
commit
4093c75241
|
|
@ -1,14 +1,13 @@
|
|||
<template>
|
||||
<n-layout-sider
|
||||
bordered
|
||||
collapse-mode="transform"
|
||||
collapse-mode="width"
|
||||
:collapsed-width="64"
|
||||
:width="240"
|
||||
:collapsed="layoutStore.siderCollapsed"
|
||||
:show-trigger="false"
|
||||
class="layout-sider"
|
||||
>
|
||||
<div class="sider-wrapper">
|
||||
<!-- Logo -->
|
||||
<div class="sider-logo" @click="router.push('/dashboard')">
|
||||
<div class="logo-icon">
|
||||
|
|
@ -29,7 +28,6 @@
|
|||
</div>
|
||||
|
||||
<!-- 菜单 -->
|
||||
<div class="sider-menu">
|
||||
<n-menu
|
||||
:value="activeMenuKey"
|
||||
:collapsed="layoutStore.siderCollapsed"
|
||||
|
|
@ -39,7 +37,6 @@
|
|||
:default-expanded-keys="['system']"
|
||||
@update:value="onMenuSelect"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 用户区 -->
|
||||
<transition name="fade-text">
|
||||
|
|
@ -58,7 +55,6 @@
|
|||
</n-dropdown>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</n-layout-sider>
|
||||
</template>
|
||||
|
||||
|
|
@ -93,7 +89,7 @@ const userInitial = computed(() => username.charAt(0).toUpperCase())
|
|||
|
||||
// ─── Icon helper ───
|
||||
function renderIcon(icon: Component) {
|
||||
return () => h(NIcon, { size: 18 }, { default: () => h(icon) })
|
||||
return () => h(NIcon, null, { default: () => h(icon) })
|
||||
}
|
||||
|
||||
function renderDropdownIcon(icon: Component) {
|
||||
|
|
@ -116,6 +112,7 @@ const menuOptions: MenuOption[] = [
|
|||
{ key: 'plugin', label: '插件管理', icon: renderIcon(ExtensionPuzzleOutline), disabled: true },
|
||||
{ key: 'settings', label: '系统设置', icon: renderIcon(SettingsOutline), disabled: true },
|
||||
]
|
||||
|
||||
const activeMenuKey = computed(() => route.path)
|
||||
|
||||
function onMenuSelect(key: string) {
|
||||
|
|
@ -146,13 +143,6 @@ function onUserAction(key: string) {
|
|||
--n-sider-border-color: var(--color-border, #E5E6EB);
|
||||
}
|
||||
|
||||
.sider-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.sider-logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
@ -179,27 +169,16 @@ function onUserAction(key: string) {
|
|||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sider-menu {
|
||||
flex: 1;
|
||||
overflow: visible;
|
||||
padding: 8px;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.sider-menu :deep(.n-menu) {
|
||||
--n-item-height: 40px;
|
||||
--n-border-radius: 6px;
|
||||
--n-font-size: 14px;
|
||||
--n-item-icon-size: 18px;
|
||||
}
|
||||
|
||||
.sider-user {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 14px;
|
||||
border-top: 1px solid var(--color-border, #E5E6EB);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.user-meta {
|
||||
|
|
|
|||
Loading…
Reference in New Issue