This commit is contained in:
Jesse-Ma
2022-07-29 15:21:20 +08:00
parent deb1fbe49d
commit 732907c3b6
22 changed files with 592 additions and 415 deletions

View File

@@ -23,40 +23,47 @@ function getNoteMetaParam() {
function getNoteView() {
let path = location.pathname;
if (null != keyMeta) {
path = "/" + keyMeta.key;
let key = path.substring(1, path.length);
if (keyMeta && keyMeta.key) {
key = keyMeta.key;
}
let reg = /^\/[abcdefhikmnopqstuvwxyz23456789]{16}$/;
if (!reg.test(path)) {
let regKey = /^[abcdefhikmnopqstuvwxyz23456789]{16}$/;
if (!regKey.test(key)) {
return;
}
let key = path.substr(1, path.length - 1);
let storeKey = getStoreKey(key);
if (keyMeta && keyMeta.cipher) {
// storage.session.setObject(storeKey + '.keyMeta', keyMeta);
if (keyMeta && keyMeta.key) {
//firstEdit
return EditNote;
}
//set noteMeta
noteMeta = getNoteMeta(key);
if (!noteMeta || !noteMeta.key) {
let storeKey = getStoreKey(key);
let storeText = storage.local.getText(storeKey + ".text");
if (storeText) {
let starray = storeText.split("|");
let commitFlag = starray[2];
if (commitFlag == "1") {
//timeout and clear local
storage.local.delete(storeKey + '.text');
return BlankNote;
} else {
//secondEdit
return EditNote;
}
} else {
//uncommited or timeout
return BlankNote;
}
}
// storage.session.setObject(storeKey + '.noteMeta', noteMeta);
// view in time
return ViewNote;
}
@@ -66,10 +73,8 @@ function getHomeRedirect() {
return;
}
let km = getKeyMeta();
km.isNew = true;
//sessionStorage.setItem(km.getKey() + '.keyMeta', km);
keyMeta = km;
//setKeyMeta
keyMeta = getKeyMeta();
return "/" + keyMeta.key;
}
@@ -89,6 +94,7 @@ const routes = [
name: "note",
component: getNoteView(),
meta: { keyMeta: getKeyMetaParam(), noteMeta: getNoteMetaParam() },
//alias:'/xxxx'
},
];