mirror of
https://github.com/vbenjs/gf-vben-admin.git
synced 2025-01-23 03:40:19 +08:00
fix: 菜单响应式隐藏时宽度计算错误 (#1945)
Co-authored-by: zeozhou <zeozhou@tencent.com>
This commit is contained in:
parent
4723f61b88
commit
821efa09da
@ -101,8 +101,12 @@ export function useMenuSetting() {
|
||||
});
|
||||
|
||||
const getMiniWidthNumber = computed(() => {
|
||||
const { collapsedShowTitle } = appStore.getMenuSetting;
|
||||
return collapsedShowTitle ? SIDE_BAR_SHOW_TIT_MINI_WIDTH : SIDE_BAR_MINI_WIDTH;
|
||||
const { collapsedShowTitle, siderHidden } = appStore.getMenuSetting;
|
||||
return siderHidden
|
||||
? 0
|
||||
: collapsedShowTitle
|
||||
? SIDE_BAR_SHOW_TIT_MINI_WIDTH
|
||||
: SIDE_BAR_MINI_WIDTH;
|
||||
});
|
||||
|
||||
const getCalcContentWidth = computed(() => {
|
||||
|
@ -1,26 +1,30 @@
|
||||
import type { Ref } from 'vue';
|
||||
|
||||
import { computed, unref, onMounted, nextTick, ref } from 'vue';
|
||||
import { computed, unref, onMounted, nextTick } from 'vue';
|
||||
|
||||
import { TriggerEnum } from '/@/enums/menuEnum';
|
||||
|
||||
import { useMenuSetting } from '/@/hooks/setting/useMenuSetting';
|
||||
import { useDebounceFn } from '@vueuse/core';
|
||||
import { useAppStore } from '/@/store/modules/app';
|
||||
|
||||
/**
|
||||
* Handle related operations of menu events
|
||||
*/
|
||||
export function useSiderEvent() {
|
||||
const brokenRef = ref(false);
|
||||
|
||||
const appStore = useAppStore();
|
||||
const { getMiniWidthNumber } = useMenuSetting();
|
||||
|
||||
const getCollapsedWidth = computed(() => {
|
||||
return unref(brokenRef) ? 0 : unref(getMiniWidthNumber);
|
||||
return unref(getMiniWidthNumber);
|
||||
});
|
||||
|
||||
function onBreakpointChange(broken: boolean) {
|
||||
brokenRef.value = broken;
|
||||
appStore.setProjectConfig({
|
||||
menuSetting: {
|
||||
siderHidden: broken,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return { getCollapsedWidth, onBreakpointChange };
|
||||
|
@ -83,6 +83,8 @@ const setting: ProjectConfig = {
|
||||
fixed: true,
|
||||
// Menu collapse
|
||||
collapsed: false,
|
||||
// When sider hide because of the responsive layout
|
||||
siderHidden: false,
|
||||
// Whether to display the menu name when folding the menu
|
||||
collapsedShowTitle: false,
|
||||
// Whether it can be dragged
|
||||
|
1
types/config.d.ts
vendored
1
types/config.d.ts
vendored
@ -16,6 +16,7 @@ export interface MenuSetting {
|
||||
bgColor: string;
|
||||
fixed: boolean;
|
||||
collapsed: boolean;
|
||||
siderHidden: boolean;
|
||||
canDrag: boolean;
|
||||
show: boolean;
|
||||
hidden: boolean;
|
||||
|
Loading…
Reference in New Issue
Block a user