2026-01-24 17:45:54 +03:30
|
|
|
export function getConfigApp(key: string) {
|
2026-06-12 20:30:00 +03:30
|
|
|
const config = window.__APP_CONFIG__ ? window.__APP_CONFIG__.user : {}
|
2026-01-24 17:45:54 +03:30
|
|
|
|
|
|
|
|
if (config) {
|
|
|
|
|
return config[key]
|
|
|
|
|
}
|
|
|
|
|
return null
|
|
|
|
|
}
|
2026-06-11 22:29:28 +03:30
|
|
|
|
2026-06-12 20:30:00 +03:30
|
|
|
let storeModeFromSettings: boolean | null = null
|
|
|
|
|
|
|
|
|
|
function isSwitchOn(value: string | undefined | null): boolean {
|
|
|
|
|
const v = (value ?? '').trim().toLowerCase()
|
|
|
|
|
return v === 'true' || v === '1' || v === 'yes'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function setStoreModeFromSettings(value: boolean): void {
|
|
|
|
|
storeModeFromSettings = value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** is_store فقط از API تنظیمات (get_settings) خوانده میشود — نه از get_user */
|
|
|
|
|
export async function initStoreModeFromSettings(): Promise<boolean> {
|
|
|
|
|
if (storeModeFromSettings !== null) return storeModeFromSettings
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const { getConfiguration } = await import('@/api/configuration')
|
|
|
|
|
const rows = await getConfiguration()
|
|
|
|
|
const row = Array.isArray(rows) ? rows.find((item) => item.key === 'is_store') : null
|
|
|
|
|
storeModeFromSettings = row ? isSwitchOn(row.value) : false
|
|
|
|
|
} catch {
|
|
|
|
|
storeModeFromSettings = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return storeModeFromSettings
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-11 22:29:28 +03:30
|
|
|
export function isStoreApp(): boolean {
|
2026-06-12 20:30:00 +03:30
|
|
|
return storeModeFromSettings === true
|
2026-06-11 22:29:28 +03:30
|
|
|
}
|