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'
|
import pasteTemplate from './pasteTemplate'
|
||||||
const WEBCONTENTS = Symbol('WEBCONTENTS')
|
const WEBCONTENTS = Symbol('WEBCONTENTS')
|
||||||
const IPCMAIN = Symbol('IPCMAIN')
|
const IPCMAIN = Symbol('IPCMAIN')
|
||||||
|
const PICGO = Symbol('PICGO')
|
||||||
|
|
||||||
class GuiApi {
|
class GuiApi {
|
||||||
constructor (ipcMain, webcontents) {
|
constructor (ipcMain, webcontents, picgo) {
|
||||||
this[WEBCONTENTS] = webcontents
|
this[WEBCONTENTS] = webcontents
|
||||||
this[IPCMAIN] = ipcMain
|
this[IPCMAIN] = ipcMain
|
||||||
|
this[PICGO] = picgo
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,7 +58,7 @@ class GuiApi {
|
|||||||
* @param {array} input
|
* @param {array} input
|
||||||
*/
|
*/
|
||||||
async upload (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) {
|
if (imgs !== false) {
|
||||||
const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown'
|
const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown'
|
||||||
let pasteText = ''
|
let pasteText = ''
|
||||||
|
@ -136,7 +136,7 @@ const handlePluginActions = (ipcMain, CONFIG_PATH) => {
|
|||||||
ipcMain.on('pluginActions', (event, name, label) => {
|
ipcMain.on('pluginActions', (event, name, label) => {
|
||||||
const picgo = new PicGo(CONFIG_PATH)
|
const picgo = new PicGo(CONFIG_PATH)
|
||||||
const plugin = picgo.pluginLoader.getPlugin(`picgo-plugin-${name}`)
|
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) {
|
if (plugin.guiMenu && plugin.guiMenu.length > 0) {
|
||||||
const menu = plugin.guiMenu(picgo)
|
const menu = plugin.guiMenu(picgo)
|
||||||
menu.forEach(item => {
|
menu.forEach(item => {
|
||||||
|
@ -75,14 +75,15 @@ const waitForRename = (window, id) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Uploader {
|
class Uploader {
|
||||||
constructor (img, webContents) {
|
constructor (img, webContents, picgo = undefined) {
|
||||||
this.img = img
|
this.img = img
|
||||||
this.webContents = webContents
|
this.webContents = webContents
|
||||||
|
this.picgo = picgo
|
||||||
}
|
}
|
||||||
|
|
||||||
upload () {
|
upload () {
|
||||||
const win = BrowserWindow.fromWebContents(this.webContents)
|
const win = BrowserWindow.fromWebContents(this.webContents)
|
||||||
const picgo = new PicGo(CONFIG_PATH)
|
const picgo = this.picgo || new PicGo(CONFIG_PATH)
|
||||||
picgo.config.debug = true
|
picgo.config.debug = true
|
||||||
// for picgo-core
|
// for picgo-core
|
||||||
picgo.config.PICGO_ENV = 'GUI'
|
picgo.config.PICGO_ENV = 'GUI'
|
||||||
|
@ -278,6 +278,9 @@ export default {
|
|||||||
|
|
||||||
// plugin custom menus
|
// plugin custom menus
|
||||||
if (plugin.guiMenu) {
|
if (plugin.guiMenu) {
|
||||||
|
menu.push({
|
||||||
|
type: 'separator'
|
||||||
|
})
|
||||||
for (let i of plugin.guiMenu) {
|
for (let i of plugin.guiMenu) {
|
||||||
menu.push({
|
menu.push({
|
||||||
label: i.label,
|
label: i.label,
|
||||||
|
Loading…
Reference in New Issue
Block a user