mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-02 18:41:01 +08:00
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
29 lines
673 B
TypeScript
29 lines
673 B
TypeScript
export interface SystemConfig {
|
|
admin_mode: boolean;
|
|
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;
|
|
}
|
|
|
|
|