uniapp-request-sdk 1.4.0 → 1.4.1

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), {
@@ -149,7 +153,8 @@ var UniRequest = /*#__PURE__*/function () {
149
153
  } else {
150
154
  _this3.rejectHandler(rej, resData);
151
155
  }
152
- } else if (statusCode === 403 && !requestedToken) {
156
+ /** 针对小网关进行的处理,历史遗留问题,需要兼容 */
157
+ } else if ('403' === statusCode && !requestedToken) {
153
158
  // #ifndef H5
154
159
  (_this3.getTokenFun ? _this3.getTokenFun() : getToken(_this3.tokenEventName)).then(function (token) {
155
160
  _this3.token = token;
@@ -167,6 +172,12 @@ var UniRequest = /*#__PURE__*/function () {
167
172
  // #ifdef H5
168
173
  _this3.rejectHandler(rej, resData);
169
174
  // #endif
175
+ /** 最新无权限处理方案,直接调用客户端logout事件,退出到登录页 */
176
+ } else if ('401' === statusCode) {
177
+ _this3.rejectHandler(rej, resData);
178
+ uni.sendNativeEvent(EVENT_NAME.LOGOUT, {}, function () {
179
+ console.log('用户无权限,调用logout事件,退出到登录页');
180
+ });
170
181
  } else {
171
182
  if (_this3.maxRetryCount > retryCount) {
172
183
  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), {
@@ -155,7 +159,8 @@
155
159
  } else {
156
160
  _this3.rejectHandler(rej, resData);
157
161
  }
158
- } else if (statusCode === 403 && !requestedToken) {
162
+ /** 针对小网关进行的处理,历史遗留问题,需要兼容 */
163
+ } else if ('403' === statusCode && !requestedToken) {
159
164
  // #ifndef H5
160
165
  (_this3.getTokenFun ? _this3.getTokenFun() : getToken(_this3.tokenEventName)).then(function (token) {
161
166
  _this3.token = token;
@@ -173,6 +178,12 @@
173
178
  // #ifdef H5
174
179
  _this3.rejectHandler(rej, resData);
175
180
  // #endif
181
+ /** 最新无权限处理方案,直接调用客户端logout事件,退出到登录页 */
182
+ } else if ('401' === statusCode) {
183
+ _this3.rejectHandler(rej, resData);
184
+ uni.sendNativeEvent(EVENT_NAME.LOGOUT, {}, function () {
185
+ console.log('用户无权限,调用logout事件,退出到登录页');
186
+ });
176
187
  } else {
177
188
  if (_this3.maxRetryCount > retryCount) {
178
189
  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.1",
4
4
  "description": "用于uniapp小程序的请求库的sdk",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": " dist/index.esm.js",