PicList/src/main/utils/uploader.js

36 lines
862 B
JavaScript
Raw Normal View History

2017-11-29 10:13:35 -05:00
import db from '../../datastore/index'
import { Notification } from 'electron'
import picBeds from '../../datastore/pic-bed-handler'
2017-12-22 09:30:16 -05:00
2018-07-10 22:52:02 -04:00
// const checkUploader = (type) => {
// const currentUploader = db.read().get(`picBed.${type}`).value()
// if (currentUploader) {
// return true
// } else {
// return false
// }
// }
2017-12-22 09:30:16 -05:00
2017-11-29 10:13:35 -05:00
const uploader = (img, type, webContents) => {
2018-06-05 08:03:53 -04:00
if (db.read().get('picBed.uploadNotification').value()) {
const notification = new Notification({
title: '上传进度',
body: '正在上传'
})
notification.show()
}
2017-11-29 10:13:35 -05:00
const uploadType = db.read().get('picBed.current').value()
2018-07-10 22:52:02 -04:00
// if (checkUploader(uploadType)) {
try {
return picBeds[uploadType](img, type, webContents)
2018-07-10 22:52:02 -04:00
} catch (e) {
console.log(e)
2017-12-22 09:30:16 -05:00
return false
2017-11-29 10:13:35 -05:00
}
2018-07-10 22:52:02 -04:00
// } else {
// return false
// }
2017-11-29 10:13:35 -05:00
}
export default uploader