12 Commits

Author SHA1 Message Date
Jesse-Ma
a9e7f88412 selection 样式 2023-04-03 11:05:00 +08:00
Jesse-Ma
d3a29444bf refresh save 2023-03-31 17:19:37 +08:00
Jesse-Ma
83c3901b86 use more Buffer 2023-03-31 15:59:13 +08:00
Jesse-Ma
64db2300b3 js compact 2023-03-31 15:58:42 +08:00
Jesse-Ma
8e6ce23b98 hex plus plus 2023-03-31 10:21:44 +08:00
Jesse-Ma
f369e59f6f hex plus 2023-03-30 10:19:18 +08:00
Jesse-Ma
0de98e660b storetext policies 2023-03-29 16:11:59 +08:00
Jesse-Ma
b017e7bda1 zip first 2023-03-23 11:34:41 +08:00
Jesse-Ma
b31563aaab compact 2023-03-22 14:28:24 +08:00
Jesse-Ma
bb7085adaa compact 2023-03-22 14:27:59 +08:00
Jesse-Ma
67035a0abf add html2canvas 2023-03-15 14:49:19 +08:00
Jesse-Ma
b86cf176dd redirect done 2023-03-14 14:21:23 +08:00
15 changed files with 480 additions and 190 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 = 409600
VUE_APP_NOTE_MAX_DESC = 400K
VUE_APP_NOTE_MAX_COUNT = 131072
VUE_APP_NOTE_MAX_DESC = 128K

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 = 409600
VUE_APP_NOTE_MAX_DESC = 400K
VUE_APP_NOTE_MAX_COUNT = 131072
VUE_APP_NOTE_MAX_DESC = 128K

View File

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

View File

@@ -24,27 +24,31 @@
background-color: #dddddd
}
</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>
<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>
<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> -->
<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/view-design@4.7.0/dist/iview.min.js" rel="stylesheet"
<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/pako@2.1.0/dist/pako.min.js" rel="stylesheet"
<!-- <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/crypto-js@4.1.1/crypto-js.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> -->
<!-- <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"
type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-i18n@8.21.1/dist/vue-i18n.min.js" rel="stylesheet"
type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/file-saver@2.0.5/dist/FileSaver.min.js" rel="stylesheet"
type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/qrcodejs2@0.0.2/qrcode.min.js" rel="stylesheet"
type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.11/dist/clipboard.min.js" rel="stylesheet"
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/html2canvas@1.4.1/dist/html2canvas.min.js"
type="text/javascript"></script>
<script>
window.wasm_flate_bg_path = "https://cdn.jsdelivr.net/npm/wasm-flate@1.0.2-browser/wasm_flate_bg.wasm"

67
public/redirect.html Normal file
View File

@@ -0,0 +1,67 @@
<!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="theme-color" content="#ed4014" />
<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" />
<title>flagnote.com</title>
<style>
body {
background-color: #dddddd
}
</style>
<script>
const servicePath = "";
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();
if (keyMeta && keyMeta.key) {
sessionStorage.setItem(keyMeta.key + ".keyMeta", JSON.stringify(keyMeta));
location.href = "/" + keyMeta.key;
} else {
location.href = "/100006";
}
</script>
</head>
<body><noscript><strong>Please enable JavaScript to continue.</strong></noscript>
</body>
</html>

View File

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

View File

@@ -3,6 +3,7 @@ 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;
@@ -48,8 +49,8 @@ export function saveNote(noteForm, secret) {
});
}
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 array = Buffer.from(note.text, 'base64')
let blob = new Blob([array], { type: "application/octet-stream" });
let form = new FormData();
form.append("file", blob, noteForm.key);

View File

