refactor: remove unused files, bug fixes and name changes

This commit is contained in:
Hansen Wang
2023-04-24 02:09:39 +08:00
parent e1528823f7
commit 5d891c1f44
32 changed files with 352 additions and 417 deletions

15
src/hooks/useAsync.ts Normal file
View File

@@ -0,0 +1,15 @@
import { isReactive, isRef } from 'vue';
function setLoading(loading, val) {
if (loading != undefined && isRef(loading)) {
loading.value = val;
} else if (loading != undefined && isReactive(loading)) {
loading.loading = val;
}
}
export const useAsync = async (func: Promise<any>, loading: any): Promise<any> => {
setLoading(loading, true);
return await func.finally(() => setLoading(loading, false));
};