mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-23 17:20:10 +08:00
Fixed: progress display when upload from clipboard
This commit is contained in:
@@ -317,24 +317,13 @@ const showWindow = (bounds) => {
|
||||
}
|
||||
|
||||
const uploadClipboardFiles = async () => {
|
||||
let img = clipboard.readImage()
|
||||
let uploadImg = null
|
||||
if (!img.isEmpty()) {
|
||||
// 从剪贴板来的图片默认转为png
|
||||
const imgUrl = 'data:image/png;base64,' + Buffer.from(img.toPNG(), 'binary').toString('base64')
|
||||
uploadImg = {
|
||||
width: img.getSize().width,
|
||||
height: img.getSize().height,
|
||||
imgUrl
|
||||
}
|
||||
}
|
||||
let win
|
||||
if (miniWindow.isVisible) {
|
||||
if (miniWindow.isVisible()) {
|
||||
win = miniWindow
|
||||
} else {
|
||||
win = settingWindow || window
|
||||
}
|
||||
img = await uploader(uploadImg, 'imgFromClipboard', win.webContents)
|
||||
let img = await uploader(undefined, 'imgFromClipboard', win.webContents)
|
||||
if (img !== false) {
|
||||
if (img.length > 0) {
|
||||
const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown'
|
||||
|
||||
@@ -63,26 +63,7 @@ const waitForRename = (window, id) => {
|
||||
const uploader = (img, type, webContents) => {
|
||||
const picgo = new PicGo(CONFIG_PATH)
|
||||
picgo.config.debug = true
|
||||
let input = []
|
||||
switch (type) {
|
||||
case 'imgFromClipboard':
|
||||
if (img !== null) {
|
||||
const today = dayjs().format('YYYYMMDDHHmmss') + '.png'
|
||||
input = [
|
||||
{
|
||||
base64Image: img.imgUrl.replace(/^data\S+,/, ''),
|
||||
fileName: today,
|
||||
width: img.width,
|
||||
height: img.height,
|
||||
extname: '.png'
|
||||
}
|
||||
]
|
||||
}
|
||||
break
|
||||
default:
|
||||
input = img
|
||||
break
|
||||
}
|
||||
let input = img
|
||||
|
||||
picgo.helper.beforeUploadPlugins.register('renameFn', {
|
||||
handle: async ctx => {
|
||||
|
||||
Reference in New Issue
Block a user