loulijun2021
2022-09-01 99a010f21d278498bafd248217c584e101db2d8f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import dayjs from 'dayjs'
import Mock from 'mockjs'
 
const colorList = ['(252, 105, 100)', '(247, 167, 71)', '(116, 202, 90)', '(83, 186, 241)', '(208, 142, 2231)']
const nameList = '希望号,飞翼号,光明号,窥探号,力神号,警官号,闪电流星号,博士号,霹雳火神号,狙击手号,希望之光号,南海忍者号,火速E3号,山神号,安全卫士号,铁锤号,寿星号,星星号,罗曼斯卡,欲望号,霹雳雷电号,消防号,欧洲之星号'.split(',')
 
const typeList = '🚅,🚈,🚄'.split(',')
 
const Random = Mock.Random
var template = {
  'id': () => 'JHR' + Random.natural(100, 999) + Random.character('upper') + Random.character('upper'),
  'name': () => Random.pick(nameList),
  'type': () => Random.pick(typeList),
  'colorPair': () => {
    const a = 'rgb' + Random.pick(colorList)
    return {
      dark: a.replace(')', ',0.8)'),
      light: a.replace(')', ',0.1)')
    }
  },
  'speed': () => Random.natural(0, 200),
  'gtArray': () => {
    const temp = []
    let i = 0
    const j = Random.natural(1, 9)
    let tempStart = dayjs().subtract(12, 'hour')
    let tempEnd = dayjs().subtract(12, 'hour')
 
    while (i < j) {
      tempStart = tempEnd.add(Random.natural(1, 5), 'hour')
      tempEnd = tempStart.add(Random.natural(1, 5), 'hour')
      temp.push({
        'id': 'D' + Random.natural(1000, 9999),
        'passenger': Random.natural(10, 200),
        'start': tempStart.toString(),
        'end': tempEnd.toString()
      })
 
      i++
    }
    return temp
  }
 
}
 
function mockDatas(nums) {
  const datas = []
  for (let i = 0,
    j = Random.natural(nums, nums); i < j; i++) {
    datas.push(Mock.mock(template))
  }
  return datas
}
 
export {
  mockDatas
}