user.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // 不使用 lowdb ,可以使用内存作为数据存储。不会持久化。
  2. const Mock = require('mockjs')
  3. function mock() {
  4. return Mock.mock({
  5. // 'id|1': ['@integer(1, 3)', '@id', '@increment'],
  6. 'id': '@guid',
  7. 'idCard': Mock.mock('@id'),
  8. 'token|1': [/[A-z0-9]{32}/, '@guid'],
  9. 'eFullName|1': ['@name', '@first @last'], // 英文姓名
  10. 'cFullName|1': ['@cname', '@cfirst@clast'], // 中文姓名
  11. email: '@email',
  12. ip: '@ip',
  13. region: '@region', // Random.region()
  14. province: '@province', // Random.province()
  15. city: ['@city', '@city(true)'], // Random.city( prefix? )
  16. county: ['@county', '@county(true)'], // Random.county( prefix? )
  17. zip: '@zip', // Random.zip()
  18. // Random.datetime( format? ) Random.date( format? ) Random.time( format? )
  19. datetime: '@datetime(yyyy yy y MM M dd d HH H hh h mm m ss s SS S A a T)',
  20. timestamp: +Mock.Random.date('T'),
  21. 'color|1': ['@color', '@hex', '@rgb', '@rgba', '@hsl'],
  22. cparagraph: '@cparagraph(1, 3)', // Random.cparagraph( min?, max? )
  23. csentence: '@csentence(1, 3)', // Random.csentence( min?, max? )
  24. ctitle: '@ctitle(8, 13)', // Random.ctitle( min?, max? ),
  25. account: '@cname',
  26. password: '@string("lower", 6)',
  27. title: '@title(5, 10)',
  28. forecast: '@float(0, 100, 2, 2)',
  29. importance: '@integer(1, 3)',
  30. 'status|1': ['published', 'draft'],
  31. comment_disabled: true,
  32. pageviews: '@integer(300, 5000)',
  33. absolutePath: '@/username @/token'
  34. })
  35. }
  36. module.exports = Array.from(new Array(2), () => mock())