diff --git a/src/main/utils/picgoCoreIPC.js b/src/main/utils/picgoCoreIPC.js index 97df425..76960ce 100644 --- a/src/main/utils/picgoCoreIPC.js +++ b/src/main/utils/picgoCoreIPC.js @@ -4,6 +4,22 @@ import path from 'path' const requireFunc = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require const PicGo = requireFunc('picgo') +// get uploader or transformer config +const getConfig = (name, type, ctx) => { + let config = [] + if (name === '') { + return config + } else { + const handler = ctx.helper[type].get(name) + if (handler) { + if (handler.config) { + config = handler.config(ctx) + } + } + return config + } +} + export default (app, ipcMain) => { const STORE_PATH = app.getPath('userData') const CONFIG_PATH = path.join(STORE_PATH, '/data.json') @@ -13,15 +29,29 @@ export default (app, ipcMain) => { const pluginList = picgo.pluginLoader.getList() const list = [] for (let i in pluginList) { + const plugin = picgo.pluginLoader.getPlugin(pluginList[i]) const pluginPath = path.join(STORE_PATH, `/node_modules/${pluginList[i]}`) const pluginPKG = requireFunc(path.join(pluginPath, 'package.json')) + const uploaderName = plugin.uploader || '' + const transformerName = plugin.transformer || '' const obj = { - name: pluginList[i], + name: pluginList[i].replace(/picgo-plugin-/, ''), author: pluginPKG.author, description: pluginPKG.description, logo: path.join(pluginPath, 'logo.png').split(path.sep).join('/'), config: { - plugin: picgo.pluginLoader.getPlugin(pluginList[i]).config ? picgo.pluginLoader.getPlugin(pluginList[i]).config(picgo) : [] + plugin: { + name: pluginList[i].replace(/picgo-plugin-/, ''), + config: plugin.config ? plugin.config(picgo) : [] + }, + uploader: { + name: uploaderName, + config: getConfig(uploaderName, 'uploader', picgo) + }, + transformer: { + name: transformerName, + config: getConfig(uploaderName, 'transformer', picgo) + } }, enabled: picgo.getConfig(`plugins.${pluginList[i]}`) } diff --git a/src/renderer/components/ConfigForm.vue b/src/renderer/components/ConfigForm.vue new file mode 100644 index 0000000..42a5086 --- /dev/null +++ b/src/renderer/components/ConfigForm.vue @@ -0,0 +1,100 @@ + + + \ No newline at end of file diff --git a/src/renderer/components/SettingView/Plugin.vue b/src/renderer/components/SettingView/Plugin.vue index b6ffa19..5689a7a 100644 --- a/src/renderer/components/SettingView/Plugin.vue +++ b/src/renderer/components/SettingView/Plugin.vue @@ -39,16 +39,42 @@ + + + + + 取消 + 确定 + +