Fixed: #166 & add showNotification for guiApi

This commit is contained in:
Molunerfinn 2019-01-15 17:28:50 +08:00
parent 8704e212bf
commit 0abdb3cf00
3 changed files with 35 additions and 5 deletions

View File

@ -82,6 +82,24 @@ class GuiApi {
}
return []
}
/**
* For notification
* @param {Object} options
*/
showNotification (options) {
if (options === undefined) {
options = {
title: '',
body: ''
}
}
const notification = new Notification({
title: options.title,
body: options.body
})
notification.show()
}
}
export default GuiApi

View File

@ -49,13 +49,19 @@ const handleGetPluginList = (ipcMain, STORE_PATH, CONFIG_PATH) => {
if (plugin.guiMenu) {
menu = plugin.guiMenu(picgo)
}
let gui = false
if (pluginPKG.keywords && pluginPKG.keywords.length > 0) {
if (pluginPKG.keywords.includes('picgo-gui-plugin')) {
gui = true
}
}
const obj = {
name: pluginList[i].replace(/picgo-plugin-/, ''),
author: pluginPKG.author.name || pluginPKG.author,
description: pluginPKG.description,
logo: 'file://' + path.join(pluginPath, 'logo.png').split(path.sep).join('/'),
version: pluginPKG.version,
gui: pluginPKG.gui || false,
gui,
config: {
plugin: {
name: pluginList[i].replace(/picgo-plugin-/, ''),
@ -70,7 +76,7 @@ const handleGetPluginList = (ipcMain, STORE_PATH, CONFIG_PATH) => {
config: handleConfigWithFunction(getConfig(uploaderName, 'transformer', picgo))
}
},
enabled: picgo.getConfig(`plugins.${pluginList[i]}`),
enabled: picgo.getConfig(`picgoPlugins.${pluginList[i]}`),
homepage: pluginPKG.homepage ? pluginPKG.homepage : '',
guiMenu: menu,
ing: false

View File

@ -219,7 +219,7 @@ export default {
label: '启用插件',
enabled: !plugin.enabled,
click () {
_this.$db.read().set(`plugins.picgo-plugin-${plugin.name}`, true).write()
_this.$db.read().set(`picgoPlugins.picgo-plugin-${plugin.name}`, true).write()
plugin.enabled = true
_this.getPicBeds()
}
@ -227,7 +227,7 @@ export default {
label: '禁用插件',
enabled: plugin.enabled,
click () {
_this.$db.read().set(`plugins.picgo-plugin-${plugin.name}`, false).write()
_this.$db.read().set(`picgoPlugins.picgo-plugin-${plugin.name}`, false).write()
plugin.enabled = false
_this.getPicBeds()
if (plugin.config.transformer.name) {
@ -398,6 +398,12 @@ export default {
},
handleSearchResult (item) {
const name = item.package.name.replace(/picgo-plugin-/, '')
let gui = false
if (item.package.keywords && item.package.keywords.length > 0) {
if (item.package.keywords.includes('picgo-gui-plugin')) {
gui = true
}
}
return {
name: name,
author: item.package.author.name,
@ -407,7 +413,7 @@ export default {
homepage: item.package.links ? item.package.links.homepage : '',
hasInstall: this.pluginNameList.some(plugin => plugin === item.package.name.replace(/picgo-plugin-/, '')),
version: item.package.version,
gui: item.package.gui || false,
gui,
ing: false // installing or uninstalling
}
},