林旭祥 před 6 měsíci
rodič
revize
f7dd368227
3 změnil soubory, kde provedl 40 přidání a 20 odebrání
  1. 6 8
      src/api/request.ts
  2. 11 0
      src/assets/styles/index.scss
  3. 23 12
      src/views/gesture/index.vue

+ 6 - 8
src/api/request.ts

@@ -21,14 +21,13 @@ service.interceptors.request.use(
     if (!token && Boolean(config.headers['auth']) == true) {
       delete config.headers['auth'];
       const message = '缺少凭证,请重新登录!';
-      localStorage.clear();
       let deviceid = localStorage.getItem('deviceid');
-      if (deviceid && router.currentRoute.value.path != '/login/qrcode') {
+      if ((router.currentRoute.value.path == '/gesture') || (deviceid && router.currentRoute.value.path != '/login/qrcode')) {
         router.push('/login/qrcode');
-      }
-      if (deviceid == undefined && router.currentRoute.value.path != '/login') {
+      }else{
         router.push('/login');
       }
+      localStorage.clear();
       ElMessage({ message: message, type: 'error', duration: 5 * 1000 });
       return Promise.reject(message);
     }
@@ -62,14 +61,13 @@ service.interceptors.response.use(
     const code = res.data.code;
     const message = res.data.message;
     if (code === 401) {
-      localStorage.clear();
       let deviceid = localStorage.getItem('deviceid');
-      if (deviceid && router.currentRoute.value.path != '/login/qrcode') {
+      if ((router.currentRoute.value.path == '/gesture') || (deviceid && router.currentRoute.value.path != '/login/qrcode')) {
         router.push('/login/qrcode');
-      }
-      if (deviceid == undefined && router.currentRoute.value.path != '/login') {
+      }else{
         router.push('/login');
       }
+      localStorage.clear();
       ElMessage({ message: message, type: 'error', duration: 5 * 1000 });
       return Promise.reject('凭证已过期,请重新登录!');
     } else {

+ 11 - 0
src/assets/styles/index.scss

@@ -50,6 +50,17 @@ ul li {
   }
 }
 
+.el-message-icon--success,
+.el-message--warning,
+.el-message-icon--error {
+  .el-message__content {
+    font-size: 1.5rem;
+  }
+  .el-message__icon {
+    font-size: 1.5rem;
+  }
+}
+
 .messageBoxClass {
   background: radial-gradient(96% 96% at 2% 32%, #ffffff 0%, #fcfdfd 54%, #e1e4e7 100%);
   width: 40% !important;

+ 23 - 12
src/views/gesture/index.vue

@@ -197,7 +197,7 @@ const getLogout = async () => {
 */
 const getTips = () => {
   getClearTimer('nextItem');
-  let myTime = 4000;
+  let myTime = 10000;
   let num = 0;
   timerManager.value.nextItem = setInterval(() => {
     if (router.currentRoute.value.path == '/gesture') {
@@ -244,22 +244,33 @@ const getErweima = () => {
 
 onBeforeMount(() => {
   //加载设备WS
-  handWs((e: any) => {
+  handWs(async (e: any) => {
     //发送设备
     if (e?.wksid) {
       console.log("e.wksid", e.wksid)
       sid.value = e.wksid;
       listenWs.value = true;
-      let deviceid = localStorage.getItem("deviceid");
-      startDevice({ deviceid: deviceid })
-      timerManager.value.deviceid = setInterval(() => {
-        if (device_info.value.handcontroller_id == undefined) {
-          proxy?.$modal.msgWarning(`获取项目信息失败,正尝试重新获取,请稍等!`)
-          startDevice({ deviceid: deviceid })
-        } else {
-          getClearTimer("deviceid");
-        }
-      }, 10000)
+      let deviceid = localStorage.getItem("deviceid") || '';
+      if (deviceid) {
+        startDevice({ deviceid: deviceid })
+        timerManager.value.deviceid = setInterval(() => {
+          if (device_info.value.handcontroller_id == undefined) {
+            //刷新
+            window.location.reload()
+          } else {
+            getClearTimer("deviceid");
+          }
+        }, 10000)
+      } else {
+        proxy?.$modal.msgError(`缺少设备信息请重新登录!`);
+        await proxy?.$http.common.logout({}).then((res: any) => {
+        });
+        proxy?.$modal?.closeLoading()
+        //清空缓存
+        localStorage.clear();
+        //跳转
+        router.push({ path: '/login/qrcode' });
+      }
     }
     if (listenWs.value == false) {
       return false;