Files
nofx/web/src/lib/config.ts
Icyoung 062184054d Dev remove admin mode (#723)
* feat: remove admin mode
* feat: bugfix
---------
Co-authored-by: icy <icyoung520@gmail.com>
2025-11-07 23:37:23 +08:00

26 lines
639 B
TypeScript

export interface SystemConfig {
beta_mode: boolean
}
let configPromise: Promise<SystemConfig> | null = null
let cachedConfig: SystemConfig | null = null
export function getSystemConfig(): Promise<SystemConfig> {
if (cachedConfig) {
return Promise.resolve(cachedConfig)
}
if (configPromise) {
return configPromise
}
configPromise = fetch('/api/config')
.then((res) => res.json())
.then((data: SystemConfig) => {
cachedConfig = data
return data
})
.finally(() => {
// Keep cachedConfig for reuse; allow re-fetch via explicit invalidation if added later
})
return configPromise
}