
let filePath = ''

export const chooseFile = async (udid, index, type, wsActions) => {
    console.log('选择文件', window.electronAPI?.selectApkFile);
    if (type == 1) {
        if (window.electronAPI?.selectApkFile) {
            const path = await window.electronAPI.selectApkFile()
            if (path) {
                filePath = path
                console.log(filePath);
                wsActions.install(udid, index, filePath)
            } else {
                filePath = '用户取消了选择'
                console.log(filePath);

            }
        } else {
            filePath = '未检测到 Electron API，可能未正确注入 preload.js'
        }
    } else {
        if (window.electronAPI?.selectFile) {
            const path = await window.electronAPI.selectFile()
            if (path) {
                filePath = path
                console.log(filePath);
                wsActions.pushFile(udid, index, filePath)
            } else {
                filePath = '用户取消了选择'
                console.log(filePath);

            }
        } else {
            filePath = '未检测到 Electron API，可能未正确注入 preload.js'
        }
    }

}