parent
08084bac0c
commit
2e0afa1d33
10 changed files with 84 additions and 125 deletions
@ -0,0 +1,46 @@ |
|||||||
|
package com.kob.backend.config; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author zhangfp |
||||||
|
*/ |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
|
||||||
|
import javax.servlet.*; |
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
import java.io.IOException; |
||||||
|
|
||||||
|
@Configuration |
||||||
|
public class CorsConfig implements Filter { |
||||||
|
@Override |
||||||
|
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { |
||||||
|
HttpServletResponse response = (HttpServletResponse) res; |
||||||
|
HttpServletRequest request = (HttpServletRequest) req; |
||||||
|
|
||||||
|
String origin = request.getHeader("Origin"); |
||||||
|
if(origin!=null) { |
||||||
|
response.setHeader("Access-Control-Allow-Origin", origin); |
||||||
|
} |
||||||
|
|
||||||
|
String headers = request.getHeader("Access-Control-Request-Headers"); |
||||||
|
if(headers!=null) { |
||||||
|
response.setHeader("Access-Control-Allow-Headers", headers); |
||||||
|
response.setHeader("Access-Control-Expose-Headers", headers); |
||||||
|
} |
||||||
|
|
||||||
|
response.setHeader("Access-Control-Allow-Methods", "*"); |
||||||
|
response.setHeader("Access-Control-Max-Age", "3600"); |
||||||
|
response.setHeader("Access-Control-Allow-Credentials", "true"); |
||||||
|
|
||||||
|
chain.doFilter(request, response); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void init(FilterConfig filterConfig) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void destroy() { |
||||||
|
} |
||||||
|
} |
@ -1,30 +1,39 @@ |
|||||||
<template> |
<template> |
||||||
<nav> |
<div> |
||||||
<router-link to="/">Home</router-link> | |
<h1>bot昵称: {{bot_name}} </h1> |
||||||
<router-link to="/about">About</router-link> |
<h1>bot战力: {{bot_rating}} </h1> |
||||||
</nav> |
</div> |
||||||
<router-view/> |
<router-view></router-view> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<style> |
<script> |
||||||
#app { |
import $ from 'jquery'; |
||||||
font-family: Avenir, Helvetica, Arial, sans-serif; |
import { ref } from 'vue'; |
||||||
-webkit-font-smoothing: antialiased; |
export default{ |
||||||
-moz-osx-font-smoothing: grayscale; |
name:"app", |
||||||
text-align: center; |
setup:() => { |
||||||
color: #2c3e50; |
let bot_name = ref(""); |
||||||
} |
let bot_rating = ref(""); |
||||||
|
$.ajax({ |
||||||
nav { |
url: "http://localhost:3000/pk/getInfo2/", |
||||||
padding: 30px; |
type: 'get', |
||||||
|
success: resp => { |
||||||
|
console.log(resp); |
||||||
|
bot_name.value = resp.name; |
||||||
|
bot_rating.value = resp.rating; |
||||||
|
} |
||||||
|
}); |
||||||
|
return { |
||||||
|
bot_name, |
||||||
|
bot_rating |
||||||
|
} |
||||||
|
} |
||||||
} |
} |
||||||
|
</script> |
||||||
|
|
||||||
nav a { |
<style> |
||||||
font-weight: bold; |
body{ |
||||||
color: #2c3e50; |
background-image: url("@/assets/background.png"); |
||||||
} |
background-size: cover; |
||||||
|
|
||||||
nav a.router-link-exact-active { |
|
||||||
color: #42b983; |
|
||||||
} |
} |
||||||
</style> |
</style> |
||||||
|
After Width: | Height: | Size: 102 KiB |
Before Width: | Height: | Size: 6.7 KiB |
@ -1,58 +0,0 @@ |
|||||||
<template> |
|
||||||
<div class="hello"> |
|
||||||
<h1>{{ msg }}</h1> |
|
||||||
<p> |
|
||||||
For a guide and recipes on how to configure / customize this project,<br> |
|
||||||
check out the |
|
||||||
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>. |
|
||||||
</p> |
|
||||||
<h3>Installed CLI Plugins</h3> |
|
||||||
<ul> |
|
||||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li> |
|
||||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li> |
|
||||||
</ul> |
|
||||||
<h3>Essential Links</h3> |
|
||||||
<ul> |
|
||||||
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li> |
|
||||||
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li> |
|
||||||
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li> |
|
||||||
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li> |
|
||||||
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li> |
|
||||||
</ul> |
|
||||||
<h3>Ecosystem</h3> |
|
||||||
<ul> |
|
||||||
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li> |
|
||||||
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li> |
|
||||||
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li> |
|
||||||
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li> |
|
||||||
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li> |
|
||||||
</ul> |
|
||||||
</div> |
|
||||||
</template> |
|
||||||
|
|
||||||
<script> |
|
||||||
export default { |
|
||||||
name: 'HelloWorld', |
|
||||||
props: { |
|
||||||
msg: String |
|
||||||
} |
|
||||||
} |
|
||||||
</script> |
|
||||||
|
|
||||||
<!-- Add "scoped" attribute to limit CSS to this component only --> |
|
||||||
<style scoped> |
|
||||||
h3 { |
|
||||||
margin: 40px 0 0; |
|
||||||
} |
|
||||||
ul { |
|
||||||
list-style-type: none; |
|
||||||
padding: 0; |
|
||||||
} |
|
||||||
li { |
|
||||||
display: inline-block; |
|
||||||
margin: 0 10px; |
|
||||||
} |
|
||||||
a { |
|
||||||
color: #42b983; |
|
||||||
} |
|
||||||
</style> |
|
@ -1,5 +0,0 @@ |
|||||||
<template> |
|
||||||
<div class="about"> |
|
||||||
<h1>This is an about page</h1> |
|
||||||
</div> |
|
||||||
</template> |
|
@ -1,18 +0,0 @@ |
|||||||
<template> |
|
||||||
<div class="home"> |
|
||||||
<img alt="Vue logo" src="../assets/logo.png"> |
|
||||||
<HelloWorld msg="Welcome to Your Vue.js App"/> |
|
||||||
</div> |
|
||||||
</template> |
|
||||||
|
|
||||||
<script> |
|
||||||
// @ is an alias to /src |
|
||||||
import HelloWorld from '@/components/HelloWorld.vue' |
|
||||||
|
|
||||||
export default { |
|
||||||
name: 'HomeView', |
|
||||||
components: { |
|
||||||
HelloWorld |
|
||||||
} |
|
||||||
} |
|
||||||
</script> |
|
Loading…
Reference in new issue