user.ts 3.06 KB
Newer Older
nikogu's avatar
nikogu committed
1
// 代码中会兼容本地 service mock 以及部署站点的静态数据
愚道's avatar
愚道 committed
2
export default {
3 4
  // 支持值为 Object 和 Array
  'GET /api/currentUser': {
陈帅's avatar
陈帅 committed
5
    name: 'Serati Ma',
Yu's avatar
Yu committed
6
    avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
陈帅's avatar
陈帅 committed
7 8 9 10 11 12 13 14 15
    userid: '00000001',
    email: 'antdesign@alipay.com',
    signature: '海纳百川,有容乃大',
    title: '交互专家',
    group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
    tags: [
      {
        key: '0',
        label: '很有想法的',
16
      },
陈帅's avatar
陈帅 committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
      {
        key: '1',
        label: '专注设计',
      },
      {
        key: '2',
        label: '辣~',
      },
      {
        key: '3',
        label: '大长腿',
      },
      {
        key: '4',
        label: '川妹子',
      },
      {
        key: '5',
        label: '海纳百川',
      },
    ],
    notifyCount: 12,
39
    unreadCount: 11,
陈帅's avatar
陈帅 committed
40 41 42 43 44 45 46 47 48
    country: 'China',
    geographic: {
      province: {
        label: '浙江省',
        key: '330000',
      },
      city: {
        label: '杭州市',
        key: '330100',
陈帅's avatar
陈帅 committed
49
      },
50
    },
陈帅's avatar
陈帅 committed
51 52
    address: '西湖区工专路 77 号',
    phone: '0752-268888888',
53 54
  },
  // GET POST 可省略
陈帅's avatar
陈帅 committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
  'GET /api/users': [
    {
      key: '1',
      name: 'John Brown',
      age: 32,
      address: 'New York No. 1 Lake Park',
    },
    {
      key: '2',
      name: 'Jim Green',
      age: 42,
      address: 'London No. 1 Lake Park',
    },
    {
      key: '3',
      name: 'Joe Black',
      age: 32,
      address: 'Sidney No. 1 Lake Park',
    },
  ],
75
  'POST /api/login/account': (req, res) => {
afc163's avatar
afc163 committed
76
    const { password, userName, type } = req.body;
afc163's avatar
afc163 committed
77
    if (password === 'ant.design' && userName === 'admin') {
ddcat1115's avatar
ddcat1115 committed
78 79 80
      res.send({
        status: 'ok',
        type,
陈帅's avatar
陈帅 committed
81
        currentAuthority: 'admin',
ddcat1115's avatar
ddcat1115 committed
82
      });
陈帅's avatar
陈帅 committed
83
      return;
ddcat1115's avatar
ddcat1115 committed
84
    }
afc163's avatar
afc163 committed
85
    if (password === 'ant.design' && userName === 'user') {
ddcat1115's avatar
ddcat1115 committed
86 87 88
      res.send({
        status: 'ok',
        type,
陈帅's avatar
陈帅 committed
89
        currentAuthority: 'user',
ddcat1115's avatar
ddcat1115 committed
90
      });
陈帅's avatar
陈帅 committed
91
      return;
ddcat1115's avatar
ddcat1115 committed
92
    }
afc163's avatar
afc163 committed
93
    res.send({
ddcat1115's avatar
ddcat1115 committed
94
      status: 'error',
afc163's avatar
afc163 committed
95
      type,
陈帅's avatar
陈帅 committed
96
      currentAuthority: 'guest',
afc163's avatar
afc163 committed
97
    });
98 99
  },
  'POST /api/register': (req, res) => {
ddcat1115's avatar
ddcat1115 committed
100
    res.send({ status: 'ok', currentAuthority: 'user' });
101
  },
陈帅's avatar
陈帅 committed
102 103
  'GET /api/500': (req, res) => {
    res.status(500).send({
陈帅's avatar
陈帅 committed
104 105 106 107 108
      timestamp: 1513932555104,
      status: 500,
      error: 'error',
      message: 'error',
      path: '/base/category/list',
陈帅's avatar
陈帅 committed
109 110 111 112
    });
  },
  'GET /api/404': (req, res) => {
    res.status(404).send({
陈帅's avatar
陈帅 committed
113 114 115 116 117
      timestamp: 1513932643431,
      status: 404,
      error: 'Not Found',
      message: 'No message available',
      path: '/base/category/list/2121212',
陈帅's avatar
陈帅 committed
118 119 120 121
    });
  },
  'GET /api/403': (req, res) => {
    res.status(403).send({
陈帅's avatar
陈帅 committed
122 123 124 125 126
      timestamp: 1513932555104,
      status: 403,
      error: 'Unauthorized',
      message: 'Unauthorized',
      path: '/base/category/list',
陈帅's avatar
陈帅 committed
127 128
    });
  },
129 130
  'GET /api/401': (req, res) => {
    res.status(401).send({
陈帅's avatar
陈帅 committed
131 132 133 134 135
      timestamp: 1513932555104,
      status: 401,
      error: 'Unauthorized',
      message: 'Unauthorized',
      path: '/base/category/list',
136 137
    });
  },
138
};