提交修改

This commit is contained in:
daihh
2022-10-25 19:37:35 +08:00
parent 21e3d0b3d9
commit 5059821ea0
4 changed files with 41 additions and 26 deletions

View File

@@ -100,6 +100,10 @@ export default {
type: Object,
default: () => { }
},
current:{ //当前是否是可编辑的
type: Boolean,
default: false
},
height:{
type: Number,
default: 200
@@ -112,7 +116,9 @@ export default {
name: 'MyNote',
data() {
return {
inAnimationText:'笔记保存成功U币+2',
inAnimationText:'笔记保存成功U币+5',
localSaveHandle:null,//本地保存的timeout对象
localKey:'NOTE_TEXT',//本地存储的key
isEdit:false,
inputHeight:70,
listHeight:170,
@@ -122,7 +128,6 @@ export default {
btnPlayTime:false,//是否显示添加视频时间
radio: '1',
notetab: 1,
autoSave: null,
mynoteData: {
type: 1, //我发布的是1 我导入的是2
content: '',
@@ -152,8 +157,7 @@ export default {
watch: {
//内容的高度
height(val){
//$this.controlHeight=h-
//$this.controlHeight=h-
this.listHeight=val-95;
this.inputHeight=(val-220);
@@ -161,13 +165,14 @@ export default {
if(this.inputRows>20){
this.inputRows=20;
}
//console.log(this.inputHeight,this.inputRows,this.listHeight,'my note height');
if(this.inputHeight>500){
this.inputHeight=500;
}
},
isedit(val){
this.isEdit=val;
},
selected:{
handler(val,old){
this.$emit('change',this.selected)
@@ -181,10 +186,7 @@ export default {
this.mynoteData.courseName = this.data.name;
// this.mynoteData.contentId = this.data.id;
}
},
// intTimeNote(val) {
// this.mynoteData.playTime = val;
// }
}
},
methods: {
handleClick(){
@@ -194,8 +196,7 @@ export default {
//这里应该加上内容的id
this.$emit('onPlayVideo',conId,time);
},
// 取消编辑
//取消编辑
editCancel(){
this.isEdit = false; // 关闭编辑框
this.getMyNote(); // 重新渲染对应课程的笔记列表
@@ -205,7 +206,6 @@ export default {
let h = Math.floor(result / 3600);
let m = Math.floor((result / 60 % 60));
let s = Math.floor((result % 60));
let res = '';
if (h > 0) {
res += `${h}:${m}:${s}`;
@@ -225,10 +225,14 @@ export default {
timeDel() {
this.mynoteData.playTime = 0;
},
autoSaveNote() {
this.autoSave = setInterval(() => {
localStorage.setItem("NOTE_TEXT", this.mynoteData.content);
}, 10000);
autoSaveNote(){
let $this=this;
if(this.notetab==1){
localStorage.setItem($this.localKey, $this.mynoteData.content);
}
// this.localSaveHandle = setInterval(() => {
// }, 10000);
},
noteEdit(note) {
this.isEdit = true;
@@ -334,6 +338,7 @@ export default {
} else {
this.mynoteData.content = this.content_new; //赋值笔记内容
let curOpenType=this.mynoteData.openType;
let $this=this;
apiNote.save(this.mynoteData).then(res => {
if (res.status == 200) {
if (!this.mynoteData.id) {
@@ -345,8 +350,8 @@ export default {
return
}
setTimeout(() => {
localStorage.setItem("NOTE_TEXT", '');
// clearInterval(this.autoSave);
localStorage.setItem($this.localKey, '');
// clearInterval(this.localSaveHandle);
that.getMyNote();
that.notetabType(2);
that.mynoteData = {
@@ -378,13 +383,21 @@ export default {
}
}
}).catch(function(error) {
//
this.$message.error('当前网络异常,内容已离线保存');
//
localStorage.setItem(this.localKey, this.mynoteData.content);
})
}
}
}
},
beforeDestroy() {
// clearInterval(this.autoSave);
this.autoSave = null;
if(this.localSaveHandle!=null){
clearInterval(this.localSaveHandle);
clearTimeout(this.localSaveHandle)
}
this.localSaveHandle = null;
},
}
</script>