_mock.ts 1.65 KB
Newer Older
1 2 3
import city from './geographic/city.json';
import province from './geographic/province.json';

陈帅's avatar
陈帅 committed
4
function getProvince(req: any, res: { json: (arg0: { name: string; id: string }[]) => void }) {
5 6 7
  return res.json(province);
}

陈帅's avatar
陈帅 committed
8 9 10 11
function getCity(
  req: { params: { province: string | number } },
  res: { json: (arg: any) => void }
) {
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 58 59 60 61 62 63 64 65 66 67 68 69
  return res.json(city[req.params.province]);
}
// 代码中会兼容本地 service mock 以及部署站点的静态数据
export default {
  // 支持值为 Object 和 Array
  'GET /api/BLOCK_NAME/currentUser': {
    name: 'Serati Ma',
    avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
    userid: '00000001',
    email: 'antdesign@alipay.com',
    signature: '海纳百川,有容乃大',
    title: '交互专家',
    group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
    tags: [
      {
        key: '0',
        label: '很有想法的',
      },
      {
        key: '1',
        label: '专注设计',
      },
      {
        key: '2',
        label: '辣~',
      },
      {
        key: '3',
        label: '大长腿',
      },
      {
        key: '4',
        label: '川妹子',
      },
      {
        key: '5',
        label: '海纳百川',
      },
    ],
    notifyCount: 12,
    unreadCount: 11,
    country: 'China',
    geographic: {
      province: {
        label: '浙江省',
        key: '330000',
      },
      city: {
        label: '杭州市',
        key: '330100',
      },
    },
    address: '西湖区工专路 77 号',
    phone: '0752-268888888',
  },
  'GET /api/BLOCK_NAME/province': getProvince,
  'GET /api/BLOCK_NAME/city/:province': getCity,
};