This commit is contained in:
Jesse-Ma
2022-07-21 18:51:30 +08:00
parent 0bdd2eea5c
commit deb1fbe49d
22 changed files with 26943 additions and 346 deletions

View File

@@ -3,7 +3,9 @@ import storage from "@/libs/storage";
import {getSecretKey} from "@/api/lock";
import escapeHtml from "escape-html";
export function setStoreText(text, secret, password) {
export function setStoreText(noteForm, secret, password) {
let text = noteForm.text;
if (!text) {
return;
}
@@ -14,7 +16,7 @@ export function setStoreText(text, secret, password) {
text = "FLAGNOTE#" + text;
let secretKey = getSecretKey(secret.cipher, password);
let secretKey = getSecretKey(noteForm.key, password);
let storeText = aesEncrypt(text, secretKey);
storeText = zip(storeText);
@@ -23,7 +25,8 @@ export function setStoreText(text, secret, password) {
lock = 1;
}
storage.local.setText(secret.storeKey + '.text', lock + '|' + secret.cipher + '|' + storeText);
storage.local.setText(secret.storeKey + '.text', lock + '|' + secret.cipher + '|0|'+ noteForm.initTime+'|' + storeText);
}
@@ -37,11 +40,10 @@ export function clearStoreText(key) {
export function getEscapeText(text) {
let textEscape = escapeHtml(text);
textEscape = textEscape.replaceAll(" ", " ");
textEscape = textEscape.replaceAll("\r\n", "<br/>");
textEscape = textEscape.replaceAll("\r", "<br/>");
textEscape = textEscape.replaceAll("\n", "<br/>");
textEscape = textEscape.replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
textEscape = textEscape.replace(new RegExp(' ','gm'), "&nbsp;");
textEscape = textEscape.replace(new RegExp('\\r\\n','gm'), "<br/>");
textEscape = textEscape.replace(new RegExp('\\r','gm'), "<br/>");
textEscape = textEscape.replace(new RegExp('\\n','gm'), "<br/>");
textEscape = textEscape.replace(new RegExp('\\t','gm'), "&nbsp;&nbsp;&nbsp;&nbsp;");
return textEscape;
}