Skip to content

Commit 63b62f4

Browse files
authored
fix: Enhance error handling in file saving process (#11152)
* fix: Enhance error handling in file saving process * f * f
1 parent 158180a commit 63b62f4

File tree

1 file changed

+12
-9
lines changed
  • frontend/src/views/host/file-management/code-editor

1 file changed

+12
-9
lines changed

frontend/src/views/host/file-management/code-editor/index.vue

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@
393393
<script lang="ts" setup>
394394
import { createFile, getFileContent, getFilesTree, saveFileContent } from '@/api/modules/files';
395395
import i18n from '@/lang';
396-
import { MsgSuccess, MsgWarning } from '@/utils/message';
396+
import { MsgError, MsgSuccess, MsgWarning } from '@/utils/message';
397397
import * as monaco from 'monaco-editor';
398398
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref } from 'vue';
399399
import { Languages } from '@/global/mimetype';
@@ -867,19 +867,22 @@ const quickSave = () => {
867867
saveContent();
868868
};
869869
870-
const saveContent = () => {
870+
const saveContent = async () => {
871871
if (isEdit.value) {
872872
loading.value = true;
873-
saveFileContent(form.value)
874-
.then(() => {
875-
loading.value = false;
873+
try {
874+
const res = await saveFileContent(form.value);
875+
if (res) {
876876
isEdit.value = false;
877877
oldFileContent.value = form.value.content;
878878
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
879-
})
880-
.catch(() => {
881-
loading.value = false;
882-
});
879+
} else {
880+
MsgError(i18n.global.t('commons.status.failed'));
881+
isEdit.value = false;
882+
}
883+
} finally {
884+
loading.value = false;
885+
}
883886
} else {
884887
MsgWarning(i18n.global.t('file.noEdit'));
885888
}

0 commit comments

Comments
 (0)