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 }) =>
|
export const setSystemConfiguration = async (obj: Const & { system_deploy?: boolean }) =>
|
||||||
await useAxios.post<Const>(`/admin/get_settings`, { ...obj, system_deploy: true })
|
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 () =>
|
export const refreshSuperAdminSettings = async () =>
|
||||||
await useAxios.post<{
|
await useAxios.post<{
|
||||||
ok?: boolean
|
ok?: boolean
|
||||||
@@ -26,4 +26,5 @@ export const refreshSuperAdminSettings = async () =>
|
|||||||
count?: number
|
count?: number
|
||||||
items?: Record<string, string>
|
items?: Record<string, string>
|
||||||
source?: string
|
source?: string
|
||||||
|
meta?: { channel?: string; origin?: string; domain?: string }
|
||||||
}>(`/admin/settings/refresh-superadmin`)
|
}>(`/admin/settings/refresh-superadmin`)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
>
|
>
|
||||||
همگامسازی از سوپرادمین
|
همگامسازی از سوپرادمین
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button :loading="loading" @click="initConfig">
|
<a-button :loading="loading || refreshingSuperAdmin" @click="onRefreshClick">
|
||||||
بروزرسانی
|
بروزرسانی
|
||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -489,7 +489,7 @@ watch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
async function refreshFromSuperAdmin() {
|
async function refreshFromSuperAdmin() {
|
||||||
if (!isSystemMode.value || refreshingSuperAdmin.value) return
|
if (refreshingSuperAdmin.value) return
|
||||||
refreshingSuperAdmin.value = true
|
refreshingSuperAdmin.value = true
|
||||||
try {
|
try {
|
||||||
const res = await refreshSuperAdminSettings()
|
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() {
|
async function initConfig() {
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
|||||||
Reference in New Issue
Block a user