添加管理端和移动端的多个新功能模块,包括文件上传、在线地图、用户认证、系统设置等,优化代码结构,提升可维护性和用户体验。
This commit is contained in:
9
client/admin/utils.ts
Normal file
9
client/admin/utils.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export function getEnumOptions<T extends string | number, M extends Record<T, string>>(enumObj: Record<string, T>, nameMap: M) {
|
||||
return Object.entries(enumObj)
|
||||
.filter(([_key, value]) => !isNaN(Number(value)) || typeof value === 'string') // 保留数字和字符串类型的值
|
||||
.filter(([key, _value]) => isNaN(Number(key))) // 过滤掉数字键(枚举的反向映射)
|
||||
.map(([_key, value]) => ({
|
||||
label: nameMap[value as T],
|
||||
value: value
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user