mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-02-25 16:06:26 +08:00
fix(menu): menu auto closed on mobile
This commit is contained in:
parent
4112fa532e
commit
71f79a5bbf
2 changed files with 34 additions and 20 deletions
|
@ -9,8 +9,6 @@
|
|||
:show-trigger="false"
|
||||
:native-scrollbar="false"
|
||||
:position="siderPosition"
|
||||
@collapse="isMenuCollapsed = true"
|
||||
@expand="isMenuCollapsed = false"
|
||||
>
|
||||
<slot name="sider" />
|
||||
</n-layout-sider>
|
||||
|
@ -36,24 +34,24 @@ const siderPosition = computed(() => isSmallScreen.value ? 'absolute' : 'static'
|
|||
|
||||
<style lang="less" scoped>
|
||||
.overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #00000080;
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #00000080;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.content {
|
||||
|
||||
// background-color: #f1f5f9;
|
||||
::v-deep(.n-layout-scroll-container) {
|
||||
padding: 26px;
|
||||
}
|
||||
// background-color: #f1f5f9;
|
||||
::v-deep(.n-layout-scroll-container) {
|
||||
padding: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
.n-layout {
|
||||
height: 100vh;
|
||||
height: 100vh;
|
||||
}
|
||||
</style>
|
|
@ -1,11 +1,27 @@
|
|||
import { useMediaQuery, useStorage } from '@vueuse/core';
|
||||
import { useMediaQuery, useStorage, whenever } from '@vueuse/core';
|
||||
import { defineStore } from 'pinia';
|
||||
import type { Ref } from 'vue';
|
||||
|
||||
export const useStyleStore = defineStore('style', {
|
||||
state: () => ({
|
||||
isDarkTheme: useStorage('isDarkTheme', true) as Ref<boolean>,
|
||||
isMenuCollapsed: useStorage('isMenuCollapsed', false) as Ref<boolean>,
|
||||
isSmallScreen: useMediaQuery('(max-width: 700px)'),
|
||||
}),
|
||||
state: () => {
|
||||
const isDarkTheme = useStorage('isDarkTheme', true) as Ref<boolean>;
|
||||
const isSmallScreen = useMediaQuery('(max-width: 700px)');
|
||||
const isMenuCollapsed = useStorage('isMenuCollapsed', !isSmallScreen.value) as Ref<boolean>;
|
||||
|
||||
whenever(
|
||||
() => !isSmallScreen.value,
|
||||
() => (isMenuCollapsed.value = false)
|
||||
);
|
||||
|
||||
whenever(
|
||||
() => isSmallScreen.value,
|
||||
() => (isMenuCollapsed.value = true)
|
||||
);
|
||||
|
||||
return {
|
||||
isDarkTheme,
|
||||
isMenuCollapsed,
|
||||
isSmallScreen,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue