mirror of
https://gitee.com/honghuangdc/soybean-admin-element-plus.git
synced 2026-09-01 01:07:57 +00:00
feat(types): ✨ enhance Option type to support customizable label types.
This commit is contained in:
@@ -22,7 +22,7 @@ export function transformRecordToOption<T extends Record<string, string>>(record
|
||||
return Object.entries(record).map(([value, label]) => ({
|
||||
value,
|
||||
label
|
||||
})) as CommonType.Option<keyof T>[];
|
||||
})) as CommonType.Option<keyof T, T[keyof T]>[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,10 +30,10 @@ export function transformRecordToOption<T extends Record<string, string>>(record
|
||||
*
|
||||
* @param options
|
||||
*/
|
||||
export function translateOptions(options: CommonType.Option<string>[]) {
|
||||
export function translateOptions(options: CommonType.Option<string, App.I18n.I18nKey>[]) {
|
||||
return options.map(option => ({
|
||||
...option,
|
||||
label: $t(option.label as App.I18n.I18nKey)
|
||||
label: $t(option.label)
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user