2017-11-29 10:13:35 -05:00
|
|
|
import db from '../../datastore/index'
|
2018-06-04 08:13:17 -04:00
|
|
|
import { Notification } from 'electron'
|
2018-06-05 07:49:01 -04:00
|
|
|
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) => {
|
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()
|
2017-12-22 09:30:16 -05:00
|
|
|
if (checkUploader(uploadType)) {
|
2018-06-05 07:49:01 -04:00
|
|
|
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
|