mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-12-25 14:20:21 +08:00
feat(projects): 添加reload context
This commit is contained in:
36
src/context/app/useReloadContext.ts
Normal file
36
src/context/app/useReloadContext.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { ref, nextTick } from 'vue';
|
||||
import type { Ref } from 'vue';
|
||||
import { useContext } from '@/hooks';
|
||||
|
||||
interface ReloadContext {
|
||||
reload: Ref<boolean>;
|
||||
handleReload(): void;
|
||||
}
|
||||
const { useProvide, useInject: useReloadInject } = useContext<ReloadContext>();
|
||||
|
||||
/** 重载上下文 */
|
||||
export default function useReloadContext() {
|
||||
const reload = ref(true);
|
||||
function handleReload() {
|
||||
reload.value = false;
|
||||
nextTick(() => {
|
||||
nextTick(() => {
|
||||
reload.value = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
const context: ReloadContext = {
|
||||
reload,
|
||||
handleReload
|
||||
};
|
||||
|
||||
function useReloadProvide() {
|
||||
useProvide(context);
|
||||
}
|
||||
|
||||
return {
|
||||
context,
|
||||
useReloadProvide,
|
||||
useReloadInject
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user