inleft
2022-02-23 81c155e7e00b83f06e6486a8d904428a44b8b275
commit | author | age
f9c38e 1
I 2 function isIE() {
3     const bw = window.navigator.userAgent
4     const compare = (s) => bw.indexOf(s) >= 0
5     const ie11 = (() => 'ActiveXObject' in window)()
6     return compare('MSIE') || ie11
7 }
8 // 判断环境不是 prod 或者 preview 是 true 时,加载 mock 服务
9 if (process.env.NODE_ENV !== 'production' || process.env.VUE_APP_PREVIEW === 'true') {
10     if (isIE()) {
11         console.error('[antd-pro] ERROR: `mockjs` NOT SUPPORT `IE` PLEASE DO NOT USE IN `production` ENV.')
12     }
13     // 使用同步加载依赖
14     // 防止 vuex 中的 GetInfo 早于 mock 运行,导致无法 mock 请求返回结果
15     console.log('[antd-pro] mock mounting')
16     const Mock = require('mockjs2')
17     // require('./services/auth')
18     // require('./services/user')
19     // require('./services/manage')
20     // require('./services/other')
21     // require('./services/tagCloud')
81c155 22     // require('./test/article.js')
f9c38e 23
I 24     Mock.setup({
25         timeout: 800 // setter delay time
26     })
27     console.log('[antd-pro] mock mounted')
28 }