feat(projects): theme store完成

This commit is contained in:
Soybean
2022-01-08 20:49:21 +08:00
parent 10e4d81bd6
commit bf020a8258
56 changed files with 1205 additions and 164 deletions

View File

@ -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 };

View 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
};
}