mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-13 07:34:36 +01:00
validate url backgrounds
This commit is contained in:
@@ -35,6 +35,8 @@ interface IState {
|
||||
bgFile: string;
|
||||
}
|
||||
|
||||
const DEFAULT_BG = 'https://webstatic.hoyoverse.com/upload/event/2020/11/04/7fd661b5184e1734f91f628b6f89a31f_7367318474207189623.png'
|
||||
|
||||
const downloadHandler = new DownloadHandler()
|
||||
|
||||
class App extends React.Component<IProps, IState> {
|
||||
@@ -46,7 +48,7 @@ class App extends React.Component<IProps, IState> {
|
||||
miniDownloadsOpen: false,
|
||||
downloadsOpen: false,
|
||||
gameDownloadsOpen: false,
|
||||
bgFile: 'https://webstatic.hoyoverse.com/upload/event/2020/11/04/7fd661b5184e1734f91f628b6f89a31f_7367318474207189623.png',
|
||||
bgFile: DEFAULT_BG,
|
||||
}
|
||||
|
||||
listen('lang_error', (payload) => {
|
||||
@@ -100,8 +102,13 @@ class App extends React.Component<IProps, IState> {
|
||||
bgFile: convertFileSrc(custom_bg)
|
||||
}, this.forceUpdate)
|
||||
} else {
|
||||
// Check if URL returns a valid image.
|
||||
const isValid = await invoke('valid_url', {
|
||||
url: custom_bg
|
||||
})
|
||||
|
||||
this.setState({
|
||||
bgFile: custom_bg
|
||||
bgFile: isValid ? custom_bg : DEFAULT_BG
|
||||
}, this.forceUpdate)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user