mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2026-02-06 02:06:29 +01:00
Fix issue with GC API implementation
This commit is contained in:
1
src-tauri/Cargo.lock
generated
1
src-tauri/Cargo.lock
generated
@@ -718,6 +718,7 @@ checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
|
|||||||
name = "cultivation"
|
name = "cultivation"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"base64",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"http",
|
"http",
|
||||||
"hudsucker",
|
"hudsucker",
|
||||||
|
|||||||
@@ -34,8 +34,9 @@ registry = "1.2.1"
|
|||||||
# Program opener.
|
# Program opener.
|
||||||
open = "2.1.2"
|
open = "2.1.2"
|
||||||
|
|
||||||
# Serialization library.
|
# Serialization.
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
base64 = "0.13.0"
|
||||||
|
|
||||||
# Dependencies for the HTTP(S) proxy.
|
# Dependencies for the HTTP(S) proxy.
|
||||||
http = "0.2"
|
http = "0.2"
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ fn main() {
|
|||||||
disconnect,
|
disconnect,
|
||||||
req_get,
|
req_get,
|
||||||
get_bg_file,
|
get_bg_file,
|
||||||
|
base64_decode,
|
||||||
system_helpers::run_program,
|
system_helpers::run_program,
|
||||||
system_helpers::run_jar,
|
system_helpers::run_jar,
|
||||||
system_helpers::open_in_browser,
|
system_helpers::open_in_browser,
|
||||||
@@ -172,3 +173,9 @@ async fn get_bg_file(bg_path: String) -> String {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn base64_decode(encoded: String) -> String {
|
||||||
|
let decoded = base64::decode(&encoded).unwrap();
|
||||||
|
return String::from_utf8(decoded).unwrap();
|
||||||
|
}
|
||||||
@@ -4,7 +4,6 @@ import React from 'react'
|
|||||||
import Tr from '../../../utils/language'
|
import Tr from '../../../utils/language'
|
||||||
|
|
||||||
import './NewsSection.css'
|
import './NewsSection.css'
|
||||||
import {base64Decode} from '../../../utils/string'
|
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
selected?: string;
|
selected?: string;
|
||||||
@@ -57,7 +56,8 @@ export default class NewsSection extends React.Component<IProps, IState> {
|
|||||||
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.github.com/repos/Grasscutters/Grasscutter/commits' })
|
||||||
obj = JSON.parse(commits)
|
obj = JSON.parse(commits)
|
||||||
} else {
|
} else {
|
||||||
const commitData = JSON.parse(base64Decode(obj.commits))
|
const decoded: string = await invoke('base64_decode', { encoded: obj.commits })
|
||||||
|
const commitData = JSON.parse(decoded)
|
||||||
obj = commitData.gc_stable
|
obj = commitData.gc_stable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,3 @@ export function byteToString(bytes: number) {
|
|||||||
if (i === 0) return `${bytes} ${sizes[i]}`
|
if (i === 0) return `${bytes} ${sizes[i]}`
|
||||||
return `${(bytes / Math.pow(1024, i)).toFixed(2)} ${sizes[i]}`
|
return `${(bytes / Math.pow(1024, i)).toFixed(2)} ${sizes[i]}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function base64Decode(str: string) {
|
|
||||||
return Buffer.from(str, 'base64').toString('utf8')
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user