mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-02-08 21:38:13 -05:00
Fixed: bug with function in config
This commit is contained in:
parent
4a420dd5c5
commit
c3b2d7b941
@ -20,6 +20,18 @@ const getConfig = (name, type, ctx) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleConfigWithFunction = config => {
|
||||||
|
for (let i in config) {
|
||||||
|
if (typeof config[i].default === 'function') {
|
||||||
|
config[i].default = config[i].default()
|
||||||
|
}
|
||||||
|
if (typeof config[i].choices === 'function') {
|
||||||
|
config[i].choices = config[i].choices()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
export default (app, ipcMain) => {
|
export default (app, ipcMain) => {
|
||||||
const STORE_PATH = app.getPath('userData')
|
const STORE_PATH = app.getPath('userData')
|
||||||
const CONFIG_PATH = path.join(STORE_PATH, '/data.json')
|
const CONFIG_PATH = path.join(STORE_PATH, '/data.json')
|
||||||
@ -42,15 +54,15 @@ export default (app, ipcMain) => {
|
|||||||
config: {
|
config: {
|
||||||
plugin: {
|
plugin: {
|
||||||
name: pluginList[i].replace(/picgo-plugin-/, ''),
|
name: pluginList[i].replace(/picgo-plugin-/, ''),
|
||||||
config: plugin.config ? plugin.config(picgo) : []
|
config: plugin.config ? handleConfigWithFunction(plugin.config(picgo)) : []
|
||||||
},
|
},
|
||||||
uploader: {
|
uploader: {
|
||||||
name: uploaderName,
|
name: uploaderName,
|
||||||
config: getConfig(uploaderName, 'uploader', picgo)
|
config: handleConfigWithFunction(getConfig(uploaderName, 'uploader', picgo))
|
||||||
},
|
},
|
||||||
transformer: {
|
transformer: {
|
||||||
name: transformerName,
|
name: transformerName,
|
||||||
config: getConfig(uploaderName, 'transformer', picgo)
|
config: handleConfigWithFunction(getConfig(uploaderName, 'transformer', picgo))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
enabled: picgo.getConfig(`plugins.${pluginList[i]}`)
|
enabled: picgo.getConfig(`plugins.${pluginList[i]}`)
|
||||||
|
@ -79,10 +79,7 @@ export default {
|
|||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.$electron.ipcRenderer.on('pluginList', (evt, list) => {
|
this.$electron.ipcRenderer.on('pluginList', (evt, list) => {
|
||||||
this.pluginList = list.map(item => {
|
this.pluginList = list.map(item => item)
|
||||||
// item.reload = false
|
|
||||||
return item
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
this.getPluginList()
|
this.getPluginList()
|
||||||
document.addEventListener('keydown', (e) => {
|
document.addEventListener('keydown', (e) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user