uniapp-request-sdk 1.4.3 → 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -131,13 +131,11 @@ var UniRequest = /*#__PURE__*/function () {
131
131
  return new Promise(function (res, rej) {
132
132
  var retryFucntion = function retryFucntion() {
133
133
  /** 因为token需要动态获取,因此放入这里 */
134
- // #ifndef H5
135
134
  header[_this3.tokenHeader] = "".concat(_this3.tokenPrefix).concat(_this3.token);
136
- // #endif
137
135
  /** 针对h5调试的时候,因为塞入cookie是不安全的,因此无需塞入cookie,使用登录页后,后端塞入的cookie */
138
136
  // #ifdef H5
139
- if (!['cookie'].includes(_this3.tokenHeader)) {
140
- header[_this3.tokenHeader] = "".concat(_this3.tokenPrefix).concat(_this3.token);
137
+ if (_this3.tokenHeader === 'cookie') {
138
+ delete header[_this3.tokenHeader];
141
139
  }
142
140
  // #endif
143
141
  callbackPromise(Object.assign(Object.assign({}, params), {
@@ -145,7 +143,6 @@ var UniRequest = /*#__PURE__*/function () {
145
143
  url: url,
146
144
  timeout: params.timeout || _this3.timeout
147
145
  })).then(function (resData) {
148
- console.log(321312321, resData);
149
146
  var statusCode = resData.statusCode,
150
147
  data = resData.data;
151
148
  if (statusCode === 200) {
@@ -155,7 +152,7 @@ var UniRequest = /*#__PURE__*/function () {
155
152
  _this3.rejectHandler(rej, resData);
156
153
  }
157
154
  /** 针对小网关进行的处理,历史遗留问题,需要兼容 */
158
- } else if ('403' === statusCode && !requestedToken) {
155
+ } else if (403 === statusCode && !requestedToken) {
159
156
  // #ifndef H5
160
157
  (_this3.getTokenFun ? _this3.getTokenFun() : getToken(_this3.tokenEventName)).then(function (token) {
161
158
  _this3.token = token;
@@ -174,7 +171,7 @@ var UniRequest = /*#__PURE__*/function () {
174
171
  _this3.rejectHandler(rej, resData);
175
172
  // #endif
176
173
  /** 最新无权限处理方案,直接调用客户端logout事件,退出到登录页 */
177
- } else if ('401' === statusCode) {
174
+ } else if (401 === statusCode) {
178
175
  _this3.rejectHandler(rej, resData);
179
176
  uni.sendNativeEvent(EVENT_NAME.LOGOUT, {}, function () {
180
177
  console.log('用户无权限,调用logout事件,退出到登录页');
package/dist/index.umd.js CHANGED
@@ -137,13 +137,11 @@
137
137
  return new Promise(function (res, rej) {
138
138
  var retryFucntion = function retryFucntion() {
139
139
  /** 因为token需要动态获取,因此放入这里 */
140
- // #ifndef H5
141
140
  header[_this3.tokenHeader] = "".concat(_this3.tokenPrefix).concat(_this3.token);
142
- // #endif
143
141
  /** 针对h5调试的时候,因为塞入cookie是不安全的,因此无需塞入cookie,使用登录页后,后端塞入的cookie */
144
142
  // #ifdef H5
145
- if (!['cookie'].includes(_this3.tokenHeader)) {
146
- header[_this3.tokenHeader] = "".concat(_this3.tokenPrefix).concat(_this3.token);
143
+ if (_this3.tokenHeader === 'cookie') {
144
+ delete header[_this3.tokenHeader];
147
145
  }
148
146
  // #endif
149
147
  callbackPromise(Object.assign(Object.assign({}, params), {
@@ -151,7 +149,6 @@
151
149
  url: url,
152
150
  timeout: params.timeout || _this3.timeout
153
151
  })).then(function (resData) {
154
- console.log(321312321, resData);
155
152
  var statusCode = resData.statusCode,
156
153
  data = resData.data;
157
154
  if (statusCode === 200) {
@@ -161,7 +158,7 @@
161
158
  _this3.rejectHandler(rej, resData);
162
159
  }
163
160
  /** 针对小网关进行的处理,历史遗留问题,需要兼容 */
164
- } else if ('403' === statusCode && !requestedToken) {
161
+ } else if (403 === statusCode && !requestedToken) {
165
162
  // #ifndef H5
166
163
  (_this3.getTokenFun ? _this3.getTokenFun() : getToken(_this3.tokenEventName)).then(function (token) {
167
164
  _this3.token = token;
@@ -180,7 +177,7 @@
180
177
  _this3.rejectHandler(rej, resData);
181
178
  // #endif
182
179
  /** 最新无权限处理方案,直接调用客户端logout事件,退出到登录页 */
183
- } else if ('401' === statusCode) {
180
+ } else if (401 === statusCode) {
184
181
  _this3.rejectHandler(rej, resData);
185
182
  uni.sendNativeEvent(EVENT_NAME.LOGOUT, {}, function () {
186
183
  console.log('用户无权限,调用logout事件,退出到登录页');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uniapp-request-sdk",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "description": "用于uniapp小程序的请求库的sdk",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": " dist/index.esm.js",