UNPKG

@fmdevui/fm-dev

Version:

Page level components developed based on Element Plus.

61 lines (58 loc) 2.15 kB
import { defineComponent, onBeforeMount, onUnmounted, createBlock, openBlock, resolveDynamicComponent, unref } from 'vue'; import { storeToRefs } from 'pinia'; import '../stores/index.mjs'; import '../utils/index.mjs'; import emitter from '../utils/emit/index.mjs'; import './main/defaults.vue.mjs'; import './main/classic.vue.mjs'; import './main/transverse.vue.mjs'; import './main/columns.vue.mjs'; import _sfc_main$1 from './main/columns.vue2.mjs'; import _sfc_main$2 from './main/transverse.vue2.mjs'; import _sfc_main$3 from './main/classic.vue2.mjs'; import _sfc_main$4 from './main/defaults.vue2.mjs'; import { useThemeConfig } from '../stores/themeConfig.mjs'; import { Local } from '../utils/storage/index.mjs'; var _sfc_main = /* @__PURE__ */ defineComponent({ __name: "layout", setup(__props) { const layouts = { defaults: _sfc_main$4, classic: _sfc_main$3, transverse: _sfc_main$2, columns: _sfc_main$1 }; const storesThemeConfig = useThemeConfig(); const { themeConfig } = storeToRefs(storesThemeConfig); let maxClientWidth = document.body.clientWidth; const onLayoutResize = () => { if (!Local.get("oldLayout")) Local.set("oldLayout", themeConfig.value.layout); const clientWidth = document.body.clientWidth; if (maxClientWidth > clientWidth) return; maxClientWidth = clientWidth; if (clientWidth < 1e3) { themeConfig.value.isCollapse = false; emitter.emit("layoutMobileResize", { layout: "defaults", clientWidth }); } else { emitter.emit("layoutMobileResize", { layout: Local.get("oldLayout") ? Local.get("oldLayout") : themeConfig.value.layout, clientWidth }); } }; onBeforeMount(() => { onLayoutResize(); window.addEventListener("resize", onLayoutResize); }); onUnmounted(() => { window.removeEventListener("resize", onLayoutResize); }); return (_ctx, _cache) => { return openBlock(), createBlock(resolveDynamicComponent(layouts[unref(themeConfig).layout])); }; } }); export { _sfc_main as default };