Files
TaskPool/web/src/utils/decompress.ts
T
2025-12-22 17:42:19 +08:00

20 lines
560 B
TypeScript

import pako from 'pako'
export function decompressFromBase64(compressed: string): string {
if (!compressed) return ''
try {
// Decode base64 to binary
const binaryString = atob(compressed)
const bytes = new Uint8Array(binaryString.length)
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i)
}
// Decompress zlib
const decompressed = pako.inflate(bytes, { to: 'string' })
return decompressed
} catch (e) {
console.error('Decompress error:', e)
return '[解压失败]'
}
}