🐛 Fix(custom): fix the issue of webcontents

This commit is contained in:
Kuingsmile
2026-02-02 09:24:37 +08:00
parent 3cafd5a351
commit cab9445032
4 changed files with 5 additions and 9 deletions

View File

@@ -74,7 +74,7 @@ class GuiApi implements IGuiApi {
this.windowId = await getWindowId() this.windowId = await getWindowId()
const webContents = this.getWebcontentsByWindowId(this.windowId) const webContents = this.getWebcontentsByWindowId(this.windowId)
const rawInput = cloneDeep(input) const rawInput = cloneDeep(input)
const res = await uploader.setWebContents(webContents!).uploadReturnCtx(input) const res = await uploader.setWebContents(webContents).uploadReturnCtx(input)
const imgs = res.ctx?.output ? res.ctx.output : false const imgs = res.ctx?.output ? res.ctx.output : false
const backImgs = res.backupCtx?.output ? res.backupCtx.output : false const backImgs = res.backupCtx?.output ? res.backupCtx.output : false
let result: ImgInfo[] = [] let result: ImgInfo[] = []

View File

@@ -56,13 +56,13 @@ const trayRoutes = [
await GalleryDB.getInstance().insert(img[0]) await GalleryDB.getInstance().insert(img[0])
trayWindow?.webContents.send('clipboardFiles', []) trayWindow?.webContents.send('clipboardFiles', [])
if (windowManager.has(IWindowList.SETTING_WINDOW)) { if (windowManager.has(IWindowList.SETTING_WINDOW)) {
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery') windowManager.get(IWindowList.SETTING_WINDOW)?.webContents.send('updateGallery')
} }
if (backupImgs && backupImgs.length > 0) { if (backupImgs && backupImgs.length > 0) {
await GalleryDB.getInstance().insert(backupImgs[0]) await GalleryDB.getInstance().insert(backupImgs[0])
trayWindow?.webContents.send('uploadFiles') trayWindow?.webContents.send('uploadFiles')
if (windowManager.has(IWindowList.SETTING_WINDOW)) { if (windowManager.has(IWindowList.SETTING_WINDOW)) {
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents?.send('updateGallery') windowManager.get(IWindowList.SETTING_WINDOW)?.webContents?.send('updateGallery')
} }
} }
} }

View File

@@ -71,7 +71,7 @@ class UploadTaskQueueManager {
maxRetryCount: 3, maxRetryCount: 3,
} }
private webContents: WebContents | null = null private webContents: WebContents | undefined = undefined
private persistPath = path.join(dataDir(), 'taskQueue.json') private persistPath = path.join(dataDir(), 'taskQueue.json')
private taskTimer: NodeJS.Timeout | null = null private taskTimer: NodeJS.Timeout | null = null
@@ -230,10 +230,6 @@ class UploadTaskQueueManager {
const win = windowManager.getAvailableWindow() const win = windowManager.getAvailableWindow()
const webContents = this.webContents || win?.webContents const webContents = this.webContents || win?.webContents
if (!webContents) {
throw new Error('No webContents available for upload')
}
const input = [task.filePath] const input = [task.filePath]
const rawInput = cloneDeep(input) const rawInput = cloneDeep(input)

View File

@@ -39,7 +39,7 @@
<!-- System Settings Tab --> <!-- System Settings Tab -->
<div <div
v-if="currentTab === 'system'" v-if="currentTab === 'system'"
class="border4 no-scrollbar flex h-full w-full flex-1 flex-col gap-6 overflow-auto p-4" class="no-scrollbar flex h-full w-full flex-1 flex-col gap-6 overflow-auto p-4"
> >
<SettingSection :title="t('pages.settings.system.languageAndAppearance')" :icon="Globe"> <SettingSection :title="t('pages.settings.system.languageAndAppearance')" :icon="Globe">
<SettingCard> <SettingCard>