t-comm
Version:
专业、稳定、纯粹的工具库
38 lines (31 loc) • 1.88 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
var _createClass = require('@babel/runtime/helpers/createClass');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
/**
* Cocos 端响应登录态拦截器
*
* 后台在响应 header `logininfo` 中下发登录态 JSON 字符串,本拦截器解析并写入 storage。
* 后续请求的 CocosLoginInfoParamInterceptor 会把它塞进 body.login_info。
*
* 参考 pmd-npm/packages/business/src/network/interceptor/response/cocos/cocosLoginInfoInterceptor.ts
*/
var CocosLoginInfoResponseInterceptor = /*#__PURE__*/function () {
function CocosLoginInfoResponseInterceptor(options) {
_classCallCheck__default["default"](this, CocosLoginInfoResponseInterceptor);
this.options = options;
}
return _createClass__default["default"](CocosLoginInfoResponseInterceptor, [{
key: "interceptor",
value: function interceptor(param) {
var _a, _b, _c, _d, _e, _f;
// 大小写不敏感取 logininfo
((_b = (_a = param.response) === null || _a === void 0 ? void 0 : _a.getHeader) === null || _b === void 0 ? void 0 : _b.call(_a, 'logininfo')) || ((_d = (_c = param.response) === null || _c === void 0 ? void 0 : _c.getHeader) === null || _d === void 0 ? void 0 : _d.call(_c, 'Logininfo')) || ((_f = (_e = param.response) === null || _e === void 0 ? void 0 : _e.getHeader) === null || _f === void 0 ? void 0 : _f.call(_e, 'LoginInfo'));
return [false, param];
}
}]);
}();
exports.CocosLoginInfoResponseInterceptor = CocosLoginInfoResponseInterceptor;