@kengic/uni 0.4.0 → 0.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.
@@ -101,7 +101,6 @@ function handleError<T = any>(
101
101
  ) {
102
102
  // @ts-ignore
103
103
  if (response.errMsg === 'request:fail') {
104
- // store.dispatch('logout');
105
104
  return;
106
105
  }
107
106
 
@@ -109,7 +108,6 @@ function handleError<T = any>(
109
108
  // @ts-ignore
110
109
  const message = (response.data as any)?.message || response?.errMsg || '请求出错';
111
110
  uni.showToast({ title: message, icon: 'none', duration: 3000 });
112
- } else {
113
111
  }
114
112
 
115
113
  reject(response);
@@ -145,6 +143,7 @@ const _httpClient: IHttpClient = {
145
143
  }
146
144
 
147
145
  uni.request({
146
+ ...(options ?? {}),
148
147
  method,
149
148
  url: _url,
150
149
  header: options?.header ?? {},
@@ -62,13 +62,26 @@ export const useAppStore = defineStore('app', {
62
62
 
63
63
  /**
64
64
  * 退出登录.
65
+ * @param param.isRequest 是否请求后端退出登录接口, 默认为 true.
65
66
  */
66
- async logout() {
67
- if (this.getToken) {
68
- await API.WMS.LoginController.Logout({}, { header: { 'X-Access-Token': this.getToken } });
69
- }
67
+ async logout(param: { isRequest?: boolean } = {}) {
68
+ const { isRequest = true } = param;
69
+
70
70
  this.setToken('');
71
71
  this.setUser(null);
72
+
73
+ if (isRequest && this.getToken) {
74
+ API.WMS.LoginController.Logout(
75
+ {},
76
+ {
77
+ header: { 'X-Access-Token': this.getToken },
78
+ timeout: 5 * 1000,
79
+ },
80
+ ).catch(() => {
81
+ // 调用退出登录接口失败, 但是并不影响前端退出,
82
+ });
83
+ }
84
+
72
85
  uni.reLaunch({ url: '/pages/login/Login' });
73
86
  },
74
87
 
package/dist/util/kg.ts CHANGED
@@ -90,6 +90,10 @@ export class Kg {
90
90
 
91
91
  const appStore = useAppStore();
92
92
 
93
+ if (!appStore.getToken) {
94
+ return false;
95
+ }
96
+
93
97
  if (isRespectCancel && appStore.getIsUpdateCancel) {
94
98
  return false;
95
99
  }
@@ -98,7 +102,7 @@ export class Kg {
98
102
  const oldVersion: number = Number(plus.runtime.versionCode);
99
103
 
100
104
  try {
101
- const newVersion = await API.WMS.CommonController.GetLatestApkVersion();
105
+ const newVersion = await API.WMS.CommonController.GetLatestApkVersion({}, { timeout: 5 * 1000 });
102
106
 
103
107
  // 无新版本
104
108
  if (newVersion === 0 || oldVersion >= newVersion) {
@@ -112,7 +116,7 @@ export class Kg {
112
116
  appStore.openKgUpdatePopup(newVersion);
113
117
  return true;
114
118
  } catch (e) {
115
- console.error(e);
119
+ // 接口请求失败
116
120
  }
117
121
 
118
122
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kengic/uni",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "scripts": {
5
5
  "build": "npm run switch-node-version && rimraf dist && vue-tsc && vite build",
6
6
  "------ -------------------------------------------": "",