mirror of
https://gitcode.com/flipped-aurora/gin-vue-admin.git
synced 2026-05-22 07:08:07 +00:00
* fix: 修改 layout 中相关 emit 和 重复声明的 theme ,采用最新的vue api * fix:修改 eslintrc 的配置文件,删除大多数无用配置 * fix: 修复 layout 切换手机样式模糊层的 bug * feature: 重构 layout , 添加暗黑模式 , 删除侧边栏颜色 * fix:细节调整,activeColor摘除。 * feature:右侧滚动模式调整 * feature:无用代码剔除 * fix: 修复暗黑模式相关细节 * fix: custome config layout * feature:样式细节调整 * fix: 增加前端样式配置文件 * feature:调整基础配置,增加表格边框 * feature:buttomInfo取消底色,a标签更改为活跃色 * feature:调整阴影颜色和配置同步 * feature:版本调整2.6.3==>2.6.4 --------- Co-authored-by: bypanghu <bypanghu@163.com>
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
// 本组件参考 arco-pro 的实现
|
|
// https://github.com/arco-design/arco-design-pro-vue/blob/main/arco-design-pro-vite/src/hooks/responsive.ts
|
|
|
|
import { onMounted, onBeforeMount, onBeforeUnmount } from 'vue';
|
|
import { useDebounceFn } from '@vueuse/core';
|
|
import { useAppStore } from '@/pinia';
|
|
import { addEventListen, removeEventListen } from '@/utils/event';
|
|
|
|
const WIDTH = 992;
|
|
|
|
function queryDevice() {
|
|
const rect = document.body.getBoundingClientRect();
|
|
return rect.width - 1 < WIDTH;
|
|
}
|
|
|
|
export default function useResponsive(immediate) {
|
|
const appStore = useAppStore();
|
|
function resizeHandler() {
|
|
if (!document.hidden) {
|
|
const isMobile = queryDevice();
|
|
appStore.toggleDevice(isMobile ? 'mobile' : 'desktop');
|
|
// appStore.toggleDevice(isMobile);
|
|
}
|
|
}
|
|
const debounceFn = useDebounceFn(resizeHandler, 100);
|
|
onMounted(() => {
|
|
if (immediate) debounceFn();
|
|
});
|
|
onBeforeMount(() => {
|
|
addEventListen(window, 'resize', debounceFn);
|
|
});
|
|
onBeforeUnmount(() => {
|
|
removeEventListen(window, 'resize', debounceFn);
|
|
});
|
|
}
|