🐛 Fix: plugin config can't save

ISSUES CLOSED: #943
This commit is contained in:
PiEgg 2022-07-31 18:22:56 +08:00
parent 219b367f7c
commit 09e4e82ca9
3 changed files with 13 additions and 12 deletions

View File

@ -21,7 +21,7 @@
:placeholder="item.message || item.name"
></el-input>
<el-select
v-else-if="item.type === 'list'"
v-else-if="item.type === 'list' && item.choices"
v-model="ruleForm[item.name]"
:placeholder="item.message || item.name"
>
@ -33,7 +33,7 @@
></el-option>
</el-select>
<el-select
v-else-if="item.type === 'checkbox'"
v-else-if="item.type === 'checkbox' && item.choices"
v-model="ruleForm[item.name]"
:placeholder="item.message || item.name"
multiple
@ -74,8 +74,8 @@ export default class extends Vue {
@Prop() private config!: any[]
@Prop() readonly type!: 'uploader' | 'transformer' | 'plugin'
@Prop() readonly id!: string
configList = []
ruleForm = {}
configList: IPicGoPluginConfig[] = []
ruleForm: IStringKeyMap = {}
@Watch('config', {
deep: true,
immediate: true
@ -114,20 +114,20 @@ export default class extends Vue {
}
}
async handleConfig (val: any) {
async handleConfig (val: IPicGoPluginConfig[]) {
this.ruleForm = Object.assign({}, {})
const config = await this.getConfig<IPicGoPluginConfig>(this.getConfigType())
if (val.length > 0) {
this.configList = cloneDeep(val).map((item: any) => {
this.configList = cloneDeep(val).map((item) => {
let defaultValue = item.default !== undefined
? item.default
: item.type === 'checkbox'
? []
: null
if (item.type === 'checkbox') {
const defaults = item.choices.filter((i: any) => {
const defaults = item.choices?.filter((i: any) => {
return i.checked
}).map((i: any) => i.value)
}).map((i: any) => i.value) || []
defaultValue = union(defaultValue, defaults)
}
if (config && config[item.name] !== undefined) {

View File

@ -428,10 +428,6 @@ export default class extends Vue {
ipcRenderer.send(OPEN_URL, 'https://github.com/PicGo/Awesome-PicGo')
}
saveConfig (data: IObj) {
ipcRenderer.send('picgoSaveData', data)
}
handleImportLocalPlugin () {
ipcRenderer.send('importLocalPlugin')
this.loading = true

View File

@ -151,6 +151,11 @@ interface IPicGoPluginConfig {
type: string
required: boolean
default?: any
alias?: string
choices?: {
name?: string
value?: any
}[]
[propName: string]: any
}