Feature: support multiple config (#1016)

This commit is contained in:
陌小路
2022-11-23 09:42:40 +08:00
committed by GitHub
parent 44f5fbbb91
commit 95556498f7
10 changed files with 312 additions and 18 deletions

View File

@@ -7,6 +7,18 @@
ref="form"
size="mini"
>
<el-form-item
:label="$T('UPLOADER_CONFIG_NAME')"
required
prop="_configName"
>
<el-input
type="input"
v-model="ruleForm._configName"
:placeholder="$T('UPLOADER_CONFIG_PLACEHOLDER')"
></el-input>
</el-form-item>
<!-- dynamic config -->
<el-form-item
v-for="(item, index) in configList"
:label="item.alias || item.name"
@@ -115,10 +127,12 @@ export default class extends Vue {
}
async handleConfig (val: IPicGoPluginConfig[]) {
this.ruleForm = Object.assign({}, {})
const config = await this.getConfig<IPicGoPluginConfig>(this.getConfigType())
const config = await this.getCurConfigFormData()
const configId = this.$route.params.configId
this.ruleForm = Object.assign({}, config)
if (val.length > 0) {
this.configList = cloneDeep(val).map((item) => {
if (!configId) return item
let defaultValue = item.default !== undefined
? item.default
: item.type === 'checkbox'
@@ -138,6 +152,12 @@ export default class extends Vue {
})
}
}
async getCurConfigFormData () {
const configId = this.$route.params.configId
const curTypeConfigList = await this.getConfig<IStringKeyMap[]>(`uploader.${this.id}.configList`) || []
return curTypeConfigList.find(i => i._id === configId) || {}
}
}
</script>
<style lang='stylus'>