顶栏提供收起按钮,收起后侧栏宽度为 0,不再保留被挤压的图标条。 Co-authored-by: Cursor <cursoragent@cursor.com>
91 lines
2.5 KiB
Vue
Executable File
91 lines
2.5 KiB
Vue
Executable File
<!-- 布局容器 -->
|
||
<template>
|
||
<div v-if="isPortalLayout" class="app-layout app-layout-portal" :style="appLayoutStyle">
|
||
<div id="app-portal-header">
|
||
<ArtPortalHeader />
|
||
<div id="app-worktab">
|
||
<ArtWorkTab />
|
||
</div>
|
||
</div>
|
||
|
||
<div id="app-portal-body">
|
||
<main id="app-workspace">
|
||
<div id="app-content">
|
||
<ArtPageContent />
|
||
</div>
|
||
</main>
|
||
</div>
|
||
|
||
<div id="app-global">
|
||
<ArtGlobalComponent />
|
||
</div>
|
||
</div>
|
||
|
||
<div v-else class="app-layout" :style="appLayoutStyle">
|
||
<aside id="app-sidebar" :class="{ 'is-collapsed': !menuOpen }">
|
||
<ArtSidebarMenu />
|
||
</aside>
|
||
|
||
<main id="app-main">
|
||
<div id="app-header">
|
||
<!-- ArtHeaderBar 内已含 ArtWorkTab,勿再挂一份 -->
|
||
<ArtHeaderBar />
|
||
</div>
|
||
<div id="app-content">
|
||
<ArtPageContent />
|
||
</div>
|
||
</main>
|
||
|
||
<div id="app-global">
|
||
<ArtGlobalComponent />
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { computed, onMounted } from 'vue'
|
||
import { storeToRefs } from 'pinia'
|
||
import { MenuTypeEnum, MenuWidth } from '@/enums/appEnum'
|
||
import { useSettingStore } from '@/store/modules/setting'
|
||
|
||
defineOptions({ name: 'AppLayout' })
|
||
|
||
const settingStore = useSettingStore()
|
||
const { menuType, getMenuOpenWidth, menuOpen } = storeToRefs(settingStore)
|
||
|
||
const isPortalLayout = computed(() => menuType.value === MenuTypeEnum.PORTAL)
|
||
|
||
const appLayoutStyle = computed(() => ({
|
||
'--app-sidebar-open-width': getMenuOpenWidth.value,
|
||
'--app-sidebar-close-width': MenuWidth.CLOSE
|
||
}))
|
||
|
||
onMounted(() => {
|
||
const width = Number(settingStore.menuOpenWidth)
|
||
if (!Number.isFinite(width) || width < 260 || width === 220 || width === 270 || width === 290) {
|
||
settingStore.setMenuOpenWidth(260)
|
||
}
|
||
|
||
// 产品默认壳层:单列树形侧栏(只展示非叶子);不再使用独立一级竖向 Tab
|
||
if (menuType.value !== MenuTypeEnum.LEFT) {
|
||
settingStore.switchMenuLayouts(MenuTypeEnum.LEFT)
|
||
}
|
||
// 产品默认不展示多页签栏;顶栏左侧展示面包屑
|
||
settingStore.setWorkTab(false)
|
||
if (!settingStore.showCrumbs) {
|
||
settingStore.setCrumbs()
|
||
}
|
||
})
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
@use './style' as layout-base;
|
||
@use './style.portal' as layout-portal;
|
||
|
||
/* 内层保持展开宽度,收起时由外层裁切,避免菜单被挤成图标条 */
|
||
#app-sidebar :deep(.layout-sidebar) {
|
||
width: var(--app-sidebar-open-width, 260px);
|
||
min-width: var(--app-sidebar-open-width, 260px);
|
||
}
|
||
</style>
|