mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-01-13 18:44:14 +08:00
fix: Enhance error handling in file saving process (#11152)
* fix: Enhance error handling in file saving process * f * f
This commit is contained in:
parent
158180a052
commit
63b62f4074
1 changed files with 12 additions and 9 deletions
|
|
@ -393,7 +393,7 @@
|
|||
<script lang="ts" setup>
|
||||
import { createFile, getFileContent, getFilesTree, saveFileContent } from '@/api/modules/files';
|
||||
import i18n from '@/lang';
|
||||
import { MsgSuccess, MsgWarning } from '@/utils/message';
|
||||
import { MsgError, MsgSuccess, MsgWarning } from '@/utils/message';
|
||||
import * as monaco from 'monaco-editor';
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref } from 'vue';
|
||||
import { Languages } from '@/global/mimetype';
|
||||
|
|
@ -867,19 +867,22 @@ const quickSave = () => {
|
|||
saveContent();
|
||||
};
|
||||
|
||||
const saveContent = () => {
|
||||
const saveContent = async () => {
|
||||
if (isEdit.value) {
|
||||
loading.value = true;
|
||||
saveFileContent(form.value)
|
||||
.then(() => {
|
||||
loading.value = false;
|
||||
try {
|
||||
const res = await saveFileContent(form.value);
|
||||
if (res) {
|
||||
isEdit.value = false;
|
||||
oldFileContent.value = form.value.content;
|
||||
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
} else {
|
||||
MsgError(i18n.global.t('commons.status.failed'));
|
||||
isEdit.value = false;
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
} else {
|
||||
MsgWarning(i18n.global.t('file.noEdit'));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue