mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat(projects): theme store完成
This commit is contained in:
@ -3,5 +3,6 @@ import useBoolean from './useBoolean';
|
||||
import useLoading from './useLoading';
|
||||
import useLoadingEmpty from './useLoadingEmpty';
|
||||
import useReload from './useReload';
|
||||
import useModalVisible from './useModalVisible';
|
||||
|
||||
export { useContext, useBoolean, useLoading, useLoadingEmpty, useReload };
|
||||
export { useContext, useBoolean, useLoading, useLoadingEmpty, useReload, useModalVisible };
|
||||
|
34
src/hooks/common/useModalVisible.ts
Normal file
34
src/hooks/common/useModalVisible.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { watch, onUnmounted } from 'vue';
|
||||
import useBoolean from './useBoolean';
|
||||
|
||||
/**
|
||||
* 使用弹窗
|
||||
* @param hide - 关闭html滚动条
|
||||
*/
|
||||
export default function useModalVisible(hideScroll = true) {
|
||||
const { bool: visible, setTrue: openModal, setFalse: closeModal, toggle: toggleModal } = useBoolean();
|
||||
|
||||
const stopHandle = watch(visible, async newValue => {
|
||||
if (hideScroll) {
|
||||
const className = 'overflow-hidden';
|
||||
if (newValue) {
|
||||
document.body.classList.add(className);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
document.body.classList.remove(className);
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
stopHandle();
|
||||
});
|
||||
|
||||
return {
|
||||
visible,
|
||||
openModal,
|
||||
closeModal,
|
||||
toggleModal
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user