کار اولیه

This commit is contained in:
2026-11-04 16:40:55 +03:30
commit 1a41ff31f2
77 changed files with 4496 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
import { reactive, readonly } from "vue";
// یک state مشترک برای تمام کامپوننت‌ها
const confirmState = reactive({
isOpen: false,
title: "تأیید عملیات",
message: "آیا از انجام این عملیات اطمینان دارید؟",
confirmText: "تأیید",
cancelText: "انصراف",
resolve: null as ((value: boolean) => void) | null,
});
export const useConfirmState = () => readonly(confirmState);
export const useConfirm = () => {
const ucoShowConfirmModal = (
options: {
title?: string;
message?: string;
confirmText?: string;
cancelText?: string;
} = {}
): Promise<boolean> => {
confirmState.title = options.title || "تأیید عملیات";
confirmState.message = options.message || "آیا از انجام این عملیات اطمینان دارید؟";
confirmState.confirmText = options.confirmText || "تأیید";
confirmState.cancelText = options.cancelText || "انصراف";
confirmState.isOpen = true;
return new Promise((resolve) => {
confirmState.resolve = resolve;
});
};
return { ucoShowConfirmModal };
};
export const useConfirmActions = () => {
const ucoConfirm = () => {
confirmState.isOpen = false;
if (confirmState.resolve) confirmState.resolve(true);
confirmState.resolve = null;
};
const ucoCancelConfirmModal = () => {
confirmState.isOpen = false;
if (confirmState.resolve) confirmState.resolve(false);
confirmState.resolve = null;
};
return { ucoConfirm, ucoCancelConfirmModal };
};