mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-02-08 21:38:13 -05:00
Added: plugin config save
This commit is contained in:
parent
51281f345b
commit
4a420dd5c5
@ -23,9 +23,9 @@ const getConfig = (name, type, ctx) => {
|
|||||||
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')
|
||||||
const picgo = new PicGo(CONFIG_PATH)
|
|
||||||
|
|
||||||
ipcMain.on('getPluginList', event => {
|
ipcMain.on('getPluginList', event => {
|
||||||
|
const picgo = new PicGo(CONFIG_PATH)
|
||||||
const pluginList = picgo.pluginLoader.getList()
|
const pluginList = picgo.pluginLoader.getList()
|
||||||
const list = []
|
const list = []
|
||||||
for (let i in pluginList) {
|
for (let i in pluginList) {
|
||||||
|
@ -10,7 +10,8 @@ import fecha from 'fecha'
|
|||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
const requireFunc = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require
|
const requireFunc = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require
|
||||||
const PicGo = requireFunc('picgo')
|
const PicGo = requireFunc('picgo')
|
||||||
|
const STORE_PATH = app.getPath('userData')
|
||||||
|
const CONFIG_PATH = path.join(STORE_PATH, '/data.json')
|
||||||
const renameURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#rename-page` : `file://${__dirname}/index.html#rename-page`
|
const renameURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#rename-page` : `file://${__dirname}/index.html#rename-page`
|
||||||
|
|
||||||
const createRenameWindow = () => {
|
const createRenameWindow = () => {
|
||||||
@ -38,9 +39,6 @@ const createRenameWindow = () => {
|
|||||||
return window
|
return window
|
||||||
}
|
}
|
||||||
|
|
||||||
const STORE_PATH = app.getPath('userData')
|
|
||||||
const CONFIG_PATH = path.join(STORE_PATH, '/data.json')
|
|
||||||
|
|
||||||
const waitForShow = (webcontent) => {
|
const waitForShow = (webcontent) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
webcontent.on('dom-ready', () => {
|
webcontent.on('dom-ready', () => {
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
>
|
>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
v-for="(item, index) in configList"
|
v-for="(item, index) in configList"
|
||||||
:key="index"
|
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
:required="item.required"
|
:required="item.required"
|
||||||
:prop="item.name"
|
:prop="item.name"
|
||||||
|
:key="item.name + index"
|
||||||
>
|
>
|
||||||
<el-input
|
<el-input
|
||||||
v-if="item.type === 'input' || item.type === 'password'"
|
v-if="item.type === 'input' || item.type === 'password'"
|
||||||
@ -44,6 +44,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import { cloneDeep } from 'lodash'
|
||||||
export default {
|
export default {
|
||||||
name: 'config-form',
|
name: 'config-form',
|
||||||
props: {
|
props: {
|
||||||
@ -58,24 +59,37 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.configList = JSON.parse(JSON.stringify(this.config)).map(item => {
|
this.configList = cloneDeep(this.config).map(item => {
|
||||||
const defaultValue = item.default !== undefined ? item.default : null
|
const defaultValue = item.default !== undefined ? item.default : null
|
||||||
this.$set(this.ruleForm, item.name, defaultValue)
|
this.$set(this.ruleForm, item.name, defaultValue)
|
||||||
return item
|
return item
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
mounted () {
|
watch: {
|
||||||
console.log(this.$refs.form)
|
config: {
|
||||||
|
deep: true,
|
||||||
|
handler (val) {
|
||||||
|
this.ruleForm = Object.assign({}, {})
|
||||||
|
this.configList = cloneDeep(val).map(item => {
|
||||||
|
const defaultValue = item.default !== undefined ? item.default : null
|
||||||
|
this.$set(this.ruleForm, item.name, defaultValue)
|
||||||
|
return item
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
validate () {
|
async validate () {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
this.$refs.form.validate(valid => {
|
this.$refs.form.validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
console.log(this.ruleForm)
|
resolve(this.ruleForm)
|
||||||
} else {
|
} else {
|
||||||
|
resolve(false)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
{{ item.author }}
|
{{ item.author }}
|
||||||
</span>
|
</span>
|
||||||
<span class="plugin-item__config" >
|
<span class="plugin-item__config" >
|
||||||
<span class="reload-button" v-if="item.reload" @click="reloadApp">
|
<!-- <span class="reload-button" v-if="item.reload" @click="reloadApp">
|
||||||
重启
|
重启
|
||||||
</span>
|
</span> -->
|
||||||
<i
|
<i
|
||||||
class="el-icon-setting"
|
class="el-icon-setting"
|
||||||
@click="buildContextMenu(item)"
|
@click="buildContextMenu(item)"
|
||||||
@ -80,7 +80,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.reload = false
|
// item.reload = false
|
||||||
return item
|
return item
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -100,7 +100,7 @@ export default {
|
|||||||
click () {
|
click () {
|
||||||
_this.$db.read().set(`plugins.picgo-plugin-${plugin.name}`, true).write()
|
_this.$db.read().set(`plugins.picgo-plugin-${plugin.name}`, true).write()
|
||||||
plugin.enabled = true
|
plugin.enabled = true
|
||||||
plugin.reload = true
|
// plugin.reload = true
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
label: '禁用插件',
|
label: '禁用插件',
|
||||||
@ -108,7 +108,7 @@ export default {
|
|||||||
click () {
|
click () {
|
||||||
_this.$db.read().set(`plugins.picgo-plugin-${plugin.name}`, false).write()
|
_this.$db.read().set(`plugins.picgo-plugin-${plugin.name}`, false).write()
|
||||||
plugin.enabled = false
|
plugin.enabled = false
|
||||||
plugin.reload = true
|
// plugin.reload = true
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
for (let i in plugin.config) {
|
for (let i in plugin.config) {
|
||||||
@ -116,11 +116,10 @@ export default {
|
|||||||
const obj = {
|
const obj = {
|
||||||
label: `配置${i} - ${plugin.config[i].name}`,
|
label: `配置${i} - ${plugin.config[i].name}`,
|
||||||
click () {
|
click () {
|
||||||
_this.configType = i
|
_this.currentType = i
|
||||||
_this.configName = plugin.config[i].name
|
_this.configName = plugin.config[i].name
|
||||||
_this.dialogVisible = true
|
_this.dialogVisible = true
|
||||||
_this.config = plugin.config[i].config
|
_this.config = plugin.config[i].config
|
||||||
console.log(plugin.config[i].config)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
menu.push(obj)
|
menu.push(obj)
|
||||||
@ -136,9 +135,29 @@ export default {
|
|||||||
this.$electron.remote.app.relaunch()
|
this.$electron.remote.app.relaunch()
|
||||||
this.$electron.remote.app.exit(0)
|
this.$electron.remote.app.exit(0)
|
||||||
},
|
},
|
||||||
handleConfirmConfig () {
|
async handleConfirmConfig () {
|
||||||
console.log(this.$refs.configForm)
|
const result = await this.$refs.configForm.validate()
|
||||||
this.$refs.configForm.validate()
|
if (result !== false) {
|
||||||
|
switch (this.currentType) {
|
||||||
|
case 'plugin':
|
||||||
|
this.$db.read().set(`picgo-plugin-${this.configName}`, result).write()
|
||||||
|
break
|
||||||
|
case 'uploader':
|
||||||
|
this.$db.read().set(`picBed.${this.configName}`, result).write()
|
||||||
|
break
|
||||||
|
case 'transformer':
|
||||||
|
this.$db.read().set(`transformer.${this.configName}`, result).write()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
const successNotification = new window.Notification('设置结果', {
|
||||||
|
body: '设置成功'
|
||||||
|
})
|
||||||
|
successNotification.onclick = () => {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
this.dialogVisible = false
|
||||||
|
this.getPluginList()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user