mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-15 08:34:43 +01:00
use cultivation API and fallback to github api
This commit is contained in:
@@ -51,7 +51,11 @@ fn disconnect() {
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn run_program(path: String) {
|
fn run_program(path: String) {
|
||||||
// Open the program from the specified path.
|
// Open the program from the specified path.
|
||||||
match open::that(path) {
|
// match open::that(path) {
|
||||||
|
// Ok(_) => (),
|
||||||
|
// Err(e) => println!("Failed to open program: {}", e),
|
||||||
|
// };
|
||||||
|
match open::with(format!("/c \"{}\"", &path), "C:\\Windows\\System32\\cmd.exe") {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(e) => println!("Failed to open program: {}", e),
|
Err(e) => println!("Failed to open program: {}", e),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,8 +42,14 @@ export default class NewsSection extends React.Component<IProps, IState> {
|
|||||||
|
|
||||||
async showLatestCommits() {
|
async showLatestCommits() {
|
||||||
if (!this.state.commitList) {
|
if (!this.state.commitList) {
|
||||||
const commits: string = await invoke('req_get', { url: 'https://api.github.com/repos/Grasscutters/Grasscutter/commits' })
|
const commits: string = await invoke('req_get', { url: 'https://api.grasscutters.xyz/cultivation/query' })
|
||||||
const obj = JSON.parse(commits)
|
let obj = JSON.parse(commits)
|
||||||
|
|
||||||
|
// If it didn't work, use official API
|
||||||
|
if (!obj.commits) {
|
||||||
|
const commits: string = await invoke('req_get', { url: 'https://api.github.com/repos/Grasscutters/Grasscutter/commits' })
|
||||||
|
obj = JSON.parse(commits)
|
||||||
|
}
|
||||||
|
|
||||||
// Probably rate-limited
|
// Probably rate-limited
|
||||||
if (!Array.isArray(obj)) return
|
if (!Array.isArray(obj)) return
|
||||||
|
|||||||
Reference in New Issue
Block a user