PicList/src/main/utils/uploader.js

29 lines
688 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
const checkUploader = (type) => {
const currentUploader = db.read().get(`picBed.${type}`).value()
if (currentUploader) {
return true
} else {
return false
}
}
2017-11-29 10:13:35 -05:00
const uploader = (img, type, webContents) => {
const notification = new Notification({
title: '上传进度',
body: '正在上传'
})
notification.show()
2017-11-29 10:13:35 -05:00
const uploadType = db.read().get('picBed.current').value()
2017-12-22 09:30:16 -05:00
if (checkUploader(uploadType)) {
return picBeds[uploadType](img, type, webContents)
2017-12-22 09:30:16 -05:00
} else {
return false
2017-11-29 10:13:35 -05:00
}
}
export default uploader