举个例子:
通过抽象设计,以下不到 50 行,且看不到任何 jsx 标签的代码就能实现一个管理模块的增删改查详情功能,附带权限校验。
import { ModelAdminDisplayListType, ModelAdminTablePage } from '@/core/admin'
import { DigitField } from '@/core/form/field'
import { Model } from '@/core/model'
class AppModel extends Model {
id = Model.InputField({
label: 'ID'
})
account = Model.InputField({
label: '账户'
})
userId = Model.InputField({
label: '账户 ID',
widget: new DigitField()
})
os = Model.InputField({
label: '操作系统'
})
ipaddr = Model.InputField({
label: '登录 IP'
})
browser = Model.InputField({
label: '浏览器'
})
address = Model.InputField({
label: '登录地点'
})
createAt = Model.InputField({
label: '登录时间'
})
}
export default class App extends ModelAdminTablePage {
moduleKey: string = 'sys:log:login'
filters: ModelAdminDisplayListType = ['userId']
listDisplay: ModelAdminDisplayListType = ['id', 'account', 'userId', 'os','ipaddr', 'browser','address', 'createAt']
detailModalSize: 'small' | 'middle' | 'large' = 'small'
showAddButton: boolean = false
showEditButton: boolean = false
getModel(): new () => AppModel {
return AppModel
}
apiUrl: string = '/dis-micro-rbac/sys/loginfor'
}
想借此看看大家对于 class component 的看法。
model, Label, inputfield, appmodel