Browse Source

accesscode

natasha 1 năm trước cách đây
mục cha
commit
b2a2a7f041
2 tập tin đã thay đổi với 86 bổ sung85 xóa
  1. 81 75
      src/App.vue
  2. 5 10
      src/views/courseWare.vue

+ 81 - 75
src/App.vue

@@ -1,10 +1,16 @@
 <template>
   <div id="app">
     <router-view />
-    <div class="userAgentTips" v-if="userAgentTipShow">
-        <img src="./assets/userAgentWarning.png" width="32px" />
-        <span>当前浏览器可能与网站不兼容!建议使用 chrome 浏览器获得最佳使用体验。 </span>
-        <img src="./assets/userAgentClose.png" width="16px" @click="handleClickUserAgent" />
+    <div v-if="userAgentTipShow" class="userAgentTips">
+      <img src="./assets/userAgentWarning.png" width="32px" />
+      <span
+        >当前浏览器可能与网站不兼容!建议使用 chrome 浏览器获得最佳使用体验。
+      </span>
+      <img
+        src="./assets/userAgentClose.png"
+        width="16px"
+        @click="handleClickUserAgent"
+      />
     </div>
   </div>
 </template>
@@ -19,86 +25,86 @@ export default {
   data() {
     return {
       userAgentTipShow: false,
-      timeOut: null
+      timeOut: null,
     };
   },
   created() {
-    this.handleUserAgentRoot()
-    window.addEventListener(
-        'click',()=>{
-            sessionStorage.setItem('lastClickTime',new Date().getTime())
-        }
-    )
-    window.addEventListener(
-        'mousewheel',()=>{
-            sessionStorage.setItem('lastClickTime',new Date().getTime())
-        }
-    )
-    window.addEventListener(
-        'mousemove',()=>{
-            sessionStorage.setItem('lastClickTime',new Date().getTime())
-        }
-    )
+    this.handleUserAgentRoot();
+    window.addEventListener("click", () => {
+      sessionStorage.setItem("lastClickTime", new Date().getTime());
+    });
+    window.addEventListener("mousewheel", () => {
+      sessionStorage.setItem("lastClickTime", new Date().getTime());
+    });
+    window.addEventListener("mousemove", () => {
+      sessionStorage.setItem("lastClickTime", new Date().getTime());
+    });
   },
-  methods:{
-      // 判断是否为chrome浏览器 
-      handleUserAgentRoot(){
-          if(!sessionStorage.getItem("useragent_root_close") && navigator.userAgent.indexOf('Chrome') == -1){
-              this.userAgentTipShow = true
+  mounted() {
+    sessionStorage.setItem("lastClickTime", new Date().getTime());
+    this.isTimeOut();
+  },
+  methods: {
+    // 判断是否为chrome浏览器
+    handleUserAgentRoot() {
+      if (
+        !sessionStorage.getItem("useragent_root_close") &&
+        navigator.userAgent.indexOf("Chrome") == -1
+      ) {
+        this.userAgentTipShow = true;
+      }
+    },
+    handleClickUserAgent() {
+      sessionStorage.setItem("useragent_root_close", true);
+      this.userAgentTipShow = false;
+    },
+    // 是否超时
+    isTimeOut() {
+      clearInterval(this.timeOut);
+      const dataConfig = getConfig() ? JSON.parse(getConfig()) : null;
+      if (dataConfig && dataConfig.user_connection_timeout_duration) {
+        this.timeOut = setInterval(() => {
+          const lastClickTime = sessionStorage.getItem("lastClickTime") * 1;
+          const nowTime = new Date().getTime();
+          if (
+            nowTime - lastClickTime >
+            1000 * dataConfig.user_connection_timeout_duration
+          ) {
+            clearInterval(this.timeOut);
+            removeSession("SysList");
+            removeToken();
+            Cookies.remove("JSESSIONID");
+            this.userShow = false;
+            this.userMessage = null;
+            sessionStorage.removeItem("useragent_root_close");
+            window.location.href = dataConfig.sys_home_url;
           }
-      },
-      handleClickUserAgent(){
-          sessionStorage.setItem("useragent_root_close", true);
-          this.userAgentTipShow = false
-      },
-      // 是否超时
-      isTimeOut(){
-        clearInterval(this.timeOut)
-        let dataConfig = JSON.parse(getConfig());
-        if(dataConfig.user_connection_timeout_duration){
-            this.timeOut = setInterval(()=>{
-                let lastClickTime = sessionStorage.getItem('lastClickTime')*1
-                let nowTime = new Date().getTime()
-                if(nowTime - lastClickTime > 1000 * dataConfig.user_connection_timeout_duration){
-                    clearInterval(this.timeOut)
-                    removeSession("SysList");
-                    removeToken();
-                    Cookies.remove("JSESSIONID");
-                    this.userShow = false;
-                    this.userMessage = null;
-                    sessionStorage.removeItem("useragent_root_close");
-                    window.location.href = dataConfig.sys_home_url
-                }
-            })
-        }
+        });
       }
-  },
-  mounted(){
-    sessionStorage.setItem('lastClickTime',new Date().getTime())
-    this.isTimeOut()
+    },
   },
 };
 </script>
 <style lang="scss" scoped>
-.userAgentTips{
-    position: fixed;
-    top: 62px;
-    left: 50%;
-    // width: 624px;
-    margin-left: -312px;
-    background: #FFFFFF;
-    border-radius: 8px;
-    padding: 12px 16px 12px 8px;
-    display: flex;
-    align-items: center;
-    justify-content: space-between;
-    font-size: 16px;
-    line-height: 24px;
-    :nth-child(1){
-        margin-right: 8px;
-    }
-    :nth-child(3){
-        cursor: pointer;
-    }
+.userAgentTips {
+  position: fixed;
+  top: 62px;
+  left: 50%;
+  // width: 624px;
+  margin-left: -312px;
+  background: #ffffff;
+  border-radius: 8px;
+  padding: 12px 16px 12px 8px;
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  font-size: 16px;
+  line-height: 24px;
+  :nth-child(1) {
+    margin-right: 8px;
+  }
+  :nth-child(3) {
+    cursor: pointer;
+  }
 }
 </style>

+ 5 - 10
src/views/courseWare.vue

@@ -259,16 +259,11 @@ export default {
   },
   created() {
     const _this = this;
-    const codeName = "login_control-CreateTempAccessCode";
-    let access_code = null;
-    getStaticContent(codeName, {}).then((res) => {
-      access_code = res.access_code;
-      const Mname = "login_control-GetLoginInfoByAccessCode";
-      getStaticContent(Mname, {
-        access_code: access_code,
-      }).then((res) => {
-        setToken(res);
-      });
+    const Mname = "login_control-ParseAccessToken";
+    getStaticContent(Mname, {
+      access_token: _this.$route.query.AccessToken,
+    }).then((res) => {
+      setToken(res);
     });
     _this.changeId();
   },