dsbridge.js 3.9 KB

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