forked from github/dataease
Merge pull request #11834 from dataease/pr@dev-v2_st
fix(系统设置): 上传字库文件没有等待文件上传成功,会导致字库文件没有真正上传,不会生效
This commit is contained in:
commit
7d295e9f22
@ -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}`)
|
||||
}
|
||||
|
@ -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 = () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="420">
|
||||
<el-dialog v-model="dialogVisible" :before-close="cancel" :title="dialogTitle" width="420">
|
||||
<el-form
|
||||
ref="ruleFormRef"
|
||||
:model="ruleForm"
|
||||
@ -117,7 +120,7 @@ const confirm = () => {
|
||||
<el-form-item v-if="action !== 'uploadFile'" label="字体名称" prop="name">
|
||||
<el-input placeholder="请输入字体名称" v-model="ruleForm.name" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="action !== 'rename'" label="字库文件">
|
||||
<el-form-item v-loading="loading" v-if="action !== 'rename'" label="字库文件">
|
||||
<el-upload
|
||||
action=""
|
||||
:multiple="false"
|
||||
@ -131,7 +134,7 @@ const confirm = () => {
|
||||
v-show="!state.fileList"
|
||||
>
|
||||
<template #trigger>
|
||||
<el-button v-loading="loading" secondary>
|
||||
<el-button secondary>
|
||||
<template #icon>
|
||||
<Icon name="icon_upload_outlined"></Icon>
|
||||
</template>
|
||||
@ -165,8 +168,8 @@ const confirm = () => {
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="confirm"> 确定 </el-button>
|
||||
<el-button @click="cancel">取消</el-button>
|
||||
<el-button v-loading="loading" type="primary" @click="confirm"> 确定 </el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
@ -61,28 +61,33 @@ const setToDefault = item => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
const setDefaultFont = (url, name) => {
|
||||
const setDefaultFont = (url, name, fileTransName) => {
|
||||
let fontStyleElement = document.querySelector('#de-custom_font')
|
||||
if (!fontStyleElement && name) {
|
||||
fontStyleElement = document.createElement('style')
|
||||
fontStyleElement.setAttribute('id', 'de-custom_font')
|
||||
document.querySelector('head').appendChild(fontStyleElement)
|
||||
}
|
||||
fontStyleElement.innerHTML = name
|
||||
? `@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 ? name : ''}`)
|
||||
document.documentElement.style.setProperty('--van-base-font', `${name ? name : ''}`)
|
||||
}
|
||||
const getDefaultFont = () => {
|
||||
defaultFont().then(res => {
|
||||
const [font] = res || []
|
||||
setDefaultFont(`${basePath}/typeface/download/${font?.fileTransName}`, font?.name)
|
||||
setDefaultFont(
|
||||
`${basePath}/typeface/download/${font?.fileTransName}`,
|
||||
font?.name,
|
||||
font?.fileTransName
|
||||
)
|
||||
})
|
||||
}
|
||||
const uploadFilish = () => {
|
||||
@ -149,7 +154,9 @@ onMounted(() => {
|
||||
<el-button v-if="!ele.isDefault" @click="setToDefault(ele)" secondary
|
||||
>设为默认字体</el-button
|
||||
>
|
||||
<el-button @click="deleteFont(ele)" secondary>删除</el-button>
|
||||
<el-button v-if="ele.name !== 'PingFang'" @click="deleteFont(ele)" secondary
|
||||
>删除</el-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user