mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-07 11:17:56 +08:00
b79878ab36
- Install ESLint 9 with TypeScript and React support - Install Prettier with custom configuration (no semicolons) - Add husky and lint-staged for pre-commit hooks - Configure lint-staged to auto-fix and format on commit - Relax ESLint rules to avoid large-scale code changes - Format all existing code with Prettier (no semicolons) Co-Authored-By: tinkle-community <tinklefund@gmail.com>
27 lines
661 B
TypeScript
27 lines
661 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
|
|
}
|