From 394ac34d84e01b9421888793dd099c481571a1ea Mon Sep 17 00:00:00 2001 From: zhangtao <9480807882@qq.com> Date: Mon, 9 Jun 2025 22:47:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E5=86=97?= =?UTF-8?q?=E4=BD=99=E7=9A=84=E6=88=90=E5=8A=9F=E6=B6=88=E6=81=AF=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 统一移除各模块中API调用后的成功消息提示,简化代码结构 保留错误处理逻辑,仅通过控制台输出错误信息 --- frontend/src/views/current/configinfo.vue | 13 +----------- frontend/src/views/current/profile.vue | 9 ++------- frontend/src/views/system/auth/login.vue | 6 ++---- frontend/src/views/system/config/index.vue | 11 +++------- frontend/src/views/system/dept/index.vue | 16 ++++----------- frontend/src/views/system/dict/data.vue | 11 +++------- frontend/src/views/system/dict/index.vue | 11 +++------- frontend/src/views/system/job/index.vue | 19 +++++------------- frontend/src/views/system/log/index.vue | 4 +--- frontend/src/views/system/menu/index.vue | 16 ++++----------- frontend/src/views/system/notice/index.vue | 15 ++++---------- frontend/src/views/system/position/index.vue | 15 ++++---------- .../views/system/role/PermissionDrawer.vue | 3 +-- frontend/src/views/system/role/index.vue | 14 +++---------- frontend/src/views/system/user/index.vue | 20 +++++-------------- 15 files changed, 45 insertions(+), 138 deletions(-) diff --git a/frontend/src/views/current/configinfo.vue b/frontend/src/views/current/configinfo.vue index e25b8d10..50f3d72e 100644 --- a/frontend/src/views/current/configinfo.vue +++ b/frontend/src/views/current/configinfo.vue @@ -193,10 +193,8 @@ const handleSave = async (item: any) => { try { await updateConfig(tempConfigState); - message.success(`${item.config_name} 保存成功`); - isEditing[item.config_key] = false; // 退出编辑模式 } catch (error) { - message.error(`${item.config_name} 保存失败: ${error.message}`); + console.error('保存失败:', error); } finally { isSaving[item.config_key] = false; // 重置保存状态 } @@ -212,15 +210,6 @@ const beforeUpload = (file: File) => { return true; }; -// 编辑操作 -const handleEdit = (configKey: string) => { - isEditing[configKey] = true; -}; - -// 取消操作 -const handleCancel = (configKey: string) => { - isEditing[configKey] = false; -}; // 生命周期钩子 onMounted(() => { diff --git a/frontend/src/views/current/profile.vue b/frontend/src/views/current/profile.vue index cb8de144..dc60e618 100644 --- a/frontend/src/views/current/profile.vue +++ b/frontend/src/views/current/profile.vue @@ -364,8 +364,7 @@ const onInfoFormFinish = async (values: any) => { try { infoSubmitting.value = true; values.avatar = infoFormState.avatar; - const response = await updateCurrentUserInfo(values); - message.success(response.data.msg); + await updateCurrentUserInfo(values); await userStore.getUserInfo; } catch (error) { console.error(error); @@ -395,9 +394,7 @@ const onPasswordFormFinish = async (values: any) => { new_password: values.newPassword }; - const response = await changeCurrentUserPassword(data); - message.success(response.data.msg); - + await changeCurrentUserPassword(data); await logout({ token: storage.get('Access-Token') }); // 重置 store 状态 @@ -439,8 +436,6 @@ const handleUpload = async (options: any) => { infoFormState.avatar = fileUrl; fileList.value = [{ url: fileUrl }]; - message.success(response.data.msg); - onSuccess(response, file); } catch (error) { onError(error); diff --git a/frontend/src/views/system/auth/login.vue b/frontend/src/views/system/auth/login.vue index 0a6e7c09..875bd539 100644 --- a/frontend/src/views/system/auth/login.vue +++ b/frontend/src/views/system/auth/login.vue @@ -232,8 +232,7 @@ const onSubmit = async () => { return; } await forgetPasswordFormRef.value.validate(); - const response = await forgetPassword({ ...forgetPasswordForm }); - message.success(response.data.msg); + await forgetPassword({ ...forgetPasswordForm }); Object.keys(forgetPasswordForm).forEach(key => delete forgetPasswordForm[key]); modalVisible.value = false; } else { @@ -244,8 +243,7 @@ const onSubmit = async () => { return; } await registerFormRef.value.validate(); - const response = await registerUser({ ...registerForm }); - message.success(response.data.msg); + await registerUser({ ...registerForm }); Object.keys(registerForm).forEach(key => delete registerForm[key]); modalVisible.value = false; } diff --git a/frontend/src/views/system/config/index.vue b/frontend/src/views/system/config/index.vue index 86f2d7bf..c1eed926 100644 --- a/frontend/src/views/system/config/index.vue +++ b/frontend/src/views/system/config/index.vue @@ -340,9 +340,7 @@ const modalHandle = (modalType: string, index?: number) => { const deleteRow = async (row: tableType) => { try { tableLoading.value = true; - const response = await deleteConfig({ id: row.id }) - const result = response.data; - message.success(result.msg); + await deleteConfig({ id: row.id }) loadingData(); } catch (error) { console.log(error) @@ -367,11 +365,9 @@ const handleModalSumbit = async () => { delete createBody[key]; } }) - const response = await createConfig(createBody) + await createConfig(createBody) openModal.value = false; Object.keys(createState).forEach(key => delete createState[key]); - const result = response.data; - message.success(result.msg); loadingData(); } catch (error) { console.log(error) @@ -382,9 +378,8 @@ const handleModalSumbit = async () => { } else if (modalTitle.value === 'update') { try { await updateForm.value.validate(); - const response = await updateConfig(updateState) + await updateConfig(updateState) openModal.value = false; - message.success(response.data.msg); loadingData(); } catch (error) { console.log(error) diff --git a/frontend/src/views/system/dept/index.vue b/frontend/src/views/system/dept/index.vue index 12cda388..ced100c9 100644 --- a/frontend/src/views/system/dept/index.vue +++ b/frontend/src/views/system/dept/index.vue @@ -383,9 +383,7 @@ const resetFields = () => { // 删除 const deleteRow = (row: tableDataType) => { - deleteDept({ id: row.id }).then(response => { - const result = response.data; - message.success(result.msg); + deleteDept({ id: row.id }).then(() => { loadingData(); }).catch(error => { console.log(error); @@ -404,9 +402,7 @@ const handleMoreClick: MenuProps['onClick'] = e => { content: e.key == 1 ? '是否确定启用选择项?' : '是否确定停用选择项?', onOk() { const body = { ids: selectedRowKeys.value, available: e.key == 1 ? true : false }; - batchAvailableDept(body).then(response => { - const result = response.data; - message.success(result.msg); + batchAvailableDept(body).then(() => { selectedRowKeys.value = []; loadingData(); }).catch(error => { @@ -468,13 +464,11 @@ const handleModalSumbit = () => { } }); - createDept(createBody).then(response => { - const result = response.data; + createDept(createBody).then(() => { modalSubmitLoading.value = false; openModal.value = false; Object.keys(createState).forEach(key => delete createState[key]); createState.order = 1; - message.success(result.msg); loadingData(); }).catch(error => { console.error(error); @@ -487,11 +481,9 @@ const handleModalSumbit = () => { } else if (modalTitle.value === 'update') { updateForm.value.validate().then(() => { - updateDept(updateState).then(response => { + updateDept(updateState).then(() => { modalSubmitLoading.value = false; openModal.value = false; - const result = response.data; - message.success(result.msg); loadingData(); }).catch(error => { diff --git a/frontend/src/views/system/dict/data.vue b/frontend/src/views/system/dict/data.vue index a5999824..987a383f 100644 --- a/frontend/src/views/system/dict/data.vue +++ b/frontend/src/views/system/dict/data.vue @@ -516,9 +516,7 @@ const modalHandle = (modalType: string, index?: number) => { // 删除 const deleteRow = (row: tableDictDataType) => { - deleteDictData({ id: row.id }).then(response => { - const result = response.data; - message.success(result.msg); + deleteDictData({ id: row.id }).then(() => { loadingData(); }).catch(error => { console.log(error) @@ -542,12 +540,10 @@ const handleModalSumbit = () => { } }) - createDictData(createBody).then(response => { + createDictData(createBody).then(() => { modalSubmitLoading.value = false; openModal.value = false; Object.keys(createState).forEach(key => delete createState[key]); - const result = response.data; - message.success(result.msg); loadingData(); }).catch(error => { @@ -562,10 +558,9 @@ const handleModalSumbit = () => { } else if (modalTitle.value === 'update') { updateForm.value.validate().then(() => { - updateDictData(updateState).then(response => { + updateDictData(updateState).then(() => { modalSubmitLoading.value = false; openModal.value = false; - message.success(response.data.msg); loadingData(); }).catch(error => { modalSubmitLoading.value = false; diff --git a/frontend/src/views/system/dict/index.vue b/frontend/src/views/system/dict/index.vue index bdd94cac..76ffae92 100644 --- a/frontend/src/views/system/dict/index.vue +++ b/frontend/src/views/system/dict/index.vue @@ -366,9 +366,7 @@ const modalHandle = (modalType: string, index?: number) => { // 删除 const deleteRow = (row: tableDictType) => { - deleteDictType({ id: row.id }).then(response => { - const result = response.data; - message.success(result.msg); + deleteDictType({ id: row.id }).then(() => { loadingData(); }).catch(error => { console.log(error) @@ -393,12 +391,10 @@ const handleModalSumbit = () => { } }) - createDictType(createBody).then(response => { + createDictType(createBody).then(() => { modalSubmitLoading.value = false; openModal.value = false; Object.keys(createState).forEach(key => delete createState[key]); - const result = response.data; - message.success(result.msg); loadingData(); }).catch(error => { @@ -413,10 +409,9 @@ const handleModalSumbit = () => { } else if (modalTitle.value === 'update') { updateForm.value.validate().then(() => { - updateDictType(updateState).then(response => { + updateDictType(updateState).then(() => { modalSubmitLoading.value = false; openModal.value = false; - message.success(response.data.msg); loadingData(); }).catch(error => { modalSubmitLoading.value = false; diff --git a/frontend/src/views/system/job/index.vue b/frontend/src/views/system/job/index.vue index 5158f37e..fdd370a8 100644 --- a/frontend/src/views/system/job/index.vue +++ b/frontend/src/views/system/job/index.vue @@ -751,9 +751,7 @@ const modalHandle = (modalType: string, index?: number) => { // 删除 const deleteRow = (row: tableJobType) => { - deleteJob({ id: row.id }).then(response => { - const result = response.data; - message.success(result.msg); + deleteJob({ id: row.id }).then(() => { loadingData(); }).catch(error => { console.log(error) @@ -777,12 +775,10 @@ const handleModalSumbit = () => { } }) - createJob(createBody).then(response => { + createJob(createBody).then(() => { modalSubmitLoading.value = false; openModal.value = false; Object.keys(createState).forEach(key => delete createState[key]); - const result = response.data; - message.success(result.msg); loadingData(); }).catch(error => { @@ -797,10 +793,9 @@ const handleModalSumbit = () => { } else if (modalTitle.value === 'update') { updateForm.value.validate().then(() => { - updateJob(updateState).then(response => { + updateJob(updateState).then(() => { modalSubmitLoading.value = false; openModal.value = false; - message.success(response.data.msg); loadingData(); }).catch(error => { modalSubmitLoading.value = false; @@ -864,9 +859,7 @@ const handleClear = () => { title: '警告', content: '是否确认清空所有定时任务数据?', onOk() { - clearJob().then(response => { - const result = response.data; - message.success(result.msg); + clearJob().then(() => { loadingData(); }) } @@ -875,9 +868,7 @@ const handleClear = () => { // 操作按钮:操作类型 1: 暂停 2: 恢复 3: 重启 const handleOption = (row: tableJobType, option: number) => { - OptionJob({ id: row.id, option: option }).then(response => { - const result = response.data; - message.success(result.msg); + OptionJob({ id: row.id, option: option }).then(() => { loadingData(); }) } diff --git a/frontend/src/views/system/log/index.vue b/frontend/src/views/system/log/index.vue index 3697bc4b..e8c6af2d 100644 --- a/frontend/src/views/system/log/index.vue +++ b/frontend/src/views/system/log/index.vue @@ -290,9 +290,7 @@ const resetFields = () => { // 删除 const deleteRow = (row: tableDataType) => { - deleteLog({ id: row.id }).then(response => { - const result = response.data; - message.success(result.msg); + deleteLog({ id: row.id }).then(() => { loadingData(); }).catch(error => { console.log(error) diff --git a/frontend/src/views/system/menu/index.vue b/frontend/src/views/system/menu/index.vue index 979baedc..c2a74a8d 100644 --- a/frontend/src/views/system/menu/index.vue +++ b/frontend/src/views/system/menu/index.vue @@ -601,9 +601,7 @@ const modalHandle = (modalType: string, record?: tableDataType) => { // 删除 const deleteRow = (row: tableDataType) => { - deleteMenu({ id: row.id }).then(response => { - const result = response.data; - message.success(result.msg); + deleteMenu({ id: row.id }).then(() => { loadingData(); }).catch(error => { @@ -623,9 +621,7 @@ const handleMoreClick: MenuProps['onClick'] = e => { content: e.key == 1 ? '是否确定启用选择项?' : '是否确定停用选择项?', onOk() { const body = { ids: selectedRowKeys.value, available: e.key == 1 ? true : false }; - batchAvailableMenu(body).then(response => { - const result = response.data; - message.success(result.msg); + batchAvailableMenu(body).then(() => { selectedRowKeys.value = []; loadingData(); }).catch(error => { @@ -651,7 +647,7 @@ const handleModalSumbit = () => { } }) - createMenu(createBody).then(response => { + createMenu(createBody).then(() => { modalSubmitLoading.value = false; openModal.value = false; Object.keys(createState).forEach(key => delete createState[key]) @@ -659,8 +655,6 @@ const handleModalSumbit = () => { createState.order = 1; createState.cache = true; createState.hidden = false; - const result = response.data; - message.success(result.msg); loadingData(); }).catch(error => { @@ -675,11 +669,9 @@ const handleModalSumbit = () => { } else if (modalTitle.value === 'update') { updateForm.value.validate().then(() => { - updateMenu(updateState).then(response => { + updateMenu(updateState).then(() => { modalSubmitLoading.value = false; openModal.value = false; - const result = response.data; - message.success(result.msg); loadingData(); }).catch(error => { diff --git a/frontend/src/views/system/notice/index.vue b/frontend/src/views/system/notice/index.vue index b339a49c..604e8b6d 100644 --- a/frontend/src/views/system/notice/index.vue +++ b/frontend/src/views/system/notice/index.vue @@ -400,9 +400,7 @@ const modalHandle = (modalType: string, index?: number) => { // 删除 const deleteRow = (row: tableDataType) => { - deleteNotice({ id: row.id }).then(response => { - const result = response.data; - message.success(result.msg); + deleteNotice({ id: row.id }).then(() => { loadingData(); }).catch(error => { console.log(error) @@ -421,9 +419,7 @@ const handleMoreClick: MenuProps['onClick'] = e => { content: e.key == 1 ? '是否确定启用选择项?' : '是否确定停用选择项?', onOk() { const body = { ids: selectedRowKeys.value, available: e.key == 1 ? true : false }; - batchAvailableNotice(body).then(response => { - const result = response.data; - message.success(result.msg); + batchAvailableNotice(body).then(() => { selectedRowKeys.value = []; loadingData(); }).catch(error => { @@ -450,12 +446,10 @@ const handleModalSumbit = () => { } }) - createNotice(createBody).then(response => { + createNotice(createBody).then(() => { modalSubmitLoading.value = false; openModal.value = false; Object.keys(createState).forEach(key => delete createState[key]); - const result = response.data; - message.success(result.msg); loadingData(); }).catch(error => { @@ -470,10 +464,9 @@ const handleModalSumbit = () => { } else if (modalTitle.value === 'update') { updateForm.value.validate().then(() => { - updateNotice(updateState).then(response => { + updateNotice(updateState).then(() => { modalSubmitLoading.value = false; openModal.value = false; - message.success(response.data.msg); loadingData(); }) diff --git a/frontend/src/views/system/position/index.vue b/frontend/src/views/system/position/index.vue index c6417e53..04f99cfc 100644 --- a/frontend/src/views/system/position/index.vue +++ b/frontend/src/views/system/position/index.vue @@ -369,9 +369,7 @@ const modalHandle = (modalType: string, index?: number) => { // 删除 const deleteRow = (row: tableDataType) => { - deletePosition({ id: row.id }).then(response => { - const result = response.data; - message.success(result.msg); + deletePosition({ id: row.id }).then(() => { loadingData(); }).catch(error => { console.log(error) @@ -390,9 +388,7 @@ const handleMoreClick: MenuProps['onClick'] = e => { content: e.key == 1 ? '是否确定启用选择项?' : '是否确定停用选择项?', onOk() { const body = { ids: selectedRowKeys.value, available: e.key == 1 ? true : false }; - batchAvailablePosition(body).then(response => { - const result = response.data; - message.success(result.msg); + batchAvailablePosition(body).then(() => { selectedRowKeys.value = []; loadingData(); }).catch(error => { @@ -419,13 +415,11 @@ const handleModalSumbit = () => { } }) - createPosition(createBody).then(response => { + createPosition(createBody).then(() => { modalSubmitLoading.value = false; openModal.value = false; Object.keys(createState).forEach(key => delete createState[key]); createState.order = 1; - const result = response.data; - message.success(result.msg); loadingData(); }).catch(error => { @@ -440,10 +434,9 @@ const handleModalSumbit = () => { } else if (modalTitle.value === 'update') { updateForm.value.validate().then(() => { - updatePosition(updateState).then(response => { + updatePosition(updateState).then(() => { modalSubmitLoading.value = false; openModal.value = false; - message.success(response.data.msg); loadingData(); }) diff --git a/frontend/src/views/system/role/PermissionDrawer.vue b/frontend/src/views/system/role/PermissionDrawer.vue index f033bf39..2dfd1f6d 100644 --- a/frontend/src/views/system/role/PermissionDrawer.vue +++ b/frontend/src/views/system/role/PermissionDrawer.vue @@ -189,8 +189,7 @@ const emit = defineEmits(['event']); const handleDrawerSave = () => { drawerSaving.value = true; - setPermission(permissionState.value).then(response => { - message.success(response.data.msg); + setPermission(permissionState.value).then(() => { drawerSaving.value = false; openDrawer.value = false; emit('event'); diff --git a/frontend/src/views/system/role/index.vue b/frontend/src/views/system/role/index.vue index 3dd34854..c2b09731 100644 --- a/frontend/src/views/system/role/index.vue +++ b/frontend/src/views/system/role/index.vue @@ -348,9 +348,7 @@ const resetFields = () => { // 删除 const deleteRow = (row: tableDataType) => { - deleteRole({ id: row.id }).then(response => { - const result = response.data; - message.success(result.msg); + deleteRole({ id: row.id }).then(() => { loadingData(); }).catch(error => { @@ -371,8 +369,6 @@ const handleMoreClick: MenuProps['onClick'] = e => { onOk() { const body = { ids: selectedRowKeys.value, available: e.key == 1 ? true : false }; batchAvailableRole(body).then(response => { - const result = response.data; - message.success(result.msg); selectedRowKeys.value = []; loadingData(); }).catch(error => { @@ -445,13 +441,11 @@ const handleModalSumbit = () => { } }) - createRole(createBody).then(response => { - const result = response.data; + createRole(createBody).then(() => { modalSubmitLoading.value = false; openModal.value = false; Object.keys(createState).forEach(key => delete createState[key]); createState.order = 1; - message.success(result.msg); loadingData(); }).catch(error => { @@ -466,11 +460,9 @@ const handleModalSumbit = () => { } else if (modalTitle.value === 'update') { updateForm.value.validate().then(() => { - updateRole(updateState).then(response => { - const result = response.data; + updateRole(updateState).then(() => { modalSubmitLoading.value = false; openModal.value = false; - message.success(result.msg); loadingData(); }).catch(error => { diff --git a/frontend/src/views/system/user/index.vue b/frontend/src/views/system/user/index.vue index 93a33b75..29d0b394 100644 --- a/frontend/src/views/system/user/index.vue +++ b/frontend/src/views/system/user/index.vue @@ -698,11 +698,8 @@ const resetFields = () => { // 删除 const deleteRow = (row: tableDataType) => { - deleteUser({ id: row.id }).then(response => { - const result = response.data; - message.success(result.msg); + deleteUser({ id: row.id }).then(() => { loadingData(); - }).catch(error => { console.log(error); }) @@ -720,9 +717,7 @@ const handleMoreClick: MenuProps['onClick'] = e => { content: e.key == 1 ? '是否确定启用选择项?' : '是否确定停用选择项?', onOk() { const body = { ids: selectedRowKeys.value, available: e.key == 1 ? true : false }; - batchAvailableUser(body).then(response => { - const result = response.data; - message.success(result.msg); + batchAvailableUser(body).then(() => { selectedRowKeys.value = []; loadingData(); }).catch(error => { @@ -838,12 +833,10 @@ const handleModalSumbit = () => { } }) - createUser(createBody).then(response => { - const result = response.data; + createUser(createBody).then(() => { modalSubmitLoading.value = false; openModal.value = false; Object.keys(createState).forEach(key => delete createState[key]); - message.success(result.msg); loadingData(); }).catch(error => { @@ -876,11 +869,9 @@ const handleModalSumbit = () => { updateBody['password'] = updateState.password; } - updateUser(updateBody).then(response => { - const result = response.data; + updateUser(updateBody).then(() => { modalSubmitLoading.value = false; openModal.value = false; - message.success(result.msg); loadingData(); }).catch(error => { @@ -1006,7 +997,6 @@ const customRequest = ({ file, onSuccess, onError, onProgress }: any) => { fileItem.percent = 100; upload.isUploading = false; upload.open = false; - message.success(response.data.msg); onSuccess(response); loadingData(); // 刷新数据 }) @@ -1014,7 +1004,7 @@ const customRequest = ({ file, onSuccess, onError, onProgress }: any) => { fileItem.status = 'error'; upload.isUploading = false; onError(error); - message.error(error.response?.data?.detail || '用户导入失败'); + console.error('导入失败:', error); }); };