mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-03-13 08:28:13 -04:00
Added: ctx for guiApi
This commit is contained in:
parent
86265ee5c5
commit
960e01f17f
@ -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 = ''
|
||||
|
@ -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 => {
|
||||
|
@ -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'
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user