uniapp-request-sdk 1.4.0 → 1.4.3

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
@@ -35,6 +35,10 @@ function _toPropertyKey(arg) {
35
35
  return typeof key === "symbol" ? key : String(key);
36
36
  }
37
37
 
38
+ /** 客户端交互内置事件名称 */
39
+ var EVENT_NAME = {
40
+ LOGOUT: 'logout'
41
+ };
38
42
  function requestPromise(options) {
39
43
  return new Promise(function (res, rej) {
40
44
  uni.request(Object.assign(Object.assign({}, options), {
@@ -141,6 +145,7 @@ var UniRequest = /*#__PURE__*/function () {
141
145
  url: url,
142
146
  timeout: params.timeout || _this3.timeout
143
147
  })).then(function (resData) {
148
+ console.log(321312321, resData);
144
149
  var statusCode = resData.statusCode,
145
150
  data = resData.data;
146
151
  if (statusCode === 200) {
@@ -149,7 +154,8 @@ var UniRequest = /*#__PURE__*/function () {
149
154
  } else {
150
155
  _this3.rejectHandler(rej, resData);
151
156
  }
152
- } else if (statusCode === 403 && !requestedToken) {
157
+ /** 针对小网关进行的处理,历史遗留问题,需要兼容 */
158
+ } else if ('403' === statusCode && !requestedToken) {
153
159
  // #ifndef H5
154
160
  (_this3.getTokenFun ? _this3.getTokenFun() : getToken(_this3.tokenEventName)).then(function (token) {
155
161
  _this3.token = token;
@@ -167,6 +173,12 @@ var UniRequest = /*#__PURE__*/function () {
167
173
  // #ifdef H5
168
174
  _this3.rejectHandler(rej, resData);
169
175
  // #endif
176
+ /** 最新无权限处理方案,直接调用客户端logout事件,退出到登录页 */
177
+ } else if ('401' === statusCode) {
178
+ _this3.rejectHandler(rej, resData);
179
+ uni.sendNativeEvent(EVENT_NAME.LOGOUT, {}, function () {
180
+ console.log('用户无权限,调用logout事件,退出到登录页');
181
+ });
170
182
  } else {
171
183
  if (_this3.maxRetryCount > retryCount) {
172
184
  delayRetryFcuntion();
package/dist/index.umd.js CHANGED
@@ -41,6 +41,10 @@
41
41
  return typeof key === "symbol" ? key : String(key);
42
42
  }
43
43
 
44
+ /** 客户端交互内置事件名称 */
45
+ var EVENT_NAME = {
46
+ LOGOUT: 'logout'
47
+ };
44
48
  function requestPromise(options) {
45
49
  return new Promise(function (res, rej) {
46
50
  uni.request(Object.assign(Object.assign({}, options), {
@@ -147,6 +151,7 @@
147
151
  url: url,
148
152
  timeout: params.timeout || _this3.timeout
149
153
  })).then(function (resData) {
154
+ console.log(321312321, resData);
150
155
  var statusCode = resData.statusCode,
151
156
  data = resData.data;
152
157
  if (statusCode === 200) {
@@ -155,7 +160,8 @@
155
160
  } else {
156
161
  _this3.rejectHandler(rej, resData);
157
162
  }
158
- } else if (statusCode === 403 && !requestedToken) {
163
+ /** 针对小网关进行的处理,历史遗留问题,需要兼容 */
164
+ } else if ('403' === statusCode && !requestedToken) {
159
165
  // #ifndef H5
160
166
  (_this3.getTokenFun ? _this3.getTokenFun() : getToken(_this3.tokenEventName)).then(function (token) {
161
167
  _this3.token = token;
@@ -173,6 +179,12 @@
173
179
  // #ifdef H5
174
180
  _this3.rejectHandler(rej, resData);
175
181
  // #endif
182
+ /** 最新无权限处理方案,直接调用客户端logout事件,退出到登录页 */
183
+ } else if ('401' === statusCode) {
184
+ _this3.rejectHandler(rej, resData);
185
+ uni.sendNativeEvent(EVENT_NAME.LOGOUT, {}, function () {
186
+ console.log('用户无权限,调用logout事件,退出到登录页');
187
+ });
176
188
  } else {
177
189
  if (_this3.maxRetryCount > retryCount) {
178
190
  delayRetryFcuntion();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uniapp-request-sdk",
3
- "version": "1.4.0",
3
+ "version": "1.4.3",
4
4
  "description": "用于uniapp小程序的请求库的sdk",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": " dist/index.esm.js",