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