diff --git a/src/main/utils/guiApi.js b/src/main/utils/guiApi.js index 1aeaf11..8a8a3c3 100644 --- a/src/main/utils/guiApi.js +++ b/src/main/utils/guiApi.js @@ -9,11 +9,13 @@ import Uploader from './uploader' import pasteTemplate from './pasteTemplate' const WEBCONTENTS = Symbol('WEBCONTENTS') const IPCMAIN = Symbol('IPCMAIN') +const PICGO = Symbol('PICGO') class GuiApi { - constructor (ipcMain, webcontents) { + constructor (ipcMain, webcontents, picgo) { this[WEBCONTENTS] = webcontents this[IPCMAIN] = ipcMain + this[PICGO] = picgo } /** @@ -56,7 +58,7 @@ class GuiApi { * @param {array} input */ async upload (input) { - const imgs = await new Uploader(input, this[WEBCONTENTS]).upload() + const imgs = await new Uploader(input, this[WEBCONTENTS], this[PICGO]).upload() if (imgs !== false) { const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown' let pasteText = '' diff --git a/src/main/utils/picgoCoreIPC.js b/src/main/utils/picgoCoreIPC.js index a47256f..55475fc 100644 --- a/src/main/utils/picgoCoreIPC.js +++ b/src/main/utils/picgoCoreIPC.js @@ -136,7 +136,7 @@ const handlePluginActions = (ipcMain, CONFIG_PATH) => { ipcMain.on('pluginActions', (event, name, label) => { const picgo = new PicGo(CONFIG_PATH) const plugin = picgo.pluginLoader.getPlugin(`picgo-plugin-${name}`) - const guiApi = new GuiApi(ipcMain, event.sender) + const guiApi = new GuiApi(ipcMain, event.sender, picgo) if (plugin.guiMenu && plugin.guiMenu.length > 0) { const menu = plugin.guiMenu(picgo) menu.forEach(item => { diff --git a/src/main/utils/uploader.js b/src/main/utils/uploader.js index e6224d5..9a8da57 100644 --- a/src/main/utils/uploader.js +++ b/src/main/utils/uploader.js @@ -75,14 +75,15 @@ const waitForRename = (window, id) => { } class Uploader { - constructor (img, webContents) { + constructor (img, webContents, picgo = undefined) { this.img = img this.webContents = webContents + this.picgo = picgo } upload () { const win = BrowserWindow.fromWebContents(this.webContents) - const picgo = new PicGo(CONFIG_PATH) + const picgo = this.picgo || new PicGo(CONFIG_PATH) picgo.config.debug = true // for picgo-core picgo.config.PICGO_ENV = 'GUI' diff --git a/src/renderer/pages/Plugin.vue b/src/renderer/pages/Plugin.vue index e8d741e..c381cc5 100644 --- a/src/renderer/pages/Plugin.vue +++ b/src/renderer/pages/Plugin.vue @@ -278,6 +278,9 @@ export default { // plugin custom menus if (plugin.guiMenu) { + menu.push({ + type: 'separator' + }) for (let i of plugin.guiMenu) { menu.push({ label: i.label,