Merge pull request #130 from xiaoxian521/perf/layout

perf: layout
This commit is contained in:
啝裳 2021-11-25 21:11:37 +08:00 committed by GitHub
commit d79e63f673
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,6 +105,9 @@ function toggle(device: string, bool: boolean) {
useAppStoreHook().toggleSideBar(bool, "resize");
}
//
let isAutoCloseSidebar = true;
//
emitter.on("resize", ({ detail }) => {
if (isMobile) return;
@ -117,11 +120,16 @@ emitter.on("resize", ({ detail }) => {
*/
if (width > 0 && width <= 760) {
toggle("mobile", false);
isAutoCloseSidebar = true;
} else if (width > 760 && width <= 990) {
toggle("desktop", false);
if (isAutoCloseSidebar) {
toggle("desktop", false);
isAutoCloseSidebar = false;
}
} else if (width > 990) {
if (!set.sidebar.isClickHamburger) {
toggle("desktop", true);
isAutoCloseSidebar = true;
}
}
});