uni-stat-app-crash-logs.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. // 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
  2. const validator = {
  3. "appid": {
  4. "rules": [
  5. {
  6. "format": "string"
  7. }
  8. ]
  9. },
  10. "version": {
  11. "rules": [
  12. {
  13. "format": "string"
  14. }
  15. ]
  16. },
  17. "platform": {
  18. "rules": [
  19. {
  20. "format": "string"
  21. }
  22. ]
  23. },
  24. "channel": {
  25. "rules": [
  26. {
  27. "format": "string"
  28. }
  29. ]
  30. },
  31. "sdk_version": {
  32. "rules": [
  33. {
  34. "format": "string"
  35. }
  36. ]
  37. },
  38. "device_id": {
  39. "rules": [
  40. {
  41. "format": "string"
  42. }
  43. ]
  44. },
  45. "device_net": {
  46. "rules": [
  47. {
  48. "format": "string"
  49. }
  50. ]
  51. },
  52. "device_os": {
  53. "rules": [
  54. {
  55. "format": "string"
  56. }
  57. ]
  58. },
  59. "device_os_version": {
  60. "rules": [
  61. {
  62. "format": "string"
  63. }
  64. ]
  65. },
  66. "device_vendor": {
  67. "rules": [
  68. {
  69. "format": "string"
  70. }
  71. ]
  72. },
  73. "device_model": {
  74. "rules": [
  75. {
  76. "format": "string"
  77. }
  78. ]
  79. },
  80. "device_is_root": {
  81. "rules": [
  82. {
  83. "format": "int"
  84. }
  85. ]
  86. },
  87. "device_os_name": {
  88. "rules": [
  89. {
  90. "format": "string"
  91. }
  92. ]
  93. },
  94. "device_batt_level": {
  95. "rules": [
  96. {
  97. "format": "int"
  98. }
  99. ]
  100. },
  101. "device_batt_temp": {
  102. "rules": [
  103. {
  104. "format": "string"
  105. }
  106. ]
  107. },
  108. "device_memory_use_size": {
  109. "rules": [
  110. {
  111. "format": "int"
  112. }
  113. ]
  114. },
  115. "device_memory_total_size": {
  116. "rules": [
  117. {
  118. "format": "int"
  119. }
  120. ]
  121. },
  122. "device_disk_use_size": {
  123. "rules": [
  124. {
  125. "format": "int"
  126. }
  127. ]
  128. },
  129. "device_disk_total_size": {
  130. "rules": [
  131. {
  132. "format": "int"
  133. }
  134. ]
  135. },
  136. "device_abis": {
  137. "rules": [
  138. {
  139. "format": "string"
  140. }
  141. ]
  142. },
  143. "app_count": {
  144. "rules": [
  145. {
  146. "format": "int"
  147. }
  148. ]
  149. },
  150. "app_use_memory_size": {
  151. "rules": [
  152. {
  153. "format": "int"
  154. }
  155. ]
  156. },
  157. "app_webview_count": {
  158. "rules": [
  159. {
  160. "format": "int"
  161. }
  162. ]
  163. },
  164. "app_use_duration": {
  165. "rules": [
  166. {
  167. "format": "int"
  168. }
  169. ]
  170. },
  171. "app_run_fore": {
  172. "rules": [
  173. {
  174. "format": "int"
  175. }
  176. ]
  177. },
  178. "package_name": {
  179. "rules": [
  180. {
  181. "format": "string"
  182. }
  183. ]
  184. },
  185. "package_version": {
  186. "rules": [
  187. {
  188. "format": "string"
  189. }
  190. ]
  191. },
  192. "page_url": {
  193. "rules": [
  194. {
  195. "format": "string"
  196. }
  197. ]
  198. },
  199. "error_msg": {
  200. "rules": [
  201. {
  202. "format": "string"
  203. }
  204. ]
  205. },
  206. "create_time": {
  207. "rules": [
  208. {
  209. "format": "timestamp"
  210. }
  211. ]
  212. }
  213. }
  214. const enumConverter = {}
  215. function filterToWhere(filter, command) {
  216. let where = {}
  217. for (let field in filter) {
  218. let { type, value } = filter[field]
  219. switch (type) {
  220. case "search":
  221. if (typeof value === 'string' && value.length) {
  222. where[field] = new RegExp(value)
  223. }
  224. break;
  225. case "select":
  226. if (value.length) {
  227. let selectValue = []
  228. for (let s of value) {
  229. selectValue.push(command.eq(s))
  230. }
  231. where[field] = command.or(selectValue)
  232. }
  233. break;
  234. case "range":
  235. if (value.length) {
  236. let gt = value[0]
  237. let lt = value[1]
  238. where[field] = command.and([command.gte(gt), command.lte(lt)])
  239. }
  240. break;
  241. case "date":
  242. if (value.length) {
  243. let [s, e] = value
  244. let startDate = new Date(s)
  245. let endDate = new Date(e)
  246. where[field] = command.and([command.gte(startDate), command.lte(endDate)])
  247. }
  248. break;
  249. case "timestamp":
  250. if (value.length) {
  251. let [startDate, endDate] = value
  252. where[field] = command.and([command.gte(startDate), command.lte(endDate)])
  253. }
  254. break;
  255. }
  256. }
  257. return where
  258. }
  259. export { validator, enumConverter, filterToWhere }