mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 23:24:35 +01:00
differ between URL and file custom bg
This commit is contained in:
@@ -84,18 +84,25 @@ export default class Options extends React.Component<IProps, IState> {
|
||||
}
|
||||
|
||||
async setCustomBackground(value: string) {
|
||||
const filename = value.replace(/\\/g, '/').split('/').pop()
|
||||
const localBgPath = (await dataDir() as string).replace(/\\/g, '/')
|
||||
const isUrl = /^(?:http(s)?:\/\/)/gm.test(value)
|
||||
|
||||
await setConfigOption('customBackground', `${localBgPath}/cultivation/bg/${filename}`)
|
||||
|
||||
// Copy the file over to the local directory
|
||||
await invoke('copy_file', {
|
||||
path: value.replace(/\\/g, '/'),
|
||||
newPath: `${localBgPath}cultivation/bg/`
|
||||
})
|
||||
|
||||
window.location.reload()
|
||||
if (!isUrl) {
|
||||
const filename = value.replace(/\\/g, '/').split('/').pop()
|
||||
const localBgPath = (await dataDir() as string).replace(/\\/g, '/')
|
||||
|
||||
await setConfigOption('customBackground', `${localBgPath}/cultivation/bg/${filename}`)
|
||||
|
||||
// Copy the file over to the local directory
|
||||
await invoke('copy_file', {
|
||||
path: value.replace(/\\/g, '/'),
|
||||
newPath: `${localBgPath}cultivation/bg/`
|
||||
})
|
||||
|
||||
window.location.reload()
|
||||
} else {
|
||||
await setConfigOption('customBackground', value)
|
||||
window.location.reload()
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user