尝试添加login逻辑
This commit is contained in:
parent
ad1abc8a3d
commit
15dbc6fcd2
@ -1,15 +1,29 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { ElInput, ElButton, ElCheckbox, ElForm, ElFormItem } from 'element-plus';
|
||||
import { ElInput, ElButton, ElCheckbox, ElForm, ElFormItem, ElMessage } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import axios from 'axios';
|
||||
|
||||
const username = ref('');
|
||||
const password = ref('');
|
||||
const rememberMe = ref(false);
|
||||
|
||||
const handleLogin = () => {
|
||||
const handleLogin = async () => {
|
||||
console.log('Logging in with', { username: username.value, password: password.value, rememberMe: rememberMe.value });
|
||||
// 处理登录逻辑
|
||||
try {
|
||||
const response = await axios.post('/api/login', {
|
||||
username: username.value,
|
||||
password: password.value,
|
||||
});
|
||||
if (response.data === 'Login successful!') {
|
||||
ElMessage.success('登录成功');
|
||||
// 处理登录成功逻辑,例如跳转到主页
|
||||
} else {
|
||||
ElMessage.error('用户名或密码错误');
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error('登录失败,请稍后再试');
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user