From 8bfe9c51941c4ff9af0d2f393d306cfdef528a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=8C=E8=90=8C=E5=93=92=E8=B5=AB=E8=90=9D?= Date: Tue, 21 Mar 2023 22:01:59 +0800 Subject: [PATCH] :bug: Fix: fixed issue of plugin system being unable to use ISSUES CLOSED: #21 --- src/main/apis/app/system/index.ts | 1 - src/main/events/ipcList.ts | 13 ++++ src/main/events/remotes/menu.ts | 7 +- src/renderer/pages/Plugin.vue | 114 +++++++++++++++++++++++------- 4 files changed, 102 insertions(+), 33 deletions(-) diff --git a/src/main/apis/app/system/index.ts b/src/main/apis/app/system/index.ts index 7fe1119..3eac35c 100644 --- a/src/main/apis/app/system/index.ts +++ b/src/main/apis/app/system/index.ts @@ -21,7 +21,6 @@ import { T } from '~/main/i18n' import { isMacOSVersionGreaterThanOrEqualTo } from '~/main/utils/getMacOSVersion' import { buildPicBedListMenu } from '~/main/events/remotes/menu' let contextMenu: Menu | null -let menu: Menu | null let tray: Tray | null export function createMenu () { diff --git a/src/main/events/ipcList.ts b/src/main/events/ipcList.ts index 3b99350..2d9172e 100644 --- a/src/main/events/ipcList.ts +++ b/src/main/events/ipcList.ts @@ -39,6 +39,7 @@ import { handleCopyUrl } from '~/main/utils/common' import { buildMainPageMenu, buildMiniPageMenu, buildPluginPageMenu, buildPicBedListMenu } from './remotes/menu' import path from 'path' import { T } from '~/main/i18n' +import picgo from '../apis/core/picgo' const STORE_PATH = app.getPath('userData') @@ -74,6 +75,18 @@ export default { uploadClipboardFiles() }) + ipcMain.handle('getStorePath', () => { + return STORE_PATH + }) + + ipcMain.on('manualRegesterPlugin', (evt: IpcMainEvent, pluginName: string) => { + picgo.pluginLoader.registerPlugin(pluginName) + }) + + ipcMain.on('manualUnRegesterPlugin', (evt: IpcMainEvent, pluginName: string) => { + picgo.pluginLoader.unregisterPlugin(pluginName) + }) + ipcMain.on('uploadChoosedFiles', async (evt: IpcMainEvent, files: IFileWithPath[]) => { return uploadChoosedFiles(evt.sender, files) }) diff --git a/src/main/events/remotes/menu.ts b/src/main/events/remotes/menu.ts index 4e0457f..3ad2fd0 100644 --- a/src/main/events/remotes/menu.ts +++ b/src/main/events/remotes/menu.ts @@ -10,7 +10,6 @@ import { privacyManager } from '~/main/utils/privacyManager' import pkg from 'root/package.json' import GuiApi from 'apis/gui' import { PICGO_CONFIG_PLUGIN, PICGO_HANDLE_PLUGIN_DONE, PICGO_HANDLE_PLUGIN_ING, PICGO_TOGGLE_PLUGIN, SHOW_MAIN_PAGE_DONATION, SHOW_MAIN_PAGE_QRCODE } from '~/universal/events/constants' -import picgoCoreIPC from '~/main/events/picgoCoreIPC' import { PicGo as PicGoCore } from 'piclist' import { T } from '~/main/i18n' import { changeCurrentUploader } from '~/main/utils/handleUploaderConfig' @@ -222,15 +221,13 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => { label: T('UNINSTALL_PLUGIN'), click () { const window = windowManager.get(IWindowList.SETTING_WINDOW)! - window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName) - picgoCoreIPC.handlePluginUninstall(plugin.fullName) + window.webContents.send('uninstallPlugin', plugin.fullName) } }, { label: T('UPDATE_PLUGIN'), click () { const window = windowManager.get(IWindowList.SETTING_WINDOW)! - window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName) - picgoCoreIPC.handlePluginUpdate(plugin.fullName) + window.webContents.send('updatePlugin', plugin.fullName) } }] for (const i in plugin.config) { diff --git a/src/renderer/pages/Plugin.vue b/src/renderer/pages/Plugin.vue index f2674de..66eaf8e 100644 --- a/src/renderer/pages/Plugin.vue +++ b/src/renderer/pages/Plugin.vue @@ -13,17 +13,6 @@ - - - - -