3 Commits

Author SHA1 Message Date
Jesse-Ma
89d099fecf delete files 2023-03-10 16:37:27 +08:00
Jesse-Ma
8ce9342b8e async way blocked :( 2023-03-10 13:42:36 +08:00
Jesse-Ma
11987b0a77 router done 2023-03-10 10:30:43 +08:00
19 changed files with 21913 additions and 1484 deletions

View File

@@ -1,6 +1,6 @@
NODE_ENV = developement
VUE_APP_BASE_NAME = developement
VUE_APP_BASE_URL = http://localhost:8080
VUE_APP_NOTE_MAX_COUNT = 131072
VUE_APP_NOTE_MAX_DESC = 128K
VUE_APP_NOTE_MAX_COUNT = 409600
VUE_APP_NOTE_MAX_DESC = 400K

View File

@@ -1,5 +1,5 @@
NODE_ENV = production
VUE_APP_BASE_NAME = production
VUE_APP_BASE_URL = https://flagnote.com
VUE_APP_NOTE_MAX_COUNT = 131072
VUE_APP_NOTE_MAX_DESC = 128K
VUE_APP_NOTE_MAX_COUNT = 409600
VUE_APP_NOTE_MAX_DESC = 400K

20618
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -11,12 +11,12 @@
},
"dependencies": {
"axios": "^0.27.2",
"buffer": "^6.0.3",
"bluebird": "^3.7.2",
"clipboard": "^2.0.11",
"crypto-js": "^4.1.1",
"escape-html": "^1.0.3",
"file-saver": "^2.0.5",
"html2canvas": "^1.4.1",
"localforage": "^1.10.0",
"pako": "^2.1.0",
"qrcodejs2": "^0.0.2",
"view-design": "^4.7.0",

View File

@@ -28,29 +28,25 @@
type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-router@3.6.5/dist/vue-router.min.js"
type="text/javascript"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/axios@0.27.2/dist/axios.min.js"
type="text/javascript"></script> -->
<script src="https://cdn.jsdelivr.net/npm/axios@0.27.2/dist/axios.min.js"
type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/view-design@4.7.0/dist/iview.min.js"
type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/pako@2.1.0/dist/pako.min.js"
type="text/javascript"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/buffer@6.0.3/index.min.js"
type="text/javascript"></script> -->
<script src="https://cdn.jsdelivr.net/npm/crypto-js@4.1.1/crypto-js.min.js"
type="text/javascript"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/vue-i18n@8.21.1/dist/vue-i18n.min.js"
type="text/javascript"></script> -->
<!-- <script src="https://cdn.jsdelivr.net/npm/file-saver@2.0.5/dist/FileSaver.min.js"
type="text/javascript"></script> -->
<!-- <script src="https://cdn.jsdelivr.net/npm/qrcodejs2@0.0.2/qrcode.min.js"
type="text/javascript"></script> -->
<!-- <script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.11/dist/clipboard.min.js"
type="text/javascript"></script> -->
<script src="https://cdn.jsdelivr.net/npm/wasm-flate@1.0.2-browser/wasm_flate.min.js"
<script src="https://cdn.jsdelivr.net/npm/vue-i18n@8.21.1/dist/vue-i18n.min.js"
type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"
<script src="https://cdn.jsdelivr.net/npm/file-saver@2.0.5/dist/FileSaver.min.js"
type="text/javascript"></script>
<script>
<script src="https://cdn.jsdelivr.net/npm/qrcodejs2@0.0.2/qrcode.min.js"
type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.11/dist/clipboard.min.js"
type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/wasm-flate@1.0.2-browser/wasm_flate.js"
type="text/javascript"></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"
</script>

View File

@@ -6,11 +6,18 @@
<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 {
@@ -18,7 +25,10 @@
}
</style>
<script>
const servicePath = "";
//const servicePath="https://flagnote.com";
function ajaxGet(url) {
let data = null;
let xmlhttp = new XMLHttpRequest();
@@ -52,12 +62,8 @@
let keyMeta = getKeyMeta();
if (keyMeta && keyMeta.key) {
sessionStorage.setItem(keyMeta.key + ".keyMeta", JSON.stringify(keyMeta));
sessionStorage.setItem("keyMeta", JSON.stringify(keyMeta));
location.href = "/" + keyMeta.key;
} else {
location.href = "/100006";
}
</script>
</head>

View File

@@ -81,23 +81,23 @@ body {
#noteText::selection {
background: #dddddd;
color: #ed4014;
background: #ed4014;
color: white;
}
#noteText::-moz-selection {
background: #dddddd;
color: #ed4014;
background: #ed4014;
color: white;
}
#noteText br::selection {
background: #dddddd;
color: #ed4014;
background: #ed4014;
color: white;
}
#noteText br::-moz-selection {
background: #dddddd;
color: #ed4014;
background: #ed4014;
color: white;
}
.noteUrl {

View File

@@ -3,7 +3,6 @@ import { getStoreKey } from "@/api/lock";
import storage from "@/libs/storage";
import { md5, wrap } from "@/libs/secret";
import NoteConstant from "@/libs/constants";
import { Buffer } from 'buffer';
axios.interceptors.response.use(undefined, (err) => {
const { config: originalRequest } = err;
@@ -18,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 storeInfo = storage.local.getText(storeKey);
const storeInfo = await storage.local.getText(storeKey);
let starray = storeInfo.split("|");
if (starray[2] == "1") {
@@ -49,8 +48,8 @@ export function saveNote(noteForm, secret) {
});
}
let array = Buffer.from(note.text, 'base64')
let bufferArrary = eval("[100,111,32,110,111,116,32," + note.text + ",100,111,32,101,118,105,108]");
let array = Uint8Array.from(bufferArrary);
let blob = new Blob([array], { type: "application/octet-stream" });
let form = new FormData();
form.append("file", blob, noteForm.key);
@@ -72,14 +71,13 @@ export function saveNote(noteForm, secret) {
});
}
export function deleteNote(key) {
export async function deleteNote(key) {
let storeKey = getStoreKey(key);
let storeInfo = storage.local.getText(storeKey);
const storeInfo = await storage.local.getText(storeKey);
let note = {
cipher: storeInfo.substring(2, 34),
key: key,
};
return axios({
url: NoteConstant.servicePath + "/note/" + key + "/delete",
method: "post",
@@ -98,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) {
let url = NoteConstant.servicePath + "/note/" + key + "/noteMeta";
let noteMeta = null;

View File

@@ -26,9 +26,6 @@ const zh = {
"100006": "服务器不可用!",
"100011": "笔记为空!",
"100012": "笔记过大,超过{0}!",
"100013": "The address is used, Copy to a new address.",
"100014": "The text has been modified.",
"800001": "Repetitive Submit!",
}
};
export default zh;

View File

@@ -1,4 +1,3 @@
import { getKeyMeta } from "@/api/note";
import { getStoreKey } from "@/api/lock";
import { wrap } from "@/libs/secret";
import storage from "@/libs/storage";
@@ -12,7 +11,7 @@ export function setStoreText(noteForm, state, secret) {
storeText = wrap(text, secret.secretKey);
}
storage.local.setText(
return storage.local.setText(
secret.storeKey,
state.lock +
"|" +
@@ -26,8 +25,7 @@ export function setStoreText(noteForm, state, secret) {
);
}
export function setNewStoreText(noteForm) {
let keyMeta =getKeyMeta();
export function setNewStoreText(noteForm,keyMeta) {
let storeKey = getStoreKey(keyMeta.key);
let text = noteForm.text;
@@ -38,7 +36,7 @@ export function setNewStoreText(noteForm) {
storeText = wrap(text, keyMeta.secretKey);
}
storage.local.setText(
return storage.local.setText(
storeKey,
"0|" +
keyMeta.cipher +
@@ -47,8 +45,6 @@ export function setNewStoreText(noteForm) {
"|" +
storeText
);
return keyMeta.key;
}
export function clearStoreText(key) {

View File

@@ -1,45 +1,9 @@
import CryptoJS from "crypto-js";
import pako from "pako";
import {Buffer} from "buffer";
//import {gzip_encode_raw,gzip_decode_raw} from 'wasm-flate';
const wasmFlate = window.wasm_bindgen;
CryptoJS.enc.Uint8Array = {
/**
* WordArray转Uint8Array
* @param wordArray
* @returns {Uint8Array}
*/
stringify: function (wordArray) {
var len = wordArray.words.length,
u8_array = new Uint8Array(len << 2),
offset = 0, word, i;
for (i = 0; i < len; i++) {
word = wordArray.words[i];
u8_array[offset++] = word >> 24;
u8_array[offset++] = (word >> 16) & 0xff;
u8_array[offset++] = (word >> 8) & 0xff;
u8_array[offset++] = word & 0xff;
}
return u8_array;
},
/**
* Uint8Array转WordArray
* @param u8arr
* @returns {WordArray}
*/
parse: function (u8arr) {
var len = u8arr.length;
var words = [];
for (var i = 0; i < len; i++) {
words[i >>> 2] |= (u8arr[i] & 0xff) << (24 - (i % 4) * 8);
}
return CryptoJS.lib.WordArray.create(words, len);
}
};
/**
* @word 要加密的内容
* @keyWord String 服务器随机返回的关键字
@@ -47,14 +11,14 @@ CryptoJS.enc.Uint8Array = {
export function wrap(text, secretKey) {
text = "FLAGNOTE#" + text;
let ui8ary = noteZip(text);
let result = aesEncrypt(convertUint8ArrayToWordArray(ui8ary), secretKey);
let result = aesEncrypt(text, secretKey);
result = noteZip(result);
return result;
}
export function unwrap(text, secretKey) {
let wdary = aesDecrypt(text, secretKey);
let result = noteUnzip(convertWordArrayToUint8Array(wdary));
export function unwrap(storeText, secretKey) {
let result = noteUnzip(storeText);
result = aesDecrypt(result, secretKey);
if (result.startsWith("FLAGNOTE#")) {
return result.substring(9);
}
@@ -73,7 +37,7 @@ export function aesEncrypt(word, keyWord) {
let key = CryptoJS.enc.Utf8.parse(keyWord);
let encrypted = CryptoJS.AES.encrypt(word, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.ZeroPadding,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.toString();
}
@@ -84,24 +48,28 @@ 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.ZeroPadding,
padding: CryptoJS.pad.Pkcs7,
});
return decrypt;
return CryptoJS.enc.Utf8.stringify(decrypt).toString();
}
//base64 encode btoa
export function base64Encode(text) {
//base64 encode
export function encode(text) {
return Buffer.from(text, 'utf-8').toString('base64');
}
//base64 decode atob
export function base64Decode(text) {
//base64 decode
export function decode(text) {
return Buffer.from(text,'base64').toString('utf-8');
}
export function noteUnzip(wdary) {
let data = unzip(wdary);
let text = new TextDecoder().decode(data);
export function noteUnzip(text) {
let charData = text.split(",").map(function (x) {
return parseInt(x);
});
let binData = new Uint8Array(charData);
let data = unzip(binData);
text = String.fromCharCode.apply(null, new Uint8Array(data));
return text;
}
@@ -128,27 +96,35 @@ export function unzip(data){
return pako.ungzip(data);
}
// function convertWordArrayToUint8Array(wordArray) {
// var len = wordArray.words.length,
// u8_array = new Uint8Array(len << 2),
// offset = 0, word, i
// ;
// for (i=0; i<len; i++) {
// word = wordArray.words[i];
// u8_array[offset++] = word >> 24;
// u8_array[offset++] = (word >> 16) & 0xff;
// u8_array[offset++] = (word >> 8) & 0xff;
// u8_array[offset++] = word & 0xff;
// }
// return u8_array;
// }
export function convertBase64ToHexString(base64) {
return CryptoJS.enc.Hex.stringify(CryptoJS.enc.Base64.parse(base64));
}
// function convertUint8ArrayToWordArray(u8Array) {
// var words = [], i = 0, len = u8Array.length;
export function convertHexStringToBase64(hexString) {
return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Hex.parse(hexString));
}
export function convertHexStringToUint8Array(hexString) {
return Uint8Array.from(Buffer.from(hexString, 'hex'));
}
export function convertUint8ArrayToHexString(byteArray) {
return Buffer.from(byteArray).toString('hex');
}
function convertWordArrayToUint8Array(wordArray) {
return CryptoJS.enc.Uint8Array.stringify(wordArray);
}
function convertUint8ArrayToWordArray(u8Array) {
return CryptoJS.enc.Uint8Array.parse(u8Array);
}
// while (i < len) {
// words.push(
// (u8Array[i++] << 24) |
// (u8Array[i++] << 16) |
// (u8Array[i++] << 8) |
// (u8Array[i++])
// );
// }
// return {
// sigBytes: words.length * 4,
// words: words
// };
// }

View File

@@ -1,3 +1,5 @@
import localforage from "localforage";
class Storage {
constructor() {
this.session = new Session();
@@ -29,23 +31,23 @@ class Session {
class Local {
setObject(key, value) {
localStorage.setItem(key, JSON.stringify(value));
return localforage.setItem(key, JSON.stringify(value));
}
getObject(key) {
return JSON.parse(localStorage.getItem(key));
return JSON.parse(localforage.getItem(key));
}
delete(key) {
localStorage.removeItem(key);
return localforage.removeItem(key);
}
setText(key, value) {
localStorage.setItem(key, value);
return localforage.setItem(key, value);
}
getText(key) {
return localStorage.getItem(key);
return localforage.getItem(key);
}
getUseSize() {

View File

@@ -1,12 +1,15 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import getRouter from './router/'
import axios from 'axios'
import VueAxios from 'vue-axios'
import './plugins/iview.js'
import {Promise} from "bluebird";
import i18n from './i18n/'
import NoteConstant from "@/libs/constants";
axios.defaults.baseURL = NoteConstant.servicePath;
Vue.use(VueAxios, axios)
@@ -16,10 +19,12 @@ Vue.config.debug = debugFlag;
Vue.config.devtools = debugFlag;
Vue.config.productionTip = debugFlag;
Promise.try(getRouter).then((router)=>{
new Vue({
i18n,
router,
render: h => h(App)
}).$mount('#app')
});

View File

@@ -1,74 +1,60 @@
import Vue from "vue";
import { getNoteMetaNew } from "@/api/note";
import VueRouter from "vue-router";
import EditNote from "@/views/EditNote.vue";
import ViewNote from "@/views/ViewNote.vue";
import ErrorRoute from "@/views/ErrorRoute.vue";
import ErrorNote from "@/views/ErrorNote.vue";
import { getNoteMeta } from "@/api/note";
import { getStoreKey } from "@/api/lock";
import storage from "@/libs/storage";
import { getStoreKey } from "@/api/lock";
Vue.use(VueRouter);
var keyMeta = null;
var noteMeta = null;
var errorMeta = null;
function getKeyMetaParam() {
return keyMeta;
}
function getNoteMetaParam() {
return noteMeta;
}
function getErrorMetaParam() {
return errorMeta;
}
function getNoteView() {
if (errorMeta) {
return;
}
export default async function getRouter() {
let path = location.pathname;
let key = path.substring(1, path.length);
//let errorMeta = null;
keyMeta = storage.session.getObject(key+".keyMeta");
if (keyMeta && keyMeta.key) {
key = keyMeta.key;
if (path == "/") {
//errorMeta = 100002;
return errorRouter(100002);
}
let keyMeta = storage.session.getObject("keyMeta");
storage.session.delete("keyMeta");
let regKey = /^[abcdefhikmnopqstuvwxyz23456789]{16}$/;
if (!regKey.test(key)) {
errorMeta = 100002;
return ErrorNote;
return errorRouter(100002);
}
if (keyMeta && keyMeta.key) {
//firstEdit
return EditNote;
// if(document.referrer=="/"){
// }
return noteRouter(EditNote, keyMeta, null);
}
//set noteMeta
noteMeta = getNoteMeta(key);
let resp = await getNoteMetaNew(key);
//server error
if (!noteMeta) {
errorMeta = 100006;
return ErrorNote;
if (null == resp || null == resp.data) {
return errorRouter(100006);
}
//invalidated key
if (!noteMeta.key) {
errorMeta = 100002;
return ErrorNote;
let result = resp.data;
if (result.code != '000000') {
return errorRouter(parseInt(result.code));
}
//validated state
let noteMeta = result.data;
if (null == noteMeta) {
return errorRouter(100001);
}
if (null == noteMeta.key) {
return errorRouter(100002);
}
//view
if (1 == noteMeta.state) {
return ViewNote;
return noteRouter(ViewNote, keyMeta, noteMeta);
}
//deleted
@@ -77,51 +63,69 @@ function getNoteView() {
storage.local.delete(storeKey);
// user deleted
if (noteMeta.ttl > 0) {
errorMeta = 100003;
return ErrorNote;
// errorMeta = 100003;
return errorRouter(100003);
} else {// timeout
errorMeta = 100004;
return ErrorNote;
// 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 (storage.local.getText(storeKey)) {
return EditNote;
} else {
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 ErrorNote;
// errorMeta = 100003;
return errorRouter(100003);
} else {//unsubmitted
errorMeta = 100005;
return ErrorNote;
// errorMeta = 100005;
return errorRouter(100005);
}
}
return errorRouter(100001);
}
// other exception
errorMeta = 100001;
return ErrorNote;
}
function noteRouter(noteView, keyMeta, noteMeta) {
const routes = [
{ 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 }
component: noteView,
meta: { keyMeta: keyMeta, noteMeta: noteMeta },
}
];
const router = new VueRouter({
routes,
mode: "history",
});
return router;
}
function errorRouter(errorCode) {
const routes = [
{
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;

View File

@@ -39,13 +39,6 @@
}
.fade-enter-active, .fade-leave-active {
transition: opacity .25s
}
.fade-enter, .fade-leave-to /* .fade-leave-active in <2.1.8 */ {
opacity: 0
}
@media print {
@@ -81,13 +74,12 @@
:lg="{ span: 18, offset: 3 }" :xl="{ span: 16, offset: 4 }" :xxl="{ span: 16, offset: 4 }">
<Affix :offset-top="0">
<div :class="[showHeaderShade ? 'noteHeaderShade' : 'noteHeader']" style="text-align: left;">
<transition name="fade">
<img v-show="!toTopState" style="height:40px;float:left;cursor: pointer;position: absolute;" alt="refresh flagnote" src="/static/logo.png"
<div :class="[showHeaderShade ? 'noteHeaderShade' : 'noteHeader']">
<img style="height:40px;float:left;cursor: pointer;" alt="refresh flagnote" src="/static/logo.png"
v-on:click="refreshPage()" />
</transition>
<transition name="fade">
<div style="float:left;width:auto;position: absolute">
<div style="float:left;width:auto;">
<Button-group size="large">
@@ -100,7 +92,7 @@
</Button-group>
</div>
</transition>
<div style="float:right;width:auto;">
@@ -108,7 +100,7 @@
<Button-group size="large">
<Button aria-label="publish" type="error" :loading="model.submitting"
style="margin-left:5px; border-radius: 0px;font-size: 21px;" @click="submitNote()"
icon="md-cloud-upload"></Button>
icon="md-share"></Button>
<Button aria-label="menu" type="error" style="margin-left:3px; border-radius: 0px;font-size: 24px;"
@click="switchMenu()" @blur.native="hideMenu()" icon="md-menu"></Button>
@@ -121,14 +113,20 @@
<Button-group vertical size="large">
<Button aria-label="create note" type="error" style="border-radius: 0px;font-size: 24px;"
@click="createNote(); switchMenu(); " icon="md-add"></Button>
<!--
<Button aria-label="crop" v-show="model.showDownloadText" type="error"
style="border-radius: 0px;font-size: 24px;" @click="saveImage(); switchMenu();" icon="md-crop"></Button>
<Button type="error" icon="md-refresh" style="border-radius: 0px;font-size: 14px;font-size: 24px;"
@click="refreshPage()"></Button>
-->
<Button aria-label="download text" v-show="model.showDownloadText" type="error"
style="border-radius: 0px;font-size: 24px;" @click="downLoadText(); switchMenu(); "
icon="md-download"></Button>
<Button aria-label="history text" v-show="model.showHistoryText" type="error"
style="border-radius: 0px;font-size: 24px;" @click="downLoadText(); switchMenu(); "
icon="md-download"></Button>
<Button type="error" icon="md-trash" style="border-radius: 0px;font-size: 24px;"
@click="showDeleteModel(); switchMenu(); "></Button>
@@ -151,7 +149,7 @@
:lg="{ span: 18, offset: 3 }" :xl="{ span: 16, offset: 4 }" :xxl="{ span: 16, offset: 4 }">
<Card :padding="0">
<Form :model="noteForm" :label-width="80">
<div ref="html2canvas" id="wrapper" style="border-left: 2px solid #ed4014;">
<div id="wrapper" style="border-left: 2px solid #ed4014;">
<Input element-id="noteText" type="textarea" :border="false" v-model="noteForm.text" autofocus
:autosize="{ minRows: 30, maxRows: 409600 }" :placeholder="$t('content.noteTip')" @input="recordText"
@on-keydown="recordEventKdown" />
@@ -165,7 +163,7 @@
</Content>
<Footer class="layout-footer-center">2023 &copy; flagnote.com</Footer>
<Footer class="layout-footer-center">2022 &copy; flagnote.com</Footer>
</Layout>
<Modal v-model="model.showDelete" width="360" footer-hide class-name="fnmodal" :styles="{ borderRadius: 0 }">
@@ -203,7 +201,7 @@ import { setStoreText, setNewStoreText } from "@/libs/noteStorage";
import { saveAs } from 'file-saver';
import { isWeixin } from "@/libs/utils";
import NoteConstant from "@/libs/constants";
import html2canvas from "html2canvas";
import { getKeyMeta } from "@/api/note";
export default {
name: 'EditNote',
@@ -238,15 +236,12 @@ export default {
toTopState: false,
showMenuState: false,
showHeaderShade: false,
pageSession: '',
errorInfo: '',
lastEditTime: 0,
backStoreTextInterval: null,
lastStoreCount: 0,
lastStoreTime: 0,
}
},
created() {
this.editTime = new Date().getTime();
this.pageSession = new Date().getTime();
// read $route
this.noteForm.key = this.$route.params.name;
@@ -282,27 +277,26 @@ export default {
// }
storage.local.setText(storeKey, "0|" + this.secret.cipher + "|0|" + this.state.initTime + "|");
storage.session.delete(keyMeta.key + ".keyMeta");
} else {
// second edit
let noteMeta = this.$route.meta.noteMeta;
this.secret.secretKey = noteMeta.secretKey;
let storeInfo = storage.local.getText(storeKey);
let that = this;
storage.local.getText(storeKey).then(function(storeInfo){
let starray = storeInfo.split('|');
this.state.lock = parseInt(starray[0]);
this.secret.cipher = starray[1];
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]) {
this.noteForm.text = unwrap(starray[4], this.secret.secretKey);
}
that.noteForm.text = unwrap(starray[4], that.secret.secretKey);
}
});
this.lastStoreCount = this.noteForm.text.length;
this.lastEditTime = new Date().getTime();
this.lastStoreTime = this.lastEditTime;
}
this.bindCtrlAllEvent();
this.bindToTopEvent();
@@ -324,15 +318,12 @@ export default {
const someOtherEl = document.querySelector('#wrapper');
myObserver.observe(someOtherEl);
window.addEventListener('beforeunload', e => this.beforeunloadHandler(e))
},
updated() {
},
beforeDestroy() {
},
destroyed() {
window.removeEventListener('beforeunload', e => this.beforeunloadHandler(e))
},
computed: {},
watch: {},
@@ -369,49 +360,7 @@ export default {
return;
}
let nowEditCount = this.noteForm.text.length;
let nowEditTime = new Date().getTime();
if (nowEditCount < 1024) {
setStoreText(this.noteForm, this.state, this.secret);
this.lastStoreTime = nowEditTime;
this.lastStoreCount = nowEditCount;
} else {
if (null == this.backStoreTextInterval) {
this.backStoreTextInterval = window.setInterval(this.backStoreFunction(), 500);
}
}
this.lastEditTime = nowEditTime;
},
backStoreFunction() {
let that = this;
return function () {
that.backStoreText();
}
},
backStoreText() {
let nowEditCount = this.noteForm.text.length;
let nowEditTime = new Date().getTime();
if (Math.abs(nowEditCount - this.lastStoreCount) > 10) {
setStoreText(this.noteForm, this.state, this.secret);
this.lastStoreTime = this.lastEditTime;
this.lastStoreCount = nowEditCount;
} else {
if (nowEditTime - this.lastEditTime >= 1000 && nowEditTime - this.lastEditTime < 20000) {
if (this.lastEditTime != this.lastStoreTime) {
setStoreText(this.noteForm, this.state, this.secret);
this.lastStoreTime = this.lastEditTime;
this.lastStoreCount = nowEditCount;
}
} else if (nowEditTime - this.lastEditTime >= 20000) {
if (this.backStoreTextInterval != null) {
let ivl = this.backStoreTextInterval;
this.backStoreTextInterval = null;
window.clearInterval(ivl);
}
}
}
},
// recordEventKup(event) {
// let tn = event.currentTarget.value;
@@ -451,16 +400,13 @@ export default {
}
this.noteForm.text = event.currentTarget.value;
this.recordText();
setStoreText(this.noteForm, this.state, this.secret);
} else if (event.ctrlKey && (event.which == 13)) {
//save
this.submitNote();
}
},
save() {
return saveNote(this.noteForm, this.secret);
},
validateForm() {
let text = this.noteForm.text;
if (text.length > NoteConstant.noteMaxCount) {
@@ -489,25 +435,28 @@ export default {
return;
}
setStoreText(this.noteForm, this.state, this.secret);
this.model.submitting = true;
let that = this;
this.save().then(res => {
saveNote(this.noteForm, this.secret).then(res => {
if (res.data && res.data.code == "000000") {
storage.session.setText(that.secret.storeKey + "_share", '1');
that.state.commited = 1;
setStoreText(this.noteForm, this.state, this.secret);
setStoreText(this.noteForm, this.state, this.secret).then(function(){
location.reload();
this.state.locking = 0;
});
} else {
alert(res.data.code);
this.model.submitting = false;
this.state.locking = 0;
if(res.data.code=="100013"||res.data.code=="800001"){
let key = setNewStoreText(this.noteForm);
location.href = "/" + key;
let keyMeta = getKeyMeta();
setNewStoreText(this.noteForm,keyMeta).then(function () {
location.href="/"+keyMeta.key;
});
}
}
@@ -553,65 +502,7 @@ export default {
}
}
}
},
dataURLToBlob(dataurl) {
let arr = dataurl.split(',');
let mime = arr[0].match(/:(.*?);/)[1];
let bstr = window.atob(arr[1]);
let n = bstr.length;
let u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new Blob([u8arr], { type: mime });
},
saveImage() {
let canvasID = this.$refs["html2canvas"];
let that = this;
let a = document.createElement('a');
html2canvas(canvasID, {
scale: 1,
windowWidth: parseInt(document.getElementById("noteText").offsetWidth) + 2,
onclone: (clonedDocument) => {
let nt = clonedDocument.getElementById("noteText");
const div = clonedDocument.createElement('div')
div.innerText = nt.value
div.style.color = "black";
div.style.padding = "10px";
div.style.textAlign = "left";
div.style.wordBreak = "break-word";
div.style.whiteSpace = "pre-wrap";
div.style.verticalAlign = "top";
div.style.fontSize = "15px";
div.style.width = "100%";
div.style.border = "0px";
div.style.fontFamily = "'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif";
nt.style.display = 'none'
nt.parentElement.parentElement.style.borderLeftColor = "white";
nt.parentElement.append(div)
}
}).then(canvas => {
let dom = document.body.appendChild(canvas);
dom.style.display = 'none';
a.style.display = 'none';
document.body.removeChild(dom);
let blob = that.dataURLToBlob(dom.toDataURL('image/png'));
a.setAttribute('href', URL.createObjectURL(blob));
a.setAttribute('download', that.noteForm.key + '.png');
document.body.appendChild(a);
a.click();
URL.revokeObjectURL(blob);
document.body.removeChild(a);
});
},
beforeunloadHandler() {
setStoreText(this.noteForm, this.state, this.secret);
},
}
}
</script>

View File

@@ -81,7 +81,7 @@
</Content>
<Footer class="layout-footer-center">2023 &copy; flagnote.com</Footer>
<Footer class="layout-footer-center">2022 &copy; flagnote.com</Footer>
</Layout>
</div>

View File

@@ -80,8 +80,8 @@
}
#qrUrl::selection {
background: #dddddd;
color: #ed4014;
background-color: #ed4014;
color: #ffffff;
}
#copyBtn {
@@ -220,7 +220,7 @@
<div id="noteMenu" :class="[showMenuState ? 'showBlock' : 'hideBlock']"
style="z-index: 100; position: absolute;top:43px;right:0px;left:auto;">
<Button-group vertical size="large">
<Button aria-label="new note" type="error" icon="md-add" style="border-radius: 0px;font-size: 24px;"
<Button type="error" icon="md-add" style="border-radius: 0px;font-size: 24px;"
@click="createNote(); switchMenu();"></Button>
<!--
@@ -228,11 +228,10 @@
<Button type="error" icon="md-refresh" style="border-radius: 0px;font-size: 24px;"
@click="refreshPage()"></Button>
-->
<Button aria-label="crop" v-show="model.showDownloadText" type="error" icon="md-crop"
style="border-radius: 0px;font-size: 24px;" @click="saveImage(); switchMenu();"></Button>
<Button aria-label="download text" v-show="model.showDownloadText" type="error"
style="border-radius: 0px;font-size: 24px;" @click="downLoadText(); " icon="md-download"></Button>
style="border-radius: 0px;font-size: 24px;" @click="downLoadText(); switchMenu();"
icon="md-download"></Button>
<Button type="error" icon="md-trash" style="border-radius: 0px;font-size: 24px;"
@click="showDeleteModel(); switchMenu();"></Button>
@@ -255,7 +254,7 @@
<Col :xs="{ span: 24, offset: 0 }" :sm="{ span: 22, offset: 1 }" :md="{ span: 20, offset: 2 }"
:lg="{ span: 18, offset: 3 }" :xl="{ span: 16, offset: 4 }" :xxl="{ span: 16, offset: 4 }">
<Card :padding="0">
<div ref="html2canvas" id="wrapper" style="border-left: 2px solid white;">
<div id="wrapper" style="border-left: 2px solid white;">
<Input element-id="noteText" readonly type="textarea" :border="false" v-model="noteForm.text"
:autosize="{ minRows: 30, maxRows: 409600 }" :placeholder="$t('content.noteTip')" />
</div>
@@ -267,7 +266,7 @@
<Footer class="layout-footer-center">
2023 &copy; flagnote.com
2022 &copy; flagnote.com
</Footer>
</Layout>
@@ -332,6 +331,9 @@
</Modal>
</div>
</template>
<script>
@@ -345,8 +347,6 @@ import QRCode from "qrcodejs2";
import Clipboard from "clipboard";
import { saveAs } from 'file-saver';
import { isWeixin, getNoteUrl } from "@/libs/utils";
import html2canvas from "html2canvas";
import { Buffer } from 'buffer';
export default {
name: 'ViewNote',
@@ -420,9 +420,13 @@ export default {
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.bindCopyUrlEvent();
@@ -517,8 +521,9 @@ export default {
that.state.ttl = that.state.initTtl - (new Date().getTime() - that.state.initTime);
if (that.state.ttl <= 0) {
storage.local.delete(that.secret.storeKey);
storage.local.delete(that.secret.storeKey).then(function(){
location.reload();
});
}
}, 1000)
},
@@ -554,8 +559,9 @@ export default {
let that = this;
deleteNote(this.noteForm.key).then(res => {
if (res.data&&res.data.code=="000000") {
storage.local.delete(that.secret.storeKey);
storage.local.delete(that.secret.storeKey).then(function(){
location.reload();
});
} else {
that.model.deleting = false;
}
@@ -563,11 +569,9 @@ export default {
alert(error);
});
},
loadText() {
loadText(storeInfo) {
let that = this;
let storeInfo = storage.local.getText(this.secret.storeKey);
let starray = [];
if (storeInfo) {
starray = storeInfo.split('|');
@@ -580,19 +584,28 @@ export default {
return;
}
res.data.arrayBuffer().then(function (ab) {
if (!ab || ab.byteLength == 0) {
let blob = new Blob([res.data], {
type: res.data.type
});
let reader = new FileReader();
reader.onload = function (e) {
if (!e.target.result || e.target.result.byteLength == 0) {
return;
}
let base64String = Buffer.from(ab).toString('base64')
that.noteForm.text = unwrap(base64String, that.secret.secretKey);
var bytes = new Uint8Array(e.target.result);
bytes = bytes.subarray(7,bytes.length-7);
let bytesString = bytes.join(",");
that.noteForm.text = unwrap(bytesString, that.secret.secretKey);
//that.noteForm.escapeText = getEscapeText(that.noteForm.text);
// if local is enough, set local
if (storage.local.getAvailableSize() > 1 * 1024 * 1024) {
storage.local.setText(that.secret.storeKey, that.state.lock + '|' + that.secret.cipher + '|1|' + that.state.serverTime + '|' + base64String);
storage.local.setText(that.secret.storeKey, that.state.lock + '|' + that.secret.cipher + '|1|' + that.state.serverTime + '|' + bytesString);
}
});
};
reader.readAsArrayBuffer(blob);
});
} else {
@@ -655,62 +668,6 @@ export default {
}
}
},
dataURLToBlob(dataurl) {
let arr = dataurl.split(',');
let mime = arr[0].match(/:(.*?);/)[1];
let bstr = window.atob(arr[1]);
let n = bstr.length;
let u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new Blob([u8arr], { type: mime });
},
saveImage() {
let canvasID = this.$refs["html2canvas"];
let that = this;
let a = document.createElement('a');
html2canvas(canvasID, {
scale: 1,
windowWidth: document.getElementById("noteText").offsetWidth,
onclone: (clonedDocument) => {
let nt = clonedDocument.getElementById("noteText");
const div = clonedDocument.createElement('div')
div.innerText = nt.value
div.style.color = "black";
div.style.padding = "0px";
div.style.textAlign = "left";
div.style.wordBreak = "break-word";
div.style.whiteSpace = "pre-wrap";
div.style.verticalAlign = "top";
div.style.fontSize = "15px";
div.style.width = "100%";
div.style.border = "0px";
div.style.fontFamily = "'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif";
nt.style.display = 'none'
nt.parentElement.parentElement.style.borderLeftColor = "white";
nt.parentElement.append(div)
}
}).then(canvas => {
let dom = document.body.appendChild(canvas);
dom.style.display = 'none';
a.style.display = 'none';
document.body.removeChild(dom);
let blob = that.dataURLToBlob(dom.toDataURL('image/png'));
a.setAttribute('href', URL.createObjectURL(blob));
a.setAttribute('download', that.noteForm.key + '.png');
document.body.appendChild(a);
a.click();
URL.revokeObjectURL(blob);
document.body.removeChild(a);
});
},
}
}
</script>

View File

@@ -14,19 +14,16 @@ module.exports = defineConfig({
config.externals = {
'vue': 'Vue',
'vue-router': 'VueRouter',
// 'axios': 'axios',
'axios': 'axios',
//'vue-axios':'VueAxios',
//'buffer': 'Buffer',
"crypto-js": "CryptoJS",
// 'qrcodejs2': 'QRCode',
'qrcodejs2': 'QRCode',
'pako': 'pako',
"view-design": 'iview',
"iview": 'ViewUI',
//"file-saver": 'saveAs',
// "clipboard": "ClipboardJS",
// "vue-i18n": "VueI18n",
"html2canvas": "html2canvas",
"wasm_flate": "wasm_flate"
"file-saver": 'saveAs',
"clipboard": "ClipboardJS",
"vue-i18n": "VueI18n"
};
// 为生产环境修改配置
@@ -68,21 +65,13 @@ module.exports = defineConfig({
devServer: {
proxy: {
"/note": {
//target: "https://flagnote.com/", // 后台接口域名
target: "http://localhost:20000/", // 后台接口域名
target: "https://flagnote.com/", // 后台接口域名
// target: "http://localhost:10000/", // 后台接口域名
secure: false, // 如果是https接口需要配置这个参数
changeOrigin: true, //是否跨域
pathRewrite: {
// '^/': '/'
},
}, "^/[abcdefhikmnopqstuvwxyz23456789]{16}\\.txt$": {
//target: "https://flagnote.com/", // 后台接口域名
target: "http://localhost:20000/", // 后台接口域名
secure: false, // 如果是https接口需要配置这个参数
changeOrigin: true, //是否跨域
pathRewrite: {
'^/': '/note/'
},
},
},
},

1864
yarn.lock

File diff suppressed because it is too large Load Diff