@@ -26,6 +26,9 @@ 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,9 +1,45 @@
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 服务器随机返回的关键字
@@ -11,14 +47,14 @@ const wasmFlate = window.wasm_bindgen;
export function wrap(text, secretKey) {
text = "FLAGNOTE#" + text;
let result = aesEncrypt(text, secretKey);
result = noteZip(result);
let ui8ary = noteZip(text);
let result = aesEncrypt(convertUint8ArrayToWordArray(ui8ary), secretKey);
return result;
}
export function unwrap(storeText, secretKey) {
let result = noteUnzip(storeText);
result = aesDecrypt(result, secretKey);
export function unwrap(text, secretKey) {
let wdary = aesDecrypt(text, secretKey);
let result = noteUnzip(convertWordArrayToUint8Array(wdary));
if (result.startsWith("FLAGNOTE#")) {
return result.substring(9);
}
@@ -37,7 +73,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.Pkcs7,
padding: CryptoJS.pad.ZeroPadding,
});
return encrypted.toString();
}
@@ -48,28 +84,24 @@ 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,
padding: CryptoJS.pad.ZeroPadding,
});
return CryptoJS.enc.Utf8.stringify(decrypt).toString();
return decrypt;
}
//base64 encode
export function encode(text) {
//base64 encode btoa
export function base64Encode(text) {
return Buffer.from(text, 'utf-8').toString('base64');
}
//base64 decode
export function decode(text) {
//base64 decode atob
export function base64Decode(text) {
return Buffer.from(text,'base64').toString('utf-8');
}
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));
export function noteUnzip(wdary) {
let data = unzip(wdary);
let text = new TextDecoder().decode(data);
return text;
}
@@ -96,35 +128,27 @@ 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;
// }
// function convertUint8ArrayToWordArray(u8Array) {
// var words = [], i = 0, len = u8Array.length;
export function convertBase64ToHexString(base64) {
return CryptoJS.enc.Hex.stringify(CryptoJS.enc.Base64.parse(base64));
}
// while (i < len) {
// words.push(
// (u8Array[i++] << 24) |
// (u8Array[i++] << 16) |
// (u8Array[i++] << 8) |
// (u8Array[i++])
// );
// }
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);
}
// return {
// sigBytes: words.length * 4,
// words: words
// };
// }

View File

@@ -4,7 +4,7 @@ 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 { getKeyMeta, getNoteMeta } from "@/api/note";
import { getNoteMeta } from "@/api/note";
import { getStoreKey } from "@/api/lock";
import storage from "@/libs/storage";
@@ -35,6 +35,7 @@ function getNoteView() {
let key = path.substring(1, path.length);
keyMeta = storage.session.getObject(key+".keyMeta");
if (keyMeta && keyMeta.key) {
key = keyMeta.key;
}
@@ -107,30 +108,7 @@ function getNoteView() {
return ErrorNote;
}
function getHomeRedirect() {
let path = location.pathname;
if (path != "/") {
return;
}
//setKeyMeta
keyMeta = getKeyMeta();
// server error
if (!keyMeta) {
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})",

View File

@@ -100,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-share"></Button>
icon="md-cloud-upload"></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>
@@ -113,18 +113,12 @@
<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 type="error" icon="md-refresh" style="border-radius: 0px;font-size: 14px;font-size: 24px;"
@click="refreshPage()"></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 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(); "
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;"
@@ -149,7 +143,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 id="wrapper" style="border-left: 2px solid #ed4014;">
<div ref="html2canvas" 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" />
@@ -163,7 +157,7 @@
</Content>
<Footer class="layout-footer-center">2022 &copy; flagnote.com</Footer>
<Footer class="layout-footer-center">2023 &copy; flagnote.com</Footer>
</Layout>
<Modal v-model="model.showDelete" width="360" footer-hide class-name="fnmodal" :styles="{ borderRadius: 0 }">
@@ -197,10 +191,11 @@ import { unwrap } from '../libs/secret'
import { saveNote } from "@/api/note";
import { getStoreKey } from "@/api/lock";
import storage from "@/libs/storage";
import { setStoreText,setNewStoreText } from "@/libs/noteStorage";
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";
export default {
name: 'EditNote',
@@ -235,22 +230,25 @@ export default {
toTopState: false,
showMenuState: false,
showHeaderShade: false,
pageSession: '',
errorInfo: '',
lastEditTime: 0,
backStoreTextInterval: null,
lastStoreCount: 0,
lastStoreTime: 0,
}
},
created() {
this.pageSession = new Date().getTime();
this.editTime = new Date().getTime();
// read $route
this.noteForm.key = this.$route.params.name;
let keyMeta = this.$route.meta.keyMeta;
//ipad chrome url not redirect
let path = location.pathname;
if ("/" == path) {
history.pushState('', '', '/' + this.noteForm.key);
}
// let path = location.pathname;
// if ("/" == path) {
// history.pushState('', '', '/' + this.noteForm.key);
// }
//wx does not show downloadText
this.model.showDownloadText = !isWeixin();
@@ -276,6 +274,7 @@ 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;
@@ -293,6 +292,10 @@ export default {
}
}
this.lastStoreCount = this.noteForm.text.length;
this.lastEditTime = new Date().getTime();
this.lastStoreTime = this.lastEditTime;
this.bindCtrlAllEvent();
this.bindToTopEvent();
@@ -313,12 +316,15 @@ 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: {},
@@ -355,7 +361,49 @@ 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;
@@ -395,7 +443,7 @@ export default {
}
this.noteForm.text = event.currentTarget.value;
setStoreText(this.noteForm, this.state, this.secret);
this.recordText();
} else if (event.ctrlKey && (event.which == 13)) {
//save
@@ -449,9 +497,9 @@ export default {
alert(res.data.code);
this.model.submitting = false;
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);
location.href="/"+key;
location.href = "/" + key;
}
}
@@ -497,7 +545,65 @@ 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">2022 &copy; flagnote.com</Footer>
<Footer class="layout-footer-center">2023 &copy; flagnote.com</Footer>
</Layout>
</div>

