mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-15 13:56:43 +08:00
2022年5月29日从svn移到git
This commit is contained in:
58
src/utils/study.js
Normal file
58
src/utils/study.js
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* 用于处理,记录 学习的情况
|
||||
*/
|
||||
const studyDurationKey='xus_duration';
|
||||
const studyVideoKeyPre='xus_video';
|
||||
|
||||
/**
|
||||
* 设置视频的播放时间
|
||||
* @param {} courseId
|
||||
* @param {*} time
|
||||
*/
|
||||
const setVideoTime=function(courseId,time){
|
||||
localStorage.setItem(studyVideoKeyPre+'_'+courseId,time);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置本地存储的学习时长
|
||||
*/
|
||||
const setStudyDuration=function(duration){
|
||||
//console.log(duration,'设置时长');
|
||||
localStorage.setItem(studyDurationKey,duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除本地记录的学习时长
|
||||
*/
|
||||
const clearStudyDuration=function(){
|
||||
localStorage.setItem(studyDurationKey,0);
|
||||
}
|
||||
|
||||
const getStudyDuration=function(){
|
||||
let speedValue=localStorage.getItem(studyDurationKey);
|
||||
if(speedValue){
|
||||
//console.log(speedValue,'speedValue');
|
||||
return Number(speedValue);
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 追加学习时长
|
||||
* @param Number duration 学习时长(秒)
|
||||
*/
|
||||
const appendStudyDuration=function(duration){
|
||||
let speedValue=localStorage.getItem(studyDurationKey);
|
||||
if(speedValue){
|
||||
localStorage.setItem(studyDurationKey,Number(speedValue)+duration);
|
||||
}else{
|
||||
localStorage.setItem(studyDurationKey,duration);
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
getStudyDuration,
|
||||
setStudyDuration,
|
||||
clearStudyDuration,
|
||||
appendStudyDuration
|
||||
}
|
||||
Reference in New Issue
Block a user