mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-01-23 06:38:13 -05:00
Added: support for upload notice & auto rename before upload
This commit is contained in:
parent
0b5981a27d
commit
9e2834c0f9
@ -32,10 +32,16 @@ const createRenameWindow = () => {
|
||||
|
||||
const imgFromPath = async (imgPath) => {
|
||||
let results = []
|
||||
let rename = db.read().get('picBed.rename').value()
|
||||
const rename = db.read().get('picBed.rename').value()
|
||||
const autoRename = db.read().get('picBed.autoRename').value()
|
||||
await Promise.all(imgPath.map(async item => {
|
||||
let name
|
||||
let fileName = path.basename(item)
|
||||
let fileName
|
||||
if (autoRename) {
|
||||
fileName = fecha.format(new Date(), 'YYYYMMDDHHmmss') + path.extname(item)
|
||||
} else {
|
||||
fileName = path.basename(item)
|
||||
}
|
||||
if (rename) {
|
||||
const window = createRenameWindow()
|
||||
await waitForShow(window.webContents)
|
||||
@ -81,22 +87,28 @@ const imgFromClipboard = async (file) => {
|
||||
|
||||
const imgFromUploader = async (files) => {
|
||||
let results = []
|
||||
let rename = db.read().get('picBed.rename').value()
|
||||
const rename = db.read().get('picBed.rename').value()
|
||||
const autoRename = db.read().get('picBed.autoRename').value()
|
||||
await Promise.all(files.map(async item => {
|
||||
let name
|
||||
let fileName
|
||||
if (autoRename) {
|
||||
fileName = fecha.format(new Date(), 'YYYYMMDDHHmmss') + path.extname(item.name)
|
||||
} else {
|
||||
fileName = path.basename(item.path)
|
||||
}
|
||||
if (rename) {
|
||||
const window = createRenameWindow()
|
||||
await waitForShow(window.webContents)
|
||||
window.webContents.send('rename', item.name, window.webContents.id)
|
||||
window.webContents.send('rename', fileName, window.webContents.id)
|
||||
name = await waitForRename(window, window.webContents.id)
|
||||
}
|
||||
let buffer = await fs.readFile(item.path)
|
||||
let base64Image = Buffer.from(buffer, 'binary').toString('base64')
|
||||
let fileName = name || item.name
|
||||
let imgSize = sizeOf(item.path)
|
||||
results.push({
|
||||
base64Image,
|
||||
fileName,
|
||||
fileName: name || fileName,
|
||||
width: imgSize.width,
|
||||
height: imgSize.height,
|
||||
extname: path.extname(item.name)
|
||||
|
@ -4,6 +4,7 @@ import tcYunUpload from './tcYunUpload'
|
||||
import upYunUpload from './upYunUpload'
|
||||
import githubUpload from './githubUpload'
|
||||
import db from '../../datastore/index'
|
||||
import { Notification } from 'electron'
|
||||
|
||||
const checkUploader = (type) => {
|
||||
const currentUploader = db.read().get(`picBed.${type}`).value()
|
||||
@ -15,6 +16,11 @@ const checkUploader = (type) => {
|
||||
}
|
||||
|
||||
const uploader = (img, type, webContents) => {
|
||||
const notification = new Notification({
|
||||
title: '上传进度',
|
||||
body: '正在上传'
|
||||
})
|
||||
notification.show()
|
||||
const uploadType = db.read().get('picBed.current').value()
|
||||
if (checkUploader(uploadType)) {
|
||||
switch (uploadType) {
|
||||
|
@ -51,6 +51,16 @@
|
||||
@change="handleRename"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="时间戳重命名"
|
||||
>
|
||||
<el-switch
|
||||
v-model="form.autoRename"
|
||||
active-text="开"
|
||||
inactive-text="关"
|
||||
@change="handleAutoRename"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="选择显示的图床"
|
||||
>
|
||||
@ -143,7 +153,8 @@ export default {
|
||||
updateHelper: this.$db.get('picBed.showUpdateTip').value(),
|
||||
showPicBedList: [],
|
||||
autoStart: this.$db.get('picBed.autoStart').value() || false,
|
||||
rename: this.$db.get('picBed.rename').value() || false
|
||||
rename: this.$db.get('picBed.rename').value() || false,
|
||||
autoRename: this.$db.get('picBed.autoRename').value() || false
|
||||
},
|
||||
picBed: this.$picBed,
|
||||
keyBindingVisible: false,
|
||||
@ -217,6 +228,9 @@ export default {
|
||||
},
|
||||
handleRename (val) {
|
||||
this.$db.read().set('picBed.rename', val).write()
|
||||
},
|
||||
handleAutoRename (val) {
|
||||
this.$db.read().set('picBed.autoRename', val).write()
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
|
Loading…
Reference in New Issue
Block a user