From e8225fbdee782bbabecda08d6d1a285e39c5ca3b Mon Sep 17 00:00:00 2001 From: MichelleChung <1242874891@qq.com> Date: 星期四, 02 二月 2023 16:15:52 +0800 Subject: [PATCH] !282 System 相关表请求响应参数优化 * update 更新 system 相关表接口 (sys_role) 新增 Bo | Vo 类, 更改请求以及响应参数 ; * update 更新 system 相关表接口 (sys_notice, sys_post) 新增 Bo | Vo 类, 更改请求以及响应参数 ; * update 更新 system 相关表接口 (sys_menu) 新增 Bo | Vo 类, 更改请求以及响应参数 ; * update 更新 system 相关表接口 (sys_dict_data, sys_dict_type) 新增 Bo | Vo 类, 更改请求以及响应参数 ; * update 更新 system 相关表接口 (sys_config, sys_dept) 新增 Bo | Vo 类, 更改请求以及响应参数 ; --- ruoyi-ui/src/layout/mixin/ResizeHandler.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-) diff --git a/ruoyi-ui/src/layout/mixin/ResizeHandler.js b/ruoyi-ui/src/layout/mixin/ResizeHandler.js new file mode 100644 index 0000000..e8d0df8 --- /dev/null +++ b/ruoyi-ui/src/layout/mixin/ResizeHandler.js @@ -0,0 +1,45 @@ +import store from '@/store' + +const { body } = document +const WIDTH = 992 // refer to Bootstrap's responsive design + +export default { + watch: { + $route(route) { + if (this.device === 'mobile' && this.sidebar.opened) { + store.dispatch('app/closeSideBar', { withoutAnimation: false }) + } + } + }, + beforeMount() { + window.addEventListener('resize', this.$_resizeHandler) + }, + beforeDestroy() { + window.removeEventListener('resize', this.$_resizeHandler) + }, + mounted() { + const isMobile = this.$_isMobile() + if (isMobile) { + store.dispatch('app/toggleDevice', 'mobile') + store.dispatch('app/closeSideBar', { withoutAnimation: true }) + } + }, + methods: { + // use $_ for mixins properties + // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential + $_isMobile() { + const rect = body.getBoundingClientRect() + return rect.width - 1 < WIDTH + }, + $_resizeHandler() { + if (!document.hidden) { + const isMobile = this.$_isMobile() + store.dispatch('app/toggleDevice', isMobile ? 'mobile' : 'desktop') + + if (isMobile) { + store.dispatch('app/closeSideBar', { withoutAnimation: true }) + } + } + } + } +} -- Gitblit v1.9.3