Formatting

This commit is contained in:
Thoronium
2023-04-26 23:05:36 -06:00
parent b34f71a301
commit 4631a6d38d
7 changed files with 19 additions and 19 deletions

View File

@@ -38,7 +38,7 @@ class App extends React.Component<Readonly<unknown>, IState> {
}
// Get custom bg AFTER theme is loaded !! important !!
const custom_bg = await getConfigOption('customBackground')
const custom_bg = await getConfigOption('custom_background')
if (custom_bg) {
const isUrl = /^http(s)?:\/\//gm.test(custom_bg)

View File

@@ -111,7 +111,7 @@ export default class Options extends React.Component<IProps, IState> {
grasscutter_with_game: config.grasscutter_with_game || false,
language_options: languages,
current_language: config.language || 'en',
bg_url_or_path: config.customBackground || '',
bg_url_or_path: config.custom_background || '',
themes: (await getThemeList()).map((t) => t.name),
theme: config.theme || 'default',
encryption: encEnabled || false,
@@ -231,13 +231,13 @@ export default class Options extends React.Component<IProps, IState> {
async setCustomBackground(value: string) {
const isUrl = /^(?:http(s)?:\/\/)/gm.test(value)
if (!value) return await setConfigOption('customBackground', '')
if (!value) return await setConfigOption('custom_background', '')
if (!isUrl) {
const filename = value.replace(/\\/g, '/').split('/').pop()
const localBgPath = ((await dataDir()) as string).replace(/\\/g, '/')
await setConfigOption('customBackground', `${localBgPath}/cultivation/bg/${filename}`)
await setConfigOption('custom_background', `${localBgPath}/cultivation/bg/${filename}`)
// Copy the file over to the local directory
await invoke('copy_file', {
@@ -247,7 +247,7 @@ export default class Options extends React.Component<IProps, IState> {
window.location.reload()
} else {
await setConfigOption('customBackground', value)
await setConfigOption('custom_background', value)
window.location.reload()
}
}
@@ -541,7 +541,7 @@ export default class Options extends React.Component<IProps, IState> {
readonly={false}
clearable={true}
customClearBehaviour={async () => {
await setConfigOption('customBackground', '')
await setConfigOption('custom_background', '')
window.location.reload()
}}
/>

View File

@@ -15,7 +15,7 @@ let defaultConfig: Configuration
last_ip: 'localhost',
last_port: '443',
language: 'en',
customBackground: '',
custom_background: '',
cert_generated: false,
theme: 'default',
https_enabled: false,
@@ -43,7 +43,7 @@ export interface Configuration {
last_ip: string
last_port: string
language: string
customBackground: string
custom_background: string
cert_generated: boolean
theme: string
https_enabled: boolean

View File

@@ -112,8 +112,8 @@ export async function loadTheme(theme: ThemeList, document: Document) {
// Set custom background
if (theme.customBackgroundURL) {
// If the custom bg is already set don't overwrite
if (config.customBackground === '') {
config.customBackground = theme.customBackgroundURL
if (config.custom_background === '') {
config.custom_background = theme.customBackgroundURL
}
}
@@ -130,13 +130,13 @@ export async function loadTheme(theme: ThemeList, document: Document) {
// Set the background
// If the custom bg is already set don't overwrite
if (config.customBackground === '') {
config.customBackground = bgPath + imageName
if (config.custom_background === '') {
config.custom_background = bgPath + imageName
}
}
// Write config
await setConfigOption('customBackground', config.customBackground)
await setConfigOption('custom_background', config.custom_background)
return
}