Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9dce2c828 | ||
|
|
9931de77de |
@@ -50,7 +50,10 @@ export default {
|
||||
// 登录接口接入后在这里提交账号和密码
|
||||
// 这里模拟登录成功,直接跳转到聊天页面
|
||||
if (this.username && this.password) {
|
||||
login(this.username, this.password)
|
||||
login({
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
})
|
||||
.then((response) => {
|
||||
const token = response.data.token;
|
||||
this.$store.commit("SET_TOKEN", token);
|
||||
@@ -59,7 +62,7 @@ export default {
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
this.$message.error("登录失败,请检查账号和密码");
|
||||
this.$message.error("账号或密码错误");
|
||||
});
|
||||
} else {
|
||||
this.$message.error("请输入账号和密码");
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { register } from "@/utils/user";
|
||||
export default {
|
||||
name: "RegisterPage",
|
||||
data() {
|
||||
@@ -60,7 +61,16 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
// 注册接口接入后在这里提交账号和密码。
|
||||
register({
|
||||
username: this.username,
|
||||
password: this.password
|
||||
}).then(() => {
|
||||
this.$message.success('注册成功,请登录')
|
||||
this.$router.push('/login')
|
||||
}).catch((error) => {
|
||||
console.error(error)
|
||||
this.$message.error('注册失败,请重试')
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@ request.interceptors.request.use(
|
||||
// 在请求头中添加token
|
||||
const token = store.state.token;
|
||||
if (token) {
|
||||
config.headers['Authorization'] = `Bearer ${token}`;
|
||||
config.headers['Authorization'] = `${token}`;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
|
||||
@@ -15,4 +15,13 @@ export function getUserInfo() {
|
||||
url: '/user/info',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 注册账号
|
||||
export function register(data) {
|
||||
return request({
|
||||
url: '/register',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
+9
-1
@@ -1,4 +1,12 @@
|
||||
const { defineConfig } = require('@vue/cli-service')
|
||||
module.exports = defineConfig({
|
||||
transpileDependencies: true
|
||||
transpileDependencies: true,
|
||||
devServer: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:3000',
|
||||
changeOrigin: true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user