feat: 完成移动端适配
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
export * from "./asr_store";
|
||||
export * from "./chat_store";
|
||||
export * from "./layout_store";
|
||||
44
web/src/stores/layout_store.ts
Normal file
44
web/src/stores/layout_store.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { matchMedia } from "@/utils";
|
||||
|
||||
export const useLayoutStore = defineStore("layout", () => {
|
||||
// 侧边栏状态
|
||||
const hiddenLeftSidebar = ref(false);
|
||||
// 简洁按钮
|
||||
const simpleMode = ref(false);
|
||||
|
||||
const handleResize = () => {
|
||||
matchMedia(
|
||||
"sm",
|
||||
() => {
|
||||
hiddenLeftSidebar.value = true;
|
||||
},
|
||||
() => {
|
||||
hiddenLeftSidebar.value = false;
|
||||
}
|
||||
);
|
||||
matchMedia(
|
||||
"536",
|
||||
() => {
|
||||
simpleMode.value = true;
|
||||
},
|
||||
() => {
|
||||
simpleMode.value = false;
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const toggleLeftSidebar = () => {
|
||||
hiddenLeftSidebar.value = !hiddenLeftSidebar.value;
|
||||
};
|
||||
|
||||
window.addEventListener("resize", handleResize);
|
||||
|
||||
onMounted(() => {
|
||||
handleResize();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener("resize", handleResize);
|
||||
});
|
||||
return { hiddenLeftSidebar, toggleLeftSidebar, simpleMode };
|
||||
});
|
||||
Reference in New Issue
Block a user