feat: Initial commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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 gzip
|
||||
const decompressed = pako.ungzip(bytes, { to: 'string' })
|
||||
return decompressed
|
||||
} catch (e) {
|
||||
console.error('Decompress error:', e)
|
||||
return '[解压失败]'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user