提交详情
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
2025-09-25 23:05:09 +08:00
parent 25117b454d
commit d7bc25d086
8 changed files with 197 additions and 85 deletions

View File

@@ -1,6 +1,7 @@
import { getTime, intervalToDuration, parseISO, type Duration } from "date-fns"
import { User } from "./types"
import { USER_TYPE } from "./constants"
import { strFromU8, strToU8, unzlibSync, zlibSync } from "fflate"
function calculateACRate(acCount: number, totalCount: number): string {
if (totalCount === 0) return "0.00"
@@ -184,6 +185,20 @@ export function getCSRFToken(): string {
return match ? decodeURIComponent(match[1]) : ""
}
export function utoa(data: string): string {
const buffer = strToU8(data)
const zipped = zlibSync(buffer, { level: 9 })
const binary = strFromU8(zipped, true)
return btoa(binary)
}
export function atou(base64: string): string {
const binary = atob(base64)
const buffer = strToU8(binary, true)
const unzipped = unzlibSync(buffer)
return strFromU8(unzipped)
}
// function getChromeVersion() {
// var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)
// return raw ? parseInt(raw[2], 10) : 0