first class

master
barney 2 years ago
parent 08084bac0c
commit 2e0afa1d33
  1. 1
      $null
  2. 46
      backend/src/main/java/com/kob/backend/config/CorsConfig.java
  3. 5
      backend/src/main/java/com/kob/backend/controller/pk/BotInfoController.java
  4. 51
      web/src/App.vue
  5. BIN
      web/src/assets/background.png
  6. BIN
      web/src/assets/logo.png
  7. 58
      web/src/components/HelloWorld.vue
  8. 21
      web/src/router/index.js
  9. 5
      web/src/views/AboutView.vue
  10. 18
      web/src/views/HomeView.vue

@ -0,0 +1 @@
Active code page: 65001

@ -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() {
}
}

@ -44,9 +44,8 @@ public class BotInfoController {
@RequestMapping("getInfo2/") @RequestMapping("getInfo2/")
public Map<String,String> getInfo2(){ public Map<String,String> getInfo2(){
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("name","John"); map.put("name","acwing");
map.put("age","14"); map.put("rating","100");
map.put("sex","male");
return map; return map;
} }

@ -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({
url: "http://localhost:3000/pk/getInfo2/",
type: 'get',
success: resp => {
console.log(resp);
bot_name.value = resp.name;
bot_rating.value = resp.rating;
} }
});
nav { return {
padding: 30px; bot_name,
bot_rating
} }
nav a {
font-weight: bold;
color: #2c3e50;
} }
}
</script>
nav a.router-link-exact-active { <style>
color: #42b983; body{
background-image: url("@/assets/background.png");
background-size: cover;
} }
</style> </style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

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,24 +1,9 @@
import { createRouter, createWebHashHistory } from 'vue-router' import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
const routes = [ const routes = []
{
path: '/',
name: 'home',
component: HomeView
},
{
path: '/about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
}
]
const router = createRouter({ const router = createRouter({
history: createWebHashHistory(), history: createWebHistory(),
routes routes
}) })

@ -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…
Cancel
Save