mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-25 10:05:43 +00:00
b77c9be36f
* bump prettier/eslint-plugin * bump nuxt pwa * use typed imports * set vue version to fix layout errors * disable import
32 lines
704 B
TypeScript
32 lines
704 B
TypeScript
import type { WritableComputedRef } from "vue";
|
|
|
|
export function useMinLoader(ms = 500): WritableComputedRef<boolean> {
|
|
const loading = ref(false);
|
|
|
|
const locked = ref(false);
|
|
|
|
const minLoading = computed({
|
|
get: () => loading.value,
|
|
set: value => {
|
|
if (value) {
|
|
loading.value = true;
|
|
|
|
if (!locked.value) {
|
|
locked.value = true;
|
|
setTimeout(() => {
|
|
locked.value = false;
|
|
}, ms);
|
|
}
|
|
}
|
|
|
|
if (!value && !locked.value) {
|
|
loading.value = false;
|
|
} else if (!value && locked.value) {
|
|
setTimeout(() => {
|
|
loading.value = false;
|
|
}, ms);
|
|
}
|
|
},
|
|
});
|
|
return minLoading;
|
|
}
|