| | |
| | | import { useThemeConfig } from '/@/stores/themeConfig'; |
| | | import { Local } from '/@/utils/storage'; |
| | | import mittBus from '/@/utils/mitt'; |
| | | import { PingLogin } from '/@/api/system'; |
| | | import { MOBILE_MIN_WIDTH } from '../constants'; |
| | | |
| | | // 引入组件 |
| | | const layouts: any = { |
| | |
| | | const onLayoutResize = () => { |
| | | if (!Local.get('oldLayout')) Local.set('oldLayout', themeConfig.value.layout); |
| | | const clientWidth = document.body.clientWidth; |
| | | if (clientWidth < 1000) { |
| | | if (clientWidth < MOBILE_MIN_WIDTH) { |
| | | themeConfig.value.isCollapse = false; |
| | | mittBus.emit('layoutMobileResize', { |
| | | layout: 'defaults', |
| | |
| | | }); |
| | | } |
| | | }; |
| | | const pingLogin = async () => { |
| | | // 5分钟 |
| | | const interval = 1000 * 60 * 5; |
| | | // const interval = 1000 *2; |
| | | |
| | | const timer = setInterval(async () => { |
| | | const res = await PingLogin({ |
| | | loading: false, |
| | | }); |
| | | if (!res?.is_login) { |
| | | clearInterval(timer); |
| | | } |
| | | }, interval); |
| | | return timer; |
| | | }; |
| | | // 页面加载前 |
| | | onBeforeMount(() => { |
| | | onLayoutResize(); |
| | | window.addEventListener('resize', onLayoutResize); |
| | | pingLogin(); |
| | | |
| | | }); |
| | | // 页面卸载时 |
| | | onUnmounted(() => { |