From e4a21e1c6c39ac3097cb70df557f3f77e5d528c3 Mon Sep 17 00:00:00 2001
From: Sparkfreeman <2440444538@qq.com>
Date: Thu, 4 Jul 2024 00:12:46 +0800
Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E6=BB=9A=E5=A4=87=E4=BB=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/services/meetingService.js | 12 ++--
src/store/meetingManagement.js | 22 +++++++-
src/views/authentication/Login.vue | 4 +-
src/views/authentication/Register.vue | 61 +++++----------------
src/views/meeting-management/AddMeeting.vue | 10 +++-
5 files changed, 48 insertions(+), 61 deletions(-)
diff --git a/src/services/meetingService.js b/src/services/meetingService.js
index 3b63be3..7d69bfe 100644
--- a/src/services/meetingService.js
+++ b/src/services/meetingService.js
@@ -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 });
}
}
diff --git a/src/store/meetingManagement.js b/src/store/meetingManagement.js
index b6e0ad1..866f7f2 100644
--- a/src/store/meetingManagement.js
+++ b/src/store/meetingManagement.js
@@ -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);
diff --git a/src/views/authentication/Login.vue b/src/views/authentication/Login.vue
index 143a251..caac4f9 100644
--- a/src/views/authentication/Login.vue
+++ b/src/views/authentication/Login.vue
@@ -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('登录失败,请稍后再试');
}
diff --git a/src/views/authentication/Register.vue b/src/views/authentication/Register.vue
index 98f810d..8653431 100644
--- a/src/views/authentication/Register.vue
+++ b/src/views/authentication/Register.vue
@@ -1,17 +1,16 @@
@@ -80,20 +62,13 @@ const getVerificationCode = async () => {
-
-
- 获取验证码
-
-
-
-
-
+
注册
- $router.push('/login')">返回登录
+ router.push('/login')">返回登录
@@ -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;
@@ -158,4 +125,4 @@ h2 {
.el-button--primary:hover {
background-color: #0056b3;
}
-
+
\ No newline at end of file
diff --git a/src/views/meeting-management/AddMeeting.vue b/src/views/meeting-management/AddMeeting.vue
index 51bd0a8..3c2fef0 100644
--- a/src/views/meeting-management/AddMeeting.vue
+++ b/src/views/meeting-management/AddMeeting.vue
@@ -35,15 +35,19 @@ export default {
startTime: '',
endTime: '',
content: '',
- status: 'Active'
+ status: 'Scheduled' // 确保状态为 'Scheduled'
}
};
},
methods: {
...mapActions('meetingManagement', ['createMeeting']),
async submitForm() {
- await this.createMeeting(this.meeting);
- this.$router.push({ name: 'MeetingManagement' });
+ 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' });