Compare commits
3 Commits
scrollbar
...
asynchroni
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89d099fecf | ||
|
|
8ce9342b8e | ||
|
|
11987b0a77 |
20618
package-lock.json
generated
Normal file
20618
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -11,10 +11,12 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
|
"bluebird": "^3.7.2",
|
||||||
"clipboard": "^2.0.11",
|
"clipboard": "^2.0.11",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
"escape-html": "^1.0.3",
|
"escape-html": "^1.0.3",
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
|
"localforage": "^1.10.0",
|
||||||
"pako": "^2.1.0",
|
"pako": "^2.1.0",
|
||||||
"qrcodejs2": "^0.0.2",
|
"qrcodejs2": "^0.0.2",
|
||||||
"view-design": "^4.7.0",
|
"view-design": "^4.7.0",
|
||||||
|
|||||||
@@ -24,29 +24,29 @@
|
|||||||
background-color: #dddddd
|
background-color: #dddddd
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.min.js" rel="stylesheet"
|
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.min.js"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue-router@3.6.5/dist/vue-router.min.js" rel="stylesheet"
|
<script src="https://cdn.jsdelivr.net/npm/vue-router@3.6.5/dist/vue-router.min.js"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/axios@0.27.2/dist/axios.min.js" rel="stylesheet"
|
<script src="https://cdn.jsdelivr.net/npm/axios@0.27.2/dist/axios.min.js"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/view-design@4.7.0/dist/iview.min.js" rel="stylesheet"
|
<script src="https://cdn.jsdelivr.net/npm/view-design@4.7.0/dist/iview.min.js"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/pako@2.1.0/dist/pako.min.js" rel="stylesheet"
|
<script src="https://cdn.jsdelivr.net/npm/pako@2.1.0/dist/pako.min.js"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/crypto-js@4.1.1/crypto-js.min.js" rel="stylesheet"
|
<script src="https://cdn.jsdelivr.net/npm/crypto-js@4.1.1/crypto-js.min.js"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue-i18n@8.21.1/dist/vue-i18n.min.js" rel="stylesheet"
|
<script src="https://cdn.jsdelivr.net/npm/vue-i18n@8.21.1/dist/vue-i18n.min.js"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/file-saver@2.0.5/dist/FileSaver.min.js" rel="stylesheet"
|
<script src="https://cdn.jsdelivr.net/npm/file-saver@2.0.5/dist/FileSaver.min.js"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/qrcodejs2@0.0.2/qrcode.min.js" rel="stylesheet"
|
<script src="https://cdn.jsdelivr.net/npm/qrcodejs2@0.0.2/qrcode.min.js"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.11/dist/clipboard.min.js" rel="stylesheet"
|
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.11/dist/clipboard.min.js"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/wasm-flate@1.0.2-browser/wasm_flate.js" rel="stylesheet"
|
<script src="https://cdn.jsdelivr.net/npm/wasm-flate@1.0.2-browser/wasm_flate.js"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script>
|
<script type="text/javascript">
|
||||||
window.wasm_flate_bg_path = "https://cdn.jsdelivr.net/npm/wasm-flate@1.0.2-browser/wasm_flate_bg.wasm"
|
window.wasm_flate_bg_path = "https://cdn.jsdelivr.net/npm/wasm-flate@1.0.2-browser/wasm_flate_bg.wasm"
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
73
public/redirect.html
Normal file
73
public/redirect.html
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="renderer" content="webkit" />
|
||||||
|
<meta name="force-rendering" content="webkit" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||||
|
<meta name="viewport"
|
||||||
|
content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=2.0, user-scalable=yes" />
|
||||||
|
<meta name="keywords" content="flagnote" />
|
||||||
|
<meta name="description" content="flag note" />
|
||||||
|
<meta name="theme-color" content="#ed4014" />
|
||||||
|
<meta name="format-detection" content="telephone=no,email=no,adress=no" />
|
||||||
|
<meta name="google" content="notranslate">
|
||||||
|
<meta http-equiv="Expires" content="0" />
|
||||||
|
<meta http-equiv="Pragma" content="no-cache" />
|
||||||
|
<meta http-equiv="Cache-control" content="no-cache" />
|
||||||
|
<meta http-equiv="Cache" content="no-cache" />
|
||||||
|
<link rel="icon" href="/static/favicon.png" />
|
||||||
|
<title>flagnote.com</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #dddddd
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
const servicePath = "";
|
||||||
|
//const servicePath="https://flagnote.com";
|
||||||
|
|
||||||
|
function ajaxGet(url) {
|
||||||
|
let data = null;
|
||||||
|
let xmlhttp = new XMLHttpRequest();
|
||||||
|
xmlhttp.open("GET", url, false);
|
||||||
|
xmlhttp.onreadystatechange = () => {
|
||||||
|
if (xmlhttp.readyState == 4) {
|
||||||
|
if (xmlhttp.status == 200 || xmlhttp.status == 304) {
|
||||||
|
if (xmlhttp.responseText) {
|
||||||
|
let rs = JSON.parse(xmlhttp.responseText);
|
||||||
|
if (rs && rs.code == "000000") {
|
||||||
|
data = rs.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xmlhttp.send();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getKeyMeta() {
|
||||||
|
let url = servicePath + "/note/keyMeta";
|
||||||
|
let keyMeta = null;
|
||||||
|
try {
|
||||||
|
keyMeta = ajaxGet(url);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
return keyMeta;
|
||||||
|
}
|
||||||
|
|
||||||
|
let keyMeta = getKeyMeta();
|
||||||
|
|
||||||
|
sessionStorage.setItem("keyMeta", JSON.stringify(keyMeta));
|
||||||
|
location.href = "/" + keyMeta.key;
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body><noscript><strong>Please enable JavaScript to continue.</strong></noscript>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { getStoreKey } from "@/api/lock";
|
import { getStoreKey } from "@/api/lock";
|
||||||
import storage from "@/libs/storage";
|
import storage from "@/libs/storage";
|
||||||
import { md5, wrap} from "@/libs/secret";
|
import { md5, wrap } from "@/libs/secret";
|
||||||
import NoteConstant from "@/libs/constants";
|
import NoteConstant from "@/libs/constants";
|
||||||
|
|
||||||
axios.interceptors.response.use(undefined, (err) => {
|
axios.interceptors.response.use(undefined, (err) => {
|
||||||
@@ -17,10 +17,10 @@ axios.interceptors.response.use(undefined, (err) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export function saveNote(noteForm, secret) {
|
export async function saveNote(noteForm, secret) {
|
||||||
let storeKey = secret.storeKey;
|
let storeKey = secret.storeKey;
|
||||||
|
|
||||||
let storeInfo = storage.local.getText(storeKey);
|
const storeInfo = await storage.local.getText(storeKey);
|
||||||
let starray = storeInfo.split("|");
|
let starray = storeInfo.split("|");
|
||||||
|
|
||||||
if (starray[2] == "1") {
|
if (starray[2] == "1") {
|
||||||
@@ -71,14 +71,13 @@ export function saveNote(noteForm, secret) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteNote(key) {
|
export async function deleteNote(key) {
|
||||||
let storeKey = getStoreKey(key);
|
let storeKey = getStoreKey(key);
|
||||||
let storeInfo = storage.local.getText(storeKey);
|
const storeInfo = await storage.local.getText(storeKey);
|
||||||
let note = {
|
let note = {
|
||||||
cipher: storeInfo.substring(2, 34),
|
cipher: storeInfo.substring(2, 34),
|
||||||
key: key,
|
key: key,
|
||||||
};
|
};
|
||||||
|
|
||||||
return axios({
|
return axios({
|
||||||
url: NoteConstant.servicePath + "/note/" + key + "/delete",
|
url: NoteConstant.servicePath + "/note/" + key + "/delete",
|
||||||
method: "post",
|
method: "post",
|
||||||
@@ -97,6 +96,28 @@ export function getNoteBlob(key) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getNoteMetaNew(key) {
|
||||||
|
let url = NoteConstant.servicePath + "/note/" + key + "/noteMeta";
|
||||||
|
return axios({
|
||||||
|
url: url,
|
||||||
|
method: "get",
|
||||||
|
ignoreError: 1,
|
||||||
|
original: true,
|
||||||
|
source: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getKeyMetaNew() {
|
||||||
|
let url = NoteConstant.servicePath + "/note/keyMeta";
|
||||||
|
return axios({
|
||||||
|
url: url,
|
||||||
|
method: "get",
|
||||||
|
ignoreError: 1,
|
||||||
|
original: true,
|
||||||
|
source: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function getNoteMeta(key) {
|
export function getNoteMeta(key) {
|
||||||
let url = NoteConstant.servicePath + "/note/" + key + "/noteMeta";
|
let url = NoteConstant.servicePath + "/note/" + key + "/noteMeta";
|
||||||
let noteMeta = null;
|
let noteMeta = null;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { getKeyMeta } from "@/api/note";
|
|
||||||
import { getStoreKey } from "@/api/lock";
|
import { getStoreKey } from "@/api/lock";
|
||||||
import { wrap } from "@/libs/secret";
|
import { wrap } from "@/libs/secret";
|
||||||
import storage from "@/libs/storage";
|
import storage from "@/libs/storage";
|
||||||
@@ -12,7 +11,7 @@ export function setStoreText(noteForm, state, secret) {
|
|||||||
storeText = wrap(text, secret.secretKey);
|
storeText = wrap(text, secret.secretKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.local.setText(
|
return storage.local.setText(
|
||||||
secret.storeKey,
|
secret.storeKey,
|
||||||
state.lock +
|
state.lock +
|
||||||
"|" +
|
"|" +
|
||||||
@@ -26,8 +25,7 @@ export function setStoreText(noteForm, state, secret) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setNewStoreText(noteForm) {
|
export function setNewStoreText(noteForm,keyMeta) {
|
||||||
let keyMeta =getKeyMeta();
|
|
||||||
let storeKey = getStoreKey(keyMeta.key);
|
let storeKey = getStoreKey(keyMeta.key);
|
||||||
|
|
||||||
let text = noteForm.text;
|
let text = noteForm.text;
|
||||||
@@ -38,7 +36,7 @@ export function setNewStoreText(noteForm) {
|
|||||||
storeText = wrap(text, keyMeta.secretKey);
|
storeText = wrap(text, keyMeta.secretKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.local.setText(
|
return storage.local.setText(
|
||||||
storeKey,
|
storeKey,
|
||||||
"0|" +
|
"0|" +
|
||||||
keyMeta.cipher +
|
keyMeta.cipher +
|
||||||
@@ -47,8 +45,6 @@ export function setNewStoreText(noteForm) {
|
|||||||
"|" +
|
"|" +
|
||||||
storeText
|
storeText
|
||||||
);
|
);
|
||||||
|
|
||||||
return keyMeta.key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function clearStoreText(key) {
|
export function clearStoreText(key) {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import localforage from "localforage";
|
||||||
|
|
||||||
class Storage {
|
class Storage {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.session = new Session();
|
this.session = new Session();
|
||||||
@@ -29,23 +31,23 @@ class Session {
|
|||||||
|
|
||||||
class Local {
|
class Local {
|
||||||
setObject(key, value) {
|
setObject(key, value) {
|
||||||
localStorage.setItem(key, JSON.stringify(value));
|
return localforage.setItem(key, JSON.stringify(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
getObject(key) {
|
getObject(key) {
|
||||||
return JSON.parse(localStorage.getItem(key));
|
return JSON.parse(localforage.getItem(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(key) {
|
delete(key) {
|
||||||
localStorage.removeItem(key);
|
return localforage.removeItem(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
setText(key, value) {
|
setText(key, value) {
|
||||||
localStorage.setItem(key, value);
|
return localforage.setItem(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
getText(key) {
|
getText(key) {
|
||||||
return localStorage.getItem(key);
|
return localforage.getItem(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUseSize() {
|
getUseSize() {
|
||||||
|
|||||||
17
src/main.js
17
src/main.js
@@ -1,12 +1,15 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import getRouter from './router/'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import VueAxios from 'vue-axios'
|
import VueAxios from 'vue-axios'
|
||||||
import './plugins/iview.js'
|
import './plugins/iview.js'
|
||||||
|
import {Promise} from "bluebird";
|
||||||
import i18n from './i18n/'
|
import i18n from './i18n/'
|
||||||
|
|
||||||
import NoteConstant from "@/libs/constants";
|
import NoteConstant from "@/libs/constants";
|
||||||
|
|
||||||
|
|
||||||
axios.defaults.baseURL = NoteConstant.servicePath;
|
axios.defaults.baseURL = NoteConstant.servicePath;
|
||||||
|
|
||||||
Vue.use(VueAxios, axios)
|
Vue.use(VueAxios, axios)
|
||||||
@@ -16,10 +19,12 @@ Vue.config.debug = debugFlag;
|
|||||||
Vue.config.devtools = debugFlag;
|
Vue.config.devtools = debugFlag;
|
||||||
Vue.config.productionTip = debugFlag;
|
Vue.config.productionTip = debugFlag;
|
||||||
|
|
||||||
new Vue({
|
Promise.try(getRouter).then((router)=>{
|
||||||
i18n,
|
new Vue({
|
||||||
router,
|
i18n,
|
||||||
render: h => h(App)
|
router,
|
||||||
}).$mount('#app')
|
render: h => h(App)
|
||||||
|
}).$mount('#app')
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,149 +1,131 @@
|
|||||||
import Vue from "vue";
|
import { getNoteMetaNew } from "@/api/note";
|
||||||
import VueRouter from "vue-router";
|
import VueRouter from "vue-router";
|
||||||
import EditNote from "@/views/EditNote.vue";
|
import EditNote from "@/views/EditNote.vue";
|
||||||
import ViewNote from "@/views/ViewNote.vue";
|
import ViewNote from "@/views/ViewNote.vue";
|
||||||
import ErrorRoute from "@/views/ErrorRoute.vue";
|
|
||||||
import ErrorNote from "@/views/ErrorNote.vue";
|
import ErrorNote from "@/views/ErrorNote.vue";
|
||||||
import { getKeyMeta, getNoteMeta } from "@/api/note";
|
|
||||||
import { getStoreKey } from "@/api/lock";
|
|
||||||
import storage from "@/libs/storage";
|
import storage from "@/libs/storage";
|
||||||
|
import { getStoreKey } from "@/api/lock";
|
||||||
|
|
||||||
Vue.use(VueRouter);
|
|
||||||
|
|
||||||
var keyMeta = null;
|
export default async function getRouter() {
|
||||||
var noteMeta = null;
|
let path = location.pathname;
|
||||||
var errorMeta = null;
|
let key = path.substring(1, path.length);
|
||||||
|
//let errorMeta = null;
|
||||||
|
|
||||||
function getKeyMetaParam() {
|
if (path == "/") {
|
||||||
return keyMeta;
|
//errorMeta = 100002;
|
||||||
}
|
return errorRouter(100002);
|
||||||
|
|
||||||
function getNoteMetaParam() {
|
|
||||||
return noteMeta;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getErrorMetaParam() {
|
|
||||||
return errorMeta;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNoteView() {
|
|
||||||
if (errorMeta) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let path = location.pathname;
|
|
||||||
|
|
||||||
let key = path.substring(1, path.length);
|
|
||||||
|
|
||||||
if (keyMeta && keyMeta.key) {
|
|
||||||
key = keyMeta.key;
|
|
||||||
}
|
|
||||||
|
|
||||||
let regKey = /^[abcdefhikmnopqstuvwxyz23456789]{16}$/;
|
|
||||||
if (!regKey.test(key)) {
|
|
||||||
errorMeta = 100002;
|
|
||||||
return ErrorNote;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyMeta && keyMeta.key) {
|
|
||||||
//firstEdit
|
|
||||||
return EditNote;
|
|
||||||
}
|
|
||||||
|
|
||||||
//set noteMeta
|
|
||||||
noteMeta = getNoteMeta(key);
|
|
||||||
|
|
||||||
//server error
|
|
||||||
if (!noteMeta) {
|
|
||||||
errorMeta = 100006;
|
|
||||||
return ErrorNote;
|
|
||||||
}
|
|
||||||
|
|
||||||
//invalidated key
|
|
||||||
if (!noteMeta.key) {
|
|
||||||
errorMeta = 100002;
|
|
||||||
return ErrorNote;
|
|
||||||
}
|
|
||||||
|
|
||||||
//validated state
|
|
||||||
if (1 == noteMeta.state) {
|
|
||||||
return ViewNote;
|
|
||||||
}
|
|
||||||
|
|
||||||
//deleted
|
|
||||||
if (0 == noteMeta.state) {
|
|
||||||
let storeKey = getStoreKey(key);
|
|
||||||
storage.local.delete(storeKey);
|
|
||||||
// user deleted
|
|
||||||
if (noteMeta.ttl > 0) {
|
|
||||||
errorMeta = 100003;
|
|
||||||
return ErrorNote;
|
|
||||||
} else {// timeout
|
|
||||||
errorMeta = 100004;
|
|
||||||
return ErrorNote;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (null == noteMeta.state) {
|
let keyMeta = storage.session.getObject("keyMeta");
|
||||||
let storeKey = getStoreKey(key);
|
storage.session.delete("keyMeta");
|
||||||
//if has storage , then edit
|
|
||||||
if (storage.local.getText(storeKey)) {
|
let regKey = /^[abcdefhikmnopqstuvwxyz23456789]{16}$/;
|
||||||
return EditNote;
|
|
||||||
} else {
|
if (!regKey.test(key)) {
|
||||||
//storage is empty
|
return errorRouter(100002);
|
||||||
let df = storage.session.getText(storeKey + "_delete")
|
|
||||||
if (df) {//unsubmitted,user deleted.
|
|
||||||
errorMeta = 100003;
|
|
||||||
return ErrorNote;
|
|
||||||
} else {//unsubmitted
|
|
||||||
errorMeta = 100005;
|
|
||||||
return ErrorNote;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// other exception
|
if (keyMeta && keyMeta.key) {
|
||||||
errorMeta = 100001;
|
// if(document.referrer=="/"){
|
||||||
return ErrorNote;
|
// }
|
||||||
|
return noteRouter(EditNote, keyMeta, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
let resp = await getNoteMetaNew(key);
|
||||||
|
|
||||||
|
|
||||||
|
if (null == resp || null == resp.data) {
|
||||||
|
return errorRouter(100006);
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = resp.data;
|
||||||
|
if (result.code != '000000') {
|
||||||
|
return errorRouter(parseInt(result.code));
|
||||||
|
}
|
||||||
|
|
||||||
|
let noteMeta = result.data;
|
||||||
|
if (null == noteMeta) {
|
||||||
|
return errorRouter(100001);
|
||||||
|
}
|
||||||
|
if (null == noteMeta.key) {
|
||||||
|
return errorRouter(100002);
|
||||||
|
}
|
||||||
|
|
||||||
|
//view
|
||||||
|
if (1 == noteMeta.state) {
|
||||||
|
return noteRouter(ViewNote, keyMeta, noteMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
//deleted
|
||||||
|
if (0 == noteMeta.state) {
|
||||||
|
let storeKey = getStoreKey(key);
|
||||||
|
storage.local.delete(storeKey);
|
||||||
|
// user deleted
|
||||||
|
if (noteMeta.ttl > 0) {
|
||||||
|
// errorMeta = 100003;
|
||||||
|
return errorRouter(100003);
|
||||||
|
} else {// timeout
|
||||||
|
// errorMeta = 100004;
|
||||||
|
return errorRouter(100004);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//edit or unsubmitted
|
||||||
|
if (null == noteMeta.state) {
|
||||||
|
let storeKey = getStoreKey(key);
|
||||||
|
const storeInfo = await storage.local.getText(storeKey);
|
||||||
|
|
||||||
|
//if has storage , then edit
|
||||||
|
if (null != storeInfo) {
|
||||||
|
return noteRouter(EditNote, keyMeta, noteMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
//storage is empty
|
||||||
|
let df = storage.session.getText(storeKey + "_delete")
|
||||||
|
if (df) {//unsubmitted,user deleted.
|
||||||
|
// errorMeta = 100003;
|
||||||
|
return errorRouter(100003);
|
||||||
|
} else {//unsubmitted
|
||||||
|
// errorMeta = 100005;
|
||||||
|
return errorRouter(100005);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return errorRouter(100001);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHomeRedirect() {
|
function noteRouter(noteView, keyMeta, noteMeta) {
|
||||||
let path = location.pathname;
|
const routes = [
|
||||||
if (path != "/") {
|
{
|
||||||
return;
|
path: "/:name([a-z0-9]{10,20})",
|
||||||
}
|
name: "note",
|
||||||
|
component: noteView,
|
||||||
|
meta: { keyMeta: keyMeta, noteMeta: noteMeta },
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
//setKeyMeta
|
const router = new VueRouter({
|
||||||
keyMeta = getKeyMeta();
|
routes,
|
||||||
|
mode: "history",
|
||||||
// server error
|
});
|
||||||
if (!keyMeta) {
|
return router;
|
||||||
errorMeta = 100006;
|
|
||||||
return "/error_"+errorMeta;
|
|
||||||
}
|
|
||||||
|
|
||||||
return "/" + keyMeta.key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const routes = [
|
|
||||||
{
|
|
||||||
path: "/",
|
|
||||||
name: "home",
|
|
||||||
redirect: getHomeRedirect(),
|
|
||||||
},
|
|
||||||
{ path: "/error_:code([0-9]{6})", component: ErrorNote },
|
|
||||||
{
|
|
||||||
path: "/:name([a-z0-9]{10,20})",
|
|
||||||
name: "note",
|
|
||||||
component: getNoteView(),
|
|
||||||
meta: { keyMeta: getKeyMetaParam(), noteMeta: getNoteMetaParam(), errorMeta: getErrorMetaParam() },
|
|
||||||
},
|
|
||||||
{ path: "/:path(.*)", component: ErrorRoute }
|
|
||||||
];
|
|
||||||
|
|
||||||
const router = new VueRouter({
|
function errorRouter(errorCode) {
|
||||||
routes,
|
const routes = [
|
||||||
mode: "history",
|
{
|
||||||
});
|
path: "/:name([a-z0-9]{10,20})",
|
||||||
|
name: "error",
|
||||||
|
component: ErrorNote,
|
||||||
|
errorMeta: errorCode
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const router = new VueRouter({
|
||||||
|
routes,
|
||||||
|
mode: "history",
|
||||||
|
});
|
||||||
|
return router;
|
||||||
|
}
|
||||||
|
|
||||||
export default router;
|
|
||||||
|
|||||||
@@ -201,6 +201,7 @@ import { setStoreText,setNewStoreText } from "@/libs/noteStorage";
|
|||||||
import { saveAs } from 'file-saver';
|
import { saveAs } from 'file-saver';
|
||||||
import { isWeixin } from "@/libs/utils";
|
import { isWeixin } from "@/libs/utils";
|
||||||
import NoteConstant from "@/libs/constants";
|
import NoteConstant from "@/libs/constants";
|
||||||
|
import { getKeyMeta } from "@/api/note";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'EditNote',
|
name: 'EditNote',
|
||||||
@@ -247,10 +248,10 @@ export default {
|
|||||||
let keyMeta = this.$route.meta.keyMeta;
|
let keyMeta = this.$route.meta.keyMeta;
|
||||||
|
|
||||||
//ipad chrome url not redirect
|
//ipad chrome url not redirect
|
||||||
let path = location.pathname;
|
// let path = location.pathname;
|
||||||
if ("/" == path) {
|
// if ("/" == path) {
|
||||||
history.pushState('', '', '/' + this.noteForm.key);
|
// history.pushState('', '', '/' + this.noteForm.key);
|
||||||
}
|
// }
|
||||||
|
|
||||||
//wx does not show downloadText
|
//wx does not show downloadText
|
||||||
this.model.showDownloadText = !isWeixin();
|
this.model.showDownloadText = !isWeixin();
|
||||||
@@ -281,16 +282,20 @@ export default {
|
|||||||
let noteMeta = this.$route.meta.noteMeta;
|
let noteMeta = this.$route.meta.noteMeta;
|
||||||
this.secret.secretKey = noteMeta.secretKey;
|
this.secret.secretKey = noteMeta.secretKey;
|
||||||
|
|
||||||
let storeInfo = storage.local.getText(storeKey);
|
let that = this;
|
||||||
let starray = storeInfo.split('|');
|
|
||||||
this.state.lock = parseInt(starray[0]);
|
storage.local.getText(storeKey).then(function(storeInfo){
|
||||||
this.secret.cipher = starray[1];
|
let starray = storeInfo.split('|');
|
||||||
this.state.initTime = parseInt(starray[3]);
|
that.state.lock = parseInt(starray[0]);
|
||||||
|
that.secret.cipher = starray[1];
|
||||||
|
that.state.initTime = parseInt(starray[3]);
|
||||||
|
|
||||||
|
//draw text;
|
||||||
|
if (starray[4]) {
|
||||||
|
that.noteForm.text = unwrap(starray[4], that.secret.secretKey);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//draw text;
|
|
||||||
if (starray[4]) {
|
|
||||||
this.noteForm.text = unwrap(starray[4], this.secret.secretKey);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bindCtrlAllEvent();
|
this.bindCtrlAllEvent();
|
||||||
@@ -398,13 +403,10 @@ export default {
|
|||||||
setStoreText(this.noteForm, this.state, this.secret);
|
setStoreText(this.noteForm, this.state, this.secret);
|
||||||
|
|
||||||
} else if (event.ctrlKey && (event.which == 13)) {
|
} else if (event.ctrlKey && (event.which == 13)) {
|
||||||
//save
|
|
||||||
this.submitNote();
|
this.submitNote();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
save() {
|
|
||||||
return saveNote(this.noteForm, this.secret);
|
|
||||||
},
|
|
||||||
validateForm() {
|
validateForm() {
|
||||||
let text = this.noteForm.text;
|
let text = this.noteForm.text;
|
||||||
if (text.length > NoteConstant.noteMaxCount) {
|
if (text.length > NoteConstant.noteMaxCount) {
|
||||||
@@ -433,25 +435,28 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setStoreText(this.noteForm, this.state, this.secret);
|
||||||
|
|
||||||
this.model.submitting = true;
|
this.model.submitting = true;
|
||||||
|
|
||||||
let that = this;
|
let that = this;
|
||||||
this.save().then(res => {
|
saveNote(this.noteForm, this.secret).then(res => {
|
||||||
if (res.data && res.data.code == "000000") {
|
if (res.data && res.data.code == "000000") {
|
||||||
storage.session.setText(that.secret.storeKey + "_share", '1');
|
storage.session.setText(that.secret.storeKey + "_share", '1');
|
||||||
|
|
||||||
that.state.commited = 1;
|
that.state.commited = 1;
|
||||||
setStoreText(this.noteForm, this.state, this.secret);
|
setStoreText(this.noteForm, this.state, this.secret).then(function(){
|
||||||
|
location.reload();
|
||||||
location.reload();
|
});
|
||||||
this.state.locking = 0;
|
|
||||||
} else {
|
} else {
|
||||||
alert(res.data.code);
|
alert(res.data.code);
|
||||||
this.model.submitting = false;
|
this.model.submitting = false;
|
||||||
this.state.locking = 0;
|
this.state.locking = 0;
|
||||||
if(res.data.code=="100013"||res.data.code=="800001"){
|
if(res.data.code=="100013"||res.data.code=="800001"){
|
||||||
let key = setNewStoreText(this.noteForm);
|
let keyMeta = getKeyMeta();
|
||||||
location.href="/"+key;
|
setNewStoreText(this.noteForm,keyMeta).then(function () {
|
||||||
|
location.href="/"+keyMeta.key;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -420,9 +420,13 @@ export default {
|
|||||||
|
|
||||||
this.startClock();
|
this.startClock();
|
||||||
|
|
||||||
storage.local.dynamicClear();
|
|
||||||
|
|
||||||
this.loadText();
|
let that = this;
|
||||||
|
storage.local.getText(this.secret.storeKey).then(function(storeInfo){
|
||||||
|
that.loadText(storeInfo);
|
||||||
|
});
|
||||||
|
|
||||||
|
storage.local.dynamicClear();
|
||||||
|
|
||||||
this.bindCtrlAllEvent();
|
this.bindCtrlAllEvent();
|
||||||
this.bindCopyUrlEvent();
|
this.bindCopyUrlEvent();
|
||||||
@@ -517,8 +521,9 @@ export default {
|
|||||||
that.state.ttl = that.state.initTtl - (new Date().getTime() - that.state.initTime);
|
that.state.ttl = that.state.initTtl - (new Date().getTime() - that.state.initTime);
|
||||||
|
|
||||||
if (that.state.ttl <= 0) {
|
if (that.state.ttl <= 0) {
|
||||||
storage.local.delete(that.secret.storeKey);
|
storage.local.delete(that.secret.storeKey).then(function(){
|
||||||
location.reload();
|
location.reload();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, 1000)
|
}, 1000)
|
||||||
},
|
},
|
||||||
@@ -554,8 +559,9 @@ export default {
|
|||||||
let that = this;
|
let that = this;
|
||||||
deleteNote(this.noteForm.key).then(res => {
|
deleteNote(this.noteForm.key).then(res => {
|
||||||
if (res.data&&res.data.code=="000000") {
|
if (res.data&&res.data.code=="000000") {
|
||||||
storage.local.delete(that.secret.storeKey);
|
storage.local.delete(that.secret.storeKey).then(function(){
|
||||||
location.reload();
|
location.reload();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
that.model.deleting = false;
|
that.model.deleting = false;
|
||||||
}
|
}
|
||||||
@@ -563,11 +569,9 @@ export default {
|
|||||||
alert(error);
|
alert(error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
loadText() {
|
loadText(storeInfo) {
|
||||||
let that = this;
|
let that = this;
|
||||||
|
|
||||||
let storeInfo = storage.local.getText(this.secret.storeKey);
|
|
||||||
|
|
||||||
let starray = [];
|
let starray = [];
|
||||||
if (storeInfo) {
|
if (storeInfo) {
|
||||||
starray = storeInfo.split('|');
|
starray = storeInfo.split('|');
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ module.exports = defineConfig({
|
|||||||
devServer: {
|
devServer: {
|
||||||
proxy: {
|
proxy: {
|
||||||
"/note": {
|
"/note": {
|
||||||
// target: "https://flagnote.com/", // 后台接口域名
|
target: "https://flagnote.com/", // 后台接口域名
|
||||||
target: "http://localhost:10000/", // 后台接口域名
|
// target: "http://localhost:10000/", // 后台接口域名
|
||||||
secure: false, // 如果是https接口,需要配置这个参数
|
secure: false, // 如果是https接口,需要配置这个参数
|
||||||
changeOrigin: true, //是否跨域
|
changeOrigin: true, //是否跨域
|
||||||
pathRewrite: {
|
pathRewrite: {
|
||||||
|
|||||||
Reference in New Issue
Block a user