mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-13 15:44:35 +01:00
25 lines
574 B
TypeScript
25 lines
574 B
TypeScript
import { invoke } from '@tauri-apps/api'
|
|
import { listen } from '@tauri-apps/api/event'
|
|
|
|
interface UnzipPayload {
|
|
file: string
|
|
new_folder: string
|
|
}
|
|
|
|
export function unzip(file: string, dest: string, topLevelStrip?: boolean): Promise<UnzipPayload> {
|
|
return new Promise((resolve) => {
|
|
invoke('unzip', {
|
|
zipfile: file,
|
|
destpath: dest,
|
|
topLevelStrip,
|
|
})
|
|
|
|
listen('extract_end', ({ payload }) => {
|
|
// @ts-expect-error Payload is an object
|
|
if (payload?.file === file) {
|
|
resolve(payload as UnzipPayload)
|
|
}
|
|
})
|
|
})
|
|
}
|