🐛 Fix(custom): fix an issue task interval can't set to lower than 100s and secondary upoload not take effect

This commit is contained in:
Kuingsmile
2026-01-12 22:55:57 +08:00
parent 9b4e762a92
commit f32c3684bb
3 changed files with 23 additions and 7 deletions

View File

@@ -31,7 +31,9 @@ const trayRoutes = [
handler: async () => {
const trayWindow = windowManager.get(IWindowList.TRAY_WINDOW)!
// macOS use builtin clipboard is OK
const img = await uploader.setWebContents(trayWindow.webContents).uploadWithBuildInClipboard()
const res = await uploader.setWebContents(trayWindow.webContents).uploadWithBuildInClipboardReturnCtx()
const img = res[0] ? res[0] : false
const backupImgs = res[1] ? res[1] : false
if (img !== false) {
const pasteStyle = db.get(configPaths.settings.pasteStyle) || IPasteStyle.MARKDOWN
const [pasteText, shortUrl] = await pasteTemplate(pasteStyle, img[0], db.get(configPaths.settings.customLink))
@@ -55,6 +57,13 @@ const trayRoutes = [
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery')
}
if (backupImgs && backupImgs.length > 0) {
await GalleryDB.getInstance().insert(backupImgs[0])
trayWindow.webContents.send('uploadFiles')
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents?.send('updateGallery')
}
}
}
trayWindow.webContents.send('uploadFiles')
},

View File

@@ -237,8 +237,9 @@ class UploadTaskQueueManager {
const input = [task.filePath]
const rawInput = cloneDeep(input)
let imgs: ImgInfo[] | false = false
imgs = await uploader.setWebContents(webContents).upload(input)
const res = await uploader.setWebContents(webContents).uploadReturnCtx(input)
const imgs = res[0] ? res[0] : false
const backupImgs = res[1] ? res[1] : false
if (imgs !== false && imgs.length > 0) {
const pasteStyle = db.get(configPaths.settings.pasteStyle) || IPasteStyle.MARKDOWN
@@ -267,6 +268,13 @@ class UploadTaskQueueManager {
}
handleCopyUrl(pasteText)
if (backupImgs && backupImgs.length > 0) {
await GalleryDB.getInstance().insert(backupImgs[0])
windowManager.get(IWindowList.TRAY_WINDOW)?.webContents?.send('uploadFiles')
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents?.send('updateGallery')
}
}
return {
url: handleUrlEncodeWithSetting(inserted.imgUrl!),