fix: 修复双列布局模式下,路由为hideInMenu时,空白右列

This commit is contained in:
Jin Mao
2025-07-28 15:50:21 +08:00
parent 5b75e5e917
commit cb3f96683f

View File

@@ -1,9 +1,11 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { SetupContext } from 'vue'; import type { SetupContext } from 'vue';
import type { RouteLocationNormalizedLoaded } from 'vue-router';
import type { MenuRecordRaw } from '@vben/types'; import type { MenuRecordRaw } from '@vben/types';
import { computed, useSlots, watch } from 'vue'; import { computed, onMounted, useSlots, watch } from 'vue';
import { useRoute } from 'vue-router';
import { useRefresh } from '@vben/hooks'; import { useRefresh } from '@vben/hooks';
import { $t, i18n } from '@vben/locales'; import { $t, i18n } from '@vben/locales';
@@ -153,6 +155,23 @@ function clickLogo() {
emit('clickLogo'); emit('clickLogo');
} }
function autoCollapseMenuByRouteMeta(route: RouteLocationNormalizedLoaded) {
// 只在双列模式下生效
if (
preferences.app.layout === 'sidebar-mixed-nav' &&
route.meta &&
route.meta.hideInMenu
) {
sidebarExtraVisible.value = false;
}
}
const route = useRoute();
onMounted(() => {
autoCollapseMenuByRouteMeta(route);
});
watch( watch(
() => preferences.app.layout, () => preferences.app.layout,
async (val) => { async (val) => {