登录接口联调完成
This commit is contained in:
@@ -50,7 +50,10 @@ export default {
|
|||||||
// 登录接口接入后在这里提交账号和密码
|
// 登录接口接入后在这里提交账号和密码
|
||||||
// 这里模拟登录成功,直接跳转到聊天页面
|
// 这里模拟登录成功,直接跳转到聊天页面
|
||||||
if (this.username && this.password) {
|
if (this.username && this.password) {
|
||||||
login(this.username, this.password)
|
login({
|
||||||
|
username: this.username,
|
||||||
|
password: this.password,
|
||||||
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const token = response.data.token;
|
const token = response.data.token;
|
||||||
this.$store.commit("SET_TOKEN", token);
|
this.$store.commit("SET_TOKEN", token);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ request.interceptors.request.use(
|
|||||||
// 在请求头中添加token
|
// 在请求头中添加token
|
||||||
const token = store.state.token;
|
const token = store.state.token;
|
||||||
if (token) {
|
if (token) {
|
||||||
config.headers['Authorization'] = `Bearer ${token}`;
|
config.headers['Authorization'] = `${token}`;
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
|
|||||||
+9
-1
@@ -1,4 +1,12 @@
|
|||||||
const { defineConfig } = require('@vue/cli-service')
|
const { defineConfig } = require('@vue/cli-service')
|
||||||
module.exports = defineConfig({
|
module.exports = defineConfig({
|
||||||
transpileDependencies: true
|
transpileDependencies: true,
|
||||||
|
devServer: {
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: 'http://localhost:3000',
|
||||||
|
changeOrigin: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user