2026-10-03 12:29:11 +03:30
|
|
|
<script setup lang="ts">
|
2026-10-03 17:45:08 +03:30
|
|
|
import { computed } from 'vue';
|
|
|
|
|
import { toFaDigits } from '@/lib/jalali';
|
|
|
|
|
|
|
|
|
|
const props = withDefaults(
|
2026-10-03 12:29:11 +03:30
|
|
|
defineProps<{
|
|
|
|
|
open: boolean;
|
|
|
|
|
message?: string;
|
|
|
|
|
/** وقتی true باشد روی مودال هم دیده میشود */
|
|
|
|
|
nest?: boolean;
|
2026-10-03 17:45:08 +03:30
|
|
|
/** درصد پیشرفت ۰ تا ۱۰۰؛ اگر null باشد نوار نشان داده نمیشود */
|
|
|
|
|
progress?: number | null;
|
2026-10-03 12:29:11 +03:30
|
|
|
}>(),
|
|
|
|
|
{
|
|
|
|
|
message: 'لطفاً صبر کنید…',
|
|
|
|
|
nest: false,
|
2026-10-03 17:45:08 +03:30
|
|
|
progress: null,
|
2026-10-03 12:29:11 +03:30
|
|
|
},
|
|
|
|
|
);
|
2026-10-03 17:45:08 +03:30
|
|
|
|
|
|
|
|
const showBar = computed(
|
|
|
|
|
() => props.progress != null && Number.isFinite(props.progress),
|
|
|
|
|
);
|
|
|
|
|
const pct = computed(() => {
|
|
|
|
|
if (!showBar.value) return 0;
|
|
|
|
|
return Math.max(0, Math.min(100, Math.round(props.progress!)));
|
|
|
|
|
});
|
|
|
|
|
const pctLabel = computed(() => toFaDigits(String(pct.value)));
|
2026-10-03 12:29:11 +03:30
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<Teleport to="body">
|
|
|
|
|
<div
|
|
|
|
|
v-if="open"
|
|
|
|
|
class="busy-overlay"
|
|
|
|
|
:class="{ nest }"
|
|
|
|
|
role="status"
|
|
|
|
|
aria-live="polite"
|
|
|
|
|
aria-busy="true"
|
2026-10-03 17:45:08 +03:30
|
|
|
:aria-valuenow="showBar ? pct : undefined"
|
|
|
|
|
aria-valuemin="0"
|
|
|
|
|
aria-valuemax="100"
|
2026-10-03 12:29:11 +03:30
|
|
|
>
|
|
|
|
|
<div class="card">
|
|
|
|
|
<span class="spinner" aria-hidden="true" />
|
|
|
|
|
<p>{{ message }}</p>
|
2026-10-03 17:45:08 +03:30
|
|
|
<div v-if="showBar" class="progress-wrap">
|
|
|
|
|
<div class="progress-track" aria-hidden="true">
|
|
|
|
|
<div class="progress-fill" :style="{ width: `${pct}%` }" />
|
|
|
|
|
</div>
|
|
|
|
|
<strong class="progress-pct">{{ pctLabel }}٪</strong>
|
|
|
|
|
</div>
|
2026-10-03 12:29:11 +03:30
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Teleport>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.busy-overlay {
|
|
|
|
|
position: fixed;
|
|
|
|
|
inset: 0;
|
|
|
|
|
z-index: 90;
|
|
|
|
|
display: grid;
|
|
|
|
|
place-items: center;
|
|
|
|
|
padding: 16px;
|
|
|
|
|
background: rgba(15, 23, 42, 0.4);
|
|
|
|
|
backdrop-filter: blur(2px);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.busy-overlay.nest {
|
|
|
|
|
z-index: 110;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.card {
|
|
|
|
|
display: grid;
|
|
|
|
|
justify-items: center;
|
|
|
|
|
gap: 0.85rem;
|
2026-10-03 17:45:08 +03:30
|
|
|
min-width: min(20rem, 100%);
|
|
|
|
|
max-width: 22rem;
|
2026-10-03 12:29:11 +03:30
|
|
|
padding: 1.35rem 1.5rem;
|
|
|
|
|
border-radius: 16px;
|
|
|
|
|
background: #fff;
|
|
|
|
|
box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
|
|
|
|
|
color: #0f172a;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.card p {
|
|
|
|
|
margin: 0;
|
|
|
|
|
font-size: 0.95rem;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
line-height: 1.6;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-03 17:45:08 +03:30
|
|
|
.progress-wrap {
|
|
|
|
|
display: grid;
|
|
|
|
|
gap: 0.45rem;
|
|
|
|
|
width: 100%;
|
|
|
|
|
justify-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.progress-track {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 8px;
|
|
|
|
|
border-radius: 999px;
|
|
|
|
|
background: #e2e8f0;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.progress-fill {
|
|
|
|
|
height: 100%;
|
|
|
|
|
border-radius: inherit;
|
|
|
|
|
background: linear-gradient(90deg, #0d9488, #14b8a6);
|
|
|
|
|
transition: width 0.25s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.progress-pct {
|
|
|
|
|
font-size: 1.15rem;
|
|
|
|
|
font-weight: 800;
|
|
|
|
|
font-variant-numeric: tabular-nums;
|
|
|
|
|
color: #0f766e;
|
|
|
|
|
letter-spacing: 0.02em;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-03 12:29:11 +03:30
|
|
|
.spinner {
|
|
|
|
|
width: 28px;
|
|
|
|
|
height: 28px;
|
|
|
|
|
border: 3px solid #ccfbf1;
|
|
|
|
|
border-top-color: #0d9488;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
animation: busy-spin 0.7s linear infinite;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@keyframes busy-spin {
|
|
|
|
|
to {
|
|
|
|
|
transform: rotate(360deg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|