Commit 41ca4e938d63027931447ebe343f47366194cac2

Authored by panlinlin
1 parent 5b181728

修复打包后静态页面加载异常

src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java
@@ -69,9 +69,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @@ -69,9 +69,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
69 // 可以直接访问的静态数据 69 // 可以直接访问的静态数据
70 web.ignoring() 70 web.ignoring()
71 .antMatchers("/") 71 .antMatchers("/")
72 - .antMatchers("/css/**")  
73 - .antMatchers("/img/**")  
74 - .antMatchers("/fonts/**") 72 + .antMatchers("/static/**")
75 .antMatchers("/index.html") 73 .antMatchers("/index.html")
76 .antMatchers("/doc.html") // "/webjars/**", "/swagger-resources/**", "/v3/api-docs/**" 74 .antMatchers("/doc.html") // "/webjars/**", "/swagger-resources/**", "/v3/api-docs/**"
77 .antMatchers("/webjars/**") 75 .antMatchers("/webjars/**")
@@ -100,6 +98,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @@ -100,6 +98,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
100 @Override 98 @Override
101 protected void configure(HttpSecurity http) throws Exception { 99 protected void configure(HttpSecurity http) throws Exception {
102 http.cors().and().csrf().disable(); 100 http.cors().and().csrf().disable();
  101 + // 设置允许添加静态文件
  102 + http.headers().contentTypeOptions().disable();
103 http.authorizeRequests() 103 http.authorizeRequests()
104 // 放行接口 104 // 放行接口
105 .antMatchers("/api/user/login","/index/hook/**").permitAll() 105 .antMatchers("/api/user/login","/index/hook/**").permitAll()
web_src/build/webpack.dev.conf.js
@@ -64,8 +64,8 @@ const devWebpackConfig = merge(baseWebpackConfig, { @@ -64,8 +64,8 @@ const devWebpackConfig = merge(baseWebpackConfig, {
64 to: config.dev.assetsSubDirectory, 64 to: config.dev.assetsSubDirectory,
65 ignore: ['.*'] 65 ignore: ['.*']
66 }, 66 },
67 - { from: 'node_modules/@easydarwin/easywasmplayer/libDecoder.wasm'},  
68 - { from: 'node_modules/@easydarwin/easywasmplayer/EasyWasmPlayer.js', to: 'js/'} 67 + { from: 'node_modules/@easydarwin/easywasmplayer/libDecoder.wasm', to: 'static/'},
  68 + { from: 'node_modules/@easydarwin/easywasmplayer/EasyWasmPlayer.js', to: 'static/js/'}
69 ]) 69 ])
70 ] 70 ]
71 }) 71 })
web_src/build/webpack.prod.conf.js
@@ -46,7 +46,7 @@ const webpackConfig = merge(baseWebpackConfig, { @@ -46,7 +46,7 @@ const webpackConfig = merge(baseWebpackConfig, {
46 filename: utils.assetsPath('css/[name].[contenthash].css'), 46 filename: utils.assetsPath('css/[name].[contenthash].css'),
47 // Setting the following option to `false` will not extract CSS from codesplit chunks. 47 // Setting the following option to `false` will not extract CSS from codesplit chunks.
48 // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack. 48 // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
49 - // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, 49 + // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
50 // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 50 // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
51 allChunks: true, 51 allChunks: true,
52 }), 52 }),
@@ -115,8 +115,8 @@ const webpackConfig = merge(baseWebpackConfig, { @@ -115,8 +115,8 @@ const webpackConfig = merge(baseWebpackConfig, {
115 to: config.build.assetsSubDirectory, 115 to: config.build.assetsSubDirectory,
116 ignore: ['.*'] 116 ignore: ['.*']
117 }, 117 },
118 - { from: 'node_modules/@easydarwin/easywasmplayer/libDecoder.wasm'},  
119 - { from: 'node_modules/@easydarwin/easywasmplayer/EasyWasmPlayer.js', to: 'js/'} 118 + { from: 'node_modules/@easydarwin/easywasmplayer/libDecoder.wasm', to: 'static/'},
  119 + { from: 'node_modules/@easydarwin/easywasmplayer/EasyWasmPlayer.js', to: 'static/js/'}
120 ]) 120 ])
121 ] 121 ]
122 }) 122 })
web_src/config/index.js
@@ -51,7 +51,7 @@ module.exports = { @@ -51,7 +51,7 @@ module.exports = {
51 51
52 // Paths 52 // Paths
53 assetsRoot: path.resolve(__dirname, '../../src/main/resources/static/'), 53 assetsRoot: path.resolve(__dirname, '../../src/main/resources/static/'),
54 - assetsSubDirectory: '.', 54 + assetsSubDirectory: './static',
55 assetsPublicPath: '/', 55 assetsPublicPath: '/',
56 56
57 /** 57 /**
web_src/index.html
@@ -4,12 +4,12 @@ @@ -4,12 +4,12 @@
4 <meta charset="utf-8"> 4 <meta charset="utf-8">
5 <meta name="viewport" content="width=device-width,initial-scale=1.0"> 5 <meta name="viewport" content="width=device-width,initial-scale=1.0">
6 <title>国标28181</title> 6 <title>国标28181</title>
7 - <link rel="stylesheet" type="text/css" href="/static/css/font-awesome.min.css">  
8 - <link rel="stylesheet" type="text/css" href="/static/css/login.css"> 7 + <link rel="stylesheet" type="text/css" href="./static/css/font-awesome.min.css">
  8 + <link rel="stylesheet" type="text/css" href="./static/css/login.css">
9 </head> 9 </head>
10 <body> 10 <body>
11 - <script type="text/javascript" src="./js/EasyWasmPlayer.js"></script>  
12 - <script type="text/javascript" src="/static/js/ZLMRTCClient.js"></script> 11 + <script type="text/javascript" src="./static/js/EasyWasmPlayer.js"></script>
  12 + <script type="text/javascript" src="./static/js/ZLMRTCClient.js"></script>
13 <script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=rk73w8dv1rkE4UdZsataG68VarhYQzrx&s=1"></script> 13 <script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=rk73w8dv1rkE4UdZsataG68VarhYQzrx&s=1"></script>
14 <div id="app"></div> 14 <div id="app"></div>
15 <!-- built files will be auto injected --> 15 <!-- built files will be auto injected -->
web_src/src/App.vue
@@ -21,6 +21,7 @@ export default { @@ -21,6 +21,7 @@ export default {
21 created() { 21 created() {
22 if(!this.$cookies.get("session")){ 22 if(!this.$cookies.get("session")){
23 //如果没有登录状态则跳转到登录页 23 //如果没有登录状态则跳转到登录页
  24 + console.log("33333333")
24 this.$router.push('/login'); 25 this.$router.push('/login');
25 } 26 }
26 }, 27 },
@@ -42,6 +43,7 @@ export default { @@ -42,6 +43,7 @@ export default {
42 //cookie操作方法在源码里有或者参考网上的即可 43 //cookie操作方法在源码里有或者参考网上的即可
43 if(!this.$cookies.get("session")){ 44 if(!this.$cookies.get("session")){
44 //如果没有登录状态则跳转到登录页 45 //如果没有登录状态则跳转到登录页
  46 + console.log("222222222")
45 this.$router.push('/login'); 47 this.$router.push('/login');
46 } 48 }
47 }, 49 },
web_src/src/main.js
@@ -41,16 +41,17 @@ Vue.prototype.$notify = Notification; @@ -41,16 +41,17 @@ Vue.prototype.$notify = Notification;
41 axios.defaults.baseURL = (process.env.NODE_ENV === 'development') ? process.env.BASE_API : ""; 41 axios.defaults.baseURL = (process.env.NODE_ENV === 'development') ? process.env.BASE_API : "";
42 42
43 // api 返回401自动回登陆页面 43 // api 返回401自动回登陆页面
44 -axios.interceptors.response.use(function (response) {  
45 - // 对响应数据做点什么  
46 - return response;  
47 -}, function (error) {  
48 - // 对响应错误做点什么  
49 - if (error.response.status === 401) {  
50 - router.push('/login');  
51 - }  
52 - return Promise.reject(error);  
53 -}); 44 +// axios.interceptors.response.use(function (response) {
  45 +// // 对响应数据做点什么
  46 +// return response;
  47 +// }, function (error) {
  48 +// // 对响应错误做点什么
  49 +// if (error.response.status === 401) {
  50 +// console.log((1111))
  51 +// router.push('/login');
  52 +// }
  53 +// return Promise.reject(error);
  54 +// });
54 55
55 Vue.prototype.$cookies.config(60*30); 56 Vue.prototype.$cookies.config(60*30);
56 57