index.ts 410 B

1234567891011121314151617
  1. import Mock from 'mockjs-x'
  2. Mock.setup({
  3. timeout: '100-200'
  4. })
  5. // 遍历目录所有ts文件
  6. const files = require.context('.', false, /\.ts$/);
  7. files.keys().forEach((key) => {
  8. if (key !== './index.ts') {
  9. const list = files(key).default;
  10. list.forEach((req: { [key: string]: unknown }) => {
  11. Mock.mock(RegExp(req.url + '.*'), req.type, req.response);
  12. })
  13. }
  14. })