changes composables routes

This commit is contained in:
Mamalizz
2025-01-14 20:48:10 +03:30
parent 02796743cb
commit 68c81a0dec
4 changed files with 0 additions and 0 deletions
@@ -1,6 +0,0 @@
const useGetCustomers = () => {
const config = useRuntimeConfig();
return config.public.API_BASE_URL;
};
export default useGetCustomers;
@@ -1,32 +0,0 @@
import type { FastAverageColorResult } from "fast-average-color";
import { FastAverageColor } from "fast-average-color";
export const useImageColor = (img: string) => {
const fac = new FastAverageColor();
const colorObject = ref<FastAverageColorResult>();
const isPending = ref(false);
const extractImageColor = async () => {
isPending.value = true;
const imageEl = document.querySelector(img) as HTMLImageElement;
try {
const color = await fac.getColorAsync(imageEl);
isPending.value = false;
colorObject.value = color;
} catch (e) {
isPending.value = false;
}
};
onMounted(() => {
extractImageColor();
});
return {
colorObject,
extractImageColor,
isPending
};
};
@@ -1,42 +0,0 @@
type Props = {
duration: number;
callback?: () => void
}
export function useTimer({ duration, callback }: Props) {
const timeout = ref<NodeJS.Timeout | null>(null);
const interval = ref<NodeJS.Timeout | null>(null);
const isPending = ref(false);
const timer = ref(duration / 1000);
const reset = () => {
if (timeout.value) clearTimeout(timeout.value);
if (interval.value) clearInterval(interval.value);
isPending.value = false;
timer.value = duration / 1000;
};
const start = () => {
isPending.value = true;
timeout.value = setTimeout(() => {
if (interval.value) clearInterval(interval.value);
if (callback) callback();
isPending.value = false;
timer.value = duration / 1000;
}, duration);
interval.value = setInterval(() => {
timer.value -= 1;
}, 1000);
};
return {
isPending,
timer,
reset,
start
};
}
@@ -1,31 +0,0 @@
export type ToastOptions = {
description?: string;
duration?: number;
status?: "success" | "error" | "info" | "warning",
}
type Toast = {
id: number;
message: string;
options?: ToastOptions
}
const toasts = ref<Toast[]>([]);
export function useToast() {
const addToast = ({ message, options = {} }: Omit<Toast, "id">) => {
const id = Date.now();
toasts.value.push({ id, message, options });
};
const destroyToast = (id: number) => {
toasts.value = toasts.value.filter(toast => toast.id !== id);
};
return {
toasts,
addToast,
destroyToast
};
}