refresh save

This commit is contained in:
Jesse-Ma
2023-03-31 17:19:37 +08:00
parent 83c3901b86
commit d3a29444bf

View File

@@ -379,27 +379,27 @@ export default {
backStoreFunction() { backStoreFunction() {
let that = this; let that = this;
return function () { return function () {
that.backStoreText(that); that.backStoreText();
} }
}, },
backStoreText(that) { backStoreText() {
let nowEditCount = that.noteForm.text.length; let nowEditCount = this.noteForm.text.length;
let nowEditTime = new Date().getTime(); let nowEditTime = new Date().getTime();
if (Math.abs(nowEditCount - that.lastStoreCount) > 10) { if (Math.abs(nowEditCount - this.lastStoreCount) > 10) {
setStoreText(that.noteForm, that.state, that.secret); setStoreText(this.noteForm, this.state, this.secret);
that.lastStoreTime = that.lastEditTime; this.lastStoreTime = this.lastEditTime;
that.lastStoreCount = nowEditCount; this.lastStoreCount = nowEditCount;
} else { } else {
if (nowEditTime - that.lastEditTime >= 1000 && nowEditTime - that.lastEditTime < 20000) { if (nowEditTime - this.lastEditTime >= 1000 && nowEditTime - this.lastEditTime < 20000) {
if (that.lastEditTime != that.lastStoreTime) { if (this.lastEditTime != this.lastStoreTime) {
setStoreText(that.noteForm, that.state, that.secret); setStoreText(this.noteForm, this.state, this.secret);
that.lastStoreTime = that.lastEditTime; this.lastStoreTime = this.lastEditTime;
that.lastStoreCount = nowEditCount; this.lastStoreCount = nowEditCount;
} }
} else if (nowEditTime - that.lastEditTime >= 20000) { } else if (nowEditTime - this.lastEditTime >= 20000) {
if (that.backStoreTextInterval != null) { if (this.backStoreTextInterval != null) {
let ivl = that.backStoreTextInterval; let ivl = this.backStoreTextInterval;
that.backStoreTextInterval = null; this.backStoreTextInterval = null;
window.clearInterval(ivl); window.clearInterval(ivl);
} }
} }
@@ -602,7 +602,7 @@ export default {
}); });
}, },
beforeunloadHandler() { beforeunloadHandler() {
this.recordText(); setStoreText(this.noteForm, this.state, this.secret);
}, },
} }
} }