2017-11-29 10:13:35 -05:00
|
|
|
import weiboUpload from './weiboUpload'
|
|
|
|
import qiniuUpload from './qiniuUpload'
|
2017-12-20 22:18:54 -05:00
|
|
|
import tcYunUpload from './tcYunUpload'
|
2017-12-22 09:30:16 -05:00
|
|
|
import upYunUpload from './upYunUpload'
|
2018-04-06 10:01:30 -04:00
|
|
|
import githubUpload from './githubUpload'
|
2018-06-04 09:30:36 -04:00
|
|
|
import smmsUpload from './smmsUpload'
|
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'
|
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-04 08:13:17 -04:00
|
|
|
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)) {
|
|
|
|
switch (uploadType) {
|
|
|
|
case 'weibo':
|
|
|
|
return weiboUpload(img, type, webContents)
|
|
|
|
case 'qiniu':
|
|
|
|
return qiniuUpload(img, type, webContents)
|
|
|
|
case 'tcyun':
|
|
|
|
return tcYunUpload(img, type, webContents)
|
|
|
|
case 'upyun':
|
|
|
|
return upYunUpload(img, type, webContents)
|
2018-04-06 10:01:30 -04:00
|
|
|
case 'github':
|
|
|
|
return githubUpload(img, type, webContents)
|
2018-06-04 09:30:36 -04:00
|
|
|
case 'smms':
|
|
|
|
return smmsUpload(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
|