Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f1a0b75e3 |
@@ -1,6 +1,6 @@
|
||||
NODE_ENV = developement
|
||||
VUE_APP_FLAG=dev
|
||||
VUE_APP_BASE_NAME = developement
|
||||
VUE_APP_BASE_URL = http://localhost:8080
|
||||
VUE_APP_NOTE_MAX_COUNT = 131072
|
||||
VUE_APP_NOTE_MAX_DESC = 128K
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
NODE_ENV = production
|
||||
VUE_APP_FLAG=prod
|
||||
VUE_APP_BASE_NAME = production
|
||||
VUE_APP_BASE_URL = https://flagnote.com
|
||||
VUE_APP_NOTE_MAX_COUNT = 131072
|
||||
VUE_APP_NOTE_MAX_DESC = 128K
|
||||
VUE_APP_CDN_PROVIDER = jsdelivr
|
||||
# VUE_APP_CDN_PROVIDER = unpkg
|
||||
@@ -1 +0,0 @@
|
||||
VUE_APP_FLAG=staging
|
||||
@@ -1,2 +0,0 @@
|
||||
assets
|
||||
mock
|
||||
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"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,35 +1,24 @@
|
||||
# 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
|
||||
# flagnote-web
|
||||
|
||||
- This operation will also run before git-commit.
|
||||
```shell
|
||||
npm run lint
|
||||
## Project setup
|
||||
```
|
||||
### Run with Fixing
|
||||
```shell
|
||||
npm run lint:fix
|
||||
yarn install
|
||||
```
|
||||
## .env Description
|
||||
|
||||
- This project exposes environment variables on `process.env` object.
|
||||
- Different modes (development/staging/production) correspond to different environment files (.env.*).
|
||||
- .env file is always included, duplicate variables are overwritten by the specific mode file (.env.*).
|
||||
### Compiles and hot-reloads for development
|
||||
```
|
||||
yarn serve
|
||||
```
|
||||
|
||||
### Compiles and minifies for production
|
||||
```
|
||||
yarn build
|
||||
```
|
||||
|
||||
### Lints and fixes files
|
||||
```
|
||||
yarn lint
|
||||
```
|
||||
|
||||
### Customize configuration
|
||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@vue/cli-plugin-babel/preset',
|
||||
],
|
||||
"plugins": [
|
||||
[
|
||||
"import",
|
||||
{
|
||||
"libraryName": "view-ui-plus",
|
||||
"libraryDirectory": "src/components"
|
||||
},
|
||||
"view-ui-plus"
|
||||
]
|
||||
]
|
||||
};
|
||||
// module.exports = {
|
||||
// presets: [
|
||||
// '@vue/cli-plugin-babel/preset'
|
||||
// ]
|
||||
// }
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"target": "esnext",
|
||||
"module": "esnext",
|
||||
"baseUrl": "./",
|
||||
"jsx": "preserve",
|
||||
"moduleResolution": "node",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
@@ -14,6 +15,10 @@
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"scripthost"
|
||||
]
|
||||
],
|
||||
"removeComments": true,
|
||||
},
|
||||
"vueCompilerOptions": {
|
||||
"target": 2.7
|
||||
}
|
||||
}
|
||||
|
||||
75
package.json
75
package.json
@@ -1,56 +1,61 @@
|
||||
{
|
||||
"name": "flagnote-web",
|
||||
"version": "1.0.0",
|
||||
"description": "flagnote web",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "npm run serve",
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"build:staging": "vue-cli-service build --mode=staging",
|
||||
"lint": "eslint ./src --ext .js,.vue",
|
||||
"lint:fix": "eslint ./src --ext .js,.vue --fix",
|
||||
"prepare": "husky install"
|
||||
"build": "vue-cli-service build --mode production",
|
||||
"build.test": "vue-cli-service build --mode test",
|
||||
"build.production": "vue-cli-service build --mode production",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.27.2",
|
||||
"babel-plugin-import": "^1.13.6",
|
||||
"buffer": "^6.0.3",
|
||||
"clipboard": "^2.0.11",
|
||||
"core-js": "^3.8.3",
|
||||
"crypto-js": "^4.1.1",
|
||||
"escape-html": "^1.0.3",
|
||||
"file-saver": "^2.0.5",
|
||||
"html2canvas": "^1.4.1",
|
||||
"pako": "^2.1.0",
|
||||
"qrcodejs2-fixes": "^0.0.2",
|
||||
"view-ui-plus": "^1.3.10",
|
||||
"vue": "^3.2.13",
|
||||
"qrcodejs2": "^0.0.2",
|
||||
"view-design": "^4.7.0",
|
||||
"vue": "^2.7.14",
|
||||
"vue-axios": "^3.5.2",
|
||||
"vue-i18n": "^9.2.2",
|
||||
"vue-router": "^4.1.6",
|
||||
"vuex": "^4.0.0"
|
||||
"vue-i18n": "^8.28.2",
|
||||
"vue-router": "^3.6.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "~5.0.0",
|
||||
"@vue/cli-plugin-router": "~5.0.0",
|
||||
"@vue/cli-plugin-vuex": "~5.0.0",
|
||||
"@vue/cli-service": "~5.0.0",
|
||||
"eslint": "^8.14.0",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"eslint-plugin-vue": "^8.7.1",
|
||||
"husky": "^7.0.4",
|
||||
"less": "^4.0.0",
|
||||
"less-loader": "^10.2.0",
|
||||
"mockjs": "^1.1.0"
|
||||
"@babel/core": "^7.12.16",
|
||||
"@babel/eslint-parser": "^7.12.16",
|
||||
"@vue/cli-plugin-babel": "~5.0.8",
|
||||
"@vue/cli-plugin-eslint": "~5.0.8",
|
||||
"@vue/cli-plugin-router": "~5.0.8",
|
||||
"@vue/cli-service": "~5.0.8",
|
||||
"compression-webpack-plugin": "^10.0.0",
|
||||
"core-js": "^3.26.1",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-vue": "^8.0.3",
|
||||
"javascript-obfuscator": "^4.0.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": [
|
||||
"> 1%",
|
||||
"last 2 versions",
|
||||
"not dead",
|
||||
"not ie 11"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 12.0.0",
|
||||
"npm": ">= 6.9.0"
|
||||
}
|
||||
"not dead"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -18,21 +18,47 @@
|
||||
<meta http-equiv="Cache-control" content="no-cache" />
|
||||
<meta http-equiv="Cache" content="no-cache" />
|
||||
<link rel="icon" href="/static/favicon.png" />
|
||||
<title>
|
||||
<%= htmlWebpackPlugin.options.title %>
|
||||
</title>
|
||||
<title>flagnote.com</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: #dddddd;
|
||||
height: 100%;
|
||||
background-color: #dddddd
|
||||
}
|
||||
</style>
|
||||
<% for (var i in htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.js) { %>
|
||||
<script type="text/javascript" src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
|
||||
<% } %>
|
||||
<% for (var i in htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.css) { %>
|
||||
<link rel="stylesheet" type="text/css" href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" />
|
||||
<% } %>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.min.js" rel="stylesheet"
|
||||
type="text/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue-router@3.6.5/dist/vue-router.min.js" rel="stylesheet"
|
||||
type="text/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios@0.27.2/dist/axios.min.js" rel="stylesheet"
|
||||
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.min.js" rel="stylesheet"
|
||||
type="text/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js" rel="stylesheet"
|
||||
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"
|
||||
</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>
|
||||
|
||||
<body><noscript><strong>Please enable JavaScript to continue.</strong></noscript>
|
||||
@@ -43,6 +69,8 @@
|
||||
if (!!window.ActiveXObject || "ActiveXObject" in window) {
|
||||
document.querySelector('#noie').style.display = 'block';
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
||||
24
src/App.vue
24
src/App.vue
@@ -1,5 +1,7 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<router-view></router-view>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -52,7 +54,7 @@ body {
|
||||
}
|
||||
|
||||
.noteHeaderShade {
|
||||
background-color: white;
|
||||
background: linear-gradient(to top,rgba(255,255,255,0.7),rgba(255,255,255,1));
|
||||
width:100%;
|
||||
height:40px;
|
||||
border-bottom: dashed #ed4014 1px;
|
||||
@@ -79,23 +81,23 @@ body {
|
||||
|
||||
|
||||
#noteText::selection {
|
||||
background: #dddddd;
|
||||
color: #ed4014;
|
||||
background: #ed4014;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#noteText::-moz-selection {
|
||||
background: #dddddd;
|
||||
color: #ed4014;
|
||||
background: #ed4014;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#noteText br::selection {
|
||||
background: #dddddd;
|
||||
color: #ed4014;
|
||||
background: #ed4014;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#noteText br::-moz-selection {
|
||||
background: #dddddd;
|
||||
color: #ed4014;
|
||||
background: #ed4014;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.noteUrl {
|
||||
@@ -120,10 +122,10 @@ body {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* button span {
|
||||
button span {
|
||||
margin-left: 0px !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;
|
||||
margin-bottom: 6px;
|
||||
} */
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import axios from "axios";
|
||||
import { getStoreKey } from "@/api/lock";
|
||||
import storage from "@/libs/storage";
|
||||
import { md5, wrap} from "@/libs/secret";
|
||||
import { md5, wrap, convertHexStringToUint8Array} from "@/libs/secret";
|
||||
import NoteConstant from "@/libs/constants";
|
||||
import { setStoreText } from "@/libs/noteStorage";
|
||||
import { Buffer } from 'buffer';
|
||||
|
||||
axios.interceptors.response.use(undefined, (err) => {
|
||||
const { config: originalRequest } = err;
|
||||
@@ -19,9 +17,7 @@ axios.interceptors.response.use(undefined, (err) => {
|
||||
}
|
||||
});
|
||||
|
||||
export function saveNote(noteForm,state, secret) {
|
||||
setStoreText(noteForm, state, secret);
|
||||
|
||||
export function saveNote(noteForm, secret) {
|
||||
let storeKey = secret.storeKey;
|
||||
|
||||
let storeInfo = storage.local.getText(storeKey);
|
||||
@@ -52,7 +48,12 @@ export function saveNote(noteForm,state, secret) {
|
||||
});
|
||||
}
|
||||
|
||||
let array = Buffer.from(note.text, 'base64')
|
||||
// let bufferArrary = eval("[" + note.text + "]");
|
||||
// let array = Uint8Array.from(bufferArrary);
|
||||
|
||||
// let encoder = new TextEncoder()
|
||||
// let array = encoder.encode(note.text)
|
||||
let array = convertHexStringToUint8Array(note.text)
|
||||
|
||||
let blob = new Blob([array], { type: "application/octet-stream" });
|
||||
let form = new FormData();
|
||||
@@ -76,7 +77,10 @@ export function saveNote(noteForm,state, secret) {
|
||||
}
|
||||
|
||||
export function deleteNote(key) {
|
||||
let storeKey = getStoreKey(key);
|
||||
let storeInfo = storage.local.getText(storeKey);
|
||||
let note = {
|
||||
cipher: storeInfo.substring(2, 34),
|
||||
key: key,
|
||||
};
|
||||
|
||||
|
||||
BIN
src/assets/logo.png
Normal file
BIN
src/assets/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
@@ -4,7 +4,7 @@ const en = {
|
||||
},
|
||||
content: {
|
||||
blankTip: "I am Blank.",
|
||||
noteTip: "Write here.",
|
||||
noteTip: "Start writing something...",
|
||||
deleteTip: "The note will be deleted automatically. ttl:"
|
||||
},
|
||||
button: {
|
||||
|
||||
@@ -4,7 +4,7 @@ const zh = {
|
||||
},
|
||||
content: {
|
||||
blankTip: "空白的内容。",
|
||||
noteTip: "写在这儿。",
|
||||
noteTip: "开始写下一些东西吧。。。",
|
||||
deleteTip: "笔记将被自动删除。剩余时间:"
|
||||
},
|
||||
button: {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { createI18n } from "vue-i18n";
|
||||
import Vue from "vue";
|
||||
import VueI18n from "vue-i18n";
|
||||
Vue.use(VueI18n);
|
||||
|
||||
import zh from "./config/zh";
|
||||
import en from "./config/en";
|
||||
@@ -8,16 +10,11 @@ const messages = {
|
||||
en,
|
||||
}
|
||||
|
||||
const i18n = createI18n({
|
||||
allowComposition: true,
|
||||
globalInjection: true,
|
||||
legacy: false,
|
||||
const i18n = new VueI18n({
|
||||
messages: messages,
|
||||
locale: getLocale(),
|
||||
messages
|
||||
});
|
||||
|
||||
|
||||
|
||||
function getLocale() {
|
||||
var lang = navigator.language;
|
||||
if (lang) {
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
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
|
||||
@@ -21,6 +25,7 @@ CryptoJS.enc.Uint8Array = {
|
||||
}
|
||||
return u8_array;
|
||||
},
|
||||
|
||||
/**
|
||||
* Uint8Array转WordArray
|
||||
* @param u8arr
|
||||
@@ -36,7 +41,6 @@ CryptoJS.enc.Uint8Array = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @word 要加密的内容
|
||||
* @keyWord String 服务器随机返回的关键字
|
||||
@@ -72,29 +76,31 @@ export function aesEncrypt(word, keyWord) {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.ZeroPadding,
|
||||
});
|
||||
return encrypted.toString();
|
||||
return encrypted.ciphertext.toString();
|
||||
}
|
||||
|
||||
//解密
|
||||
export function aesDecrypt(word, keyWord) {
|
||||
|
||||
let key = CryptoJS.enc.Utf8.parse(keyWord);
|
||||
let decrypt = CryptoJS.AES.decrypt(word, key, {
|
||||
var srcs = CryptoJS.enc.Hex.parse(word);
|
||||
let decrypt = CryptoJS.AES.decrypt({
|
||||
ciphertext: srcs
|
||||
}, key, {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.ZeroPadding,
|
||||
});
|
||||
return decrypt;
|
||||
}
|
||||
|
||||
//base64 encode btoa
|
||||
export function base64Encode(text) {
|
||||
return Buffer.from(text, 'utf-8').toString('base64');
|
||||
}
|
||||
//base64 encode
|
||||
// export function encode(text) {
|
||||
// return Buffer.from(text, 'utf-8').toString('base64');
|
||||
// }
|
||||
|
||||
//base64 decode atob
|
||||
export function base64Decode(text) {
|
||||
return Buffer.from(text, 'base64').toString('utf-8');
|
||||
}
|
||||
//base64 decode
|
||||
// export function decode(text) {
|
||||
// return Buffer.from(text,'base64').toString('utf-8');
|
||||
// }
|
||||
|
||||
export function noteUnzip(wdary) {
|
||||
let data = unzip(wdary);
|
||||
@@ -110,34 +116,76 @@ export function noteZip(text) {
|
||||
}
|
||||
|
||||
export function zip(data) {
|
||||
if (wasmFlate.__wbindgen_wasm_module) {
|
||||
return wasmFlate.gzip_encode_raw(data);
|
||||
}
|
||||
|
||||
return pako.gzip(data);
|
||||
}
|
||||
|
||||
export function unzip(data) {
|
||||
if (wasmFlate.__wbindgen_wasm_module) {
|
||||
return wasmFlate.gzip_decode_raw(data);
|
||||
}
|
||||
|
||||
return pako.ungzip(data);
|
||||
}
|
||||
|
||||
|
||||
export function convertBase64ToHexString(base64) {
|
||||
return CryptoJS.enc.Hex.stringify(CryptoJS.enc.Base64.parse(base64));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
let rr = CryptoJS.enc.Uint8Array.stringify(wordArray);
|
||||
return rr;
|
||||
// console.log(rr)
|
||||
|
||||
|
||||
// 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) {
|
||||
return CryptoJS.enc.Uint8Array.parse(u8Array);
|
||||
|
||||
let rr = CryptoJS.enc.Uint8Array.parse(u8Array);
|
||||
return rr;
|
||||
// console.log(rr)
|
||||
|
||||
// var words = [], i = 0, len = u8Array.length;
|
||||
|
||||
// while (i < len) {
|
||||
// words.push(
|
||||
// (u8Array[i++] << 24) |
|
||||
// (u8Array[i++] << 16) |
|
||||
// (u8Array[i++] << 8) |
|
||||
// (u8Array[i++])
|
||||
// );
|
||||
// }
|
||||
|
||||
// return {
|
||||
// sigBytes: words.length * 4,
|
||||
// words: words
|
||||
// };
|
||||
}
|
||||
|
||||
export function convertHexStringToUint8Array(hexString) {
|
||||
var result = [];
|
||||
for (var i = 0; i < hexString.length; i += 2) {
|
||||
result.push(parseInt(hexString.substr(i, 2), 16));
|
||||
}
|
||||
return Uint8Array.from(result);
|
||||
// Uint8Array.from(hexString.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
|
||||
}
|
||||
|
||||
export function convertUint8ArrayToHexString(byteArray) {
|
||||
return Array.prototype.map.call(byteArray, function(byte) {
|
||||
return ('0' + (byte & 0xFF).toString(16)).slice(-2);
|
||||
}).join('');
|
||||
}
|
||||
47
src/main.js
47
src/main.js
@@ -1,44 +1,25 @@
|
||||
import { createApp } from 'vue'
|
||||
// import ViewUIPlus from 'view-ui-plus'
|
||||
import Vue from 'vue'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import axios from 'axios'
|
||||
import VueAxios from 'vue-axios'
|
||||
import './plugins/iview.js'
|
||||
import i18n from './i18n/'
|
||||
import NoteConstant from "@/libs/constants"
|
||||
|
||||
import {Layout,Header,Row,Col,Modal,Button,ButtonGroup,Card,Content,Input,Form,WordCount,Footer,Badge,Icon,Tag} from 'view-ui-plus';
|
||||
//import 'view-ui-plus/dist/styles/viewuiplus.css';
|
||||
import NoteConstant from "@/libs/constants";
|
||||
|
||||
axios.defaults.baseURL = NoteConstant.servicePath;
|
||||
|
||||
Vue.use(VueAxios, axios)
|
||||
|
||||
const debugFlag = process.env.NODE_ENV !== 'production';
|
||||
Vue.config.debug = debugFlag;
|
||||
Vue.config.devtools = debugFlag;
|
||||
Vue.config.productionTip = debugFlag;
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
app.config.debug = debugFlag;
|
||||
app.config.devtools = debugFlag;
|
||||
app.config.productionTip = debugFlag;
|
||||
|
||||
app.component('Layout', Layout);
|
||||
app.component('Header', Header);
|
||||
app.component('Row', Row);
|
||||
app.component('Col', Col);
|
||||
app.component('Modal', Modal);
|
||||
app.component('Button', Button);
|
||||
app.component('ButtonGroup', ButtonGroup);
|
||||
app.component('Card', Card);
|
||||
app.component('Content', Content);
|
||||
app.component('Input', Input);
|
||||
app.component('Form', Form);
|
||||
app.component('WordCount', WordCount);
|
||||
app.component('Footer', Footer);
|
||||
app.component('Badge', Badge);
|
||||
app.component('Icon', Icon);
|
||||
app.component('Tag', Tag);
|
||||
new Vue({
|
||||
i18n,
|
||||
router,
|
||||
render: h => h(App)
|
||||
}).$mount('#app')
|
||||
|
||||
|
||||
app.use(router)
|
||||
.use(i18n)
|
||||
.use(VueAxios, axios)
|
||||
.mount('#app')
|
||||
|
||||
|
||||
6
src/plugins/iview.js
Normal file
6
src/plugins/iview.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import Vue from 'vue'
|
||||
import ViewUI from 'view-design'
|
||||
|
||||
Vue.use(ViewUI)
|
||||
|
||||
//import 'view-design/dist/styles/iview.css'
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import Vue from "vue";
|
||||
import VueRouter from "vue-router";
|
||||
import EditNote from "@/views/EditNote.vue";
|
||||
import ViewNote from "@/views/ViewNote.vue";
|
||||
import ErrorRoute from "@/views/ErrorRoute.vue";
|
||||
@@ -7,6 +8,8 @@ import { getNoteMeta } from "@/api/note";
|
||||
import { getStoreKey } from "@/api/lock";
|
||||
import storage from "@/libs/storage";
|
||||
|
||||
Vue.use(VueRouter);
|
||||
|
||||
var keyMeta = null;
|
||||
var noteMeta = null;
|
||||
var errorMeta = null;
|
||||
@@ -116,11 +119,9 @@ const routes = [
|
||||
{ path: "/:path(.*)", component: ErrorRoute }
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(process.env.VUE_APP_URL_BASE_PATH),
|
||||
linkExactActiveClass: "active",
|
||||
const router = new VueRouter({
|
||||
routes,
|
||||
mode: "history",
|
||||
routes
|
||||
})
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -38,13 +38,6 @@
|
||||
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 {
|
||||
@@ -75,30 +68,42 @@
|
||||
|
||||
<Layout>
|
||||
|
||||
<div style="position:fixed;z-index:10;width:100%">
|
||||
<Header class="header">
|
||||
<Row>
|
||||
<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 }">
|
||||
|
||||
<Affix :offset-top="0">
|
||||
<div :class="[showHeaderShade ? 'noteHeaderShade' : 'noteHeader']">
|
||||
|
||||
<img style="height:40px;float:left;cursor: pointer;" alt="refresh flagnote" src="/static/logo.png"
|
||||
v-on:click="refreshPage()" />
|
||||
|
||||
<div style="float:left;width:auto;">
|
||||
|
||||
<Button-group size="large">
|
||||
|
||||
|
||||
|
||||
<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;"
|
||||
@click="toTop()" icon="ios-arrow-up" ghost></Button>
|
||||
|
||||
</Button-group>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div style="float:right;width:auto;">
|
||||
|
||||
<Button-group size="large">
|
||||
<Button aria-label="publish" type="error" :loading="model.submitting"
|
||||
style="margin-left:5px; border-radius: 0px;font-size: 21px;" @click="submitNote()"
|
||||
icon="md-cloud-upload"></Button>
|
||||
<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>
|
||||
|
||||
</Button-group>
|
||||
</div>
|
||||
</div>
|
||||
@@ -123,22 +128,13 @@
|
||||
|
||||
|
||||
</div>
|
||||
</Affix>
|
||||
|
||||
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
</Header>
|
||||
</div>
|
||||
|
||||
<Content class="content">
|
||||
<div>
|
||||
<Row>
|
||||
<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 }">
|
||||
<div class="noteHeader" style="height:40px;border-left: 2px solid #ed4014;"></div>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
</Content>
|
||||
|
||||
<Content class="content">
|
||||
<div style="min-height: 650px;">
|
||||
@@ -149,13 +145,11 @@
|
||||
<Form :model="noteForm" :label-width="80">
|
||||
<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: 35, maxRows: 100000 }" :placeholder="$t('content.noteTip')" @input="recordText"
|
||||
:autosize="{ minRows: 30, maxRows: 409600 }" :placeholder="$t('content.noteTip')" @input="recordText"
|
||||
@on-keydown="recordEventKdown" />
|
||||
|
||||
</div>
|
||||
</Form>
|
||||
</Card>
|
||||
<WordCount :value="noteForm.text" :total="100000" style="border-top:1px solid #ed4014;float:left" />
|
||||
</Col>
|
||||
|
||||
</Row>
|
||||
@@ -166,7 +160,7 @@
|
||||
<Footer class="layout-footer-center">2023 © flagnote.com</Footer>
|
||||
</Layout>
|
||||
|
||||
<Modal scrollable 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 }">
|
||||
<p style="text-align: center;font-size:medium ;margin-bottom: 20px;">
|
||||
{{ $t("message.askTodelete") }}
|
||||
</p>
|
||||
@@ -177,7 +171,7 @@
|
||||
</p>
|
||||
</Modal>
|
||||
|
||||
<Modal scrollable v-model="model.showError" width="360" footer-hide class-name="fnmodal" :styles="{ borderRadius: 0 }">
|
||||
<Modal v-model="model.showError" width="360" footer-hide class-name="fnmodal" :styles="{ borderRadius: 0 }">
|
||||
<p style="text-align: center;font-size:medium ;margin-bottom: 20px;">
|
||||
{{ errorInfo }}
|
||||
</p>
|
||||
@@ -203,7 +197,6 @@ import { isWeixin } from "@/libs/utils";
|
||||
import NoteConstant from "@/libs/constants";
|
||||
import html2canvas from "html2canvas";
|
||||
|
||||
|
||||
export default {
|
||||
name: 'EditNote',
|
||||
props: {},
|
||||
@@ -224,7 +217,6 @@ export default {
|
||||
lock: 0,
|
||||
locking: 0,
|
||||
commited: 0,
|
||||
deleted: 0,
|
||||
serverTime: '',
|
||||
initTime: '',
|
||||
},
|
||||
@@ -307,11 +299,24 @@ export default {
|
||||
this.bindCtrlAllEvent();
|
||||
this.bindToTopEvent();
|
||||
|
||||
if(window.wasm_flate_bg_path){
|
||||
window.wasm_bindgen(window.wasm_flate_bg_path);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
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);
|
||||
|
||||
window.addEventListener('beforeunload', e => this.beforeunloadHandler(e))
|
||||
},
|
||||
updated() {
|
||||
@@ -374,27 +379,27 @@ export default {
|
||||
backStoreFunction() {
|
||||
let that = this;
|
||||
return function () {
|
||||
that.backStoreText();
|
||||
that.backStoreText(that);
|
||||
}
|
||||
},
|
||||
backStoreText() {
|
||||
let nowEditCount = this.noteForm.text.length;
|
||||
backStoreText(that) {
|
||||
let nowEditCount = that.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;
|
||||
if (Math.abs(nowEditCount - that.lastStoreCount) > 10) {
|
||||
setStoreText(that.noteForm, that.state, that.secret);
|
||||
that.lastStoreTime = that.lastEditTime;
|
||||
that.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;
|
||||
if (nowEditTime - that.lastEditTime >= 1000 && nowEditTime - that.lastEditTime < 20000) {
|
||||
if (that.lastEditTime != that.lastStoreTime) {
|
||||
setStoreText(that.noteForm, that.state, that.secret);
|
||||
that.lastStoreTime = that.lastEditTime;
|
||||
that.lastStoreCount = nowEditCount;
|
||||
}
|
||||
} else if (nowEditTime - this.lastEditTime >= 20000) {
|
||||
if (this.backStoreTextInterval != null) {
|
||||
let ivl = this.backStoreTextInterval;
|
||||
this.backStoreTextInterval = null;
|
||||
} else if (nowEditTime - that.lastEditTime >= 20000) {
|
||||
if (that.backStoreTextInterval != null) {
|
||||
let ivl = that.backStoreTextInterval;
|
||||
that.backStoreTextInterval = null;
|
||||
window.clearInterval(ivl);
|
||||
}
|
||||
}
|
||||
@@ -446,7 +451,7 @@ export default {
|
||||
}
|
||||
},
|
||||
save() {
|
||||
return saveNote(this.noteForm,this.state,this.secret);
|
||||
return saveNote(this.noteForm, this.secret);
|
||||
},
|
||||
validateForm() {
|
||||
let text = this.noteForm.text;
|
||||
@@ -513,7 +518,6 @@ export default {
|
||||
},
|
||||
dropNote() {
|
||||
this.model.deleting = true;
|
||||
this.state.deleted = 1;
|
||||
storage.local.delete(this.secret.storeKey);
|
||||
storage.session.setText(this.secret.storeKey + "_delete", 1);
|
||||
location.reload();
|
||||
@@ -545,7 +549,7 @@ export default {
|
||||
dataURLToBlob(dataurl) {
|
||||
let arr = dataurl.split(',');
|
||||
let mime = arr[0].match(/:(.*?);/)[1];
|
||||
let bstr = window.atob(arr[1]);
|
||||
let bstr = atob(arr[1]);
|
||||
let n = bstr.length;
|
||||
let u8arr = new Uint8Array(n);
|
||||
while (n--) {
|
||||
@@ -598,9 +602,7 @@ export default {
|
||||
});
|
||||
},
|
||||
beforeunloadHandler() {
|
||||
if (this.state.deleted == 0) {
|
||||
setStoreText(this.noteForm, this.state, this.secret);
|
||||
}
|
||||
this.recordText();
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +135,19 @@ export default {
|
||||
|
||||
//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 {
|
||||
background: #dddddd;
|
||||
color: #ed4014;
|
||||
background-color: #ed4014;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
#copyBtn {
|
||||
@@ -151,26 +151,40 @@
|
||||
|
||||
|
||||
|
||||
/* button span {
|
||||
margin-left: 0px !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;
|
||||
margin-bottom: 6px;
|
||||
/* #noteMenu button span{
|
||||
font-size: 20px;
|
||||
line-height: 20px;
|
||||
margin-left: 7px !important;
|
||||
margin-right: 5px !important;
|
||||
} */
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<div class="layout">
|
||||
<Layout>
|
||||
<div style="position:fixed;z-index:10;width:100%">
|
||||
|
||||
<Header class="header">
|
||||
<Row>
|
||||
<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 }">
|
||||
|
||||
<Affix :offset-top="0">
|
||||
<div :class="[showHeaderShade ? 'noteHeaderShade' : 'noteHeader']">
|
||||
<img style="height:40px;float:left;cursor: pointer;" alt="refresh flagnote" src="/static/logo.png"
|
||||
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;">
|
||||
|
||||
<Button-group size="large">
|
||||
@@ -189,16 +203,8 @@
|
||||
<Button-group size="large">
|
||||
|
||||
<Button aria-label="ttl" type="error"
|
||||
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()">
|
||||
<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>
|
||||
style="margin-left:5px; border-radius: 0px;font-size: 21px; font-family: Arial, sans-serif"
|
||||
@click="showTtlDeleteModel()" icon="md-alarm">{{ state.ttlDesc }}</Button>
|
||||
|
||||
<Button aria-label="share" type="error"
|
||||
style="margin-left:3px; border-radius: 0px;font-size: 21px; font-family: Arial, sans-serif"
|
||||
@@ -235,25 +241,13 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</Affix>
|
||||
|
||||
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
</Header>
|
||||
</div>
|
||||
|
||||
<Content class="content">
|
||||
<div>
|
||||
<Row>
|
||||
<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 }">
|
||||
<div class="noteHeader" style="height:40px;border-left: 2px solid white;"></div>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
</Content>
|
||||
|
||||
<Content class="content">
|
||||
<div style="min-height: 650px;">
|
||||
@@ -263,7 +257,7 @@
|
||||
<Card :padding="0">
|
||||
<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: 35 }" />
|
||||
:autosize="{ minRows: 30, maxRows: 409600 }" :placeholder="$t('content.noteTip')" />
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
@@ -278,9 +272,14 @@
|
||||
|
||||
</Layout>
|
||||
|
||||
<Modal scrollable 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">
|
||||
<p style="text-align: center; z-index: 1000; position: absolute; top: -2px; left: 0px; width: 100%;">
|
||||
<p style="text-align: center;
|
||||
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>
|
||||
</p>
|
||||
<p style="text-align: center;margin-top:20px;line-height:100%">
|
||||
@@ -298,7 +297,7 @@
|
||||
</p>
|
||||
</Modal>
|
||||
|
||||
<Modal scrollable v-model="model.showTtlDelete" width="360" footer-hide class-name="qrmodal" :styles="{ borderRadius: 0 }">
|
||||
<Modal v-model="model.showTtlDelete" width="360" footer-hide class-name="qrmodal" :styles="{ borderRadius: 0 }">
|
||||
<p style="text-align: center;font-size:medium ;margin-top:20px;">
|
||||
{{ $t("content.deleteTip") }}{{ state.ttlDesc }}
|
||||
</p>
|
||||
@@ -310,7 +309,7 @@
|
||||
</p>
|
||||
</Modal>
|
||||
|
||||
<Modal scrollable 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 }">
|
||||
<p style="text-align: center;font-size:medium;margin-bottom: 20px;">
|
||||
{{ $t("message.askTodelete") }}
|
||||
</p>
|
||||
@@ -321,7 +320,7 @@
|
||||
</p>
|
||||
</Modal>
|
||||
|
||||
<Modal scrollable v-model="model.showError" width="360" footer-hide class-name="fnmodal" :styles="{ borderRadius: 0 }">
|
||||
<Modal v-model="model.showError" width="360" footer-hide class-name="fnmodal" :styles="{ borderRadius: 0 }">
|
||||
<p style="text-align: center;font-size:medium ;margin-bottom: 20px;">
|
||||
{{ errorInfo }}
|
||||
</p>
|
||||
@@ -337,17 +336,16 @@
|
||||
|
||||
<script>
|
||||
|
||||
import { md5, unwrap } from "@/libs/secret";
|
||||
import { md5, unwrap, convertUint8ArrayToHexString} from "@/libs/secret";
|
||||
import { getStoreKey } from "@/api/lock";
|
||||
import { deleteNote, getNoteBlob } from "@/api/note";
|
||||
import storage from "@/libs/storage";
|
||||
//import { getEscapeText } from "@/libs/noteStorage";
|
||||
import QRCode from "qrcodejs2-fixes";
|
||||
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',
|
||||
@@ -389,8 +387,6 @@ export default {
|
||||
showMenuState: false,
|
||||
showHeaderShade: false,
|
||||
errorInfo: '',
|
||||
targetTime: null,
|
||||
showSkeleton: true,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -416,7 +412,6 @@ export default {
|
||||
this.state.initTime = new Date().getTime();
|
||||
this.state.initTtl = noteMeta.ttl;
|
||||
this.state.ttl = noteMeta.ttl;
|
||||
this.targetTime = noteMeta.ttl + new Date().getTime();
|
||||
this.state.serverTime = noteMeta.serverTime;
|
||||
|
||||
this.secret.cipher = "00000000000000000000000000000000";//noteMeta.cipher; //读者有没有值可配置
|
||||
@@ -440,6 +435,27 @@ export default {
|
||||
|
||||
},
|
||||
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 => {
|
||||
// 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);
|
||||
|
||||
let qrimg = document.getElementById("qrImg");
|
||||
let qrurl = "https://flagnote.com/" + this.noteForm.key;
|
||||
var opts = {
|
||||
@@ -452,13 +468,6 @@ export default {
|
||||
}
|
||||
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() {
|
||||
},
|
||||
@@ -495,7 +504,9 @@ export default {
|
||||
} else if (mins < 10) {
|
||||
mins = "0" + mins;
|
||||
}
|
||||
|
||||
let seds = parseInt(ittl % 60);
|
||||
|
||||
if (seds < 0) {
|
||||
seds = "00";
|
||||
} else if (seds < 10) {
|
||||
@@ -503,6 +514,7 @@ export default {
|
||||
}
|
||||
that.state.ttlDesc = mins + ":" + seds;
|
||||
that.state.ttl = that.state.initTtl - (new Date().getTime() - that.state.initTime);
|
||||
|
||||
if (that.state.ttl <= 0) {
|
||||
storage.local.delete(that.secret.storeKey);
|
||||
location.reload();
|
||||
@@ -567,19 +579,28 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
res.data.arrayBuffer().then(function (ab) {
|
||||
if (!ab || ab.byteLength == 0) {
|
||||
let blob = new Blob([res.data], {
|
||||
type: res.data.type
|
||||
});
|
||||
|
||||
let reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
if (!e.target.result || e.target.result.byteLength == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
let base64String = Buffer.from(ab).toString('base64')
|
||||
that.noteForm.text = unwrap(base64String, that.secret.secretKey);
|
||||
that.showSkeleton = false;
|
||||
// let decoder = new TextDecoder();
|
||||
// let bytesString = decoder.decode(e.target.result);
|
||||
let bytesString = convertUint8ArrayToHexString(new Uint8Array(e.target.result));
|
||||
that.noteForm.text = unwrap(bytesString, that.secret.secretKey);
|
||||
//that.noteForm.escapeText = getEscapeText(that.noteForm.text);
|
||||
|
||||
// if local is enough, set local
|
||||
if (storage.local.getAvailableSize() > 1 * 1024 * 1024) {
|
||||
storage.local.setText(that.secret.storeKey, that.state.lock + '|' + that.secret.cipher + '|1|' + that.state.serverTime + '|' + base64String);
|
||||
storage.local.setText(that.secret.storeKey, that.state.lock + '|' + that.secret.cipher + '|1|' + that.state.serverTime + '|' + bytesString);
|
||||
}
|
||||
});
|
||||
};
|
||||
reader.readAsArrayBuffer(blob);
|
||||
});
|
||||
|
||||
} else {
|
||||
@@ -590,7 +611,6 @@ export default {
|
||||
}
|
||||
|
||||
this.noteForm.text = unwrap(starray[4], this.secret.secretKey);
|
||||
this.showSkeleton = false;
|
||||
//this.noteForm.escapeText = getEscapeText(this.noteForm.text);
|
||||
|
||||
// local is usable, and set commited flag
|
||||
@@ -646,7 +666,7 @@ export default {
|
||||
dataURLToBlob(dataurl) {
|
||||
let arr = dataurl.split(',');
|
||||
let mime = arr[0].match(/:(.*?);/)[1];
|
||||
let bstr = window.atob(arr[1]);
|
||||
let bstr = atob(arr[1]);
|
||||
let n = bstr.length;
|
||||
let u8arr = new Uint8Array(n);
|
||||
while (n--) {
|
||||
|
||||
@@ -1,47 +1,32 @@
|
||||
const { defineConfig } = require('@vue/cli-service')
|
||||
const { defineConfig } = require("@vue/cli-service");
|
||||
const CompressionPlugin = require("compression-webpack-plugin");
|
||||
const WebpackObfuscator = require('webpack-obfuscator');
|
||||
const path = require('path')
|
||||
|
||||
const { NODE_ENV, VUE_APP_TITLE = '' } = process.env
|
||||
|
||||
const assetsCDN = {
|
||||
// 忽略打包的第三方库
|
||||
externals: {
|
||||
'vue': 'Vue',
|
||||
'vue-router': 'VueRouter',
|
||||
"crypto-js": "CryptoJS",
|
||||
'pako': 'pako',
|
||||
"html2canvas": "html2canvas",
|
||||
// 'view-ui-plus':'ViewUIPlus',
|
||||
},
|
||||
|
||||
// 通过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/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 = {
|
||||
module.exports = defineConfig({
|
||||
|
||||
assetsDir: 'static',
|
||||
productionSourceMap: NODE_ENV !== 'production',
|
||||
productionSourceMap: false,
|
||||
|
||||
configureWebpack: (config) => {
|
||||
config.experiments = { asyncWebAssembly: true, syncWebAssembly: true }
|
||||
|
||||
config.externals = assetsCDN.externals;
|
||||
|
||||
config.externals = {
|
||||
'vue': 'Vue',
|
||||
'vue-router': 'VueRouter',
|
||||
'axios': 'axios',
|
||||
//'vue-axios':'VueAxios',
|
||||
"crypto-js": "CryptoJS",
|
||||
'qrcodejs2': 'QRCode',
|
||||
'pako': 'pako',
|
||||
"view-design": 'iview',
|
||||
"iview": 'ViewUI',
|
||||
"file-saver": 'saveAs',
|
||||
"clipboard": "ClipboardJS",
|
||||
"vue-i18n": "VueI18n",
|
||||
"html2canvas": "html2canvas",
|
||||
"wasm_flate": "wasm_flate"
|
||||
};
|
||||
|
||||
// 为生产环境修改配置
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
@@ -63,7 +48,7 @@ const config = {
|
||||
|
||||
new CompressionPlugin({
|
||||
algorithm: "gzip", // 使用gzip压缩
|
||||
test: /\.js$|\.html$|\.png$|\.jpg$|\.svg$|\.css$/, // 匹配文件名
|
||||
test: /\.js$|\.html$|\.png$|\.jpg$|\.svg$|\.wasm$|\.css$/, // 匹配文件名
|
||||
filename: "[path][base].gz[query]", // 压缩后的文件名(保持原文件名,后缀加.gz)
|
||||
minRatio: 1, // 压缩率小于1才会压缩
|
||||
threshold: 5120, // 对超过10k的数据压缩
|
||||
@@ -72,48 +57,24 @@ const config = {
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
transpileDependencies: false,
|
||||
|
||||
chainWebpack: (setting) => {
|
||||
setting.plugin("html").tap((args) => {
|
||||
args[0].cdn = assetsCDN
|
||||
args[0].title = VUE_APP_TITLE;
|
||||
transpileDependencies: true,
|
||||
chainWebpack: (config) => {
|
||||
config.plugin("html").tap((args) => {
|
||||
args[0].title = "flagnote.com";
|
||||
return args;
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
css: {
|
||||
loaderOptions: {
|
||||
less: {
|
||||
lessOptions: {
|
||||
javascriptEnabled: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
devServer: {
|
||||
proxy: {
|
||||
"/note": {
|
||||
target: "https://flagnote.com/", // 后台接口域名
|
||||
//target: "http://localhost:20000/", // 后台接口域名
|
||||
// target: "http://localhost:10000/", // 后台接口域名
|
||||
secure: false, // 如果是https接口,需要配置这个参数
|
||||
changeOrigin: true, //是否跨域
|
||||
pathRewrite: {
|
||||
// '^/': '/'
|
||||
},
|
||||
}, "^/[abcdefhikmnopqstuvwxyz23456789]{16}\\.txt$": {
|
||||
target: "https://flagnote.com/", // 后台接口域名
|
||||
//target: "http://localhost:20000/", // 后台接口域名
|
||||
secure: false, // 如果是https接口,需要配置这个参数
|
||||
changeOrigin: true, //是否跨域
|
||||
pathRewrite: {
|
||||
'^/': '/note/'
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = defineConfig(config)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user