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

View File

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