fix(plugins): move plugin store toggle onto each khanegi tenant

Remove the global header switch and let SuperAdmin enable the store per project from the plugins list and tenant page.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-07 19:51:12 +03:30
co-authored by Cursor
parent 7eacb513cd
commit 8d0dfba60f
3 changed files with 122 additions and 37 deletions
-36
View File
@@ -9,9 +9,7 @@ import api from '@/api/http'
const auth = useAuthStore()
const router = useRouter()
const adminSmsEnabled = ref(true)
const pluginStoreEnabled = ref(false)
const smsToggleLoading = ref(false)
const storeToggleLoading = ref(false)
const canSettingsWrite = computed(() => auth.can('settings:write'))
function goHome() {
@@ -28,7 +26,6 @@ async function loadSmsToggle() {
try {
const { data } = await api.get('/settings/admin-sms')
adminSmsEnabled.value = data.adminSmsEnabled !== false
pluginStoreEnabled.value = data.pluginStoreEnabled === true
} catch {
// keep default on; non-blocking for layout
}
@@ -53,25 +50,6 @@ async function onSmsToggle(checked: boolean) {
}
}
async function onStoreToggle(checked: boolean) {
if (!canSettingsWrite.value) return
storeToggleLoading.value = true
const previous = pluginStoreEnabled.value
pluginStoreEnabled.value = checked
try {
const { data } = await api.patch('/settings/plugin-store', { enabled: checked })
pluginStoreEnabled.value = data.pluginStoreEnabled === true
message.success(
pluginStoreEnabled.value ? 'فروشگاه افزونه روشن شد' : 'فروشگاه افزونه خاموش شد',
)
} catch (e: any) {
pluginStoreEnabled.value = previous
message.error(e?.response?.data?.message || 'تغییر فروشگاه افزونه ناموفق')
} finally {
storeToggleLoading.value = false
}
}
onMounted(loadSmsToggle)
</script>
@@ -101,20 +79,6 @@ onMounted(loadSmsToggle)
@change="onSmsToggle"
/>
</div>
<div
v-if="canSettingsWrite"
class="sms-toggle"
:class="{ off: !pluginStoreEnabled }"
>
<span class="sms-toggle-label">فروشگاه افزونه</span>
<a-switch
:checked="pluginStoreEnabled"
:loading="storeToggleLoading"
checked-children="روشن"
un-checked-children="خاموش"
@change="onStoreToggle"
/>
</div>
<button type="button" class="icon-btn" title="داشبورد" @click="goHome">
<HomeOutlined />
</button>