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 69 // 可以直接访问的静态数据
70 70 web.ignoring()
71 71 .antMatchers("/")
72   - .antMatchers("/css/**")
73   - .antMatchers("/img/**")
74   - .antMatchers("/fonts/**")
  72 + .antMatchers("/static/**")
75 73 .antMatchers("/index.html")
76 74 .antMatchers("/doc.html") // "/webjars/**", "/swagger-resources/**", "/v3/api-docs/**"
77 75 .antMatchers("/webjars/**")
... ... @@ -100,6 +98,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
100 98 @Override
101 99 protected void configure(HttpSecurity http) throws Exception {
102 100 http.cors().and().csrf().disable();
  101 + // 设置允许添加静态文件
  102 + http.headers().contentTypeOptions().disable();
103 103 http.authorizeRequests()
104 104 // 放行接口
105 105 .antMatchers("/api/user/login","/index/hook/**").permitAll()
... ...
web_src/build/webpack.dev.conf.js
... ... @@ -64,8 +64,8 @@ const devWebpackConfig = merge(baseWebpackConfig, {
64 64 to: config.dev.assetsSubDirectory,
65 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 46 filename: utils.assetsPath('css/[name].[contenthash].css'),
47 47 // Setting the following option to `false` will not extract CSS from codesplit chunks.
48 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 50 // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
51 51 allChunks: true,
52 52 }),
... ... @@ -115,8 +115,8 @@ const webpackConfig = merge(baseWebpackConfig, {
115 115 to: config.build.assetsSubDirectory,
116 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 51  
52 52 // Paths
53 53 assetsRoot: path.resolve(__dirname, '../../src/main/resources/static/'),
54   - assetsSubDirectory: '.',
  54 + assetsSubDirectory: './static',
55 55 assetsPublicPath: '/',
56 56  
57 57 /**
... ...
web_src/index.html
... ... @@ -4,12 +4,12 @@
4 4 <meta charset="utf-8">
5 5 <meta name="viewport" content="width=device-width,initial-scale=1.0">
6 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 9 </head>
10 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 13 <script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=rk73w8dv1rkE4UdZsataG68VarhYQzrx&s=1"></script>
14 14 <div id="app"></div>
15 15 <!-- built files will be auto injected -->
... ...
web_src/src/App.vue
... ... @@ -21,6 +21,7 @@ export default {
21 21 created() {
22 22 if(!this.$cookies.get("session")){
23 23 //如果没有登录状态则跳转到登录页
  24 + console.log("33333333")
24 25 this.$router.push('/login');
25 26 }
26 27 },
... ... @@ -42,6 +43,7 @@ export default {
42 43 //cookie操作方法在源码里有或者参考网上的即可
43 44 if(!this.$cookies.get("session")){
44 45 //如果没有登录状态则跳转到登录页
  46 + console.log("222222222")
45 47 this.$router.push('/login');
46 48 }
47 49 },
... ...
web_src/src/main.js
... ... @@ -41,16 +41,17 @@ Vue.prototype.$notify = Notification;
41 41 axios.defaults.baseURL = (process.env.NODE_ENV === 'development') ? process.env.BASE_API : "";
42 42  
43 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 56 Vue.prototype.$cookies.config(60*30);
56 57  
... ...