mock平台

CheckCrossInstall.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import React from 'react';
  2. import { Alert } from 'antd';
  3. import PropTypes from 'prop-types';
  4. exports.initCrossRequest = function (fn) {
  5. let startTime = 0;
  6. let _crossRequest = setInterval(() => {
  7. startTime += 500;
  8. if (startTime > 5000) {
  9. clearInterval(_crossRequest);
  10. }
  11. if (window.crossRequest) {
  12. clearInterval(_crossRequest);
  13. fn(true);
  14. } else {
  15. fn(false);
  16. }
  17. }, 500);
  18. return _crossRequest;
  19. };
  20. CheckCrossInstall.propTypes = {
  21. hasPlugin: PropTypes.bool
  22. };
  23. function CheckCrossInstall(props) {
  24. const hasPlugin = props.hasPlugin;
  25. return (
  26. <div className={hasPlugin ? null : 'has-plugin'}>
  27. {hasPlugin ? (
  28. ''
  29. ) : (
  30. <Alert
  31. message={
  32. <div>
  33. 重要:当前的接口测试服务,需安装免费测试增强插件,仅支持 chrome
  34. 浏览器,选择下面任意一种安装方式:
  35. <div>
  36. <a
  37. target="blank"
  38. href="https://chrome.google.com/webstore/detail/cross-request/cmnlfmgbjmaciiopcgodlhpiklaghbok?hl=en-US"
  39. >
  40. [Google 商店获取(需翻墙]
  41. </a>
  42. </div>
  43. <div>
  44. <a target="blank" href="/api/interface/download_crx">
  45. {' '}
  46. [手动下载]{' '}
  47. </a>
  48. <span> zip 文件解压后将 crx 文件拖入到 chrome://extensions/ </span>
  49. <a target="blank" href="http://www.jianshu.com/p/12ca04c61fc6">
  50. {' '}
  51. [详细安装教程]{' '}
  52. </a>
  53. </div>
  54. </div>
  55. }
  56. type="warning"
  57. />
  58. )}
  59. </div>
  60. );
  61. }
  62. export default CheckCrossInstall;