Files
TaskPool/web/src/utils/decompress.ts
T

20 lines
560 B
TypeScript
Raw Normal View History

2025-12-20 09:30:16 +08:00
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)
}
2025-12-22 17:42:19 +08:00
// Decompress zlib
const decompressed = pako.inflate(bytes, { to: 'string' })
2025-12-20 09:30:16 +08:00
return decompressed
} catch (e) {
console.error('Decompress error:', e)
return '[解压失败]'
}
}