chore(uni-admin): 同步官方 2.5.1 框架文件
来源: gitee.com/dcloud/uni-admin master (2.5.1, 2025-04-24)。含 uni-stat-tabs 组件更新、uni-id-users/uni-id-log validator、uni-stat 页面修复、菜单初始数据与 DB schema 更新;版本号对齐 2.5.1。
This commit is contained in:
+12
-160
@@ -1,16 +1,21 @@
|
||||
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
|
||||
// 校验规则由 schema 生成,请不要直接修改当前文件,如果需要请在uniCloud控制台修改schema
|
||||
// uniCloud: https://unicloud.dcloud.net.cn/
|
||||
|
||||
|
||||
const validator = {
|
||||
"create_date": {
|
||||
|
||||
export default {
|
||||
"user_name": {
|
||||
"rules": [
|
||||
{
|
||||
"format": "timestamp"
|
||||
"format": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"device_uuid": {
|
||||
"content": {
|
||||
"rules": [
|
||||
{
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"format": "string"
|
||||
}
|
||||
@@ -23,164 +28,11 @@ const validator = {
|
||||
}
|
||||
]
|
||||
},
|
||||
"state": {
|
||||
"create_date": {
|
||||
"rules": [
|
||||
{
|
||||
"format": "int"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": {
|
||||
"rules": [
|
||||
{
|
||||
"format": "string"
|
||||
},
|
||||
{
|
||||
"range": [
|
||||
{
|
||||
"value": "logout",
|
||||
"text": "logout"
|
||||
},
|
||||
{
|
||||
"value": "login",
|
||||
"text": "login"
|
||||
},
|
||||
{
|
||||
"value": "register",
|
||||
"text": "register"
|
||||
},
|
||||
{
|
||||
"value": "reset-pwd",
|
||||
"text": "reset-pwd"
|
||||
},
|
||||
{
|
||||
"value": "bind-mobile",
|
||||
"text": "bind-mobile"
|
||||
},
|
||||
{
|
||||
"value": "bind-weixin",
|
||||
"text": "bind-weixin"
|
||||
},
|
||||
{
|
||||
"value": "bind-qq",
|
||||
"text": "bind-qq"
|
||||
},
|
||||
{
|
||||
"value": "bind-apple",
|
||||
"text": "bind-apple"
|
||||
},
|
||||
{
|
||||
"value": "bind-alipay",
|
||||
"text": "bind-alipay"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"ua": {
|
||||
"rules": [
|
||||
{
|
||||
"format": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"user_id": {
|
||||
"rules": [
|
||||
{
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"format": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"username": {
|
||||
"rules": [
|
||||
{
|
||||
"format": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"email": {
|
||||
"rules": [
|
||||
{
|
||||
"format": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"mobile": {
|
||||
"rules": [
|
||||
{
|
||||
"format": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"appid": {
|
||||
"rules": [
|
||||
{
|
||||
"format": "string"
|
||||
"format": "timestamp"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
const enumConverter = {
|
||||
"type_valuetotext": {
|
||||
"logout": "logout",
|
||||
"login": "login",
|
||||
"register": "register",
|
||||
"reset-pwd": "reset-pwd",
|
||||
"bind-mobile": "bind-mobile",
|
||||
"bind-weixin": "bind-weixin",
|
||||
"bind-qq": "bind-qq",
|
||||
"bind-apple": "bind-apple",
|
||||
"bind-alipay": "bind-alipay"
|
||||
}
|
||||
}
|
||||
|
||||
function filterToWhere(filter, command) {
|
||||
let where = {}
|
||||
for (let field in filter) {
|
||||
let { type, value } = filter[field]
|
||||
switch (type) {
|
||||
case "search":
|
||||
if (typeof value === 'string' && value.length) {
|
||||
where[field] = new RegExp(value)
|
||||
}
|
||||
break;
|
||||
case "select":
|
||||
if (value.length) {
|
||||
let selectValue = []
|
||||
for (let s of value) {
|
||||
selectValue.push(command.eq(s))
|
||||
}
|
||||
where[field] = command.or(selectValue)
|
||||
}
|
||||
break;
|
||||
case "range":
|
||||
if (value.length) {
|
||||
let gt = value[0]
|
||||
let lt = value[1]
|
||||
where[field] = command.and([command.gte(gt), command.lte(lt)])
|
||||
}
|
||||
break;
|
||||
case "date":
|
||||
if (value.length) {
|
||||
let [s, e] = value
|
||||
let startDate = new Date(s)
|
||||
let endDate = new Date(e)
|
||||
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
|
||||
}
|
||||
break;
|
||||
case "timestamp":
|
||||
if (value.length) {
|
||||
let [startDate, endDate] = value
|
||||
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return where
|
||||
}
|
||||
|
||||
export { validator, enumConverter, filterToWhere }
|
||||
|
||||
Reference in New Issue
Block a user