tag2
This commit is contained in:
@@ -44,6 +44,6 @@ export function getEscapeText(text) {
|
||||
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'), " ");
|
||||
textEscape = textEscape.replace(new RegExp('\\t','gm'), "<pre class=\"tab_pre\">	</pre>");
|
||||
return textEscape;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export function md5(word, keyWord = 'F1agn0te') {
|
||||
}
|
||||
|
||||
//加密
|
||||
export function aesEncrypt(word, keyWord = 'F1agn0te') {
|
||||
export function aesEncrypt(word, keyWord) {
|
||||
let key = CryptoJS.enc.Utf8.parse(keyWord);
|
||||
let srcWords = CryptoJS.enc.Utf8.parse(word);
|
||||
let encrypted = CryptoJS.AES.encrypt(srcWords, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7});
|
||||
@@ -22,7 +22,7 @@ export function aesEncrypt(word, keyWord = 'F1agn0te') {
|
||||
}
|
||||
|
||||
//解密
|
||||
export function aesDecrypt(word, keyWord = 'F1agn0te') {
|
||||
export function aesDecrypt(word, keyWord) {
|
||||
let key = CryptoJS.enc.Utf8.parse(keyWord);
|
||||
let decrypt = CryptoJS.AES.decrypt(word, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7});
|
||||
return CryptoJS.enc.Utf8.stringify(decrypt).toString()
|
||||
|
||||
@@ -67,9 +67,8 @@ class Local {
|
||||
return 5 * 1024 * 1024 - storage.local.getUseSize();
|
||||
}
|
||||
|
||||
dynamicClear(ctt) {
|
||||
dynamicClear() {
|
||||
if (storage.local.getAvailableSize() < 1 * 1024 * 1024) {
|
||||
|
||||
//remove commited
|
||||
for (let i = 0, len = localStorage.length; i < len; i++) {
|
||||
let key = localStorage.key(i);
|
||||
@@ -86,26 +85,42 @@ class Local {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//remove expired
|
||||
if (storage.local.getAvailableSize() < 1 * 1024 * 1024) {
|
||||
for (let i = 0, len = localStorage.length; i < len; i++) {
|
||||
let key = localStorage.key(i);
|
||||
if (null == key) {
|
||||
continue;
|
||||
}
|
||||
let value = localStorage.getItem(key);
|
||||
dynamicDeepClear(ctt, excludeKey) {
|
||||
if (!ctt) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.length == 37 && key.endsWith(".text") && value.length > 50) {
|
||||
let starray = value.split("|");
|
||||
let fl = starray[2];
|
||||
let ts = starray[3];
|
||||
//remove expired
|
||||
let availableSize = storage.local.getAvailableSize();
|
||||
|
||||
if (fl == "0") {
|
||||
if (ctt - ts > 3 * 24 * 3600 * 1000) {
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
for (
|
||||
let i = 0, len = localStorage.length;
|
||||
i < len && availableSize < 2 * 1024 * 1024;
|
||||
i++
|
||||
) {
|
||||
let key = localStorage.key(i);
|
||||
if (null == key) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key.indexOf(excludeKey) >= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let value = localStorage.getItem(key);
|
||||
|
||||
if (key.length == 37 && key.endsWith(".text") && value.length > 50) {
|
||||
let starray = value.split("|");
|
||||
let fl = starray[2];
|
||||
let ts = starray[3];
|
||||
|
||||
if (fl == "0") {
|
||||
if (ctt - ts > 3 * 24 * 3600 * 1000) {
|
||||
localStorage.removeItem(key);
|
||||
availableSize = availableSize + value.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,8 @@ export function isIE() {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getNoteUrl(key){
|
||||
return "https://flagnote.com/" + key;
|
||||
}
|
||||
Reference in New Issue
Block a user