natasha преди 1 година
родител
ревизия
38c7b1004a
променени са 1 файла, в които са добавени 30 реда и са изтрити 42 реда
  1. 30 42
      src/App.vue

+ 30 - 42
src/App.vue

@@ -6,88 +6,76 @@
     <router-view v-if="!$route.meta.keepAlive" />
     <router-view v-if="!$route.meta.keepAlive" />
     <div class="userAgentTips" v-if="userAgentTipShow">
     <div class="userAgentTips" v-if="userAgentTipShow">
       <img src="./assets/userAgentWarning.png" width="32px" />
       <img src="./assets/userAgentWarning.png" width="32px" />
-      <span
-        >当前浏览器可能与网站不兼容!建议使用 chrome 浏览器获得最佳使用体验。
-      </span>
-      <img
-        src="./assets/userAgentClose.png"
-        width="16px"
-        @click="handleClickUserAgent"
-      />
+      <span>当前浏览器可能与网站不兼容!建议使用 chrome 浏览器获得最佳使用体验。 </span>
+      <img src="./assets/userAgentClose.png" width="16px" @click="handleClickUserAgent" />
     </div>
     </div>
   </div>
   </div>
 </template>
 </template>
 <script>
 <script>
-import { removeSession } from "@/utils/role";
-import { removeToken } from "@/utils/auth";
-import Cookies from "js-cookie";
-import { getConfig } from "@/utils/auth";
+import { removeSession } from '@/utils/role';
+import { removeToken } from '@/utils/auth';
+import Cookies from 'js-cookie';
+import { getConfig } from '@/utils/auth';
 export default {
 export default {
-  name: "App",
+  name: 'App',
   data() {
   data() {
     return {
     return {
-      dir: "ltr",
+      dir: 'ltr',
       userAgentTipShow: false,
       userAgentTipShow: false,
       timeOut: null,
       timeOut: null,
     };
     };
   },
   },
   created() {
   created() {
-    let lang_type = localStorage.getItem("language_type");
-    if (lang_type == "AR") {
-      this.dir = "rtl";
+    let lang_type = localStorage.getItem('language_type');
+    if (lang_type == 'AR') {
+      this.dir = 'rtl';
     }
     }
     if (
     if (
-      localStorage.getItem("useragent_root_type") &&
-      localStorage.getItem("useragent_root_type") !== "true" &&
-      !localStorage.getItem("useragent_root_close")
+      localStorage.getItem('useragent_root_type') &&
+      localStorage.getItem('useragent_root_type') !== 'true' &&
+      !localStorage.getItem('useragent_root_close')
     ) {
     ) {
       this.userAgentTipShow = true;
       this.userAgentTipShow = true;
     } else {
     } else {
       this.handleUserAgentRoot();
       this.handleUserAgentRoot();
     }
     }
-    window.addEventListener("click", () => {
-      sessionStorage.setItem("lastClickTime", new Date().getTime());
+    window.addEventListener('click', () => {
+      sessionStorage.setItem('lastClickTime', new Date().getTime());
     });
     });
-    window.addEventListener("mousewheel", () => {
-      sessionStorage.setItem("lastClickTime", new Date().getTime());
+    window.addEventListener('mousewheel', () => {
+      sessionStorage.setItem('lastClickTime', new Date().getTime());
     });
     });
-    window.addEventListener("mousemove", () => {
-      sessionStorage.setItem("lastClickTime", new Date().getTime());
+    window.addEventListener('mousemove', () => {
+      sessionStorage.setItem('lastClickTime', new Date().getTime());
     });
     });
   },
   },
   methods: {
   methods: {
     // 判断是否为chrome浏览器
     // 判断是否为chrome浏览器
     handleUserAgentRoot() {
     handleUserAgentRoot() {
-      if (
-        !sessionStorage.getItem("useragent_root_close") &&
-        navigator.userAgent.indexOf("Chrome") == -1
-      ) {
+      if (!sessionStorage.getItem('useragent_root_close') && navigator.userAgent.indexOf('Chrome') == -1) {
         this.userAgentTipShow = true;
         this.userAgentTipShow = true;
       }
       }
     },
     },
     handleClickUserAgent() {
     handleClickUserAgent() {
-      sessionStorage.setItem("useragent_root_close", true);
+      sessionStorage.setItem('useragent_root_close', true);
       this.userAgentTipShow = false;
       this.userAgentTipShow = false;
     },
     },
     // 是否超时
     // 是否超时
     isTimeOut() {
     isTimeOut() {
       clearInterval(this.timeOut);
       clearInterval(this.timeOut);
-      let dataConfig = JSON.parse(getConfig());
-      if (dataConfig.user_connection_timeout_duration) {
+      let dataConfig = getConfig() ? JSON.parse(getConfig()) : null;
+      if (dataConfig && dataConfig.user_connection_timeout_duration) {
         this.timeOut = setInterval(() => {
         this.timeOut = setInterval(() => {
-          let lastClickTime = sessionStorage.getItem("lastClickTime") * 1;
+          let lastClickTime = sessionStorage.getItem('lastClickTime') * 1;
           let nowTime = new Date().getTime();
           let nowTime = new Date().getTime();
-          if (
-            nowTime - lastClickTime >
-            1000 * dataConfig.user_connection_timeout_duration
-          ) {
+          if (nowTime - lastClickTime > 1000 * dataConfig.user_connection_timeout_duration) {
             clearInterval(this.timeOut);
             clearInterval(this.timeOut);
-            removeSession("SysList");
+            removeSession('SysList');
             removeToken();
             removeToken();
-            Cookies.remove("JSESSIONID");
+            Cookies.remove('JSESSIONID');
             this.userShow = false;
             this.userShow = false;
             this.userMessage = null;
             this.userMessage = null;
-            sessionStorage.removeItem("useragent_root_close");
+            sessionStorage.removeItem('useragent_root_close');
             window.location.href = dataConfig.sys_home_url;
             window.location.href = dataConfig.sys_home_url;
           }
           }
         });
         });
@@ -95,7 +83,7 @@ export default {
     },
     },
   },
   },
   mounted() {
   mounted() {
-    sessionStorage.setItem("lastClickTime", new Date().getTime());
+    sessionStorage.setItem('lastClickTime', new Date().getTime());
     this.isTimeOut();
     this.isTimeOut();
   },
   },
 };
 };