fix(admin): refresh SuperAdmin flags when clicking بروزرسانی
Reload live program-settings overlay before reloading the settings list so menus like special pricing update without relying on cached flags. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -18,7 +18,7 @@ export const getSystemConfiguration = async () =>
|
||||
export const setSystemConfiguration = async (obj: Const & { system_deploy?: boolean }) =>
|
||||
await useAxios.post<Const>(`/admin/get_settings`, { ...obj, system_deploy: true })
|
||||
|
||||
/** همگامسازی overlay تنظیمات can_edit=0 از سوپرادمین (پاک کردن کش last-good) */
|
||||
/** همگامسازی زندهٔ overlay تنظیمات can_edit=0 از سوپرادمین (بدون کش) */
|
||||
export const refreshSuperAdminSettings = async () =>
|
||||
await useAxios.post<{
|
||||
ok?: boolean
|
||||
@@ -26,4 +26,5 @@ export const refreshSuperAdminSettings = async () =>
|
||||
count?: number
|
||||
items?: Record<string, string>
|
||||
source?: string
|
||||
meta?: { channel?: string; origin?: string; domain?: string }
|
||||
}>(`/admin/settings/refresh-superadmin`)
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
>
|
||||
همگامسازی از سوپرادمین
|
||||
</a-button>
|
||||
<a-button :loading="loading" @click="initConfig">
|
||||
<a-button :loading="loading || refreshingSuperAdmin" @click="onRefreshClick">
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
</div>
|
||||
@@ -489,7 +489,7 @@ watch(
|
||||
)
|
||||
|
||||
async function refreshFromSuperAdmin() {
|
||||
if (!isSystemMode.value || refreshingSuperAdmin.value) return
|
||||
if (refreshingSuperAdmin.value) return
|
||||
refreshingSuperAdmin.value = true
|
||||
try {
|
||||
const res = await refreshSuperAdminSettings()
|
||||
@@ -505,6 +505,23 @@ async function refreshFromSuperAdmin() {
|
||||
}
|
||||
}
|
||||
|
||||
/** بروزرسانی: اول از سوپرادمین زنده بخوان، بعد لیست تنظیمات را دوباره بگیر */
|
||||
async function onRefreshClick() {
|
||||
if (refreshingSuperAdmin.value || loading.value) return
|
||||
refreshingSuperAdmin.value = true
|
||||
try {
|
||||
await refreshSuperAdminSettings()
|
||||
} catch (e: any) {
|
||||
console.error(e)
|
||||
const msg = e?.response?.data?.message || e?.message || 'همگامسازی از سوپرادمین ناموفق بود'
|
||||
message.error(Array.isArray(msg) ? msg.join('، ') : msg)
|
||||
} finally {
|
||||
refreshingSuperAdmin.value = false
|
||||
}
|
||||
await initConfig()
|
||||
refreshMenuAfterStoreChange()
|
||||
}
|
||||
|
||||
async function initConfig() {
|
||||
try {
|
||||
loading.value = true
|
||||
|
||||
Reference in New Issue
Block a user