From 41ca4e938d63027931447ebe343f47366194cac2 Mon Sep 17 00:00:00 2001
From: panlinlin <648540858@qq.com>
Date: 星期一, 19 四月 2021 11:04:11 +0800
Subject: [PATCH] 修复打包后静态页面加载异常
---
web_src/build/webpack.prod.conf.js | 6 +++---
web_src/src/main.js | 21 +++++++++++----------
web_src/config/index.js | 2 +-
src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java | 6 +++---
web_src/src/App.vue | 2 ++
web_src/build/webpack.dev.conf.js | 4 ++--
web_src/index.html | 8 ++++----
7 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java
index 1de14e6..ebeefd4 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java
@@ -69,9 +69,7 @@
// 鍙互鐩存帴璁块棶鐨勯潤鎬佹暟鎹�
web.ignoring()
.antMatchers("/")
- .antMatchers("/css/**")
- .antMatchers("/img/**")
- .antMatchers("/fonts/**")
+ .antMatchers("/static/**")
.antMatchers("/index.html")
.antMatchers("/doc.html") // "/webjars/**", "/swagger-resources/**", "/v3/api-docs/**"
.antMatchers("/webjars/**")
@@ -100,6 +98,8 @@
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable();
+ // 璁剧疆鍏佽娣诲姞闈欐�佹枃浠�
+ http.headers().contentTypeOptions().disable();
http.authorizeRequests()
// 鏀捐鎺ュ彛
.antMatchers("/api/user/login","/index/hook/**").permitAll()
diff --git a/web_src/build/webpack.dev.conf.js b/web_src/build/webpack.dev.conf.js
index e33cb01..58c5457 100755
--- a/web_src/build/webpack.dev.conf.js
+++ b/web_src/build/webpack.dev.conf.js
@@ -64,8 +64,8 @@
to: config.dev.assetsSubDirectory,
ignore: ['.*']
},
- { from: 'node_modules/@easydarwin/easywasmplayer/libDecoder.wasm'},
- { from: 'node_modules/@easydarwin/easywasmplayer/EasyWasmPlayer.js', to: 'js/'}
+ { from: 'node_modules/@easydarwin/easywasmplayer/libDecoder.wasm', to: 'static/'},
+ { from: 'node_modules/@easydarwin/easywasmplayer/EasyWasmPlayer.js', to: 'static/js/'}
])
]
})
diff --git a/web_src/build/webpack.prod.conf.js b/web_src/build/webpack.prod.conf.js
index 13d373d..61e63e9 100644
--- a/web_src/build/webpack.prod.conf.js
+++ b/web_src/build/webpack.prod.conf.js
@@ -46,7 +46,7 @@
filename: utils.assetsPath('css/[name].[contenthash].css'),
// Setting the following option to `false` will not extract CSS from codesplit chunks.
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
- // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
+ // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
allChunks: true,
}),
@@ -115,8 +115,8 @@
to: config.build.assetsSubDirectory,
ignore: ['.*']
},
- { from: 'node_modules/@easydarwin/easywasmplayer/libDecoder.wasm'},
- { from: 'node_modules/@easydarwin/easywasmplayer/EasyWasmPlayer.js', to: 'js/'}
+ { from: 'node_modules/@easydarwin/easywasmplayer/libDecoder.wasm', to: 'static/'},
+ { from: 'node_modules/@easydarwin/easywasmplayer/EasyWasmPlayer.js', to: 'static/js/'}
])
]
})
diff --git a/web_src/config/index.js b/web_src/config/index.js
index e6c0f6c..5ab5eac 100644
--- a/web_src/config/index.js
+++ b/web_src/config/index.js
@@ -51,7 +51,7 @@
// Paths
assetsRoot: path.resolve(__dirname, '../../src/main/resources/static/'),
- assetsSubDirectory: '.',
+ assetsSubDirectory: './static',
assetsPublicPath: '/',
/**
diff --git a/web_src/index.html b/web_src/index.html
index 6c46937..8879175 100644
--- a/web_src/index.html
+++ b/web_src/index.html
@@ -4,12 +4,12 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>鍥芥爣28181</title>
- <link rel="stylesheet" type="text/css" href="/static/css/font-awesome.min.css">
- <link rel="stylesheet" type="text/css" href="/static/css/login.css">
+ <link rel="stylesheet" type="text/css" href="./static/css/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="./static/css/login.css">
</head>
<body>
- <script type="text/javascript" src="./js/EasyWasmPlayer.js"></script>
- <script type="text/javascript" src="/static/js/ZLMRTCClient.js"></script>
+ <script type="text/javascript" src="./static/js/EasyWasmPlayer.js"></script>
+ <script type="text/javascript" src="./static/js/ZLMRTCClient.js"></script>
<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=rk73w8dv1rkE4UdZsataG68VarhYQzrx&s=1"></script>
<div id="app"></div>
<!-- built files will be auto injected -->
diff --git a/web_src/src/App.vue b/web_src/src/App.vue
index e114545..5828acd 100644
--- a/web_src/src/App.vue
+++ b/web_src/src/App.vue
@@ -21,6 +21,7 @@
created() {
if(!this.$cookies.get("session")){
//濡傛灉娌℃湁鐧诲綍鐘舵�佸垯璺宠浆鍒扮櫥褰曢〉
+ console.log("33333333")
this.$router.push('/login');
}
},
@@ -42,6 +43,7 @@
//cookie鎿嶄綔鏂规硶鍦ㄦ簮鐮侀噷鏈夋垨鑰呭弬鑰冪綉涓婄殑鍗冲彲
if(!this.$cookies.get("session")){
//濡傛灉娌℃湁鐧诲綍鐘舵�佸垯璺宠浆鍒扮櫥褰曢〉
+ console.log("222222222")
this.$router.push('/login');
}
},
diff --git a/web_src/src/main.js b/web_src/src/main.js
index 56586f5..20ad485 100644
--- a/web_src/src/main.js
+++ b/web_src/src/main.js
@@ -41,16 +41,17 @@
axios.defaults.baseURL = (process.env.NODE_ENV === 'development') ? process.env.BASE_API : "";
// api 杩斿洖401鑷姩鍥炵櫥闄嗛〉闈�
-axios.interceptors.response.use(function (response) {
- // 瀵瑰搷搴旀暟鎹仛鐐逛粈涔�
- return response;
-}, function (error) {
- // 瀵瑰搷搴旈敊璇仛鐐逛粈涔�
- if (error.response.status === 401) {
- router.push('/login');
- }
- return Promise.reject(error);
-});
+// axios.interceptors.response.use(function (response) {
+// // 瀵瑰搷搴旀暟鎹仛鐐逛粈涔�
+// return response;
+// }, function (error) {
+// // 瀵瑰搷搴旈敊璇仛鐐逛粈涔�
+// if (error.response.status === 401) {
+// console.log((1111))
+// router.push('/login');
+// }
+// return Promise.reject(error);
+// });
Vue.prototype.$cookies.config(60*30);
--
Gitblit v1.8.0