Skip to content

Commit 0abdb3c

Browse files
committed
Fixed: Molunerfinn#166 & add showNotification for guiApi
1 parent 8704e21 commit 0abdb3c

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

src/main/utils/guiApi.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,24 @@ class GuiApi {
8282
}
8383
return []
8484
}
85+
86+
/**
87+
* For notification
88+
* @param {Object} options
89+
*/
90+
showNotification (options) {
91+
if (options === undefined) {
92+
options = {
93+
title: '',
94+
body: ''
95+
}
96+
}
97+
const notification = new Notification({
98+
title: options.title,
99+
body: options.body
100+
})
101+
notification.show()
102+
}
85103
}
86104

87105
export default GuiApi

src/main/utils/picgoCoreIPC.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,19 @@ const handleGetPluginList = (ipcMain, STORE_PATH, CONFIG_PATH) => {
4949
if (plugin.guiMenu) {
5050
menu = plugin.guiMenu(picgo)
5151
}
52+
let gui = false
53+
if (pluginPKG.keywords && pluginPKG.keywords.length > 0) {
54+
if (pluginPKG.keywords.includes('picgo-gui-plugin')) {
55+
gui = true
56+
}
57+
}
5258
const obj = {
5359
name: pluginList[i].replace(/picgo-plugin-/, ''),
5460
author: pluginPKG.author.name || pluginPKG.author,
5561
description: pluginPKG.description,
5662
logo: 'file://' + path.join(pluginPath, 'logo.png').split(path.sep).join('/'),
5763
version: pluginPKG.version,
58-
gui: pluginPKG.gui || false,
64+
gui,
5965
config: {
6066
plugin: {
6167
name: pluginList[i].replace(/picgo-plugin-/, ''),
@@ -70,7 +76,7 @@ const handleGetPluginList = (ipcMain, STORE_PATH, CONFIG_PATH) => {
7076
config: handleConfigWithFunction(getConfig(uploaderName, 'transformer', picgo))
7177
}
7278
},
73-
enabled: picgo.getConfig(`plugins.${pluginList[i]}`),
79+
enabled: picgo.getConfig(`picgoPlugins.${pluginList[i]}`),
7480
homepage: pluginPKG.homepage ? pluginPKG.homepage : '',
7581
guiMenu: menu,
7682
ing: false

src/renderer/pages/Plugin.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,15 @@ export default {
219219
label: '启用插件',
220220
enabled: !plugin.enabled,
221221
click () {
222-
_this.$db.read().set(`plugins.picgo-plugin-${plugin.name}`, true).write()
222+
_this.$db.read().set(`picgoPlugins.picgo-plugin-${plugin.name}`, true).write()
223223
plugin.enabled = true
224224
_this.getPicBeds()
225225
}
226226
}, {
227227
label: '禁用插件',
228228
enabled: plugin.enabled,
229229
click () {
230-
_this.$db.read().set(`plugins.picgo-plugin-${plugin.name}`, false).write()
230+
_this.$db.read().set(`picgoPlugins.picgo-plugin-${plugin.name}`, false).write()
231231
plugin.enabled = false
232232
_this.getPicBeds()
233233
if (plugin.config.transformer.name) {
@@ -398,6 +398,12 @@ export default {
398398
},
399399
handleSearchResult (item) {
400400
const name = item.package.name.replace(/picgo-plugin-/, '')
401+
let gui = false
402+
if (item.package.keywords && item.package.keywords.length > 0) {
403+
if (item.package.keywords.includes('picgo-gui-plugin')) {
404+
gui = true
405+
}
406+
}
401407
return {
402408
name: name,
403409
author: item.package.author.name,
@@ -407,7 +413,7 @@ export default {
407413
homepage: item.package.links ? item.package.links.homepage : '',
408414
hasInstall: this.pluginNameList.some(plugin => plugin === item.package.name.replace(/picgo-plugin-/, '')),
409415
version: item.package.version,
410-
gui: item.package.gui || false,
416+
gui,
411417
ing: false // installing or uninstalling
412418
}
413419
},

0 commit comments

Comments
 (0)