🍒 refactor(sysDict): 优化多选值模式的类型声明
This commit is contained in:
parent
47ebee8f3e
commit
f11f8808e4
@ -57,15 +57,18 @@ interface MutexConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多选值模式枚举
|
* 多选值模式常量
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
* @property {string} Array - 数组模式,如['1','2','3']
|
* @property {string} Array - 数组模式,如['1','2','3']
|
||||||
* @property {string} Comma - 逗号分隔模式,如'1,2,3'
|
* @property {string} Comma - 逗号分隔模式,如'1,2,3'
|
||||||
*/
|
*/
|
||||||
enum MultipleModel {
|
const MultipleModel = {
|
||||||
Array = 'array',
|
Array: 'array',
|
||||||
Comma = 'comma',
|
Comma: 'comma',
|
||||||
}
|
} as const
|
||||||
|
|
||||||
|
// 多选值模式枚举类型
|
||||||
|
type MultipleModelType = typeof MultipleModel[keyof typeof MultipleModel];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查是否为合法的渲染类型
|
* 检查是否为合法的渲染类型
|
||||||
@ -83,7 +86,7 @@ function isRenderType(value: any): value is RenderType {
|
|||||||
* @param {any} value - 待检查的值
|
* @param {any} value - 待检查的值
|
||||||
* @returns {value is MultipleModel} - 是否为合法的多选模式
|
* @returns {value is MultipleModel} - 是否为合法的多选模式
|
||||||
*/
|
*/
|
||||||
function isMultipleModel(value: any): value is MultipleModel {
|
function isMultipleModel(value: any): value is MultipleModelType {
|
||||||
return Object.values(MultipleModel).includes(value);
|
return Object.values(MultipleModel).includes(value);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -224,7 +227,7 @@ const props = defineProps({
|
|||||||
* @example 'comma'
|
* @example 'comma'
|
||||||
*/
|
*/
|
||||||
multipleModel: {
|
multipleModel: {
|
||||||
type: String as PropType<MultipleModel>,
|
type: String as PropType<MultipleModelType>,
|
||||||
default: MultipleModel.Array,
|
default: MultipleModel.Array,
|
||||||
validator: isMultipleModel,
|
validator: isMultipleModel,
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user