From 1d8c9705e9c1849f77d298ba23266df04dda4da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E5=B8=86?= <201379873@qq.com> Date: Sun, 2 Jun 2024 10:55:06 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E4=BC=98=E5=8C=96=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/config/components/BasicSetting.vue | 241 +++++++++--------- .../system/config/components/MailSetting.vue | 106 ++++---- .../config/components/SecuritySetting.vue | 158 ++++++------ src/views/system/user/index.vue | 24 +- 4 files changed, 255 insertions(+), 274 deletions(-) diff --git a/src/views/system/config/components/BasicSetting.vue b/src/views/system/config/components/BasicSetting.vue index 98efd72..395025f 100644 --- a/src/views/system/config/components/BasicSetting.vue +++ b/src/views/system/config/components/BasicSetting.vue @@ -1,100 +1,94 @@ @@ -114,6 +108,7 @@ import { useForm } from '@/hooks' defineOptions({ name: 'BasicSetting' }) +const loading = ref(false) const formRef = ref() const { form } = useForm({ SITE_FAVICON: '', @@ -162,12 +157,14 @@ const queryForm = reactive({ }) // 查询列表数据 const getDataList = async () => { + loading.value = true const { data } = await listOption(queryForm) siteConfig.value = data.reduce((obj: SiteConfig, option: OptionResp) => { obj[option.code] = { ...option } return obj }, {}) handleCancel() + loading.value = false } const appStore = useAppStore() @@ -206,20 +203,20 @@ const onResetValue = () => { const handleUploadFavicon = (options: RequestOption) => { const controller = new AbortController() ; (async function requestWrap() { - const { onProgress, onError, onSuccess, fileItem, name = 'file' } = options - onProgress(20) - const formData = new FormData() - formData.append(name as string, fileItem.file as Blob) - uploadFile(formData) - .then((res) => { - onSuccess(res) - form.SITE_FAVICON = res.data.url - Message.success('上传成功') - }) - .catch((error) => { - onError(error) - }) - })() + const { onProgress, onError, onSuccess, fileItem, name = 'file' } = options + onProgress(20) + const formData = new FormData() + formData.append(name as string, fileItem.file as Blob) + uploadFile(formData) + .then((res) => { + onSuccess(res) + form.SITE_FAVICON = res.data.url + Message.success('上传成功') + }) + .catch((error) => { + onError(error) + }) + })() return { abort() { controller.abort() @@ -236,20 +233,20 @@ const handleChangeFavicon = (_: any, currentFile: any) => { const handleUploadLogo = (options: RequestOption) => { const controller = new AbortController() ; (async function requestWrap() { - const { onProgress, onError, onSuccess, fileItem, name = 'file' } = options - onProgress(20) - const formData = new FormData() - formData.append(name as string, fileItem.file as Blob) - uploadFile(formData) - .then((res) => { - onSuccess(res) - form.SITE_LOGO = res.data.url - Message.success('上传成功') - }) - .catch((error) => { - onError(error) - }) - })() + const { onProgress, onError, onSuccess, fileItem, name = 'file' } = options + onProgress(20) + const formData = new FormData() + formData.append(name as string, fileItem.file as Blob) + uploadFile(formData) + .then((res) => { + onSuccess(res) + form.SITE_LOGO = res.data.url + Message.success('上传成功') + }) + .catch((error) => { + onError(error) + }) + })() return { abort() { controller.abort() @@ -268,6 +265,10 @@ onMounted(() => {