idk some wip shit

This commit is contained in:
SpikeHD
2022-07-13 23:43:55 -07:00
parent bae193050f
commit aa10a908ad
4 changed files with 53 additions and 7 deletions

View File

@@ -49,7 +49,8 @@ fn main() {
downloader::stop_download,
lang::get_lang,
lang::get_languages,
web::valid_url
web::valid_url,
web::web_get
])
.run(tauri::generate_context!())
.expect("error while running tauri application");

View File

@@ -15,4 +15,10 @@ pub(crate) async fn valid_url(url: String) -> bool {
let response = client.get(url).header(USER_AGENT, "cultivation").send().await.unwrap();
response.status().as_str() == "200"
}
#[tauri::command]
pub async fn web_get(url: String) -> String {
// Send a GET request to the specified URL and send the response body back to the client.
query(&url).await
}

View File

@@ -13,12 +13,6 @@ import { invoke } from '@tauri-apps/api'
import { listen } from '@tauri-apps/api/event'
import HelpButton from '../common/HelpButton'
const STABLE_REPO_DOWNLOAD = 'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/stable.zip'
const DEV_REPO_DOWNLOAD = 'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/development.zip'
const STABLE_DOWNLOAD = 'https://nightly.link/Grasscutters/Grasscutter/workflows/build/stable/Grasscutter.zip'
const DEV_DOWNLOAD = 'https://nightly.link/Grasscutters/Grasscutter/workflows/build/development/Grasscutter.zip'
const RESOURCES_DOWNLOAD = 'https://github.com/Koko-boya/Grasscutter_Resources/archive/refs/heads/main.zip'
interface IProps {
closeFn: () => void;
downloadManager: DownloadHandler;

45
src/utils/resources.ts Normal file
View File

@@ -0,0 +1,45 @@
import { invoke } from '@tauri-apps/api'
import { getConfig } from './configuration'
const globals = {
'2.8.0': {
game: '2.8.0',
metadata: '2.8.0',
resources: 'https://gitlab.com/yukiz/GrasscutterResources/-/archive/2.8/GrasscutterResources-2.8.zip',
stableJar: '',
devJar: 'https://nightly.link/Grasscutters/Grasscutter/workflows/build/2.8/Grasscutter.zip',
stable: '',
dev: 'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/2.8.zip'
},
'2.7.0': {
game: '2.7.0',
metadata: null,
resources: 'https://github.com/Koko-boya/Grasscutter_Resources/archive/refs/heads/main.zip',
stableJar: 'https://nightly.link/Grasscutters/Grasscutter/workflows/build/stable/Grasscutter.zip',
devJar: 'https://nightly.link/Grasscutters/Grasscutter/workflows/build/development/Grasscutter.zip',
stable: 'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/stable.zip',
dev: 'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/development.zip'
},
'2.6.0': {
game: '2.6.0',
metadata: null,
resources: 'https://github.com/Koko-boya/Grasscutter_Resources/archive/0e99a59218a346c2d56c54953f99077882de4a6d.zip',
stableJar: 'https://github.com/Grasscutters/Grasscutter/releases/download/v1.1.0/grasscutter-1.1.0.jar',
stable: 'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/2.6.zip',
dev: ''
}
}
export async function cacheLauncherResources() {
const versionAPIUrl = 'https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/resource?channel_id=1&key=gcStgarh&launcher_id=10&sub_channel_id=0'
// Get versions from API
const versions = JSON.parse(await invoke('web_get', {
url: versionAPIUrl
}))
if (!versions || versions.retcode !== 0) {
console.log('Failed to get versions from API')
return false
}
}