fix: 枚举字典插件readonly处理

This commit is contained in:
aringlai 2021-02-02 18:10:37 +08:00
parent 7f9149d26c
commit 8912fa409d

View File

@ -25,13 +25,15 @@ function get(name, key, opt = { dir: 'value', extend: []}) {
key = '' key = ''
} }
let list = ENUMS[name] || [] let list = ENUMS[name] || []
let value
if (key) { if (key) {
let res = list.filter(item => item.key === key)[0] let res = list.filter(item => item.key === key)[0]
if (!res) return key if (!res) return key
return readonly(parseValueDir(res.value, opt.dir) || key) value = parseValueDir(res.value, opt.dir) || key
} else { } else {
return readonly(format(list, opt.extend)) value = format(list, opt.extend)
} }
return typeof value === 'object' ? readonly(value) : value
} }
/** /**