mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 23:24:35 +01:00
Auto RSA patching
Add fallback bg for when api is down
This commit is contained in:
BIN
src/resources/icons/FALLBACK_BG.jpg
Normal file
BIN
src/resources/icons/FALLBACK_BG.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 MiB |
@@ -8,6 +8,9 @@ import { convertFileSrc, invoke } from '@tauri-apps/api/tauri'
|
||||
import { Main } from './Main'
|
||||
import { Mods } from './Mods'
|
||||
|
||||
// From https://www.pixiv.net/en/artworks/93995273
|
||||
import FALLBACK_BG from '../resources/icons/FALLBACK_BG.jpg'
|
||||
|
||||
interface IState {
|
||||
page: string
|
||||
bgFile: string
|
||||
@@ -64,6 +67,18 @@ class App extends React.Component<Readonly<unknown>, IState> {
|
||||
this.forceUpdate
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// Check if api bg is accessible
|
||||
const isDefaultValid = await invoke('valid_url', {
|
||||
url: DEFAULT_BG,
|
||||
})
|
||||
|
||||
this.setState(
|
||||
{
|
||||
bgFile: isDefaultValid ? DEFAULT_BG : FALLBACK_BG,
|
||||
},
|
||||
this.forceUpdate
|
||||
)
|
||||
}
|
||||
|
||||
window.addEventListener('changePage', (e) => {
|
||||
|
||||
@@ -112,6 +112,10 @@ export class Main extends React.Component<IProps, IState> {
|
||||
await setConfigOption('cert_generated', true)
|
||||
}
|
||||
|
||||
// Ensure old configs are updated to use RSA
|
||||
const updatedConfig = await getConfigOption('patch_rsa')
|
||||
await setConfigOption('patch_rsa', updatedConfig)
|
||||
|
||||
// Period check to only show progress bar when downloading files
|
||||
setInterval(() => {
|
||||
this.setState({
|
||||
|
||||
Reference in New Issue
Block a user