| | |
| | | static inDevMod = (() => { |
| | | // 网页 |
| | | if (process.env.TARO_ENV === 'h5') { |
| | | const reg = new RegExp('(^|&)query=([^&]*)(&|$)', 'i'); |
| | | const match = window.location.search.substr(1).match(reg); |
| | | const param = match !== null ? decodeURIComponent(match[2]) : null; |
| | | // 当处于 mock 请求模式,视为本地开发 |
| | | if (Tools.getUrlParam('query') === 'mock') { |
| | | if (param === 'mock') { |
| | | return true; |
| | | } |
| | | // 强制 real 请求,可在本地使用真实请求 |
| | | if (Tools.getUrlParam('query') === 'real') { |
| | | if (param === 'real') { |
| | | return false; |
| | | } |
| | | // 当没有 url 指定时,只有内网 ip 和 33** 的端口号,视为本地开发模式 |
| | | return /^(192|127|localhost).*?:33\d{2}$/i.test(window.location.host); |
| | | // 当没有 url 指定时,只有内网 ip 和 33**/35** 的端口号,视为本地开发模式 |
| | | return /^(192|127|localhost).*?:3[35]\d{2}$/i.test(window.location.host); |
| | | } |
| | | // 小程序 |
| | | else if (process.env.TARO_ENV === 'weapp') { |