export const download = ({ url, onProgress, onSuccess, onFail }) => { const task = uni.downloadFile({ url, success(res) { if (res.statusCode === 200) { onSuccess && onSuccess(res.tempFilePath); } }, fail() { onFail && onFail(); } }); task.onProgressUpdate(res => { onProgress && onProgress(res.progress); }); }; export const install = (filePath, restart = false, version='') => { plus.runtime.install(filePath, { force: true }, () => { console.log('install success...'); if (restart) { uni.setStorageSync('wgt_version', version); plus.runtime.restart(); } }, (e) => { console.error('install fail...', e); }); };