|
|
@@ -12,14 +12,19 @@ import { BtnClassName, BtnList, ButtonListKey } from './interface';
|
|
|
*/
|
|
|
function getClassName(val: string): BtnClassName {
|
|
|
let result: BtnClassName = 'btnDeafault'
|
|
|
- if (val.includes('disable') || val.includes('cancle') || val.includes('delete')) {
|
|
|
- result = 'btnDanger'
|
|
|
- } else if (val === '') {
|
|
|
- result = 'btnDeafault'
|
|
|
- } else if (val.includes('add')) {
|
|
|
- result = 'operBtn'
|
|
|
- } else {
|
|
|
- result = 'btnPrimary'
|
|
|
+ const btnDanger = ['disable', 'cancle', 'delete', 'logout', 'locked']
|
|
|
+ const operBtn = ['add', 'modify', 'reset']
|
|
|
+ const map = new Map<BtnClassName, string[]>([
|
|
|
+ ['btnDanger', btnDanger],
|
|
|
+ ['operBtn', operBtn],
|
|
|
+ ])
|
|
|
+ for (const [key, value] of map) {
|
|
|
+ for (const item of value) {
|
|
|
+ if (val.includes(item)) {
|
|
|
+ result = key
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return result
|
|
|
}
|