refactor: 调整字体选项

This commit is contained in:
wangjiahao 2024-11-22 10:00:20 +08:00
parent efb9189413
commit fb5a654d98
5 changed files with 17 additions and 6 deletions

View File

@ -29,7 +29,7 @@
:class="'form-item-' + themes"
label="仪表板字体选择"
>
<el-select :effect="themes" v-model="canvasStyleData.fontFamily" @change="styleChange">
<el-select :effect="themes" v-model="canvasStyleData.fontFamily" @change="fontFamilyChange()">
<el-option
v-for="option in fontFamily"
:key="option.value"
@ -279,6 +279,7 @@ const fontFamily = CHART_FONT_FAMILY.concat(
value: ele.name
}))
)
const toolTip = computed(() => {
return props.themes === 'dark' ? 'ndark' : 'dark'
})
@ -296,8 +297,8 @@ const onRefreshChange = val => {
}
themeChange()
}
const styleChange = () => {
snapshotStore.recordSnapshotCache('renderChart')
const fontFamilyChange = () => {
appearanceStore.setCurrentFont(canvasStyleData.fontFamily)
}
const themeChange = (modifyName?) => {

View File

@ -6,7 +6,11 @@
:class="'form-item-' + themes"
label="数据大屏字体选择"
>
<el-select :effect="themes" v-model="canvasStyleData.fontFamily" @change="onThemeChange">
<el-select
:effect="themes"
v-model="canvasStyleData.fontFamily"
@change="onFontFamilyChange"
>
<el-option
v-for="option in fontFamily"
:key="option.value"
@ -91,6 +95,9 @@ const fontFamily = CHART_FONT_FAMILY.concat(
value: ele.name
}))
)
const onFontFamilyChange = () => {
appearanceStore.setCurrentFont(canvasStyleData.fontFamily)
}
const onThemeChange = () => {
snapshotStore.recordSnapshotCache()
}

View File

@ -143,7 +143,7 @@ const curFontFamily = () => {
value: ele.name
}))
).forEach(font => {
result = result + font.name + '=' + font.name + ';'
result = result + font.name + '=' + font.value + ';'
})
return result
}

View File

@ -35,7 +35,9 @@ const { inMobile, dvInfo, canvasStyleData, componentData, canvasViewInfo, appDat
storeToRefs(dvMainStore)
const snapshotStore = snapshotStoreWithOut()
import { useI18n } from '@/hooks/web/useI18n'
import { useAppearanceStoreWithOut } from '@/store/modules/appearance'
const { t } = useI18n()
const appearanceStore = useAppearanceStoreWithOut()
export function chartTransStr2Object(targetIn, copy) {
const target = copy === 'Y' ? cloneDeep(targetIn) : targetIn
@ -346,6 +348,7 @@ export function initCanvasDataPrepare(dvId, busiFlag, callBack) {
dvInfo.type === 'dashboard' && canvasStyleResult['dashboard'].gap === 'yes'
? canvasStyleResult['dashboard'].gapSize
: 0
appearanceStore.setCurrentFont(canvasStyleData.fontFamily)
callBack({ canvasDataResult, canvasStyleResult, dvInfo, canvasViewInfoPreview, curPreviewGap })
})
}

View File

@ -226,7 +226,7 @@ export function getCanvasStyle(canvasStyleData, canvasId = 'canvas-main') {
style['background'] = `url(${imgUrlTrans(background)}) no-repeat`
}
}
style['font-family'] = fontFamily
style['font-family'] = fontFamily + '!important'
}
return style