回滚备份

This commit is contained in:
Sparkfreeman 2024-07-04 00:12:46 +08:00
parent 4b0c7ec534
commit e4a21e1c6c
5 changed files with 48 additions and 61 deletions

View File

@ -1,29 +1,29 @@
import axios from 'axios';
const API_URL = 'http://localhost:8080/meetings';
//const API_URL = 'http://localhost:8080/meetings';
class MeetingService {
getAllMeetings() {
return axios.get(`${API_URL}/listAll`);
return axios.get(`/api/meetings/listAll`);
}
getMeetingById(id) {
// 使用 POST 方法并传递请求体
return axios.post(`${API_URL}/getMeetingById`, { id });
return axios.post(`/api/meetings/getMeetingById`, { id });
}
createMeeting(meeting) {
return axios.post(`${API_URL}/addMeeting`, meeting);
return axios.post(`/api/meetings/addMeeting`, meeting);
}
updateMeeting(id, meeting) {
// 使用 POST 方法而不是 PUT 方法
return axios.post(`${API_URL}/updateMeeting`, meeting);
return axios.post(`/api/meetings/updateMeeting`, meeting);
}
deleteMeeting(id) {
// 使用 POST 方法并传递请求体
return axios.post(`${API_URL}/deleteMeeting`, { id });
return axios.post(`/api/meetings/deleteMeeting`, { id });
}
}

View File

@ -33,15 +33,31 @@ const actions = {
},
async createMeeting({ dispatch }, meeting) {
try {
await MeetingService.createMeeting(meeting);
const formattedMeeting = {
name: meeting.name,
organizer: meeting.organizer,
startTime: meeting.startTime,
endTime: meeting.endTime,
content: meeting.content,
status: 'Scheduled' // 确保状态为 'Scheduled'
};
await MeetingService.createMeeting(formattedMeeting);
dispatch('fetchMeetings');
} catch (error) {
console.error('Failed to create meeting:', error);
}
},
async updateMeeting({ dispatch }, meeting) {
async editMeeting({ dispatch }, meeting) {
try {
await MeetingService.updateMeeting(meeting.id, meeting);
const formattedMeeting = {
name: meeting.name,
organizer: meeting.organizer,
startTime: meeting.startTime,
endTime: meeting.endTime,
content: meeting.content,
status: 'Scheduled' // 确保状态为 'Scheduled'
};
await MeetingService.updateMeeting(meeting.id, formattedMeeting);
dispatch('fetchMeetings');
} catch (error) {
console.error('Failed to update meeting:', error);

View File

@ -16,14 +16,14 @@ const handleLogin = async () => {
console.log('Logging in with', { username: username.value, password: password.value, rememberMe: rememberMe.value });
try {
const response = await store.dispatch('authentication/login', {
const response = await axios.post('/api/users/login', {
username: username.value,
password: password.value,
});
if (response.status === 200) {
ElMessage.success('登录成功');
router.push('/profile');
await router.push('/profile');
} else {
ElMessage.error('登录失败,请稍后再试');
}

View File

@ -9,9 +9,8 @@ const username = ref('');
const phoneNumber = ref('');
const password = ref('');
const verificationCode = ref('');
const correctCode = ref('');
const correctCode = '1234'; //
const router = useRouter();
const verificationCodeImage = ref('');
const handleRegister = async () => {
console.log('Registering with', {
@ -20,43 +19,26 @@ const handleRegister = async () => {
password: password.value,
verificationCode: verificationCode.value
});
if (verificationCode.value!==correctCode.value){
if (verificationCode.value !== correctCode) {
await ElMessageBox.alert("验证码错误");
return
return;
}
try {
const response = await axios.post('/api/register', {
const response = await axios.post('/api/users/register', { //
username: username.value,
phoneNumber: phoneNumber.value,
password: password.value,
verificationCode: verificationCode.value,
});
if (response.status === 200) {
ElMessage.success(response.data.message);
router.push('/login');
ElMessage.success('注册成功');
await router.push('/login');
} else {
await ElMessageBox.alert(response.data.message);
}
} catch (error) {
await ElMessageBox.alert(error.response.data.message || '注册失败,请稍后再试');
}
};
const getVerificationCode = async () => {
try {
const response = await axios.get('/api/getVerificationCode');
if (response.status === 200) {
verificationCodeImage.value = '/api/'+response.data.path; //
correctCode.value = response.data.code;
ElMessage.success('验证码已获取');
} else {
ElMessage.error('获取验证码失败,请稍后再试');
}
} catch (error) {
ElMessage.error('获取验证码失败,请稍后再试');
await ElMessageBox.alert(error.response?.data?.message || '注册失败,请稍后再试');
}
};
</script>
@ -80,20 +62,13 @@ const getVerificationCode = async () => {
</ElFormItem>
<ElFormItem>
<label for="verificationCode">验证码</label>
<ElInput v-model="verificationCode" type="text" id="verificationCode" placeholder="请输入验证码" required>
<template #append>
<ElButton type="primary" @click="getVerificationCode" class="verification-button">获取验证码</ElButton>
</template>
</ElInput>
</ElFormItem>
<ElFormItem v-if="verificationCodeImage">
<img :src="verificationCodeImage" alt="验证码" />
<ElInput v-model="verificationCode" type="text" id="verificationCode" placeholder="请输入验证码" required/>
</ElFormItem>
<ElFormItem>
<ElButton type="primary" native-type="submit" class="register-button">注册</ElButton>
</ElFormItem>
<ElFormItem>
<ElButton type="text" @click="() => $router.push('/login')">返回登录</ElButton>
<ElButton type="text" @click="() => router.push('/login')">返回登录</ElButton>
</ElFormItem>
</ElForm>
</div>
@ -137,14 +112,6 @@ h2 {
width: 100%;
}
.verification-button {
width: 120px; /* 确保按钮宽度合适 */
display: flex;
justify-content: center;
align-items: center;
padding: 0; /* 去除默认内边距 */
}
.el-button {
width: 100%;
padding: 0.75rem;

View File

@ -35,15 +35,19 @@ export default {
startTime: '',
endTime: '',
content: '',
status: 'Active'
status: 'Scheduled' // 'Scheduled'
}
};
},
methods: {
...mapActions('meetingManagement', ['createMeeting']),
async submitForm() {
try {
await this.createMeeting(this.meeting);
this.$router.push({ name: 'MeetingManagement' });
} catch (error) {
console.error('Failed to create meeting:', error);
}
},
cancel() {
this.$router.push({ name: 'MeetingManagement' });