new UI and handle cashing

This commit is contained in:
2026-06-16 19:47:28 +03:30
parent e174ae28c5
commit 6e5ea0319f
41 changed files with 2936 additions and 641 deletions
+37
View File
@@ -0,0 +1,37 @@
import type { AppConfig } from './types'
type RawAppConfig = AppConfig & {
user?: Record<string, any>
}
let appConfig: RawAppConfig | null = null
export function setAppConfig(config: RawAppConfig) {
appConfig = config || {}
window.__APP_CONFIG__ = appConfig
}
export function getRawAppConfig() {
return appConfig ?? window.__APP_CONFIG__ ?? null
}
export function getTenantConfig() {
const rawConfig = getRawAppConfig()
if (rawConfig?.user && typeof rawConfig.user === 'object') {
return rawConfig.user
}
if (rawConfig && Object.keys(rawConfig).length > 0) {
return rawConfig
}
return {}
}
export function getConfig<T = any>(key: string, fallback?: T): T {
const config = getTenantConfig()
const value = config?.[key]
return (value ?? fallback ?? null) as T
}