mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-31 18:39:50 +08:00
Fixed: plugin handler require bug
This commit is contained in:
@@ -3,7 +3,7 @@ import path from 'path'
|
||||
// eslint-disable-next-line
|
||||
const requireFunc = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require
|
||||
const PicGo = requireFunc('picgo')
|
||||
const PluginHandler = requireFunc('picgo/lib/PluginHandler')
|
||||
const PluginHandler = requireFunc('picgo/dist/lib/PluginHandler').default
|
||||
|
||||
// get uploader or transformer config
|
||||
const getConfig = (name, type, ctx) => {
|
||||
@@ -46,7 +46,7 @@ const handleGetPluginList = (ipcMain, STORE_PATH, CONFIG_PATH) => {
|
||||
const transformerName = plugin.transformer || ''
|
||||
const obj = {
|
||||
name: pluginList[i].replace(/picgo-plugin-/, ''),
|
||||
author: pluginPKG.author,
|
||||
author: pluginPKG.author.name || pluginPKG.author,
|
||||
description: pluginPKG.description,
|
||||
logo: 'file://' + path.join(pluginPath, 'logo.png').split(path.sep).join('/'),
|
||||
config: {
|
||||
@@ -83,9 +83,22 @@ const handlePluginInstall = (ipcMain, STORE_PATH, CONFIG_PATH) => {
|
||||
})
|
||||
}
|
||||
|
||||
const handlePluginUninstall = (ipcMain, STORE_PATH, CONFIG_PATH) => {
|
||||
ipcMain.on('uninstallPlugin', (event, msg) => {
|
||||
const picgo = new PicGo(CONFIG_PATH)
|
||||
const pluginHandler = new PluginHandler(picgo)
|
||||
console.log(msg, 123)
|
||||
picgo.on('uninstallSuccess', (plugin) => {
|
||||
console.log(plugin)
|
||||
})
|
||||
pluginHandler.uninstall([`picgo-plugin-${msg}`])
|
||||
})
|
||||
}
|
||||
|
||||
export default (app, ipcMain) => {
|
||||
const STORE_PATH = app.getPath('userData')
|
||||
const CONFIG_PATH = path.join(STORE_PATH, '/data.json')
|
||||
handleGetPluginList(ipcMain, STORE_PATH, CONFIG_PATH)
|
||||
handlePluginInstall(ipcMain, STORE_PATH, CONFIG_PATH)
|
||||
handlePluginUninstall(ipcMain, STORE_PATH, CONFIG_PATH)
|
||||
}
|
||||
|
||||
@@ -137,6 +137,12 @@ export default {
|
||||
plugin.enabled = false
|
||||
// plugin.reload = true
|
||||
}
|
||||
}, {
|
||||
label: '卸载插件',
|
||||
click () {
|
||||
_this.loading = true
|
||||
_this.uninstallPlugin(plugin.name)
|
||||
}
|
||||
}]
|
||||
for (let i in plugin.config) {
|
||||
if (plugin.config[i].config.length > 0) {
|
||||
@@ -161,6 +167,9 @@ export default {
|
||||
installPlugin (val) {
|
||||
this.$electron.ipcRenderer.send('installPlugin', val)
|
||||
},
|
||||
uninstallPlugin (val) {
|
||||
this.$electron.ipcRenderer.send('uninstallPlugin', val)
|
||||
},
|
||||
reloadApp () {
|
||||
this.$electron.remote.app.relaunch()
|
||||
this.$electron.remote.app.exit(0)
|
||||
@@ -215,6 +224,7 @@ export default {
|
||||
config: {},
|
||||
homepage: item.package.links ? item.package.links.homepage : '',
|
||||
hasInstall: this.pluginNameList.some(plugin => plugin === item.package.name),
|
||||
installing: false,
|
||||
reload: false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user