Compare commits
15 Commits
dev
...
view-ui-pl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff3e77200c | ||
|
|
4e32a23eea | ||
|
|
612c9b2164 | ||
|
|
a9e7f88412 | ||
|
|
d3a29444bf | ||
|
|
83c3901b86 | ||
|
|
64db2300b3 | ||
|
|
8e6ce23b98 | ||
|
|
f369e59f6f | ||
|
|
0de98e660b | ||
|
|
b017e7bda1 | ||
|
|
b31563aaab | ||
|
|
bb7085adaa | ||
|
|
67035a0abf | ||
|
|
b86cf176dd |
@@ -1,6 +1,6 @@
|
|||||||
NODE_ENV = developement
|
NODE_ENV=developement
|
||||||
|
VUE_APP_FLAG=dev
|
||||||
VUE_APP_BASE_NAME = developement
|
VUE_APP_BASE_NAME = developement
|
||||||
VUE_APP_BASE_URL = http://localhost:8080
|
VUE_APP_BASE_URL = http://localhost:8080
|
||||||
VUE_APP_NOTE_MAX_COUNT = 409600
|
VUE_APP_NOTE_MAX_COUNT = 131072
|
||||||
VUE_APP_NOTE_MAX_DESC = 400K
|
VUE_APP_NOTE_MAX_DESC = 128K
|
||||||
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
NODE_ENV = production
|
NODE_ENV=production
|
||||||
|
VUE_APP_FLAG=prod
|
||||||
VUE_APP_BASE_NAME = production
|
VUE_APP_BASE_NAME = production
|
||||||
VUE_APP_BASE_URL = https://flagnote.com
|
VUE_APP_BASE_URL = https://flagnote.com
|
||||||
VUE_APP_NOTE_MAX_COUNT = 409600
|
VUE_APP_NOTE_MAX_COUNT = 131072
|
||||||
VUE_APP_NOTE_MAX_DESC = 400K
|
VUE_APP_NOTE_MAX_DESC = 128K
|
||||||
1
.env.staging
Normal file
1
.env.staging
Normal file
@@ -0,0 +1 @@
|
|||||||
|
VUE_APP_FLAG=staging
|
||||||
2
.eslintignore
Normal file
2
.eslintignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
assets
|
||||||
|
mock
|
||||||
31
.eslintrc.json
Normal file
31
.eslintrc.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"plugin:vue/essential",
|
||||||
|
"airbnb-base"
|
||||||
|
],
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"vue"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"semi": [2, "never"],
|
||||||
|
"comma-dangle": 0,
|
||||||
|
"no-console": 0,
|
||||||
|
"quotes": [2, "single"],
|
||||||
|
"no-undef": 0,
|
||||||
|
"no-debugger": 0,
|
||||||
|
"import/no-unresolved": 0,
|
||||||
|
"import/extensions": 0,
|
||||||
|
"no-param-reassign": 0,
|
||||||
|
"vue/multi-word-component-names": 0,
|
||||||
|
"vue/no-multiple-template-root": 0,
|
||||||
|
"import/no-extraneous-dependencies": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
51
README.md
51
README.md
@@ -1,24 +1,35 @@
|
|||||||
# flagnote-web
|
# view-ui-project-vuecli
|
||||||
|
This project build for Vue3, Vue-router, Vuex, ViewUIPlus and Vue-cli.
|
||||||
|
## Install
|
||||||
|
```shell
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
## Run
|
||||||
|
```shell
|
||||||
|
npm run serve
|
||||||
|
```
|
||||||
|
## Build
|
||||||
|
### Build for Production
|
||||||
|
```shell
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
### Build for Staging
|
||||||
|
```shell
|
||||||
|
npm run build:staging
|
||||||
|
```
|
||||||
|
## Run Eslint
|
||||||
|
### Run without Fixing
|
||||||
|
|
||||||
## Project setup
|
- This operation will also run before git-commit.
|
||||||
|
```shell
|
||||||
|
npm run lint
|
||||||
```
|
```
|
||||||
yarn install
|
### Run with Fixing
|
||||||
|
```shell
|
||||||
|
npm run lint:fix
|
||||||
```
|
```
|
||||||
|
## .env Description
|
||||||
|
|
||||||
### Compiles and hot-reloads for development
|
- This project exposes environment variables on `process.env` object.
|
||||||
```
|
- Different modes (development/staging/production) correspond to different environment files (.env.*).
|
||||||
yarn serve
|
- .env file is always included, duplicate variables are overwritten by the specific mode file (.env.*).
|
||||||
```
|
|
||||||
|
|
||||||
### Compiles and minifies for production
|
|
||||||
```
|
|
||||||
yarn build
|
|
||||||
```
|
|
||||||
|
|
||||||
### Lints and fixes files
|
|
||||||
```
|
|
||||||
yarn lint
|
|
||||||
```
|
|
||||||
|
|
||||||
### Customize configuration
|
|
||||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
// module.exports = {
|
module.exports = {
|
||||||
// presets: [
|
presets: [
|
||||||
// '@vue/cli-plugin-babel/preset'
|
'@vue/cli-plugin-babel/preset',
|
||||||
// ]
|
],
|
||||||
// }
|
plugins: [
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "esnext",
|
"target": "es5",
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
"jsx": "preserve",
|
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": [
|
"@/*": [
|
||||||
@@ -15,10 +14,6 @@
|
|||||||
"dom",
|
"dom",
|
||||||
"dom.iterable",
|
"dom.iterable",
|
||||||
"scripthost"
|
"scripthost"
|
||||||
],
|
]
|
||||||
"removeComments": true,
|
|
||||||
},
|
|
||||||
"vueCompilerOptions": {
|
|
||||||
"target": 2.7
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
76
package.json
76
package.json
@@ -1,60 +1,56 @@
|
|||||||
{
|
{
|
||||||
"name": "flagnote-web",
|
"name": "flagnote-web",
|
||||||
"version": "0.1.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"description": "flagnote web",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"dev": "npm run serve",
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
"build": "vue-cli-service build --mode production",
|
"build": "vue-cli-service build",
|
||||||
"build.test": "vue-cli-service build --mode test",
|
"build:staging": "vue-cli-service build --mode=staging",
|
||||||
"build.production": "vue-cli-service build --mode production",
|
"lint": "eslint ./src --ext .js,.vue",
|
||||||
"lint": "vue-cli-service lint"
|
"lint:fix": "eslint ./src --ext .js,.vue --fix",
|
||||||
|
"prepare": "husky install"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
|
"babel-plugin-import": "^1.13.6",
|
||||||
|
"buffer": "^6.0.3",
|
||||||
"clipboard": "^2.0.11",
|
"clipboard": "^2.0.11",
|
||||||
|
"core-js": "^3.8.3",
|
||||||
"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",
|
||||||
|
"html2canvas": "^1.4.1",
|
||||||
"pako": "^2.1.0",
|
"pako": "^2.1.0",
|
||||||
"qrcodejs2": "^0.0.2",
|
"qrcodejs2-fixes": "^0.0.2",
|
||||||
"view-design": "^4.7.0",
|
"view-ui-plus": "^1.3.10",
|
||||||
"vue": "^2.7.14",
|
"vue": "^3.2.13",
|
||||||
"vue-axios": "^3.5.2",
|
"vue-axios": "^3.5.2",
|
||||||
"vue-i18n": "^8.28.2",
|
"vue-i18n": "^9.2.2",
|
||||||
"vue-router": "^3.6.5"
|
"vue-router": "^4.1.6",
|
||||||
|
"vuex": "^4.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.12.16",
|
"@vue/cli-plugin-babel": "~5.0.0",
|
||||||
"@babel/eslint-parser": "^7.12.16",
|
"@vue/cli-plugin-router": "~5.0.0",
|
||||||
"@vue/cli-plugin-babel": "~5.0.8",
|
"@vue/cli-plugin-vuex": "~5.0.0",
|
||||||
"@vue/cli-plugin-eslint": "~5.0.8",
|
"@vue/cli-service": "~5.0.0",
|
||||||
"@vue/cli-plugin-router": "~5.0.8",
|
"eslint": "^8.14.0",
|
||||||
"@vue/cli-service": "~5.0.8",
|
"eslint-config-airbnb-base": "^15.0.0",
|
||||||
"compression-webpack-plugin": "^10.0.0",
|
"eslint-plugin-vue": "^8.7.1",
|
||||||
"core-js": "^3.26.1",
|
"husky": "^7.0.4",
|
||||||
"eslint": "^7.32.0",
|
"less": "^4.0.0",
|
||||||
"eslint-plugin-vue": "^8.0.3",
|
"less-loader": "^10.2.0",
|
||||||
"javascript-obfuscator": "^4.0.0",
|
"mockjs": "^1.1.0"
|
||||||
"webpack": "^5.1.0",
|
|
||||||
"webpack-obfuscator": "^3.5.1"
|
|
||||||
},
|
|
||||||
"eslintConfig": {
|
|
||||||
"root": true,
|
|
||||||
"env": {
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
"extends": [
|
|
||||||
"plugin:vue/essential",
|
|
||||||
"eslint:recommended"
|
|
||||||
],
|
|
||||||
"parserOptions": {
|
|
||||||
"parser": "@babel/eslint-parser"
|
|
||||||
},
|
|
||||||
"rules": {}
|
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"> 1%",
|
"> 1%",
|
||||||
"last 2 versions",
|
"last 2 versions",
|
||||||
"not dead"
|
"not dead",
|
||||||
]
|
"not ie 11"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12.0.0",
|
||||||
|
"npm": ">= 6.9.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,45 +18,23 @@
|
|||||||
<meta http-equiv="Cache-control" content="no-cache" />
|
<meta http-equiv="Cache-control" content="no-cache" />
|
||||||
<meta http-equiv="Cache" content="no-cache" />
|
<meta http-equiv="Cache" content="no-cache" />
|
||||||
<link rel="icon" href="/static/favicon.png" />
|
<link rel="icon" href="/static/favicon.png" />
|
||||||
<title>flagnote.com</title>
|
<title>
|
||||||
|
<%= htmlWebpackPlugin.options.title %>
|
||||||
|
</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
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"
|
<% for (var i in htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.js) { %>
|
||||||
type="text/javascript"></script>
|
<script type="text/javascript" src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue-router@3.6.5/dist/vue-router.min.js" rel="stylesheet"
|
<% } %>
|
||||||
type="text/javascript"></script>
|
<% for (var i in htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.css) { %>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/axios@0.27.2/dist/axios.min.js" rel="stylesheet"
|
<link rel="stylesheet" type="text/css" href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" />
|
||||||
type="text/javascript"></script>
|
<% } %>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/view-design@4.7.0/dist/iview.min.js" rel="stylesheet"
|
|
||||||
type="text/javascript"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/pako@2.1.0/dist/pako.min.js" rel="stylesheet"
|
|
||||||
type="text/javascript"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/crypto-js@4.1.1/crypto-js.min.js" rel="stylesheet"
|
|
||||||
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"
|
|
||||||
type="text/javascript"></script>
|
|
||||||
<script>
|
<script>
|
||||||
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>
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/view-design@4.7.0/dist/styles/iview.css">
|
|
||||||
<!--Global site tag(gtag.js)-Google Analytics-->
|
|
||||||
<!--
|
|
||||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-FPS9PD2DFF"></script>
|
|
||||||
|
|
||||||
<script>window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments) } gtag("js", new Date()); gtag("config", "G-FPS9PD2DFF");</script>
|
|
||||||
-->
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body><noscript><strong>Please enable JavaScript to continue.</strong></noscript>
|
<body><noscript><strong>Please enable JavaScript to continue.</strong></noscript>
|
||||||
@@ -67,8 +45,6 @@
|
|||||||
if (!!window.ActiveXObject || "ActiveXObject" in window) {
|
if (!!window.ActiveXObject || "ActiveXObject" in window) {
|
||||||
document.querySelector('#noie').style.display = 'block';
|
document.querySelector('#noie').style.display = 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
67
public/redirect.html
Normal file
67
public/redirect.html
Normal 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>
|
||||||
20
src/App.vue
20
src/App.vue
@@ -81,23 +81,23 @@ body {
|
|||||||
|
|
||||||
|
|
||||||
#noteText::selection {
|
#noteText::selection {
|
||||||
background: #ed4014;
|
background: #dddddd;
|
||||||
color: white;
|
color: #ed4014;
|
||||||
}
|
}
|
||||||
|
|
||||||
#noteText::-moz-selection {
|
#noteText::-moz-selection {
|
||||||
background: #ed4014;
|
background: #dddddd;
|
||||||
color: white;
|
color: #ed4014;
|
||||||
}
|
}
|
||||||
|
|
||||||
#noteText br::selection {
|
#noteText br::selection {
|
||||||
background: #ed4014;
|
background: #dddddd;
|
||||||
color: white;
|
color: #ed4014;
|
||||||
}
|
}
|
||||||
|
|
||||||
#noteText br::-moz-selection {
|
#noteText br::-moz-selection {
|
||||||
background: #ed4014;
|
background: #dddddd;
|
||||||
color: white;
|
color: #ed4014;
|
||||||
}
|
}
|
||||||
|
|
||||||
.noteUrl {
|
.noteUrl {
|
||||||
@@ -122,10 +122,10 @@ body {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
button span {
|
/* button span {
|
||||||
margin-left: 0px !important;
|
margin-left: 0px !important;
|
||||||
font-size: 16px !important;
|
font-size: 16px !important;
|
||||||
font-family: apple-system,BlinkMacSystemFont,Helvetica Neue,PingFang SC,Microsoft YaHei,Source Han Sans SC,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif;
|
font-family: apple-system,BlinkMacSystemFont,Helvetica Neue,PingFang SC,Microsoft YaHei,Source Han Sans SC,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif;
|
||||||
margin-bottom: 6px;
|
margin-bottom: 6px;
|
||||||
}
|
} */
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ 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";
|
||||||
|
import { Buffer } from 'buffer';
|
||||||
|
|
||||||
axios.interceptors.response.use(undefined, (err) => {
|
axios.interceptors.response.use(undefined, (err) => {
|
||||||
const { config: originalRequest } = 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 = Buffer.from(note.text, 'base64')
|
||||||
let array = Uint8Array.from(bufferArrary);
|
|
||||||
let blob = new Blob([array], { type: "application/octet-stream" });
|
let blob = new Blob([array], { type: "application/octet-stream" });
|
||||||
let form = new FormData();
|
let form = new FormData();
|
||||||
form.append("file", blob, noteForm.key);
|
form.append("file", blob, noteForm.key);
|
||||||
@@ -72,10 +73,7 @@ export function saveNote(noteForm, secret) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function deleteNote(key) {
|
export function deleteNote(key) {
|
||||||
let storeKey = getStoreKey(key);
|
|
||||||
let storeInfo = storage.local.getText(storeKey);
|
|
||||||
let note = {
|
let note = {
|
||||||
cipher: storeInfo.substring(2, 34),
|
|
||||||
key: key,
|
key: key,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.7 KiB |
@@ -4,7 +4,7 @@ const en = {
|
|||||||
},
|
},
|
||||||
content: {
|
content: {
|
||||||
blankTip: "I am Blank.",
|
blankTip: "I am Blank.",
|
||||||
noteTip: "Start writing something...",
|
noteTip: "Write here.",
|
||||||
deleteTip: "The note will be deleted automatically. ttl:"
|
deleteTip: "The note will be deleted automatically. ttl:"
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const zh = {
|
|||||||
},
|
},
|
||||||
content: {
|
content: {
|
||||||
blankTip: "空白的内容。",
|
blankTip: "空白的内容。",
|
||||||
noteTip: "开始写下一些东西吧。。。",
|
noteTip: "写在这儿。",
|
||||||
deleteTip: "笔记将被自动删除。剩余时间:"
|
deleteTip: "笔记将被自动删除。剩余时间:"
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
@@ -26,6 +26,9 @@ const zh = {
|
|||||||
"100006": "服务器不可用!",
|
"100006": "服务器不可用!",
|
||||||
"100011": "笔记为空!",
|
"100011": "笔记为空!",
|
||||||
"100012": "笔记过大,超过{0}!",
|
"100012": "笔记过大,超过{0}!",
|
||||||
|
"100013": "The address is used, Copy to a new address.",
|
||||||
|
"100014": "The text has been modified.",
|
||||||
|
"800001": "Repetitive Submit!",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export default zh;
|
export default zh;
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import Vue from "vue";
|
import { createI18n } from "vue-i18n";
|
||||||
import VueI18n from "vue-i18n";
|
|
||||||
Vue.use(VueI18n);
|
|
||||||
|
|
||||||
import zh from "./config/zh";
|
import zh from "./config/zh";
|
||||||
import en from "./config/en";
|
import en from "./config/en";
|
||||||
@@ -10,11 +8,16 @@ const messages = {
|
|||||||
en,
|
en,
|
||||||
}
|
}
|
||||||
|
|
||||||
const i18n = new VueI18n({
|
const i18n = createI18n({
|
||||||
messages: messages,
|
allowComposition: true,
|
||||||
|
globalInjection: true,
|
||||||
|
legacy: false,
|
||||||
locale: getLocale(),
|
locale: getLocale(),
|
||||||
|
messages
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getLocale() {
|
function getLocale() {
|
||||||
var lang = navigator.language;
|
var lang = navigator.language;
|
||||||
if (lang) {
|
if (lang) {
|
||||||
|
|||||||
@@ -1,9 +1,45 @@
|
|||||||
import CryptoJS from "crypto-js";
|
import CryptoJS from "crypto-js";
|
||||||
import pako from "pako";
|
import pako from "pako";
|
||||||
|
import {Buffer} from "buffer";
|
||||||
//import {gzip_encode_raw,gzip_decode_raw} from 'wasm-flate';
|
//import {gzip_encode_raw,gzip_decode_raw} from 'wasm-flate';
|
||||||
|
|
||||||
const wasmFlate = window.wasm_bindgen;
|
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 要加密的内容
|
* @word 要加密的内容
|
||||||
* @keyWord String 服务器随机返回的关键字
|
* @keyWord String 服务器随机返回的关键字
|
||||||
@@ -11,14 +47,14 @@ const wasmFlate = window.wasm_bindgen;
|
|||||||
|
|
||||||
export function wrap(text, secretKey) {
|
export function wrap(text, secretKey) {
|
||||||
text = "FLAGNOTE#" + text;
|
text = "FLAGNOTE#" + text;
|
||||||
let result = aesEncrypt(text, secretKey);
|
let ui8ary = noteZip(text);
|
||||||
result = noteZip(result);
|
let result = aesEncrypt(convertUint8ArrayToWordArray(ui8ary), secretKey);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function unwrap(storeText, secretKey) {
|
export function unwrap(text, secretKey) {
|
||||||
let result = noteUnzip(storeText);
|
let wdary = aesDecrypt(text, secretKey);
|
||||||
result = aesDecrypt(result, secretKey);
|
let result = noteUnzip(convertWordArrayToUint8Array(wdary));
|
||||||
if (result.startsWith("FLAGNOTE#")) {
|
if (result.startsWith("FLAGNOTE#")) {
|
||||||
return result.substring(9);
|
return result.substring(9);
|
||||||
}
|
}
|
||||||
@@ -37,7 +73,7 @@ export function aesEncrypt(word, keyWord) {
|
|||||||
let key = CryptoJS.enc.Utf8.parse(keyWord);
|
let key = CryptoJS.enc.Utf8.parse(keyWord);
|
||||||
let encrypted = CryptoJS.AES.encrypt(word, key, {
|
let encrypted = CryptoJS.AES.encrypt(word, key, {
|
||||||
mode: CryptoJS.mode.ECB,
|
mode: CryptoJS.mode.ECB,
|
||||||
padding: CryptoJS.pad.Pkcs7,
|
padding: CryptoJS.pad.ZeroPadding,
|
||||||
});
|
});
|
||||||
return encrypted.toString();
|
return encrypted.toString();
|
||||||
}
|
}
|
||||||
@@ -48,28 +84,24 @@ export function aesDecrypt(word, keyWord) {
|
|||||||
let key = CryptoJS.enc.Utf8.parse(keyWord);
|
let key = CryptoJS.enc.Utf8.parse(keyWord);
|
||||||
let decrypt = CryptoJS.AES.decrypt(word, key, {
|
let decrypt = CryptoJS.AES.decrypt(word, key, {
|
||||||
mode: CryptoJS.mode.ECB,
|
mode: CryptoJS.mode.ECB,
|
||||||
padding: CryptoJS.pad.Pkcs7,
|
padding: CryptoJS.pad.ZeroPadding,
|
||||||
});
|
});
|
||||||
return CryptoJS.enc.Utf8.stringify(decrypt).toString();
|
return decrypt;
|
||||||
}
|
}
|
||||||
|
|
||||||
//base64 encode
|
//base64 encode btoa
|
||||||
export function encode(text) {
|
export function base64Encode(text) {
|
||||||
return Buffer.from(text, 'utf-8').toString('base64');
|
return Buffer.from(text, 'utf-8').toString('base64');
|
||||||
}
|
}
|
||||||
|
|
||||||
//base64 decode
|
//base64 decode atob
|
||||||
export function decode(text) {
|
export function base64Decode(text) {
|
||||||
return Buffer.from(text,'base64').toString('utf-8');
|
return Buffer.from(text,'base64').toString('utf-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function noteUnzip(text) {
|
export function noteUnzip(wdary) {
|
||||||
let charData = text.split(",").map(function (x) {
|
let data = unzip(wdary);
|
||||||
return parseInt(x);
|
let text = new TextDecoder().decode(data);
|
||||||
});
|
|
||||||
let binData = new Uint8Array(charData);
|
|
||||||
let data = unzip(binData);
|
|
||||||
text = String.fromCharCode.apply(null, new Uint8Array(data));
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,35 +128,27 @@ export function unzip(data){
|
|||||||
return pako.ungzip(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) {
|
export function convertBase64ToHexString(base64) {
|
||||||
// var words = [], i = 0, len = u8Array.length;
|
return CryptoJS.enc.Hex.stringify(CryptoJS.enc.Base64.parse(base64));
|
||||||
|
}
|
||||||
|
|
||||||
// while (i < len) {
|
export function convertHexStringToBase64(hexString) {
|
||||||
// words.push(
|
return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Hex.parse(hexString));
|
||||||
// (u8Array[i++] << 24) |
|
}
|
||||||
// (u8Array[i++] << 16) |
|
|
||||||
// (u8Array[i++] << 8) |
|
export function convertHexStringToUint8Array(hexString) {
|
||||||
// (u8Array[i++])
|
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
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|||||||
32
src/main.js
32
src/main.js
@@ -1,25 +1,29 @@
|
|||||||
import Vue from 'vue'
|
import { createApp } from 'vue'
|
||||||
|
import ViewUIPlus from 'view-ui-plus'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import router 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 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)
|
|
||||||
|
|
||||||
const debugFlag = process.env.NODE_ENV !== 'production';
|
const debugFlag = process.env.NODE_ENV !== 'production';
|
||||||
Vue.config.debug = debugFlag;
|
|
||||||
Vue.config.devtools = debugFlag;
|
|
||||||
Vue.config.productionTip = debugFlag;
|
|
||||||
|
|
||||||
new Vue({
|
const app = createApp(App)
|
||||||
i18n,
|
|
||||||
router,
|
|
||||||
render: h => h(App)
|
|
||||||
}).$mount('#app')
|
|
||||||
|
|
||||||
|
app.config.debug = debugFlag;
|
||||||
|
app.config.devtools = debugFlag;
|
||||||
|
app.config.productionTip = debugFlag;
|
||||||
|
|
||||||
|
app.use(router)
|
||||||
|
.use(i18n)
|
||||||
|
.use(VueAxios, axios)
|
||||||
|
.use(ViewUIPlus, {
|
||||||
|
i18n: i18n,
|
||||||
|
transfer: true,
|
||||||
|
size: 'large',
|
||||||
|
capture: false,
|
||||||
|
})
|
||||||
|
.mount('#app')
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
import Vue from 'vue'
|
|
||||||
import ViewUI from 'view-design'
|
|
||||||
|
|
||||||
Vue.use(ViewUI)
|
|
||||||
|
|
||||||
//import 'view-design/dist/styles/iview.css'
|
|
||||||
@@ -1,15 +1,12 @@
|
|||||||
import Vue from "vue";
|
import { createRouter, createWebHistory } 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 ErrorRoute from "@/views/ErrorRoute.vue";
|
||||||
import ErrorNote from "@/views/ErrorNote.vue";
|
import ErrorNote from "@/views/ErrorNote.vue";
|
||||||
import { getKeyMeta, getNoteMeta } from "@/api/note";
|
import { getNoteMeta } from "@/api/note";
|
||||||
import { getStoreKey } from "@/api/lock";
|
import { getStoreKey } from "@/api/lock";
|
||||||
import storage from "@/libs/storage";
|
import storage from "@/libs/storage";
|
||||||
|
|
||||||
Vue.use(VueRouter);
|
|
||||||
|
|
||||||
var keyMeta = null;
|
var keyMeta = null;
|
||||||
var noteMeta = null;
|
var noteMeta = null;
|
||||||
var errorMeta = null;
|
var errorMeta = null;
|
||||||
@@ -35,6 +32,7 @@ function getNoteView() {
|
|||||||
|
|
||||||
let key = path.substring(1, path.length);
|
let key = path.substring(1, path.length);
|
||||||
|
|
||||||
|
keyMeta = storage.session.getObject(key+".keyMeta");
|
||||||
if (keyMeta && keyMeta.key) {
|
if (keyMeta && keyMeta.key) {
|
||||||
key = keyMeta.key;
|
key = keyMeta.key;
|
||||||
}
|
}
|
||||||
@@ -107,30 +105,7 @@ function getNoteView() {
|
|||||||
return ErrorNote;
|
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 = [
|
const routes = [
|
||||||
{
|
|
||||||
path: "/",
|
|
||||||
name: "home",
|
|
||||||
redirect: getHomeRedirect(),
|
|
||||||
},
|
|
||||||
{ path: "/error_:code([0-9]{6})", component: ErrorNote },
|
{ path: "/error_:code([0-9]{6})", component: ErrorNote },
|
||||||
{
|
{
|
||||||
path: "/:name([a-z0-9]{10,20})",
|
path: "/:name([a-z0-9]{10,20})",
|
||||||
@@ -141,9 +116,11 @@ const routes = [
|
|||||||
{ path: "/:path(.*)", component: ErrorRoute }
|
{ path: "/:path(.*)", component: ErrorRoute }
|
||||||
];
|
];
|
||||||
|
|
||||||
const router = new VueRouter({
|
const router = createRouter({
|
||||||
routes,
|
history: createWebHistory(process.env.VUE_APP_URL_BASE_PATH),
|
||||||
|
linkExactActiveClass: "active",
|
||||||
mode: "history",
|
mode: "history",
|
||||||
});
|
routes
|
||||||
|
})
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -38,6 +38,13 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* button span {
|
||||||
|
margin-left: 0px !important;
|
||||||
|
font-size: 18px !important;
|
||||||
|
font-family: apple-system,BlinkMacSystemFont,Helvetica Neue,PingFang SC,Microsoft YaHei,Source Han Sans SC,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@media print {
|
@media print {
|
||||||
@@ -80,30 +87,19 @@
|
|||||||
v-on:click="refreshPage()" />
|
v-on:click="refreshPage()" />
|
||||||
|
|
||||||
<div style="float:left;width:auto;">
|
<div style="float:left;width:auto;">
|
||||||
|
|
||||||
<Button-group size="large">
|
<Button-group size="large">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Button aria-label="to top" v-show="toTopState" type="text"
|
<Button aria-label="to top" v-show="toTopState" type="text"
|
||||||
style="margin-left:5px; border-radius: 0px; font-size: 28px;color:red;line-height: 20px;"
|
style="margin-left:5px; border-radius: 0px; font-size: 28px;color:red;line-height: 20px;"
|
||||||
@click="toTop()" icon="ios-arrow-up" ghost></Button>
|
@click="toTop()" icon="ios-arrow-up" ghost></Button>
|
||||||
|
|
||||||
</Button-group>
|
</Button-group>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div style="float:right;width:auto;">
|
<div style="float:right;width:auto;">
|
||||||
|
|
||||||
<Button-group size="large">
|
<Button-group size="large">
|
||||||
<Button aria-label="publish" type="error" :loading="model.submitting"
|
<Button aria-label="publish" type="error" :loading="model.submitting"
|
||||||
style="margin-left:5px; border-radius: 0px;font-size: 21px;" @click="submitNote()"
|
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;"
|
<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>
|
@click="switchMenu()" @blur.native="hideMenu()" icon="md-menu"></Button>
|
||||||
|
|
||||||
</Button-group>
|
</Button-group>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -113,18 +109,12 @@
|
|||||||
<Button-group vertical size="large">
|
<Button-group vertical size="large">
|
||||||
<Button aria-label="create note" type="error" style="border-radius: 0px;font-size: 24px;"
|
<Button aria-label="create note" type="error" style="border-radius: 0px;font-size: 24px;"
|
||||||
@click="createNote(); switchMenu(); " icon="md-add"></Button>
|
@click="createNote(); switchMenu(); " icon="md-add"></Button>
|
||||||
<!--
|
|
||||||
|
|
||||||
<Button type="error" icon="md-refresh" style="border-radius: 0px;font-size: 14px;font-size: 24px;"
|
<Button aria-label="crop" v-show="model.showDownloadText" type="error"
|
||||||
@click="refreshPage()"></Button>
|
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"
|
<Button aria-label="download text" v-show="model.showDownloadText" 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 aria-label="history text" v-show="model.showHistoryText" type="error"
|
|
||||||
style="border-radius: 0px;font-size: 24px;" @click="downLoadText(); switchMenu(); "
|
|
||||||
icon="md-download"></Button>
|
icon="md-download"></Button>
|
||||||
|
|
||||||
<Button type="error" icon="md-trash" style="border-radius: 0px;font-size: 24px;"
|
<Button type="error" icon="md-trash" style="border-radius: 0px;font-size: 24px;"
|
||||||
@@ -149,13 +139,15 @@
|
|||||||
:lg="{ span: 18, offset: 3 }" :xl="{ span: 16, offset: 4 }" :xxl="{ span: 16, offset: 4 }">
|
:lg="{ span: 18, offset: 3 }" :xl="{ span: 16, offset: 4 }" :xxl="{ span: 16, offset: 4 }">
|
||||||
<Card :padding="0">
|
<Card :padding="0">
|
||||||
<Form :model="noteForm" :label-width="80">
|
<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
|
<Input element-id="noteText" type="textarea" :border="false" v-model="noteForm.text" autofocus
|
||||||
:autosize="{ minRows: 30, maxRows: 409600 }" :placeholder="$t('content.noteTip')" @input="recordText"
|
:autosize="{ minRows: 35, maxRows: 100000 }" :placeholder="$t('content.noteTip')" @input="recordText"
|
||||||
@on-keydown="recordEventKdown" />
|
@on-keydown="recordEventKdown" />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
</Card>
|
</Card>
|
||||||
|
<WordCount :value="noteForm.text" :total="100000" style="border-top:1px solid #ed4014;float:left" />
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
</Row>
|
</Row>
|
||||||
@@ -163,7 +155,7 @@
|
|||||||
|
|
||||||
</Content>
|
</Content>
|
||||||
|
|
||||||
<Footer class="layout-footer-center">2022 © flagnote.com</Footer>
|
<Footer class="layout-footer-center">2023 © flagnote.com</Footer>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
||||||
<Modal v-model="model.showDelete" width="360" footer-hide class-name="fnmodal" :styles="{ borderRadius: 0 }">
|
<Modal v-model="model.showDelete" width="360" footer-hide class-name="fnmodal" :styles="{ borderRadius: 0 }">
|
||||||
@@ -197,10 +189,11 @@ import { unwrap } from '../libs/secret'
|
|||||||
import { saveNote } from "@/api/note";
|
import { saveNote } from "@/api/note";
|
||||||
import { getStoreKey } from "@/api/lock";
|
import { getStoreKey } from "@/api/lock";
|
||||||
import storage from "@/libs/storage";
|
import storage from "@/libs/storage";
|
||||||
import { setStoreText,setNewStoreText } from "@/libs/noteStorage";
|
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 html2canvas from "html2canvas";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'EditNote',
|
name: 'EditNote',
|
||||||
@@ -222,6 +215,7 @@ export default {
|
|||||||
lock: 0,
|
lock: 0,
|
||||||
locking: 0,
|
locking: 0,
|
||||||
commited: 0,
|
commited: 0,
|
||||||
|
deleted: 0,
|
||||||
serverTime: '',
|
serverTime: '',
|
||||||
initTime: '',
|
initTime: '',
|
||||||
},
|
},
|
||||||
@@ -235,22 +229,25 @@ export default {
|
|||||||
toTopState: false,
|
toTopState: false,
|
||||||
showMenuState: false,
|
showMenuState: false,
|
||||||
showHeaderShade: false,
|
showHeaderShade: false,
|
||||||
pageSession: '',
|
|
||||||
errorInfo: '',
|
errorInfo: '',
|
||||||
|
lastEditTime: 0,
|
||||||
|
backStoreTextInterval: null,
|
||||||
|
lastStoreCount: 0,
|
||||||
|
lastStoreTime: 0,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.pageSession = new Date().getTime();
|
this.editTime = new Date().getTime();
|
||||||
|
|
||||||
// read $route
|
// read $route
|
||||||
this.noteForm.key = this.$route.params.name;
|
this.noteForm.key = this.$route.params.name;
|
||||||
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();
|
||||||
@@ -276,6 +273,7 @@ export default {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
storage.local.setText(storeKey, "0|" + this.secret.cipher + "|0|" + this.state.initTime + "|");
|
storage.local.setText(storeKey, "0|" + this.secret.cipher + "|0|" + this.state.initTime + "|");
|
||||||
|
storage.session.delete(keyMeta.key + ".keyMeta");
|
||||||
} else {
|
} else {
|
||||||
// second edit
|
// second edit
|
||||||
let noteMeta = this.$route.meta.noteMeta;
|
let noteMeta = this.$route.meta.noteMeta;
|
||||||
@@ -293,6 +291,10 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.lastStoreCount = this.noteForm.text.length;
|
||||||
|
this.lastEditTime = new Date().getTime();
|
||||||
|
this.lastStoreTime = this.lastEditTime;
|
||||||
|
|
||||||
this.bindCtrlAllEvent();
|
this.bindCtrlAllEvent();
|
||||||
this.bindToTopEvent();
|
this.bindToTopEvent();
|
||||||
|
|
||||||
@@ -313,12 +315,15 @@ export default {
|
|||||||
const someOtherEl = document.querySelector('#wrapper');
|
const someOtherEl = document.querySelector('#wrapper');
|
||||||
|
|
||||||
myObserver.observe(someOtherEl);
|
myObserver.observe(someOtherEl);
|
||||||
|
|
||||||
|
window.addEventListener('beforeunload', e => this.beforeunloadHandler(e))
|
||||||
},
|
},
|
||||||
updated() {
|
updated() {
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
|
window.removeEventListener('beforeunload', e => this.beforeunloadHandler(e))
|
||||||
},
|
},
|
||||||
computed: {},
|
computed: {},
|
||||||
watch: {},
|
watch: {},
|
||||||
@@ -355,7 +360,49 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let nowEditCount = this.noteForm.text.length;
|
||||||
|
let nowEditTime = new Date().getTime();
|
||||||
|
|
||||||
|
if (nowEditCount < 1024) {
|
||||||
setStoreText(this.noteForm, this.state, this.secret);
|
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) {
|
// recordEventKup(event) {
|
||||||
// let tn = event.currentTarget.value;
|
// let tn = event.currentTarget.value;
|
||||||
@@ -395,7 +442,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.noteForm.text = event.currentTarget.value;
|
this.noteForm.text = event.currentTarget.value;
|
||||||
setStoreText(this.noteForm, this.state, this.secret);
|
this.recordText();
|
||||||
|
|
||||||
} else if (event.ctrlKey && (event.which == 13)) {
|
} else if (event.ctrlKey && (event.which == 13)) {
|
||||||
//save
|
//save
|
||||||
@@ -449,9 +496,9 @@ export default {
|
|||||||
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 key = setNewStoreText(this.noteForm);
|
||||||
location.href="/"+key;
|
location.href = "/" + key;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -470,6 +517,7 @@ export default {
|
|||||||
},
|
},
|
||||||
dropNote() {
|
dropNote() {
|
||||||
this.model.deleting = true;
|
this.model.deleting = true;
|
||||||
|
this.state.deleted = 1;
|
||||||
storage.local.delete(this.secret.storeKey);
|
storage.local.delete(this.secret.storeKey);
|
||||||
storage.session.setText(this.secret.storeKey + "_delete", 1);
|
storage.session.setText(this.secret.storeKey + "_delete", 1);
|
||||||
location.reload();
|
location.reload();
|
||||||
@@ -497,7 +545,67 @@ 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() {
|
||||||
|
if(this.state.deleted==0){
|
||||||
|
setStoreText(this.noteForm, this.state, this.secret);
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
</Content>
|
</Content>
|
||||||
|
|
||||||
|
|
||||||
<Footer class="layout-footer-center">2022 © flagnote.com</Footer>
|
<Footer class="layout-footer-center">2023 © flagnote.com</Footer>
|
||||||
|
|
||||||
</Layout>
|
</Layout>
|
||||||
</div>
|
</div>
|
||||||
@@ -135,19 +135,6 @@ export default {
|
|||||||
|
|
||||||
//this.bindCopyTextEvent();
|
//this.bindCopyTextEvent();
|
||||||
|
|
||||||
const myObserver = new ResizeObserver(entries => {
|
|
||||||
// iterate over the entries, do something.
|
|
||||||
entries.forEach(entry => {
|
|
||||||
let affix = document.querySelector('.ivu-affix');
|
|
||||||
if (affix) {
|
|
||||||
affix.setAttribute("style", "top: 0px; width: " + (entry.contentRect.width +2) + "px;");
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const someOtherEl = document.querySelector('#wrapper');
|
|
||||||
myObserver.observe(someOtherEl);
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -80,8 +80,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#qrUrl::selection {
|
#qrUrl::selection {
|
||||||
background-color: #ed4014;
|
background: #dddddd;
|
||||||
color: #ffffff;
|
color: #ed4014;
|
||||||
}
|
}
|
||||||
|
|
||||||
#copyBtn {
|
#copyBtn {
|
||||||
@@ -151,11 +151,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* #noteMenu button span{
|
/* button span {
|
||||||
font-size: 20px;
|
margin-left: 0px !important;
|
||||||
line-height: 20px;
|
font-size: 16px !important;
|
||||||
margin-left: 7px !important;
|
font-family: apple-system,BlinkMacSystemFont,Helvetica Neue,PingFang SC,Microsoft YaHei,Source Han Sans SC,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif;
|
||||||
margin-right: 5px !important;
|
margin-bottom: 6px;
|
||||||
} */
|
} */
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@@ -171,20 +171,6 @@
|
|||||||
<div :class="[showHeaderShade ? 'noteHeaderShade' : 'noteHeader']">
|
<div :class="[showHeaderShade ? 'noteHeaderShade' : 'noteHeader']">
|
||||||
<img style="height:40px;float:left;cursor: pointer;" alt="refresh flagnote" src="/static/logo.png"
|
<img style="height:40px;float:left;cursor: pointer;" alt="refresh flagnote" src="/static/logo.png"
|
||||||
v-on:click="refreshPage()">
|
v-on:click="refreshPage()">
|
||||||
<!--
|
|
||||||
<div style="float:left;width:auto;vertical-align: center;">
|
|
||||||
<div style="font-size: 18px;
|
|
||||||
color: red;
|
|
||||||
line-height: 40px;
|
|
||||||
display: inline-block;
|
|
||||||
font-weight: bold;
|
|
||||||
height: 40px;">{{
|
|
||||||
state.ttlDesc
|
|
||||||
}}</div>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
<div style="float:left;width:auto;">
|
<div style="float:left;width:auto;">
|
||||||
|
|
||||||
<Button-group size="large">
|
<Button-group size="large">
|
||||||
@@ -203,8 +189,16 @@
|
|||||||
<Button-group size="large">
|
<Button-group size="large">
|
||||||
|
|
||||||
<Button aria-label="ttl" type="error"
|
<Button aria-label="ttl" type="error"
|
||||||
style="margin-left:5px; border-radius: 0px;font-size: 21px; font-family: Arial, sans-serif"
|
style="margin-left:5px; border-radius: 0px;font-size: 21px; padding-left: 3px !important;padding-right: 7px !important; font-family: Arial, sans-serif"
|
||||||
@click="showTtlDeleteModel()" icon="md-alarm">{{ state.ttlDesc }}</Button>
|
@click="showTtlDeleteModel()">
|
||||||
|
<Badge :offset="[8, 0]" style="padding-top:1px;">
|
||||||
|
<Icon type="md-trash" color="#FFFFFF" size="24" />
|
||||||
|
<template #count>
|
||||||
|
<Icon type="md-time" color="#FFFFFF" size="14" />
|
||||||
|
</template>
|
||||||
|
</Badge>
|
||||||
|
<span style="font-size:18px;margin-left: 7px">{{ state.ttlDesc }}</span>
|
||||||
|
</Button>
|
||||||
|
|
||||||
<Button aria-label="share" type="error"
|
<Button aria-label="share" type="error"
|
||||||
style="margin-left:3px; border-radius: 0px;font-size: 21px; font-family: Arial, sans-serif"
|
style="margin-left:3px; border-radius: 0px;font-size: 21px; font-family: Arial, sans-serif"
|
||||||
@@ -220,7 +214,7 @@
|
|||||||
<div id="noteMenu" :class="[showMenuState ? 'showBlock' : 'hideBlock']"
|
<div id="noteMenu" :class="[showMenuState ? 'showBlock' : 'hideBlock']"
|
||||||
style="z-index: 100; position: absolute;top:43px;right:0px;left:auto;">
|
style="z-index: 100; position: absolute;top:43px;right:0px;left:auto;">
|
||||||
<Button-group vertical size="large">
|
<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>
|
@click="createNote(); switchMenu();"></Button>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -228,10 +222,11 @@
|
|||||||
<Button type="error" icon="md-refresh" style="border-radius: 0px;font-size: 24px;"
|
<Button type="error" icon="md-refresh" style="border-radius: 0px;font-size: 24px;"
|
||||||
@click="refreshPage()"></Button>
|
@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"
|
<Button aria-label="download text" v-show="model.showDownloadText" type="error"
|
||||||
style="border-radius: 0px;font-size: 24px;" @click="downLoadText(); switchMenu();"
|
style="border-radius: 0px;font-size: 24px;" @click="downLoadText(); " icon="md-download"></Button>
|
||||||
icon="md-download"></Button>
|
|
||||||
|
|
||||||
<Button type="error" icon="md-trash" style="border-radius: 0px;font-size: 24px;"
|
<Button type="error" icon="md-trash" style="border-radius: 0px;font-size: 24px;"
|
||||||
@click="showDeleteModel(); switchMenu();"></Button>
|
@click="showDeleteModel(); switchMenu();"></Button>
|
||||||
@@ -254,9 +249,33 @@
|
|||||||
<Col :xs="{ span: 24, offset: 0 }" :sm="{ span: 22, offset: 1 }" :md="{ span: 20, offset: 2 }"
|
<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 }">
|
:lg="{ span: 18, offset: 3 }" :xl="{ span: 16, offset: 4 }" :xxl="{ span: 16, offset: 4 }">
|
||||||
<Card :padding="0">
|
<Card :padding="0">
|
||||||
<div id="wrapper" style="border-left: 2px solid white;">
|
<div ref="html2canvas" id="wrapper" style="border-left: 2px solid white;">
|
||||||
|
<Skeleton :loading="showSkeleton">
|
||||||
|
<template #template>
|
||||||
|
<div style=" padding: 10px; width: 100%; height: 800px;text-align: left;" >
|
||||||
|
<SkeletonItem />
|
||||||
|
<SkeletonItem block width="80%" height="16px" />
|
||||||
|
<SkeletonItem width="80%" height="16px" class="ivu-mr" />
|
||||||
|
<SkeletonItem width="68%" height="16px" class="ivu-mr" />
|
||||||
|
<SkeletonItem width="38%" height="16px" />
|
||||||
|
<SkeletonItem width="88%" height="16px" />
|
||||||
|
<SkeletonItem block width="80%" height="16px" />
|
||||||
|
<SkeletonItem width="80%" height="16px" class="ivu-mr" />
|
||||||
|
<SkeletonItem width="68%" height="16px" class="ivu-mr" />
|
||||||
|
<SkeletonItem width="38%" height="16px" />
|
||||||
|
<SkeletonItem width="88%" height="16px" />
|
||||||
|
<SkeletonItem block width="80%" height="16px" />
|
||||||
|
<SkeletonItem width="80%" height="16px" class="ivu-mr" />
|
||||||
|
<SkeletonItem width="68%" height="16px" class="ivu-mr" />
|
||||||
|
<SkeletonItem width="38%" height="16px" />
|
||||||
|
<SkeletonItem width="88%" height="16px" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #default>
|
||||||
<Input element-id="noteText" readonly type="textarea" :border="false" v-model="noteForm.text"
|
<Input element-id="noteText" readonly type="textarea" :border="false" v-model="noteForm.text"
|
||||||
:autosize="{ minRows: 30, maxRows: 409600 }" :placeholder="$t('content.noteTip')" />
|
:autosize="{ minRows: 35 }" />
|
||||||
|
</template>
|
||||||
|
</Skeleton>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
@@ -266,19 +285,14 @@
|
|||||||
|
|
||||||
|
|
||||||
<Footer class="layout-footer-center">
|
<Footer class="layout-footer-center">
|
||||||
2022 © flagnote.com
|
2023 © flagnote.com
|
||||||
</Footer>
|
</Footer>
|
||||||
|
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
||||||
<Modal v-model="model.showShare" width="360" footer-hide class-name="qrmodal" :styles="{ borderRadius: 0 }"
|
<Modal v-model="model.showShare" width="360" footer-hide class-name="qrmodal" :styles="{ borderRadius: 0 }"
|
||||||
@on-cancel="closeShareModel">
|
@on-cancel="closeShareModel">
|
||||||
<p style="text-align: center;
|
<p style="text-align: center; z-index: 1000; position: absolute; top: -2px; left: 0px; width: 100%;">
|
||||||
z-index: 1000;
|
|
||||||
position: absolute;
|
|
||||||
top: -2px;
|
|
||||||
left: 0px;
|
|
||||||
width: 100%;">
|
|
||||||
<Tag style="border-radius: 0px;" v-show="model.copyTip" color="#ed4014" text="">Url Copied.</Tag>
|
<Tag style="border-radius: 0px;" v-show="model.copyTip" color="#ed4014" text="">Url Copied.</Tag>
|
||||||
</p>
|
</p>
|
||||||
<p style="text-align: center;margin-top:20px;line-height:100%">
|
<p style="text-align: center;margin-top:20px;line-height:100%">
|
||||||
@@ -331,9 +345,6 @@
|
|||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -343,10 +354,12 @@ import { getStoreKey } from "@/api/lock";
|
|||||||
import { deleteNote, getNoteBlob } from "@/api/note";
|
import { deleteNote, getNoteBlob } from "@/api/note";
|
||||||
import storage from "@/libs/storage";
|
import storage from "@/libs/storage";
|
||||||
//import { getEscapeText } from "@/libs/noteStorage";
|
//import { getEscapeText } from "@/libs/noteStorage";
|
||||||
import QRCode from "qrcodejs2";
|
import QRCode from "qrcodejs2-fixes";
|
||||||
import Clipboard from "clipboard";
|
import Clipboard from "clipboard";
|
||||||
import { saveAs } from 'file-saver';
|
import { saveAs } from 'file-saver';
|
||||||
import { isWeixin, getNoteUrl } from "@/libs/utils";
|
import { isWeixin, getNoteUrl } from "@/libs/utils";
|
||||||
|
import html2canvas from "html2canvas";
|
||||||
|
import { Buffer } from 'buffer';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ViewNote',
|
name: 'ViewNote',
|
||||||
@@ -388,6 +401,8 @@ export default {
|
|||||||
showMenuState: false,
|
showMenuState: false,
|
||||||
showHeaderShade: false,
|
showHeaderShade: false,
|
||||||
errorInfo: '',
|
errorInfo: '',
|
||||||
|
targetTime: null,
|
||||||
|
showSkeleton: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@@ -413,6 +428,7 @@ export default {
|
|||||||
this.state.initTime = new Date().getTime();
|
this.state.initTime = new Date().getTime();
|
||||||
this.state.initTtl = noteMeta.ttl;
|
this.state.initTtl = noteMeta.ttl;
|
||||||
this.state.ttl = noteMeta.ttl;
|
this.state.ttl = noteMeta.ttl;
|
||||||
|
this.targetTime = noteMeta.ttl + new Date().getTime();
|
||||||
this.state.serverTime = noteMeta.serverTime;
|
this.state.serverTime = noteMeta.serverTime;
|
||||||
|
|
||||||
this.secret.cipher = "00000000000000000000000000000000";//noteMeta.cipher; //读者有没有值可配置
|
this.secret.cipher = "00000000000000000000000000000000";//noteMeta.cipher; //读者有没有值可配置
|
||||||
@@ -437,12 +453,6 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
||||||
let stateInfo = storage.session.getText(this.secret.storeKey + "_share");
|
|
||||||
if (stateInfo == '1') {
|
|
||||||
storage.session.setText(this.secret.storeKey + "_share", '0');
|
|
||||||
this.showShareModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
const myObserver = new ResizeObserver(entries => {
|
const myObserver = new ResizeObserver(entries => {
|
||||||
// iterate over the entries, do something.
|
// iterate over the entries, do something.
|
||||||
entries.forEach(entry => {
|
entries.forEach(entry => {
|
||||||
@@ -469,6 +479,13 @@ export default {
|
|||||||
}
|
}
|
||||||
new QRCode(qrimg, opts);
|
new QRCode(qrimg, opts);
|
||||||
|
|
||||||
|
let stateInfo = storage.session.getText(this.secret.storeKey + "_share");
|
||||||
|
if (stateInfo == '1') {
|
||||||
|
storage.session.setText(this.secret.storeKey + "_share", '0');
|
||||||
|
setTimeout(() => {
|
||||||
|
this.showShareModel();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
updated() {
|
updated() {
|
||||||
},
|
},
|
||||||
@@ -505,9 +522,7 @@ export default {
|
|||||||
} else if (mins < 10) {
|
} else if (mins < 10) {
|
||||||
mins = "0" + mins;
|
mins = "0" + mins;
|
||||||
}
|
}
|
||||||
|
|
||||||
let seds = parseInt(ittl % 60);
|
let seds = parseInt(ittl % 60);
|
||||||
|
|
||||||
if (seds < 0) {
|
if (seds < 0) {
|
||||||
seds = "00";
|
seds = "00";
|
||||||
} else if (seds < 10) {
|
} else if (seds < 10) {
|
||||||
@@ -515,7 +530,6 @@ export default {
|
|||||||
}
|
}
|
||||||
that.state.ttlDesc = mins + ":" + seds;
|
that.state.ttlDesc = mins + ":" + seds;
|
||||||
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);
|
||||||
location.reload();
|
location.reload();
|
||||||
@@ -553,7 +567,7 @@ export default {
|
|||||||
this.model.deleting = true;
|
this.model.deleting = true;
|
||||||
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);
|
||||||
location.reload();
|
location.reload();
|
||||||
} else {
|
} else {
|
||||||
@@ -580,28 +594,19 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let blob = new Blob([res.data], {
|
res.data.arrayBuffer().then(function (ab) {
|
||||||
type: res.data.type
|
if (!ab || ab.byteLength == 0) {
|
||||||
});
|
|
||||||
|
|
||||||
let reader = new FileReader();
|
|
||||||
reader.onload = function (e) {
|
|
||||||
if (!e.target.result || e.target.result.byteLength == 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bytes = new Uint8Array(e.target.result);
|
let base64String = Buffer.from(ab).toString('base64')
|
||||||
bytes = bytes.subarray(7,bytes.length-7);
|
that.noteForm.text = unwrap(base64String, that.secret.secretKey);
|
||||||
let bytesString = bytes.join(",");
|
that.showSkeleton = false;
|
||||||
that.noteForm.text = unwrap(bytesString, that.secret.secretKey);
|
|
||||||
//that.noteForm.escapeText = getEscapeText(that.noteForm.text);
|
|
||||||
|
|
||||||
// if local is enough, set local
|
// if local is enough, set local
|
||||||
if (storage.local.getAvailableSize() > 1 * 1024 * 1024) {
|
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 {
|
} else {
|
||||||
@@ -612,6 +617,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.noteForm.text = unwrap(starray[4], this.secret.secretKey);
|
this.noteForm.text = unwrap(starray[4], this.secret.secretKey);
|
||||||
|
this.showSkeleton = false;
|
||||||
//this.noteForm.escapeText = getEscapeText(this.noteForm.text);
|
//this.noteForm.escapeText = getEscapeText(this.noteForm.text);
|
||||||
|
|
||||||
// local is usable, and set commited flag
|
// local is usable, and set commited flag
|
||||||
@@ -664,6 +670,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>
|
</script>
|
||||||
|
|||||||
117
vue.config.js
117
vue.config.js
@@ -1,30 +1,70 @@
|
|||||||
const { defineConfig } = require("@vue/cli-service");
|
const { defineConfig } = require('@vue/cli-service')
|
||||||
const CompressionPlugin = require("compression-webpack-plugin");
|
const CompressionPlugin = require("compression-webpack-plugin");
|
||||||
const WebpackObfuscator = require('webpack-obfuscator');
|
const WebpackObfuscator = require('webpack-obfuscator');
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
module.exports = defineConfig({
|
const { NODE_ENV, VUE_APP_TITLE = '' } = process.env
|
||||||
|
|
||||||
assetsDir: 'static',
|
const assetsCDN = {
|
||||||
productionSourceMap: false,
|
// 忽略打包的第三方库
|
||||||
|
externals: {
|
||||||
configureWebpack: (config) => {
|
|
||||||
config.experiments = { asyncWebAssembly: true,syncWebAssembly:true }
|
|
||||||
|
|
||||||
|
|
||||||
config.externals = {
|
|
||||||
'vue': 'Vue',
|
'vue': 'Vue',
|
||||||
'vue-router': 'VueRouter',
|
'vue-router': 'VueRouter',
|
||||||
'axios': 'axios',
|
|
||||||
//'vue-axios':'VueAxios',
|
|
||||||
"crypto-js": "CryptoJS",
|
"crypto-js": "CryptoJS",
|
||||||
'qrcodejs2': 'QRCode',
|
|
||||||
'pako': 'pako',
|
'pako': 'pako',
|
||||||
"view-design": 'iview',
|
"html2canvas": "html2canvas",
|
||||||
"iview": 'ViewUI',
|
'view-ui-plus':'ViewUIPlus',
|
||||||
"file-saver": 'saveAs',
|
},
|
||||||
"clipboard": "ClipboardJS",
|
|
||||||
"vue-i18n": "VueI18n"
|
// 通过cdn方式使用
|
||||||
};
|
js: [
|
||||||
|
'https://cdn.jsdelivr.net/npm/vue@3.2.47/dist/vue.global.min.js',
|
||||||
|
'https://cdn.jsdelivr.net/npm/vue-router@4.1.6/dist/vue-router.global.min.js',
|
||||||
|
'https://cdn.jsdelivr.net/npm/crypto-js@4.1.1/crypto-js.min.js',
|
||||||
|
'https://cdn.jsdelivr.net/npm/pako@2.1.0/dist/pako.min.js',
|
||||||
|
'https://cdn.jsdelivr.net/npm/view-ui-plus@1.3.10/dist/viewuiplus.min.js',
|
||||||
|
|
||||||
|
'https://cdn.jsdelivr.net/npm/wasm-flate@1.0.2-browser/wasm_flate.min.js',
|
||||||
|
'https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js',
|
||||||
|
],
|
||||||
|
|
||||||
|
css: [
|
||||||
|
'https://cdn.jsdelivr.net/npm/view-ui-plus@1.3.10/dist/styles/viewuiplus.min.css',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
|
||||||
|
assetsDir: 'static',
|
||||||
|
productionSourceMap: NODE_ENV !== 'production',
|
||||||
|
|
||||||
|
configureWebpack: (config) => {
|
||||||
|
config.experiments = { asyncWebAssembly: true, syncWebAssembly: true }
|
||||||
|
|
||||||
|
config.externals = assetsCDN.externals;
|
||||||
|
|
||||||
|
// const assetsCDN = {
|
||||||
|
// // 放置需要使用 cdn 的库
|
||||||
|
// externals: {
|
||||||
|
// 'vue': 'Vue',
|
||||||
|
// 'vue-router': 'VueRouter',
|
||||||
|
// "crypto-js": "CryptoJS",
|
||||||
|
// 'pako': 'pako',
|
||||||
|
// "html2canvas": "html2canvas",
|
||||||
|
// 'view-ui-plus':'ViewUIPlus',
|
||||||
|
// },
|
||||||
|
// css: [
|
||||||
|
// // 存放 引用 css文件的地址
|
||||||
|
// '//unpkg.com/element-plus@1.0.2-beta.48/lib/theme-chalk/index.css',
|
||||||
|
// ],
|
||||||
|
// js: [
|
||||||
|
// // 存放 引用 js 文件的地址
|
||||||
|
// '//unpkg.com/vue@3.1.1/dist/vue.global.js',
|
||||||
|
// '//unpkg.com/element-plus@1.0.2-beta.48/lib/index.full.js'
|
||||||
|
// ]
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
// 为生产环境修改配置
|
// 为生产环境修改配置
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
@@ -55,24 +95,49 @@ module.exports = defineConfig({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transpileDependencies: true,
|
|
||||||
chainWebpack: (config) => {
|
transpileDependencies: false,
|
||||||
config.plugin("html").tap((args) => {
|
|
||||||
args[0].title = "flagnote.com";
|
|
||||||
|
chainWebpack: (setting) => {
|
||||||
|
setting.plugin("html").tap((args) => {
|
||||||
|
args[0].cdn = assetsCDN
|
||||||
|
args[0].title = VUE_APP_TITLE;
|
||||||
return args;
|
return args;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
css: {
|
||||||
|
loaderOptions: {
|
||||||
|
less: {
|
||||||
|
lessOptions: {
|
||||||
|
javascriptEnabled: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
devServer: {
|
devServer: {
|
||||||
proxy: {
|
proxy: {
|
||||||
"/note": {
|
"/note": {
|
||||||
// target: "https://flagnote.com/", // 后台接口域名
|
target: "https://flagnote.com/", // 后台接口域名
|
||||||
target: "http://localhost:10000/", // 后台接口域名
|
//target: "http://localhost:20000/", // 后台接口域名
|
||||||
secure: false, // 如果是https接口,需要配置这个参数
|
secure: false, // 如果是https接口,需要配置这个参数
|
||||||
changeOrigin: true, //是否跨域
|
changeOrigin: true, //是否跨域
|
||||||
pathRewrite: {
|
pathRewrite: {
|
||||||
// '^/': '/'
|
// '^/': '/'
|
||||||
},
|
},
|
||||||
|
}, "^/[abcdefhikmnopqstuvwxyz23456789]{16}\\.txt$": {
|
||||||
|
target: "https://flagnote.com/", // 后台接口域名
|
||||||
|
//target: "http://localhost:20000/", // 后台接口域名
|
||||||
|
secure: false, // 如果是https接口,需要配置这个参数
|
||||||
|
changeOrigin: true, //是否跨域
|
||||||
|
pathRewrite: {
|
||||||
|
'^/': '/note/'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = defineConfig(config)
|
||||||
Reference in New Issue
Block a user