前端的/users/code改成post方法,传递json改成正确格式

pull/2/head
2991692032 4 months ago
parent 126c1e9151
commit 4908ad6408

@ -186,10 +186,8 @@ const password = computed(()=>register_password.value ?? login_password.value)
const vericode = computed(()=>register_vericode.value ?? login_vericode.value) const vericode = computed(()=>register_vericode.value ?? login_vericode.value)
// //
async function emailcode(){ async function emailcode(){
const res = await request.get('/users/code', { const res = await request.post('/users/code', {
data:{
email: email.value email: email.value
}
}) })
console.log("success") console.log("success")
@ -198,10 +196,8 @@ async function emailcode(){
// //
async function testcode() { async function testcode() {
const res = await request.post('/users/login/code', { const res = await request.post('/users/login/code', {
data: {
email: email.value, email: email.value,
code: vericode.value code: vericode.value
}
}) })
return res.data; return res.data;
@ -209,7 +205,6 @@ async function testcode() {
async function register(){ async function register(){
const res = await request.post('/users/register', { const res = await request.post('/users/register', {
data:{
email: email.value, email: email.value,
password: password.value, password: password.value,
username:null, username:null,
@ -218,17 +213,14 @@ async function register(){
department:null, department:null,
major:null, major:null,
grade:null, grade:null,
}
}) })
return res.data; return res.data;
} }
async function login(){ async function login(){
const res = await request.post('/users/login', { const res = await request.post('/users/login', {
data:{
email: email.value, email: email.value,
password: password.value password: password.value
}
}) })
return res.data; return res.data;
} }

@ -3,6 +3,7 @@ package com.unilife.config;
import com.unilife.interceptor.JwtInterceptor; import com.unilife.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@ -26,4 +27,14 @@ public class WebMvcConfig implements WebMvcConfigurer {
); );
} }
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns("*") // 允许所有来源,生产环境建议限制为特定域名
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("*")
.allowCredentials(true)
.maxAge(3600);
}
} }

@ -1,5 +1,5 @@
server: server:
port: 8084 port: 8080
spring: spring:
datasource: datasource:
url: jdbc:mysql://localhost:3306/UniLife?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC&characterEncoding=UTF-8 url: jdbc:mysql://localhost:3306/UniLife?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC&characterEncoding=UTF-8

Loading…
Cancel
Save