cdn 分离

This commit is contained in:
Jesse-Ma
2022-12-02 15:51:49 +08:00
parent b2efddc755
commit 49916b166e
8 changed files with 165 additions and 85 deletions

View File

@@ -12,7 +12,6 @@
"dependencies": { "dependencies": {
"axios": "^0.27.2", "axios": "^0.27.2",
"clipboard": "^2.0.11", "clipboard": "^2.0.11",
"core-js": "^3.26.1",
"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",
@@ -25,6 +24,7 @@
"vue-router": "^3.5.4" "vue-router": "^3.5.4"
}, },
"devDependencies": { "devDependencies": {
"core-js": "^3.26.1",
"@babel/core": "^7.12.16", "@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16", "@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.8", "@vue/cli-plugin-babel": "~5.0.8",

View File

@@ -1,37 +1,36 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang=""> <html lang="">
<head>
<meta charset="utf-8" />
<meta name="renderer" content="webkit" /> <head>
<meta name="force-rendering" content="webkit"/> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta
name="viewport"
content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=2.0, user-scalable=yes"
/>
<meta name="keywords" content="flagnote" /> <meta name="renderer" content="webkit" />
<meta name="description" content="flag note" /> <meta name="force-rendering" content="webkit" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport"
content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=2.0, user-scalable=yes" />
<meta name="theme-color" content="#ed4014" /> <meta name="keywords" content="flagnote" />
<meta name="format-detection" content="telephone=no,email=no,adress=no" /> <meta name="description" content="flag note" />
<meta name="google" content="notranslate"> <meta name="theme-color" content="#ed4014" />
<meta name="format-detection" content="telephone=no,email=no,adress=no" />
<meta http-equiv="Expires" content="0" /> <meta name="google" content="notranslate">
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-control" content="no-cache" />
<meta http-equiv="Cache" content="no-cache" />
<link rel="icon" href="/static/favicon.ico" /> <meta http-equiv="Expires" content="0" />
<title>flagnote.com</title> <meta http-equiv="Pragma" content="no-cache" />
<style> <meta http-equiv="Cache-control" content="no-cache" />
body { <meta http-equiv="Cache" content="no-cache" />
background-color: #dddddd;
} <link rel="icon" href="/static/favicon.ico" />
</style> <title>flagnote.com</title>
<!-- <style>
body {
background-color: #dddddd;
}
</style>
<!--
<script src="https://www.recaptcha.net/recaptcha/api.js?render=6Le0CJwfAAAAAGk0J6aDngi7Dya-b0qyFRdIf6Wu"></script> <script src="https://www.recaptcha.net/recaptcha/api.js?render=6Le0CJwfAAAAAGk0J6aDngi7Dya-b0qyFRdIf6Wu"></script>
<script type="text/javascript"> <script type="text/javascript">
@@ -56,51 +55,75 @@
</script> </script>
--> -->
<script type="text/javascript"> <script type="text/javascript">
(function () { (function () {
var ua = navigator.userAgent.toLocaleLowerCase(); var ua = navigator.userAgent.toLocaleLowerCase();
var browserType = "", var browserType = "",
browserVersion = ""; browserVersion = "";
if (ua.match(/msie/) != null || ua.match(/trident/) != null) { if (ua.match(/msie/) != null || ua.match(/trident/) != null) {
browserType = "IE"; browserType = "IE";
alert("IE is not supported."); alert("IE is not supported.");
window.location = "/IeIsNotSupported.html"; window.location = "/IeIsNotSupported.html";
} }
var lang = navigator.language; var lang = navigator.language;
if (lang) { if (lang) {
if (localStorage) { if (localStorage) {
if (!localStorage.getItem("locale")) { if (!localStorage.getItem("locale")) {
localStorage.setItem("locale", lang); localStorage.setItem("locale", lang);
}
} }
} }
})();
</script>
<!-- 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()); })();
</script>
gtag("config", "G-FPS9PD2DFF"); <!-- Global site tag (gtag.js) - Google Analytics -->
</script> <script async src="https://www.googletagmanager.com/gtag/js?id=G-FPS9PD2DFF"></script>
</head> <script>
<body> window.dataLayer = window.dataLayer || [];
<noscript> function gtag() {
<strong dataLayer.push(arguments);
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work }
gtag("js", new Date());
gtag("config", "G-FPS9PD2DFF");
</script>
<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.5.4/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/pako@2.1.0/dist/pako.min.js" rel="stylesheet"
type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/qrcode@1.5.1/build/qrcode.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/crypto-js@4.1.1/crypto-js.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/clipboard@2.0.11/dist/clipboard.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/vue-axios@3.5.2/dist/vue-axios.esm.min.js" rel="stylesheet" type="text/javascript"></script>
-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/view-design@4.7.0/dist/styles/iview.css">
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
properly without JavaScript enabled. Please enable it to properly without JavaScript enabled. Please enable it to
continue.</strong> continue.</strong>
</noscript> </noscript>
<div id="app"></div> <div id="app"></div>
<!-- built files will be auto injected --> <!-- built files will be auto injected -->
</body> </body>
</html>
</html>

View File

@@ -3,4 +3,4 @@ import ViewUI from 'view-design'
Vue.use(ViewUI) Vue.use(ViewUI)
import 'view-design/dist/styles/iview.css' //import 'view-design/dist/styles/iview.css'

View File

@@ -2,6 +2,7 @@ import Vue from "vue";
import VueRouter 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 ErrorView from "@/views/ErrorView.vue";
import InvalidateNote from "@/views/InvalidateNote.vue"; import InvalidateNote from "@/views/InvalidateNote.vue";
import { getKeyMeta, getNoteMeta } from "@/api/note"; import { getKeyMeta, getNoteMeta } from "@/api/note";
import { getStoreKey } from "@/api/lock"; import { getStoreKey } from "@/api/lock";
@@ -27,6 +28,7 @@ function getErrorMetaParam() {
function getNoteView() { function getNoteView() {
let path = location.pathname; let path = location.pathname;
let key = path.substring(1, path.length); let key = path.substring(1, path.length);
if (keyMeta && keyMeta.key) { if (keyMeta && keyMeta.key) {
@@ -113,12 +115,12 @@ const routes = [
redirect: getHomeRedirect(), redirect: getHomeRedirect(),
}, },
{ {
path: "/:name([a-z0-9]{16})", path: "/:name([a-z0-9]{1,20})",
name: "note", name: "note",
component: getNoteView(), component: getNoteView(),
meta: { keyMeta: getKeyMetaParam(), noteMeta: getNoteMetaParam(), errorMeta: getErrorMetaParam() }, meta: { keyMeta: getKeyMetaParam(), noteMeta: getNoteMetaParam(), errorMeta: getErrorMetaParam() },
//alias:'/xxxx'
}, },
{ path: "/:path(.*)", component: ErrorView }
]; ];
const router = new VueRouter({ const router = new VueRouter({

21
src/views/ErrorNote.vue Normal file
View File

@@ -0,0 +1,21 @@
<template>
<div>
error
</div>
</template>
<script>
export default {
name: 'ErrorView',
components: {
},
data() {
return {
}
},
created() {
alert("error")
}
}
</script>

17
src/views/ErrorView.vue Normal file
View File

@@ -0,0 +1,17 @@
<template>
<div class="home">
error
</div>
</template>
<script>
export default {
name: 'ErrorView',
components: {},
data() {
return {}
},
created() {
}
}
</script>

View File

@@ -80,7 +80,7 @@
#copyBtn { #copyBtn {
color: #ed4014; color: #ed4014;
font-size:large; font-size: large;
} }
.ivu-btn-text:focus { .ivu-btn-text:focus {
@@ -251,7 +251,8 @@
</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">
<p style="text-align: center; <p style="text-align: center;
z-index: 1000; z-index: 1000;
position: absolute; position: absolute;
@@ -261,7 +262,9 @@
<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%">
<span style="margin-right:3px;" id="copyBtn"><Icon type="md-copy" /></span><span id="qrUrl">{{ noteForm.noteUrl }}</span> <span style="margin-right:3px;" id="copyBtn">
<Icon type="md-copy" />
</span><span id="qrUrl">{{ noteForm.noteUrl }}</span>
</p> </p>
<p style="text-align: center;margin-top:5px;"> <p style="text-align: center;margin-top:5px;">
@@ -269,7 +272,7 @@
</p> </p>
<p style="text-align: center;margin-top:10px;"> <p style="text-align: center;margin-top:10px;">
<Button type="error" style="border-radius: 0px;font-size:19px;" <Button type="error" style="border-radius: 0px;font-size:19px;"
@click="closeShareModel()">{{$t("button.close")}}</Button> @click="closeShareModel()">{{ $t("button.close") }}</Button>
</p> </p>
</Modal> </Modal>
@@ -487,7 +490,9 @@ export default {
storage.session.setText(this.secret.storeKey + "_share", '1'); storage.session.setText(this.secret.storeKey + "_share", '1');
}, },
closeShareModel() { closeShareModel() {
this.model.showShare = false; if (this.model.showShare) {
this.model.showShare = false;
}
storage.session.setText(this.secret.storeKey + "_share", '0'); storage.session.setText(this.secret.storeKey + "_share", '0');
}, },
showDeleteModel() { showDeleteModel() {

View File

@@ -8,26 +8,38 @@ module.exports = defineConfig({
productionSourceMap: false, productionSourceMap: false,
configureWebpack: (config) => { configureWebpack: (config) => {
config.externals = {
'vue': 'Vue',
'vue-router': 'VueRouter',
'axios': 'axios',
//'vue-axios':'VueAxios',
"crypto-js": "CryptoJS",
'qrcode': 'QRCode',
'pako': 'pako',
"view-design": 'iview',
"iview": 'ViewUI',
"file-saver": 'saveAs',
"clipboard": "ClipboardJS",
"vue-i18n": "VueI18n",
};
// 为生产环境修改配置 // 为生产环境修改配置
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
config.plugins.push( config.plugins.push(
new WebpackObfuscator({ new WebpackObfuscator({
compact: true,//压缩代码 compact: true,//压缩代码
controlFlowFlattening: true,//是否启用控制流扁平化(降低1.5倍的运行速度) controlFlowFlattening: false,//是否启用控制流扁平化(降低1.5倍的运行速度)
controlFlowFlatteningThreshold: 1,//应用概率;在较大的代码库中,建议降低此值,因为大量的控制流转换可能会增加代码的大小并降低代码的速度。
deadCodeInjection: true,//随机的死代码块(增加了混淆代码的大小) deadCodeInjection: true,//随机的死代码块(增加了混淆代码的大小)
deadCodeInjectionThreshold: 1,//死代码块的影响概率
debugProtection: true,//此选项几乎不可能使用开发者工具的控制台选项卡 debugProtection: true,//此选项几乎不可能使用开发者工具的控制台选项卡
disableConsoleOutput: true,//通过用空函数替换它们来禁用console.logconsole.infoconsole.error和console.warn。这使得调试器的使用更加困难。 disableConsoleOutput: true,//通过用空函数替换它们来禁用console.logconsole.infoconsole.error和console.warn。这使得调试器的使用更加困难。
identifierNamesGenerator: 'hexadecimal',//标识符的混淆方式 hexadecimal(十六进制) mangled(短标识符) identifierNamesGenerator: 'mangled',//标识符的混淆方式 hexadecimal(十六进制) mangled(短标识符)
log: false, log: false,
renameGlobals: false,//是否启用全局变量和函数名称的混淆 renameGlobals: true,//是否启用全局变量和函数名称的混淆
rotateStringArray: true,//通过固定和随机(在代码混淆时生成)的位置移动数组。这使得将删除的字符串的顺序与其原始位置相匹配变得更加困难。如果原始源代码不小,建议使用此选项,因为辅助函数可以引起注意。 rotateStringArray: true,//通过固定和随机(在代码混淆时生成)的位置移动数组。这使得将删除的字符串的顺序与其原始位置相匹配变得更加困难。如果原始源代码不小,建议使用此选项,因为辅助函数可以引起注意。
selfDefending: true,//混淆后的代码,不能使用代码美化,同时需要配置 cpmpat:true; selfDefending: true,//混淆后的代码,不能使用代码美化,同时需要配置 cpmpat:true;
stringArray: true,//删除字符串文字并将它们放在一个特殊的数组中 // transformObjectKeys: true,
stringArrayThreshold: 1, unicodeEscapeSequence: true//允许启用/禁用字符串转换为unicode转义序列。Unicode转义序列大大增加了代码大小并且可以轻松地将字符串恢复为原始视图。建议仅对小型源代码启用此选项。
transformObjectKeys: true,
unicodeEscapeSequence: false//允许启用/禁用字符串转换为unicode转义序列。Unicode转义序列大大增加了代码大小并且可以轻松地将字符串恢复为原始视图。建议仅对小型源代码启用此选项。
}, ['static/js/chunk-vendors.*.js']), }, ['static/js/chunk-vendors.*.js']),
new CompressionPlugin({ new CompressionPlugin({