mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-14 08:04:52 +01:00
Implement new GC API & rename to zipUtils
This commit is contained in:
@@ -2,7 +2,7 @@ import React from 'react'
|
||||
import Menu from './Menu'
|
||||
import Tr from '../../../utils/language'
|
||||
import DownloadHandler from '../../../utils/download'
|
||||
import { unzip } from '../../../utils/zip_utils'
|
||||
import { unzip } from '../../../utils/zipUtils'
|
||||
import BigButton from '../common/BigButton'
|
||||
import { dataDir } from '@tauri-apps/api/path'
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import React from 'react'
|
||||
import Tr from '../../../utils/language'
|
||||
|
||||
import './NewsSection.css'
|
||||
import {base64Decode} from '../../../utils/string'
|
||||
|
||||
interface IProps {
|
||||
selected?: string;
|
||||
@@ -55,6 +56,9 @@ export default class NewsSection extends React.Component<IProps, IState> {
|
||||
if (!obj.commits) {
|
||||
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))
|
||||
obj = commitData.gc_stable
|
||||
}
|
||||
|
||||
// Probably rate-limited
|
||||
|
||||
@@ -8,4 +8,8 @@ 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')
|
||||
}
|
||||
Reference in New Issue
Block a user