Fix issue with GC API implementation

This commit is contained in:
KingRainbow44
2022-05-22 23:42:07 -04:00
parent 8383fcfd1f
commit 5c57a2bde0
5 changed files with 12 additions and 7 deletions

View File

@@ -4,7 +4,6 @@ import React from 'react'
import Tr from '../../../utils/language'
import './NewsSection.css'
import {base64Decode} from '../../../utils/string'
interface IProps {
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' })
obj = JSON.parse(commits)
} 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
}

View File

@@ -8,8 +8,4 @@ export function byteToString(bytes: number) {
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)).toString(), 10)
if (i === 0) return `${bytes} ${sizes[i]}`
return `${(bytes / Math.pow(1024, i)).toFixed(2)} ${sizes[i]}`
}
export function base64Decode(str: string) {
return Buffer.from(str, 'base64').toString('utf8')
}