From cd796e273d04c3a6e8469e4c1aa9606647969fa5 Mon Sep 17 00:00:00 2001 From: nisen Date: Wed, 22 Nov 2023 10:18:26 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9loding=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=B2=A1=E6=9C=89token=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Loading.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/Loading.vue b/src/views/Loading.vue index 9f35933e..7fa95cec 100644 --- a/src/views/Loading.vue +++ b/src/views/Loading.vue @@ -19,7 +19,7 @@ $this.curToken=getToken(); if(!$this.curToken){ //console.log(token,'第二次未获取token'); - location.href=this.webBaseUrl+process.env.VUE_APP_LOGIN_URL; + location.href = process.env.VUE_APP_LOGIN_URL; }else{ $this.boeLogin(); } From edec2b7f3023ccb2fc8f371de52cd752a9392722 Mon Sep 17 00:00:00 2001 From: nisen Date: Wed, 22 Nov 2023 13:59:44 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E8=AE=B0=E5=BD=95=E6=97=B6=E9=95=BF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/study/coursenew.vue | 109 ++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 43 deletions(-) diff --git a/src/views/study/coursenew.vue b/src/views/study/coursenew.vue index a15c90df..3ba59886 100644 --- a/src/views/study/coursenew.vue +++ b/src/views/study/coursenew.vue @@ -386,7 +386,7 @@ appendHandle: null, //追加学习时长的timeout句柄 isAppendTime: false, //是否追加学习时长 appentId: '', //当前追加的学习时长的id,此字段已经不再使用 - appentInterval: 5000, //追加学习时间的间隔 5秒加一次 + appentInterval: 15, //追加学习时间的间隔 5秒加一次 handleTimeout: null, completed: [], tab: 1, @@ -1408,7 +1408,7 @@ apiStat.sendEvent(postData).then(rs=>{ if(rs.status == 200) { // this.appendStartTime = new Date();//重新计时 - studyUtil.clearStudyDuration(); //清除本地存储 + // studyUtil.clearStudyDuration(); //清除本地存储 } else { console.log(rs.message); } @@ -1441,8 +1441,9 @@ window.clearTimeout(this.appendHandle); } }, - //追加学习时长, flag是否提交到后台 appendStudyTime() { + //重新覆盖时间 + this.appendStartTime = new Date().getTime(); //console.log('开始追加学习时长',this.isAppendTime); if (this.studyId == '') { return; @@ -1451,50 +1452,72 @@ return; } if (!this.isAppendTime) { - this.appendStartTime = null; return; } - - if (this.appendHandle != null) { - window.clearTimeout(this.appendHandle); - } - //首先从本地读取 - let duration = studyUtil.getStudyDuration(); - //console.log('追加学习时长,当前本地积累的学习时长='+duration); - //追加学习长 - let $this = this; - if (this.appendStartTime == null) { - this.appendStartTime = new Date(); - this.appendHandle = setTimeout(function() { - $this.appendStudyTime(); - }, $this.appentInterval); //设置定时追加学习时长 - //保存之前的 - if (duration >= 60 ) { - this.saveStudyDuration(duration); - } - return; - } - //如果当前追加开始时间不为空 - let now = new Date(); - let m = now.getTime() - this.appendStartTime.getTime(); //相差的毫秒数 - // console.log(m/1000,'时间'); - - let sen = Math.round(m / 1000); //计算秒数 - // console.log('定时器时间',sen); - // 每次添加的是定时器计时的时间 - duration = duration + sen;//追加的是秒 - if (duration >= 60) { //一分钟保存一次 - this.saveStudyDuration(duration); - } else { - studyUtil.setStudyDuration(duration); //添加到本地存储中 - } - //重新覆盖时间 - this.appendStartTime = new Date(); + this.appendHandle && window.clearTimeout(this.appendHandle); //启动下次追加学习时长 - this.appendHandle = setTimeout(function() { - $this.appendStudyTime(); - }, $this.appentInterval); + this.appendHandle = setTimeout(() => { + let endTime = new Date().getTime(); + this.appentInterval = 60 + let totalTime = Math.round((endTime - this.appendStartTime) / 1000); + this.saveStudyDuration(totalTime) + this.appendStudyTime(); + }, this.appentInterval * 1000); }, + //追加学习时长, flag是否提交到后台 + // appendStudyTime() { + // //console.log('开始追加学习时长',this.isAppendTime); + // if (this.studyId == '') { + // return; + // } + // if (!this.contentData.id) { + // return; + // } + // if (!this.isAppendTime) { + // this.appendStartTime = null; + // return; + // } + + // if (this.appendHandle != null) { + // window.clearTimeout(this.appendHandle); + // } + // //首先从本地读取 + // let duration = studyUtil.getStudyDuration(); + // //console.log('追加学习时长,当前本地积累的学习时长='+duration); + // //追加学习长 + // let $this = this; + // if (this.appendStartTime == null) { + // this.appendStartTime = new Date(); + // this.appendHandle = setTimeout(function() { + // $this.appendStudyTime(); + // }, $this.appentInterval); //设置定时追加学习时长 + // //保存之前的 + // if (duration >= 60 ) { + // this.saveStudyDuration(duration); + // } + // return; + // } + // //如果当前追加开始时间不为空 + // let now = new Date(); + // let m = now.getTime() - this.appendStartTime.getTime(); //相差的毫秒数 + // // console.log(m/1000,'时间'); + + // let sen = Math.round(m / 1000); //计算秒数 + // // console.log('定时器时间',sen); + // // 每次添加的是定时器计时的时间 + // duration = duration + sen;//追加的是秒 + // if (duration >= 60) { //一分钟保存一次 + // this.saveStudyDuration(duration); + // } else { + // studyUtil.setStudyDuration(duration); //添加到本地存储中 + // } + // //重新覆盖时间 + // this.appendStartTime = new Date(); + // //启动下次追加学习时长 + // this.appendHandle = setTimeout(function() { + // $this.appendStudyTime(); + // }, $this.appentInterval); + // }, finishStudyItem() { //设置完成学习的内容,针对于音视频的内容 if (!this.contentData.studyItemId) { From 8105682cd0e8b30651b47bc0405cc3cafabfb601 Mon Sep 17 00:00:00 2001 From: nisen Date: Wed, 22 Nov 2023 14:05:52 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=8F=90=E5=89=8D=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E8=AE=A1=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/study/coursenew.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/study/coursenew.vue b/src/views/study/coursenew.vue index 3ba59886..edc8d874 100644 --- a/src/views/study/coursenew.vue +++ b/src/views/study/coursenew.vue @@ -1460,8 +1460,8 @@ let endTime = new Date().getTime(); this.appentInterval = 60 let totalTime = Math.round((endTime - this.appendStartTime) / 1000); - this.saveStudyDuration(totalTime) this.appendStudyTime(); + this.saveStudyDuration(totalTime) }, this.appentInterval * 1000); }, //追加学习时长, flag是否提交到后台 From 0ae85485a432d8f9e0b1511dbfa69911327f104f Mon Sep 17 00:00:00 2001 From: nisen Date: Wed, 22 Nov 2023 17:00:12 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9loading=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E5=A4=84=E7=90=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/login.js | 2 +- src/views/Loading.vue | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/api/login.js b/src/api/login.js index 084b8afa..c7a11fc3 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -34,7 +34,7 @@ const refreshToken = function(token){ const boeLogin = function(token){ //return ajax.post('/xboe/account/boelogin',{token:token}); //登录时,新的用户接口调用查询用户信息 - return ajax.post('/xboe/account/boenewlogin',{token:token}); + return ajax.post('/xboe/account/boenewlogin',{token:token},{timeout: 20000}); } export default{ diff --git a/src/views/Loading.vue b/src/views/Loading.vue index 7fa95cec..09c5acfb 100644 --- a/src/views/Loading.vue +++ b/src/views/Loading.vue @@ -33,7 +33,8 @@ data(){ return { curToken:'', - toUrl:'' + toUrl:'', + onceTimeout:false } }, methods:{ @@ -51,6 +52,12 @@ }else{ this.$message.error("登录失败:"+rs.message); } + }).catch((error) => { + console.log(error); + if(!this.onceTimeout){ + this.onceTimeout = true; + this.boeLogin() + } }) } } From 5c1ecc348ae9c6c5a61860438d5b899b0c697101 Mon Sep 17 00:00:00 2001 From: nisen Date: Thu, 23 Nov 2023 11:04:28 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=9A=82=E5=81=9C=E6=92=AD=E6=94=BE=E6=97=B6?= =?UTF-8?q?=E5=8D=81=E4=BA=94=E7=A7=92=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/study/coursenew.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/views/study/coursenew.vue b/src/views/study/coursenew.vue index edc8d874..1d4747c8 100644 --- a/src/views/study/coursenew.vue +++ b/src/views/study/coursenew.vue @@ -1442,6 +1442,10 @@ } }, appendStudyTime() { + // 暂停的时候重新从十五秒开始计时 + if(!this.appendStartTime){ + this.appentInterval = 15 + } //重新覆盖时间 this.appendStartTime = new Date().getTime(); //console.log('开始追加学习时长',this.isAppendTime); From 90872938bee8afed8522b8afb485deb1f74a2e7d Mon Sep 17 00:00:00 2001 From: nisen Date: Thu, 23 Nov 2023 14:28:25 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/login.js | 2 +- src/views/Loading.vue | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/api/login.js b/src/api/login.js index c7a11fc3..084b8afa 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -34,7 +34,7 @@ const refreshToken = function(token){ const boeLogin = function(token){ //return ajax.post('/xboe/account/boelogin',{token:token}); //登录时,新的用户接口调用查询用户信息 - return ajax.post('/xboe/account/boenewlogin',{token:token},{timeout: 20000}); + return ajax.post('/xboe/account/boenewlogin',{token:token}); } export default{ diff --git a/src/views/Loading.vue b/src/views/Loading.vue index 09c5acfb..7fa95cec 100644 --- a/src/views/Loading.vue +++ b/src/views/Loading.vue @@ -33,8 +33,7 @@ data(){ return { curToken:'', - toUrl:'', - onceTimeout:false + toUrl:'' } }, methods:{ @@ -52,12 +51,6 @@ }else{ this.$message.error("登录失败:"+rs.message); } - }).catch((error) => { - console.log(error); - if(!this.onceTimeout){ - this.onceTimeout = true; - this.boeLogin() - } }) } }