dsbridge.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else {
  7. var a = factory();
  8. for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
  9. }
  10. })(this, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // identity function for calling harmony imports with the correct context
  47. /******/ __webpack_require__.i = function(value) { return value; };
  48. /******/
  49. /******/ // define getter function for harmony exports
  50. /******/ __webpack_require__.d = function(exports, name, getter) {
  51. /******/ if(!__webpack_require__.o(exports, name)) {
  52. /******/ Object.defineProperty(exports, name, {
  53. /******/ configurable: false,
  54. /******/ enumerable: true,
  55. /******/ get: getter
  56. /******/ });
  57. /******/ }
  58. /******/ };
  59. /******/
  60. /******/ // getDefaultExport function for compatibility with non-harmony modules
  61. /******/ __webpack_require__.n = function(module) {
  62. /******/ var getter = module && module.__esModule ?
  63. /******/ function getDefault() { return module['default']; } :
  64. /******/ function getModuleExports() { return module; };
  65. /******/ __webpack_require__.d(getter, 'a', getter);
  66. /******/ return getter;
  67. /******/ };
  68. /******/
  69. /******/ // Object.prototype.hasOwnProperty.call
  70. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  71. /******/
  72. /******/ // __webpack_public_path__
  73. /******/ __webpack_require__.p = "";
  74. /******/
  75. /******/ // Load entry module and return exports
  76. /******/ return __webpack_require__(__webpack_require__.s = 8);
  77. /******/ })
  78. /************************************************************************/
  79. /******/ ({
  80. /***/ 3:
  81. /***/ (function(module, exports, __webpack_require__) {
  82. "use strict";
  83. /**
  84. * Add base64 tag, like data:image/img;base64
  85. * @param responseData
  86. */
  87. module.exports = function handleImgBase64Data(responseData) {
  88. var headers = responseData.headers || {};
  89. var contentType = (headers["content-type"] || headers["Content-Type"] || "").toString().toLowerCase();
  90. if (contentType.indexOf("image") !== -1 && responseData.responseText.indexOf("base64") === -1) {
  91. responseData.responseText = "data:" + contentType + ";base64," + responseData.responseText;
  92. }
  93. };
  94. /***/ }),
  95. /***/ 8:
  96. /***/ (function(module, exports, __webpack_require__) {
  97. function KEEP(_,cb){cb();}
  98. "use strict";
  99. var handleImgBase64Data = __webpack_require__(3);
  100. var adapter = void 0;
  101. if (window.dsBridge) {
  102. adapter = function adapter(request, responseCallBack) {
  103. dsBridge.call("onAjaxRequest", request, function (responseData) {
  104. responseData = JSON.parse(responseData);
  105. if (request.responseType === "stream") {
  106. handleImgBase64Data(responseData);
  107. }
  108. responseCallBack(responseData);
  109. });
  110. };
  111. } else {
  112. console.error("dsBridge is not exist!");
  113. }
  114. //build环境定义全局变量
  115. ;
  116. module.exports = adapter;
  117. /***/ })
  118. /******/ });
  119. });