mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-07 00:17:03 +08:00
Fixed: progress display when upload from clipboard
This commit is contained in:
+2
-13
@@ -317,24 +317,13 @@ const showWindow = (bounds) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const uploadClipboardFiles = async () => {
|
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
|
let win
|
||||||
if (miniWindow.isVisible) {
|
if (miniWindow.isVisible()) {
|
||||||
win = miniWindow
|
win = miniWindow
|
||||||
} else {
|
} else {
|
||||||
win = settingWindow || window
|
win = settingWindow || window
|
||||||
}
|
}
|
||||||
img = await uploader(uploadImg, 'imgFromClipboard', win.webContents)
|
let img = await uploader(undefined, 'imgFromClipboard', win.webContents)
|
||||||
if (img !== false) {
|
if (img !== false) {
|
||||||
if (img.length > 0) {
|
if (img.length > 0) {
|
||||||
const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown'
|
const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown'
|
||||||
|
|||||||
@@ -63,26 +63,7 @@ const waitForRename = (window, id) => {
|
|||||||
const uploader = (img, type, webContents) => {
|
const uploader = (img, type, webContents) => {
|
||||||
const picgo = new PicGo(CONFIG_PATH)
|
const picgo = new PicGo(CONFIG_PATH)
|
||||||
picgo.config.debug = true
|
picgo.config.debug = true
|
||||||
let input = []
|
let input = img
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
picgo.helper.beforeUploadPlugins.register('renameFn', {
|
picgo.helper.beforeUploadPlugins.register('renameFn', {
|
||||||
handle: async ctx => {
|
handle: async ctx => {
|
||||||
|
|||||||
Reference in New Issue
Block a user