diff --git a/package.json b/package.json
index d1e8a0d..77ccd3e 100644
--- a/package.json
+++ b/package.json
@@ -5,6 +5,8 @@
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
+ "build.test": "vue-cli-service build --mode test",
+ "build.production": "vue-cli-service build --mode production",
"lint": "vue-cli-service lint"
},
"dependencies": {
@@ -15,7 +17,6 @@
"crypto-js": "^4.1.1",
"escape-html": "^1.0.3",
"file-saver": "^2.0.5",
- "jquery": "^3.6.0",
"nprogress": "^0.2.0",
"pako": "^2.0.4",
"qrcode": "^1.5.0",
diff --git a/public/IeIsNotSupported.html b/public/IeIsNotSupported.html
index f43d1fb..527315c 100644
--- a/public/IeIsNotSupported.html
+++ b/public/IeIsNotSupported.html
@@ -1,25 +1,37 @@
-
-
-
-
-
-
-
-
-
-
-
- flagnote.com
-
-
-
-
- IE is not supported.
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ flagnote.com
+
+
+
+
+ IE is not supported.
+
\ No newline at end of file
diff --git a/public/index.html b/public/index.html
index ac26e2f..a5a933b 100644
--- a/public/index.html
+++ b/public/index.html
@@ -2,13 +2,25 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
flagnote.com
diff --git a/src/api/lock.js b/src/api/lock.js
index d9bb425..72bcbd2 100644
--- a/src/api/lock.js
+++ b/src/api/lock.js
@@ -1,40 +1,13 @@
-// import Jquery from "jquery";
-import {aesEncrypt, md5} from "@/libs/secret";
-
-// export function getSecretKey(key, password) {
-// console.log("getSecretKey");
-// let secretKey = '';
-// Jquery.ajax({
-// method: 'POST',
-// url: '/note/' + key + "/secretKey",
-// async: false,
-// contentType: 'application/json',
-// dataTeyp: 'json',
-// data: JSON.stringify({'password': password}),
-// success: function (data) {
-// secretKey = data;
-// },
-// error: function () {
-// alert('服务器链接异常 ');
-// },
-// });
-// return secretKey;
-// }
+import { aesEncrypt, md5 } from "@/libs/secret";
export function getStoreKey(key) {
- return md5(aesEncrypt(key, key));
+ return md5(key + key);
}
-export function getSecretKey(cipher, password) {
- if(!password){
- password = '';
- }
- return md5(cipher + password);
+export function getSecretKey(key, password) {
+ if (!password) {
+ password = key;
+ }
+
+ return md5(aesEncrypt(key, password));
}
-
-
-
-
-
-
-
diff --git a/src/api/note.js b/src/api/note.js
index c212aef..efed9a3 100644
--- a/src/api/note.js
+++ b/src/api/note.js
@@ -1,109 +1,99 @@
import axios from "axios";
-import Jquery from "jquery";
-import {getStoreKey} from "@/api/lock";
+import { getStoreKey } from "@/api/lock";
import storage from "@/libs/storage";
+import { md5 } from "@/libs/secret";
-const servicePath = 'https://service.flagnote.com';
+const servicePath = "https://flagnote.com";
+//const servicePath = "http://localhost:8080";
-export function saveNote(noteForm) {
- let storeKey = getStoreKey(noteForm.key);
- let storeText = storage.local.getText(storeKey + '.text');
- let note = {
- "lock": storeText.substring(0, 1),
- "cipher": storeText.substring(2, 34),
- "text": storeText.substring(35+16),
- "key": noteForm.key
- }
+export function saveNote(noteForm, secret) {
+ let storeKey = secret.storeKey;
- return axios({
- url: servicePath+'/note/' + noteForm.key,
- method: 'post',
- data: note
- }
- )
+ let storeInfo = storage.local.getText(storeKey);
+ let starray = storeInfo.split("|");
+
+ let note = {
+ lock: starray[0],
+ cipher: starray[1],
+ text: starray[4],
+ key: noteForm.key,
+ };
+
+ let bufferArrary = eval("[" + note.text + "]");
+ let array = Uint8Array.from(bufferArrary);
+ let blob = new Blob([array], { type: "application/octet-stream" });
+ let form = new FormData();
+ form.append("file", blob, noteForm.key);
+ form.append("cipher", note.cipher);
+ form.append("lock", note.lock);
+ form.append("key", note.key);
+ form.append("md5", md5(note.text));
+
+ let config = {
+ headers: { "Content-Type": "multipart/form-data" },
+ };
+
+ return axios({
+ url: servicePath + "/note/" + noteForm.key,
+ method: "post",
+ data: form,
+ config: config,
+ });
}
export function deleteNote(key) {
- let storeKey = getStoreKey(key);
- let storeText = storage.local.getText(storeKey + '.text');
- let note = {
- "cipher": storeText.substring(2, 34),
- "key": key
- }
+ let storeKey = getStoreKey(key);
+ let storeInfo = storage.local.getText(storeKey);
+ let note = {
+ cipher: storeInfo.substring(2, 34),
+ key: key,
+ };
- return axios({
- url: servicePath+'/note/' + key +'/delete',
- method: 'post',
- data: note
- }
- )
+ return axios({
+ url: servicePath + "/note/" + key + "/delete",
+ method: "post",
+ data: note,
+ });
}
-// export function getSecretKey(key, password) {
-// console.log("getSecretKey");
-// let secretKey = '';
-// Jquery.ajax({
-// method: 'POST',
-// url: '/note/' + key + "/secretKey",
-// async: false,
-// contentType: 'application/json',
-// dataTeyp: 'json',
-// data: JSON.stringify({'password': password}),
-// success: function (data) {
-// secretKey = data;
-// },
-// error: function () {
-// alert('服务器链接异常 ');
-// },
-// });
-// return secretKey;
-// }
-
+export function getNoteBlob(key) {
+ return axios({
+ url: servicePath + "/note/" + key,
+ method: "get",
+ responseType: "blob",
+ ignoreError: 1,
+ original: true,
+ source: true,
+ });
+}
export function getNoteMeta(key) {
- let noteMeta = {};
- Jquery.ajax({
- method: 'GET',
- url: servicePath+'/note/' + key + "/noteMeta",
- async: false,
- success: function (data) {
- noteMeta = eval(data); //eval("(" + data + ")");
- },
- error: function () {
- noteMeta = null;
- },
- });
- return noteMeta;
+ let url = servicePath + "/note/" + key + "/noteMeta";
+ let noteMeta = ajaxGet(url);
+ return noteMeta;
}
-export function getNote(key) {
- let noteObject = {};
- Jquery.ajax({
- method: 'GET',
- url: servicePath + '/note/' + key,
- async: false,
- success: function (data) {
- noteObject = eval(data);
- },
- error: function () {
- noteObject = null;
- },
- });
- return noteObject;
- }
-
export function getKeyMeta() {
- let keyMeta = {};
- Jquery.ajax({
- method: 'GET',
- url: servicePath+'/note/keyMeta',
- async: false,
- success: function (data) {
- keyMeta = eval(data); //eval("(" + data + ")");
- },
- error: function () {
- keyMeta = null;
- },
- });
- return keyMeta;
+ let url = servicePath + "/note/keyMeta";
+ let keyMeta = ajaxGet(url);
+ return keyMeta;
+}
+
+export function ajaxGet(url) {
+ let data = {};
+ 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){
+ data = JSON.parse(xmlhttp.responseText);
+ }else{
+ data ={};
+ }
+ }
+ }
+ };
+ xmlhttp.send();
+ return data;
}
diff --git a/src/i18n/config/en.js b/src/i18n/config/en.js
index c5db776..a75e571 100644
--- a/src/i18n/config/en.js
+++ b/src/i18n/config/en.js
@@ -1,17 +1,17 @@
-const en = {
- message: {
- askTodelete: "Are you sure to delete?",
- },
- content: {
- blankTip: "I am Blank.",
- },
- button: {
- ok: "OK",
- yes: "Yes",
- no: "No",
- selectAll: "Select All",
- copy: "Copy",
- copyAll: "Copy All",
- },
-};
-export default en;
+const en = {
+ message: {
+ askTodelete: "Are you sure to delete?",
+ },
+ content: {
+ blankTip: "I am Blank.",
+ },
+ button: {
+ ok: "OK",
+ yes: "Yes",
+ no: "No",
+ selectAll: "Select All",
+ copy: "Copy",
+ copyAll: "Copy All",
+ },
+};
+export default en;
diff --git a/src/i18n/config/zh.js b/src/i18n/config/zh.js
index c3bf267..fcc6068 100644
--- a/src/i18n/config/zh.js
+++ b/src/i18n/config/zh.js
@@ -1,17 +1,17 @@
-const zh = {
- message: {
- askTodelete: "是否确定要删除?",
- },
- content: {
- blankTip: "我是布兰克。",
- },
- button: {
- ok: "好的",
- yes: "是的",
- no: "不",
- selectAll: "全选",
- copy: "复制",
- copyAll: "复制全部",
- },
-};
-export default zh;
+const zh = {
+ message: {
+ askTodelete: "是否确定要删除?",
+ },
+ content: {
+ blankTip: "I am Blank.",
+ },
+ button: {
+ ok: "好的",
+ yes: "是的",
+ no: "不",
+ selectAll: "全选",
+ copy: "复制",
+ copyAll: "复制全部",
+ },
+};
+export default zh;
diff --git a/src/i18n/index.js b/src/i18n/index.js
index b2b3c1a..1e3f664 100644
--- a/src/i18n/index.js
+++ b/src/i18n/index.js
@@ -1,24 +1,24 @@
-import Vue from "vue";
-import VueI18n from "vue-i18n";
-Vue.use(VueI18n);
-
-import zh from "./config/zh";
-import en from "./config/en";
-
-const i18n = new VueI18n({
- locale: getLocale(),
- messages: {
- zh,
- en,
- },
-});
-
-function getLocale(){
- if(localStorage.getItem("locale")){
- return localStorage.getItem("locale").substring(0,2);
- }
-
- return "en";
-}
-
-export default i18n;
+import Vue from "vue";
+import VueI18n from "vue-i18n";
+Vue.use(VueI18n);
+
+import zh from "./config/zh";
+import en from "./config/en";
+
+const i18n = new VueI18n({
+ locale: getLocale(),
+ messages: {
+ zh,
+ en,
+ },
+});
+
+function getLocale(){
+ if(localStorage.getItem("locale")){
+ return localStorage.getItem("locale").substring(0,2);
+ }
+
+ return "en";
+}
+
+export default i18n;
diff --git a/src/libs/noteStorage.js b/src/libs/noteStorage.js
index ddf7219..4351b39 100644
--- a/src/libs/noteStorage.js
+++ b/src/libs/noteStorage.js
@@ -1,49 +1,45 @@
-import {zip, aesEncrypt} from '../libs/secret'
+import { wrap } from "@/libs/secret";
import storage from "@/libs/storage";
-import {getSecretKey} from "@/api/lock";
import escapeHtml from "escape-html";
-export function setStoreText(noteForm, secret, password) {
- let text = noteForm.text;
+export function setStoreText(noteForm, state, secret) {
+ let text = noteForm.text;
- if (!text) {
- return;
- }
+ let storeText = "";
+ if (text) {
+ storeText = wrap(text, secret.secretKey);
+ }
- if (!password) {
- password = "";
- }
-
- text = "FLAGNOTE#" + text;
-
- let secretKey = getSecretKey(noteForm.key, password);
- let storeText = aesEncrypt(text, secretKey);
- storeText = zip(storeText);
-
- let lock = 0;
- if (password) {
- lock = 1;
- }
-
-
- storage.local.setText(secret.storeKey + '.text', lock + '|' + secret.cipher + '|0|'+ noteForm.initTime+'|' + storeText);
+ storage.local.setText(
+ secret.storeKey,
+ state.lock +
+ "|" +
+ secret.cipher +
+ "|" +
+ state.commited +
+ "|" +
+ state.initTime +
+ "|" +
+ storeText
+ );
}
-
export function clearStoreText(key) {
- if (!key) {
- return;
- }
- storage.local.delete(key);
+ if (!key) {
+ return;
+ }
+ storage.local.delete(key);
}
-
export function getEscapeText(text) {
- let textEscape = escapeHtml(text);
- textEscape = textEscape.replace(new RegExp(' ','gm'), " ");
- textEscape = textEscape.replace(new RegExp('\\r\\n','gm'), "
");
- textEscape = textEscape.replace(new RegExp('\\r','gm'), "
");
- textEscape = textEscape.replace(new RegExp('\\n','gm'), "
");
- textEscape = textEscape.replace(new RegExp('\\t','gm'), "
");
- return textEscape;
+ let textEscape = escapeHtml(text);
+ textEscape = textEscape.replace(new RegExp(" ", "gm"), " ");
+ textEscape = textEscape.replace(new RegExp("\\r\\n", "gm"), "
");
+ textEscape = textEscape.replace(new RegExp("\\r", "gm"), "
");
+ textEscape = textEscape.replace(new RegExp("\\n", "gm"), "
");
+ textEscape = textEscape.replace(
+ new RegExp("\\t", "gm"),
+ '
'
+ );
+ return textEscape;
}
diff --git a/src/libs/secret.js b/src/libs/secret.js
index bbf5d2d..dbe6553 100644
--- a/src/libs/secret.js
+++ b/src/libs/secret.js
@@ -1,57 +1,77 @@
-import CryptoJS from 'crypto-js'
-import pako from 'pako'
+import CryptoJS from "crypto-js";
+import pako from "pako";
/**
* @word 要加密的内容
* @keyWord String 服务器随机返回的关键字
* */
+export function wrap(text, secretKey) {
+ text = "FLAGNOTE#" + text;
+ let result = aesEncrypt(text, secretKey);
+ result = zip(result);
+ return result;
+}
+
+export function unwrap(storeText, secretKey) {
+ let result = unzip(storeText);
+ result = aesDecrypt(result, secretKey);
+ if (result.startsWith("FLAGNOTE#")) {
+ return result.substring(9);
+ }
+ return null;
+}
+
//加密
-export function md5(word, keyWord = 'F1agn0te') {
- let srcWords = CryptoJS.enc.Utf8.parse(word + '_' + keyWord);
- let encrypted = CryptoJS.MD5(srcWords);
- return encrypted.toString();
+export function md5(word, keyWord = "F1agn0te") {
+ let srcWords = CryptoJS.enc.Utf8.parse(word + "_" + keyWord);
+ let encrypted = CryptoJS.MD5(srcWords);
+ return encrypted.toString();
}
//加密
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});
- return encrypted.toString();
+ 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,
+ });
+ return encrypted.toString();
}
//解密
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()
+ 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();
}
export function encode(text) {
- return btoa(encodeURIComponent(text))
+ return btoa(encodeURIComponent(text));
}
export function decode(text) {
- return decodeURIComponent(atob(text))
+ return decodeURIComponent(atob(text));
}
export function unzip(text) {
- let charData = text.split(',').map(function (x) {
- return parseInt(x)
- });
- let binData = new Uint8Array(charData);
- let data = pako.ungzip(binData);
- //text = String.fromCharCode.apply(null, new Uint8Array(data));
- text = new Uint8Array(data).reduce(function (data, byte) {
- return data + String.fromCharCode(byte);
- }, '');
- return text;
+ let charData = text.split(",").map(function (x) {
+ return parseInt(x);
+ });
+ let binData = new Uint8Array(charData);
+ let data = pako.ungzip(binData);
+ //text = String.fromCharCode.apply(null, new Uint8Array(data));
+ text = new Uint8Array(data).reduce(function (data, byte) {
+ return data + String.fromCharCode(byte);
+ }, "");
+ return text;
}
export function zip(text) {
- text = pako.gzip(text, {to: 'string'});
- return text;
+ text = pako.gzip(text, { to: "string" });
+ return text;
}
-
-
diff --git a/src/libs/utils.js b/src/libs/utils.js
index db1288b..1c7c5c9 100644
--- a/src/libs/utils.js
+++ b/src/libs/utils.js
@@ -1,18 +1,18 @@
-export function isWeixin(){
- var useragent = navigator.userAgent;
- if (useragent.match(/MicroMessenger/i) == 'MicroMessenger') {
- return true;
- }
- return false;
-}
-
-export function isIE() {
- if (navigator.userAgent.match(/msie/) != null || navigator.userAgent.match(/trident/) != null) {
- return true;
- }
- return false;
-}
-
-export function getNoteUrl(key){
- return "https://flagnote.com/" + key;
+export function isWeixin(){
+ var useragent = navigator.userAgent;
+ if (useragent.match(/MicroMessenger/i) == 'MicroMessenger') {
+ return true;
+ }
+ return false;
+}
+
+export function isIE() {
+ if (navigator.userAgent.match(/msie/) != null || navigator.userAgent.match(/trident/) != null) {
+ return true;
+ }
+ return false;
+}
+
+export function getNoteUrl(key){
+ return "https://flagnote.com/" + key;
}
\ No newline at end of file
diff --git a/src/main.js b/src/main.js
index a8b660c..314ff91 100644
--- a/src/main.js
+++ b/src/main.js
@@ -13,11 +13,14 @@ Vue.use(VueContextMenu)
-axios.defaults.baseURL="https://service.flagnote.com"
+axios.defaults.baseURL="https://flagnote.com";
Vue.use(VueAxios, axios)
-Vue.config.productionTip = false
+const debugFlag = process.env.NODE_ENV !== 'production';
+Vue.config.debug = debugFlag;
+Vue.config.devtools = debugFlag;
+Vue.config.productionTip = debugFlag;
new Vue({
i18n,
diff --git a/src/router/index.js b/src/router/index.js
index a3c160c..75224b1 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -46,13 +46,13 @@ function getNoteView() {
let storeKey = getStoreKey(key);
- let storeText = storage.local.getText(storeKey + ".text");
- if (storeText) {
- let starray = storeText.split("|");
+ let storeInfo = storage.local.getText(storeKey);
+ if (storeInfo) {
+ let starray = storeInfo.split("|");
let commitFlag = starray[2];
if (commitFlag == "1") {
//timeout and clear local
- storage.local.delete(storeKey + '.text');
+ storage.local.delete(storeKey );
return BlankNote;
} else {
//secondEdit
diff --git a/src/views/BlankNote.vue b/src/views/BlankNote.vue
index 13c7a8e..dcd6596 100644
--- a/src/views/BlankNote.vue
+++ b/src/views/BlankNote.vue
@@ -34,24 +34,22 @@
border: 0px solid #dcdee2;
border-color: #e8eaec;
}
-