mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
refactor(projects): 精简版+动态路由权限初步
This commit is contained in:
@ -2,5 +2,6 @@ import useContext from './useContext';
|
||||
import useBoolean from './useBoolean';
|
||||
import useLoading from './useLoading';
|
||||
import useLoadingEmpty from './useLoadingEmpty';
|
||||
import useReload from './useReload';
|
||||
|
||||
export { useContext, useBoolean, useLoading, useLoadingEmpty };
|
||||
export { useContext, useBoolean, useLoading, useLoadingEmpty, useReload };
|
||||
|
29
src/hooks/common/useReload.ts
Normal file
29
src/hooks/common/useReload.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { nextTick } from 'vue';
|
||||
import useBoolean from './useBoolean';
|
||||
|
||||
/** 重载 */
|
||||
export default function useReload() {
|
||||
// 重载的标志
|
||||
const { bool: reloadFlag, setTrue, setFalse } = useBoolean(true);
|
||||
|
||||
/**
|
||||
* 触发重载
|
||||
* @param duration - 延迟时间(ms)
|
||||
*/
|
||||
async function handleReload(duration = 0) {
|
||||
setFalse();
|
||||
await nextTick();
|
||||
if (duration) {
|
||||
setTimeout(() => {
|
||||
setTrue();
|
||||
}, duration);
|
||||
} else {
|
||||
setTrue();
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
reloadFlag,
|
||||
handleReload
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user