Skip to content

Commit

Permalink
🐛 Fix: plugin config can't save
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #943
  • Loading branch information
Molunerfinn committed Jul 31, 2022
1 parent 219b367 commit 09e4e82
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/renderer/components/ConfigForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions src/renderer/pages/Plugin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/universal/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ interface IPicGoPluginConfig {
type: string
required: boolean
default?: any
alias?: string
choices?: {
name?: string
value?: any
}[]
[propName: string]: any
}

Expand Down

0 comments on commit 09e4e82

Please sign in to comment.