View File

@@ -80,8 +80,8 @@
}
#qrUrl::selection {
background-color: #ed4014;
color: #ffffff;
background: #dddddd;
color: #ed4014;
}
#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 type="error" icon="md-add" style="border-radius: 0px;font-size: 24px;"
<Button aria-label="new note" type="error" icon="md-add" style="border-radius: 0px;font-size: 24px;"
@click="createNote(); switchMenu();"></Button>
<!--
@@ -228,10 +228,11 @@
<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(); switchMenu();"
icon="md-download"></Button>
style="border-radius: 0px;font-size: 24px;" @click="downLoadText(); " icon="md-download"></Button>
<Button type="error" icon="md-trash" style="border-radius: 0px;font-size: 24px;"
@click="showDeleteModel(); switchMenu();"></Button>
@@ -254,7 +255,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 id="wrapper" style="border-left: 2px solid white;">
<div ref="html2canvas" 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>
@@ -266,7 +267,7 @@
<Footer class="layout-footer-center">
2022 &copy; flagnote.com
2023 &copy; flagnote.com
</Footer>
</Layout>
@@ -331,9 +332,6 @@
</Modal>
</div>
</template>
<script>
@@ -347,6 +345,8 @@ 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',
@@ -553,7 +553,7 @@ export default {
this.model.deleting = true;
let that = this;
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);
location.reload();
} else {
@@ -580,28 +580,19 @@ export default {
return;
}
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) {
res.data.arrayBuffer().then(function (ab) {
if (!ab || ab.byteLength == 0) {
return;
}
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);
let base64String = Buffer.from(ab).toString('base64')
that.noteForm.text = unwrap(base64String, that.secret.secretKey);
// 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 + '|' + bytesString);
storage.local.setText(that.secret.storeKey, that.state.lock + '|' + that.secret.cipher + '|1|' + that.state.serverTime + '|' + base64String);
}
};
reader.readAsArrayBuffer(blob);
});
});
} else {
@@ -664,6 +655,62 @@ 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

@@ -8,22 +8,25 @@ module.exports = defineConfig({
productionSourceMap: false,
configureWebpack: (config) => {
config.experiments = { asyncWebAssembly: true,syncWebAssembly:true }
config.experiments = { asyncWebAssembly: true, syncWebAssembly: true }
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"
//"file-saver": 'saveAs',
// "clipboard": "ClipboardJS",
// "vue-i18n": "VueI18n",
"html2canvas": "html2canvas",
"wasm_flate": "wasm_flate"
};
// 为生产环境修改配置
@@ -65,13 +68,21 @@ module.exports = defineConfig({
devServer: {
proxy: {
"/note": {
// target: "https://flagnote.com/", // 后台接口域名
target: "http://localhost:10000/", // 后台接口域名
//target: "https://flagnote.com/", // 后台接口域名
target: "http://localhost:20000/", // 后台接口域名
secure: false, // 如果是https接口需要配置这个参数
changeOrigin: true, //是否跨域
pathRewrite: {
// '^/': '/'
},
}, "^/[abcdefhikmnopqstuvwxyz23456789]{16}\\.txt$": {
//target: "https://flagnote.com/", // 后台接口域名
target: "http://localhost:20000/", // 后台接口域名
secure: false, // 如果是https接口需要配置这个参数
changeOrigin: true, //是否跨域
pathRewrite: {
'^/': '/note/'
},
},
},
},

View File

@@ -2013,6 +2013,11 @@ balanced-match@^1.0.0:
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
base64-arraybuffer@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz#1c37589a7c4b0746e34bd1feb951da2df01c1bdc"
integrity sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==
base64-js@^1.3.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
@@ -2123,6 +2128,14 @@ buffer@^5.5.0:
base64-js "^1.3.1"
ieee754 "^1.1.13"
buffer@^6.0.3:
version "6.0.3"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
dependencies:
base64-js "^1.3.1"
ieee754 "^1.2.1"
bytes@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048"
@@ -2558,6 +2571,13 @@ css-declaration-sorter@^6.3.1:
resolved "https://registry.yarnpkg.com/css-declaration-sorter/-/css-declaration-sorter-6.3.1.tgz#be5e1d71b7a992433fb1c542c7a1b835e45682ec"
integrity sha512-fBffmak0bPAnyqc/HO8C3n2sHrp9wcqQz6ES9koRF2/mLOVAx9zIQ3Y7R29sYCteTPqMCwns4WYQoCX91Xl3+w==
css-line-break@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/css-line-break/-/css-line-break-2.1.0.tgz#bfef660dfa6f5397ea54116bb3cb4873edbc4fa0"
integrity sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==
dependencies:
utrie "^1.0.2"
css-loader@^6.5.0:
version "6.7.2"
resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-6.7.2.tgz#26bc22401b5921686a10fbeba75d124228302304"
@@ -3650,6 +3670,14 @@ html-webpack-plugin@^5.1.0:
pretty-error "^4.0.0"
tapable "^2.0.0"
html2canvas@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/html2canvas/-/html2canvas-1.4.1.tgz#7cef1888311b5011d507794a066041b14669a543"
integrity sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==
dependencies:
css-line-break "^2.1.0"
text-segmentation "^1.0.3"
htmlparser2@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-6.1.0.tgz#c4d762b6c3371a05dbe65e94ae43a9f845fb8fb7"
@@ -3728,7 +3756,7 @@ icss-utils@^5.0.0, icss-utils@^5.1.0:
resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-5.1.0.tgz#c6be6858abd013d768e98366ae47e25d5887b1ae"
integrity sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==
ieee754@^1.1.13:
ieee754@^1.1.13, ieee754@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
@@ -5927,6 +5955,13 @@ terser@^5.10.0, terser@^5.14.1:
commander "^2.20.0"
source-map-support "~0.5.20"
text-segmentation@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/text-segmentation/-/text-segmentation-1.0.3.tgz#52a388159efffe746b24a63ba311b6ac9f2d7943"
integrity sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==
dependencies:
utrie "^1.0.2"
text-table@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
@@ -6120,6 +6155,13 @@ utils-merge@1.0.1:
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==
utrie@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/utrie/-/utrie-1.0.2.tgz#d42fe44de9bc0119c25de7f564a6ed1b2c87a645"
integrity sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==
dependencies:
base64-arraybuffer "^1.0.2"
uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
@@ -6204,7 +6246,7 @@ vue-loader@^17.0.0:
hash-sum "^2.0.0"
loader-utils "^2.0.0"
vue-router@^3.5.4:
vue-router@^3.6.5:
version "3.6.5"
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-3.6.5.tgz#95847d52b9a7e3f1361cb605c8e6441f202afad8"
integrity sha512-VYXZQLtjuvKxxcshuRAwjHnciqZVoXAjTjcqBTz4rKc8qih9g9pI3hbDjmqXaHdgL3v8pV6P8Z335XvHzESxLQ==
@@ -6230,6 +6272,11 @@ vue@^2.7.14:
"@vue/compiler-sfc" "2.7.14"
csstype "^3.1.0"
wasm-flate@^1.0.2-browser:
version "1.0.2-browser"
resolved "https://registry.yarnpkg.com/wasm-flate/-/wasm-flate-1.0.2-browser.tgz#e10e758b37c3d38829b54809fa2fef853b48131c"
integrity sha512-qpqOzvbKtgG/2Mb0DYXVPQ2nOrkKYoAQtpr4QZzgO8SMfKieeODUy2vomMnimQjH/K2RGWnw+kZmO8yf+Yh9qA==
watchpack@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.0.tgz#fa33032374962c78113f93c7f2fb4c54c9862a5d"