mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-15 16:44:43 +01:00
write modinfo.json after installing mod
This commit is contained in:
@@ -1,16 +1,24 @@
|
||||
import { invoke } from '@tauri-apps/api'
|
||||
import { listen } from '@tauri-apps/api/event'
|
||||
|
||||
export function unzip(file: string, dest: string, topLevelStrip?: boolean, onFinish?: () => void) {
|
||||
invoke('unzip', {
|
||||
zipfile: file,
|
||||
destpath: dest,
|
||||
topLevelStrip,
|
||||
})
|
||||
interface UnzipPayload {
|
||||
file: string
|
||||
new_folder: string
|
||||
}
|
||||
|
||||
listen('extract_end', ({ payload }) => {
|
||||
if (payload === file && onFinish) {
|
||||
onFinish()
|
||||
}
|
||||
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)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user