mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-13 15:44:35 +01:00
Add debug mode as a config setting
This commit is contained in:
@@ -3,20 +3,27 @@ import ReactDOM from 'react-dom/client'
|
|||||||
|
|
||||||
import './index.css'
|
import './index.css'
|
||||||
import App from './ui/App'
|
import App from './ui/App'
|
||||||
// import Debug from './ui/Debug'
|
import Debug from './ui/Debug'
|
||||||
|
|
||||||
|
import { getConfigOption } from './utils/configuration'
|
||||||
|
|
||||||
const root = ReactDOM.createRoot(
|
const root = ReactDOM.createRoot(
|
||||||
document.getElementById('root') as HTMLElement
|
document.getElementById('root') as HTMLElement
|
||||||
)
|
)
|
||||||
|
|
||||||
|
let isDebug = false;
|
||||||
|
|
||||||
|
(async() => {
|
||||||
|
isDebug = await getConfigOption('debug_enabled')
|
||||||
|
})
|
||||||
|
|
||||||
root.render(
|
root.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<App />
|
{
|
||||||
|
isDebug ? <Debug /> : <App />
|
||||||
|
}
|
||||||
</React.StrictMode>
|
</React.StrictMode>
|
||||||
)
|
)
|
||||||
|
|
||||||
// If you want to start measuring performance in your app, pass a function
|
|
||||||
// to log results (for example: reportWebVitals(console.log))
|
|
||||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
||||||
import reportWebVitals from './utils/reportWebVitals'
|
import reportWebVitals from './utils/reportWebVitals'
|
||||||
reportWebVitals(console.log)
|
isDebug && reportWebVitals(console.log)
|
||||||
@@ -20,6 +20,7 @@ let defaultConfig: Configuration
|
|||||||
cert_generated: false,
|
cert_generated: false,
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
https_enabled: false,
|
https_enabled: false,
|
||||||
|
debug_enabled: false
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
@@ -39,8 +40,9 @@ export interface Configuration {
|
|||||||
language: string
|
language: string
|
||||||
customBackground: string
|
customBackground: string
|
||||||
cert_generated: boolean
|
cert_generated: boolean
|
||||||
theme: string;
|
theme: string
|
||||||
https_enabled: boolean
|
https_enabled: boolean
|
||||||
|
debug_enabled: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setConfigOption(key: string, value: any): Promise<void> {
|
export async function setConfigOption(key: string, value: any): Promise<void> {
|
||||||
@@ -52,8 +54,9 @@ export async function setConfigOption(key: string, value: any): Promise<void> {
|
|||||||
|
|
||||||
export async function getConfigOption(key: string): Promise<any> {
|
export async function getConfigOption(key: string): Promise<any> {
|
||||||
const config: any = await getConfig()
|
const config: any = await getConfig()
|
||||||
|
const defaults: any = defaultConfig
|
||||||
|
|
||||||
return config[key] || null
|
return config[key] || defaults[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getConfig() {
|
export async function getConfig() {
|
||||||
|
|||||||
Reference in New Issue
Block a user