diff --git a/packages/core/api/src/dns-provider/abstract-dns-provider.js b/packages/core/api/src/dns-provider/abstract-dns-provider.js index a437ba96..2eb10273 100644 --- a/packages/core/api/src/dns-provider/abstract-dns-provider.js +++ b/packages/core/api/src/dns-provider/abstract-dns-provider.js @@ -1,9 +1,10 @@ import _ from 'lodash-es' import logger from '../utils/util.log.js' +import commonUtil from '../utils/util.common' export class AbstractDnsProvider { constructor ({ accessProviders }) { this.logger = logger - this.accessProviders = accessProviders + this.accessProviders = commonUtil.arrayToMap(accessProviders) } async createRecord ({ fullRecord, type, value }) { diff --git a/packages/core/api/src/plugin/abstract-plugin.js b/packages/core/api/src/plugin/abstract-plugin.js index 55c71cab..d7f44bbf 100644 --- a/packages/core/api/src/plugin/abstract-plugin.js +++ b/packages/core/api/src/plugin/abstract-plugin.js @@ -2,7 +2,7 @@ import fs from 'fs' import logger from '../utils/util.log.js' import dayjs from 'dayjs' import Sleep from '../utils/util.sleep.js' - +import commonUtil from '../utils/util.common.js' export class AbstractPlugin { constructor (options) { if (options == null) { @@ -10,7 +10,7 @@ export class AbstractPlugin { } const { accessProviders } = options this.logger = logger - this.accessProviders = accessProviders + this.accessProviders = commonUtil.arrayToMap(accessProviders) } appendTimeSuffix (name) { diff --git a/packages/core/api/src/utils/index.js b/packages/core/api/src/utils/index.js index f74b1de2..5ffc5c1e 100644 --- a/packages/core/api/src/utils/index.js +++ b/packages/core/api/src/utils/index.js @@ -2,6 +2,7 @@ import logger from './util.log.js' import path from './util.path.js' import { request } from './util.request.js' import sleep from './util.sleep.js' +import common from './util.common.js' export const util = { - logger, path, request, sleep + logger, path, request, sleep, common } diff --git a/packages/core/api/src/utils/util.common.js b/packages/core/api/src/utils/util.common.js new file mode 100644 index 00000000..47e6b51a --- /dev/null +++ b/packages/core/api/src/utils/util.common.js @@ -0,0 +1,33 @@ +import _ from 'lodash-es' +export default { + arrayToMap (array) { + if (!array) { + return {} + } + if (!_.isArray(array)) { + return array + } + const map = {} + for (const item of array) { + if (item.key) { + map[item.key] = item + } + } + return map + }, + mapToArray (map) { + if (!map) { + return [] + } + if (_.isArray(map)) { + return map + } + const array = [] + for (const key in map) { + const item = map[key] + item.key = key + array.push(item) + } + return array + } +} diff --git a/packages/ui/certd-ui/src/utils/util.common.js b/packages/ui/certd-ui/src/utils/util.common.js new file mode 100644 index 00000000..47e6b51a --- /dev/null +++ b/packages/ui/certd-ui/src/utils/util.common.js @@ -0,0 +1,33 @@ +import _ from 'lodash-es' +export default { + arrayToMap (array) { + if (!array) { + return {} + } + if (!_.isArray(array)) { + return array + } + const map = {} + for (const item of array) { + if (item.key) { + map[item.key] = item + } + } + return map + }, + mapToArray (map) { + if (!map) { + return [] + } + if (_.isArray(map)) { + return map + } + const array = [] + for (const key in map) { + const item = map[key] + item.key = key + array.push(item) + } + return array + } +} diff --git a/packages/ui/certd-ui/src/views/detail/index.vue b/packages/ui/certd-ui/src/views/detail/index.vue index 31b16f61..848c9c5b 100644 --- a/packages/ui/certd-ui/src/views/detail/index.vue +++ b/packages/ui/certd-ui/src/views/detail/index.vue @@ -190,7 +190,7 @@ import TaskForm from './components/task-form' import exportsApi from '../../api/api.exports' import _ from 'lodash-es' import DContainer from '../../components/d-container' - +import commonUtil from '@/utils/util.common' function useDeploy (options) { const deployAdd = () => { options.deploy.push({ @@ -248,6 +248,9 @@ export default { const route = useRoute() console.log('route', route) const optionParams = route.params.options ? JSON.parse(route.params.options) : {} + if (optionParams.accessProviders) { + optionParams.accessProviders = commonUtil.mapToArray(optionParams.accessProviders) + } const optionsDefault = { cert: { csr: {