From 0bdd2eea5c72d07671850f1f77750ef00ddcaabd Mon Sep 17 00:00:00 2001
From: Jesse-Ma <24167796@qq.com>
Date: Thu, 30 Jun 2022 12:32:28 +0800
Subject: [PATCH] 0630
---
src/api/note.js | 1 -
src/libs/noteStorage.js | 4 +--
src/views/BlankNote.vue | 8 ++---
src/views/EditNote.vue | 76 ++++++++++++++++-------------------------
src/views/ViewNote.vue | 35 +++++++++++--------
5 files changed, 55 insertions(+), 69 deletions(-)
diff --git a/src/api/note.js b/src/api/note.js
index eed9b9f..9028575 100644
--- a/src/api/note.js
+++ b/src/api/note.js
@@ -62,7 +62,6 @@ export function deleteNote(key) {
export function getNoteMeta(key) {
- console.log("getNoteMeta");
let noteMeta = {};
Jquery.ajax({
method: 'GET',
diff --git a/src/libs/noteStorage.js b/src/libs/noteStorage.js
index a217466..5ab27ba 100644
--- a/src/libs/noteStorage.js
+++ b/src/libs/noteStorage.js
@@ -18,9 +18,9 @@ export function setStoreText(text, secret, password) {
let storeText = aesEncrypt(text, secretKey);
storeText = zip(storeText);
- let lock = '0';
+ let lock = 0;
if (password) {
- lock = '1';
+ lock = 1;
}
storage.local.setText(secret.storeKey + '.text', lock + '|' + secret.cipher + '|' + storeText);
diff --git a/src/views/BlankNote.vue b/src/views/BlankNote.vue
index efd481c..648e4f4 100644
--- a/src/views/BlankNote.vue
+++ b/src/views/BlankNote.vue
@@ -161,7 +161,7 @@ export default {
escapeText: '',
key: '',
md5: '',
- lock: '0',
+ lock: 0,
},
secret: {
storeKey: '',
@@ -169,9 +169,9 @@ export default {
cipher: '',
},
state: {
- lock: '0',
- locking: '0',
- commited: '0'
+ lock: 0,
+ locking: 0,
+ commited: 0
}
}
},
diff --git a/src/views/EditNote.vue b/src/views/EditNote.vue
index 22645fa..1221917 100644
--- a/src/views/EditNote.vue
+++ b/src/views/EditNote.vue
@@ -93,19 +93,13 @@
-
-
-
-
-
-
-
-
-
+
@@ -120,24 +114,12 @@
-
-
-
-
-
-
-
-
@@ -206,7 +188,7 @@
@@ -269,11 +251,11 @@ export default {
cipher: '',
},
state: {
- lock: '0',
+ lock: 0,
- locking: '0',
+ locking: 0,
- commited: '0'
+ commited: 0
}
}
},
@@ -284,17 +266,17 @@ export default {
let keyMeta = storage.session.getObject(storeKey + '.keyMeta');
if (keyMeta) {
- this.state.lock = '0';
+ this.state.lock = 0;
this.secret.cipher = keyMeta.cipher;
storage.local.setText(storeKey + '.text', "0|" + this.secret.cipher);
storage.session.setObject(storeKey + '.keyMeta', null);
} else {
let storeText = storage.local.getText(storeKey + '.text');
- this.state.lock = storeText.substring(0, 1);
+ this.state.lock = parseInt(storeText.substring(0, 1));
this.secret.cipher = storeText.substring(2, 34)
}
- if (this.state.lock == "1") {
+ if (this.state.lock == 1) {
this.show = false;
this.noteForm.text = "*****lock*****";
return;
@@ -336,8 +318,8 @@ export default {
let storeText = storage.local.getText(this.secret.storeKey + '.text');
if (null != storeText && '' != storeText) {
- let lock = storeText.substring(0, 1);
- if (lock == "1") {
+ let lock = parseInt(storeText.substring(0, 1));
+ if (lock == 1) {
alert("note is encrypt!");
return;
}
@@ -350,9 +332,9 @@ export default {
let plainText = aesDecrypt(storeText, secretKey);
if (plainText.startsWith("FLAGNOTE#")) {
this.noteForm.text = plainText.substring(9);
- this.state.lock = "0";
+ this.state.lock = 0;
} else {
- if (this.state.lock == "1") {
+ if (this.state.lock == 1) {
alert("password is wrong!")
}
}
@@ -396,28 +378,28 @@ export default {
return saveNote(this.noteForm);
},
submitNote() {
- if (this.state.locking == "1") {
+ if (this.state.locking == 1) {
return;
}
- this.state.locking = "1";
+ this.state.locking = 1;
this.loading = true;
this.save().then(res => {
if (res) {
location.reload();
- this.state.locking = "0";
+ this.state.locking = 0;
}
});
},
hideNote() {
- if (this.state.locking == "1") {
+ if (this.state.locking == 1) {
return;
}
- this.state.locking = "1";
+ this.state.locking = 1;
- if (this.state.lock == "1") {
- this.state.locking = "0";
+ if (this.state.lock == 1) {
+ this.state.locking = 0;
return;
}
@@ -427,7 +409,7 @@ export default {
setStoreText(this.noteForm.text, this.secret, password);
- this.state.lock = "1"
+ this.state.lock = 1
this.noteForm.text = '******lock******';
@@ -439,20 +421,20 @@ export default {
noteText.selectionEnd = 1;
this.show = false;
- this.state.locking = "0";
+ this.state.locking = 0;
},
showNote() {
- if (this.state.locking == "1") {
+ if (this.state.locking == 1) {
return;
}
- this.state.locking = "1";
+ this.state.locking = 1;
- if (this.state.lock == "0") {
- this.state.locking = "0";
+ if (this.state.lock == 0) {
+ this.state.locking = 0;
return;
}
@@ -460,7 +442,7 @@ export default {
let storeText = storage.local.getText(this.secret.storeKey + '.text');
if (storeText) {
- let lock = storeText.substring(0, 1);
+ let lock = parseInt(storeText.substring(0, 1));
if (!lock) {
alert("note is not encrypt!");
diff --git a/src/views/ViewNote.vue b/src/views/ViewNote.vue
index ed2a1f2..1c34962 100644
--- a/src/views/ViewNote.vue
+++ b/src/views/ViewNote.vue
@@ -123,7 +123,7 @@ button span {
-
@@ -207,7 +207,7 @@ export default {
escapeText: '',
key: '',
md5: '',
- lock: '0',
+ lock: 0,
ttl: 3600,
ttlDesc: '',
},
@@ -217,9 +217,11 @@ export default {
cipher: '',
},
state: {
- lock: '0',
- locking: '0',
- commited: '0'
+ lock: 0,
+ locking: 0,
+ initTime: null,
+ initTtl: null,
+ commited: 0
}
}
},
@@ -230,6 +232,8 @@ export default {
let noteMeta = storage.session.getObject(storeKey + '.noteMeta');
if (noteMeta) {
this.state.lock = noteMeta.lock;
+ this.state.initTime = new Date().getTime();
+ this.state.initTtl = noteMeta.ttl;
this.secret.cipher = noteMeta.cipher;
this.noteForm.md5 = noteMeta.md5;
this.noteForm.ttl = noteMeta.ttl;
@@ -246,24 +250,25 @@ export default {
window.setInterval(function () {
let ittl = parseInt(that.noteForm.ttl / 1000);
let mins = parseInt(ittl / 60);
- if (mins < 10) {
- mins = "0" + mins;
- }
if (mins < 0) {
mins = "00";
+ } else if (mins < 10) {
+ mins = "0" + mins;
}
+
let seds = parseInt(ittl % 60);
- if (seds < 10) {
- seds = "0" + seds;
- }
+
if (seds < 0) {
seds = "00";
+ } else if (seds < 10) {
+ seds = "0" + seds;
}
that.noteForm.ttlDesc = mins + ":" + seds;
- that.noteForm.ttl -= 1000;
+ that.noteForm.ttl = that.state.initTtl - (new Date().getTime() - that.state.initTime);
+
if (that.noteForm.ttl <= 0) {
- that.storage.local.delete(that.secret.storeKey + '.text');
- that.storage.session.delete(that.secret.storeKey + '.keyMeta');
+ storage.local.delete(that.secret.storeKey + '.text');
+ storage.session.delete(that.secret.storeKey + '.keyMeta');
location.reload();
}
}, 1000)
@@ -290,7 +295,7 @@ export default {
let password;
- if (this.noteForm.lock == "1") {
+ if (this.noteForm.lock == 1) {
password = "123456"
}