From 0b533cb375c7d123ae8a1295b44063fa96dae0bb Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Thu, 29 Aug 2024 10:53:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=AD=97=E5=BA=93=E6=96=87=E4=BB=B6=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E7=AD=89=E5=BE=85=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=88=90=E5=8A=9F=EF=BC=8C=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=AD=97?= =?UTF-8?q?=E5=BA=93=E6=96=87=E4=BB=B6=E6=B2=A1=E6=9C=89=E7=9C=9F=E6=AD=A3?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=EF=BC=8C=E4=B8=8D=E4=BC=9A=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/store/modules/appearance.ts | 14 ++++++++--- .../src/views/system/font/UploadDetail.vue | 25 +++++++++++-------- .../src/views/system/font/index.vue | 19 +++++++++----- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/core/core-frontend/src/store/modules/appearance.ts b/core/core-frontend/src/store/modules/appearance.ts index c053de6e7b..6c4015ff96 100644 --- a/core/core-frontend/src/store/modules/appearance.ts +++ b/core/core-frontend/src/store/modules/appearance.ts @@ -205,21 +205,27 @@ export const useAppearanceStore = defineStore('appearanceStore', { } defaultFont().then(res => { const [font] = res || [] - setDefaultFont(`${basePath}/typeface/download/${font?.fileTransName}`, font?.name) - function setDefaultFont(url, name) { - if (!name) return + setDefaultFont( + `${basePath}/typeface/download/${font?.fileTransName}`, + font?.name, + font?.fileTransName + ) + function setDefaultFont(url, name, fileTransName) { let fontStyleElement = document.querySelector('#de-custom_font') if (!fontStyleElement) { fontStyleElement = document.createElement('style') fontStyleElement.setAttribute('id', 'de-custom_font') document.querySelector('head').appendChild(fontStyleElement) } - fontStyleElement.innerHTML = `@font-face { + fontStyleElement.innerHTML = + name && fileTransName + ? `@font-face { font-family: '${name}'; src: url(${url}); font-weight: normal; font-style: normal; }` + : '' document.documentElement.style.setProperty('--de-custom_font', `${name}`) document.documentElement.style.setProperty('--van-base-font', `${name}`) } diff --git a/core/core-frontend/src/views/system/font/UploadDetail.vue b/core/core-frontend/src/views/system/font/UploadDetail.vue index fdc3e88529..1a7357b5b7 100644 --- a/core/core-frontend/src/views/system/font/UploadDetail.vue +++ b/core/core-frontend/src/views/system/font/UploadDetail.vue @@ -20,7 +20,6 @@ const uploadExcel = () => { ruleForm.size = res.data.size ruleForm.fileTransName = res.data.fileTransName upload.value?.clearFiles() - loading.value = false }) .catch(error => { if (error.code === 'ECONNABORTED') { @@ -30,6 +29,8 @@ const uploadExcel = () => { showClose: true }) } + }) + .finally(() => { loading.value = false }) } @@ -82,7 +83,11 @@ const uploadFail = response => { } const emits = defineEmits(['finish']) - +const cancel = () => { + Object.assign(ruleForm, cloneDeep(defaultForm)) + state.fileList = null + dialogVisible.value = false +} const confirm = () => { ruleFormRef.value.validate(val => { if (val) { @@ -92,11 +97,9 @@ const confirm = () => { return } } - edit(ruleForm).then(res => { + edit(ruleForm).then(() => { ElMessage.success(dialogTitle.value + '成功') - dialogVisible.value = false - Object.assign(ruleForm, cloneDeep(defaultForm)) - state.fileList = null + cancel() emits('finish') }) } @@ -105,7 +108,7 @@ const confirm = () => {