feat(settings): add SuperAdmin sync button on advanced settings

Lets deploy admins clear overlay cache and reload can_edit=0 switches like enable_automation without SSH.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-24 21:22:49 +03:30
co-authored by Cursor
parent 91ae4ed207
commit 71bf8dfc47
2 changed files with 43 additions and 2 deletions
+32 -1
View File
@@ -36,6 +36,14 @@
>
افزودن تنظیم
</a-button>
<a-button
v-if="isSystemMode"
class="settings-toolbar__action"
:loading="refreshingSuperAdmin"
@click="refreshFromSuperAdmin"
>
همگام‌سازی از سوپرادمین
</a-button>
<a-button class="settings-toolbar__action" :loading="loading" @click="initConfig">
بروزرسانی
</a-button>
@@ -197,7 +205,7 @@ import type { FormInstance } from 'ant-design-vue'
import { message } from 'ant-design-vue'
import type { Const } from '@/model/configuration'
import { loading } from '@/utils'
import { getEditableConfiguration, getSystemConfiguration, setConfiguration, setSystemConfiguration } from '@/api/configuration'
import { getEditableConfiguration, getSystemConfiguration, setConfiguration, setSystemConfiguration, refreshSuperAdminSettings } from '@/api/configuration'
import SettingValueField from './SettingValueField.vue'
import SettingCard from './SettingCard.vue'
import { refreshAppModeMenu } from '@/router'
@@ -236,6 +244,7 @@ function refreshMenuAfterStoreChange() {
const isSystemMode = computed(() => props.mode === 'system')
const pageTitle = computed(() => (isSystemMode.value ? 'تنظیمات پیشرفته' : 'تنظیمات'))
const refreshingSuperAdmin = ref(false)
const settingGroups = computed(() =>
isSystemMode.value ? SYSTEM_SETTING_GROUPS : EDITABLE_SETTING_GROUPS
)
@@ -479,6 +488,28 @@ watch(
}
)
async function refreshFromSuperAdmin() {
if (!isSystemMode.value || refreshingSuperAdmin.value) return
refreshingSuperAdmin.value = true
try {
const res = await refreshSuperAdminSettings()
const auto = res?.enable_automation
message.success(
auto != null && auto !== ''
? `همگام شد (${res?.count ?? 0} کلید) — اتوماسیون: ${isSwitchOn(auto) ? 'روشن' : 'خاموش'}`
: (res?.message || `همگام شد (${res?.count ?? 0} کلید)`)
)
await initConfig()
refreshMenuAfterStoreChange()
} 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
}
}
async function initConfig() {
try {
loading.value = true