refactor: 默认字体Mac系统适配

This commit is contained in:
wangjiahao 2024-11-28 10:36:11 +08:00
parent 074e86cef9
commit 9f711737fa
6 changed files with 30 additions and 11 deletions

View File

@ -241,7 +241,7 @@ import {
LIGHT_THEME_DASHBOARD_BACKGROUND
} from '@/utils/canvasStyle'
import {
CHART_FONT_FAMILY,
CHART_FONT_FAMILY_ORIGIN,
DEFAULT_COLOR_CASE_DARK,
DEFAULT_COLOR_CASE_LIGHT,
DEFAULT_TAB_COLOR_CASE_DARK,
@ -274,7 +274,7 @@ const props = defineProps({
default: 'light'
}
})
const fontFamily = CHART_FONT_FAMILY.concat(
const fontFamily = CHART_FONT_FAMILY_ORIGIN.concat(
appearanceStore.fontList.map(ele => ({
name: ele.name,
value: ele.name

View File

@ -83,7 +83,7 @@ import { storeToRefs } from 'pinia'
import { ElFormItem, ElIcon } from 'element-plus-secondary'
import Icon from '../icon-custom/src/Icon.vue'
import { useAppearanceStoreWithOut } from '@/store/modules/appearance'
import { CHART_FONT_FAMILY } from '@/views/chart/components/editor/util/chart'
import { CHART_FONT_FAMILY_ORIGIN } from '@/views/chart/components/editor/util/chart'
import { adaptTitleFontFamilyAll } from '@/utils/canvasStyle'
import { useI18n } from '@/hooks/web/useI18n'
const snapshotStore = snapshotStoreWithOut()
@ -91,7 +91,7 @@ const { t } = useI18n()
const dvMainStore = dvMainStoreWithOut()
const { canvasStyleData } = storeToRefs(dvMainStore)
const appearanceStore = useAppearanceStoreWithOut()
const fontFamily = CHART_FONT_FAMILY.concat(
const fontFamily = CHART_FONT_FAMILY_ORIGIN.concat(
appearanceStore.fontList.map(ele => ({
name: ele.name,
value: ele.name

View File

@ -580,8 +580,7 @@ const list = [
color: '',
padding: 4,
verticalAlign: 'middle',
scrollSpeed: 0,
fontFamily: 'Microsoft YaHei'
scrollSpeed: 0
}
}
]

View File

@ -62,7 +62,7 @@ import { useEmitt } from '@/hooks/web/useEmitt'
import { valueFormatter } from '@/views/chart/components/js/formatter'
import { parseJson } from '@/views/chart/components/js/util'
import { mappingColor } from '@/views/chart/components/js/panel/common/common_table'
import { CHART_FONT_FAMILY } from '@/views/chart/components/editor/util/chart'
import { CHART_FONT_FAMILY_ORIGIN } from '@/views/chart/components/editor/util/chart'
import { useAppearanceStoreWithOut } from '@/store/modules/appearance'
const snapshotStore = snapshotStoreWithOut()
const errMsg = ref('')
@ -137,7 +137,7 @@ const myValue = ref('')
const systemFontFamily = appearanceStore.fontList.map(item => item.name)
const curFontFamily = () => {
let result = ''
CHART_FONT_FAMILY.concat(
CHART_FONT_FAMILY_ORIGIN.concat(
appearanceStore.fontList.map(ele => ({
name: ele.name,
value: ele.name

View File

@ -1,12 +1,15 @@
import { cos, sin } from '@/utils/translate'
import {
CHART_FONT_FAMILY_MAP,
CHART_FONT_FAMILY_MAP_TRANS,
DEFAULT_COLOR_CASE,
DEFAULT_COLOR_CASE_DARK
DEFAULT_COLOR_CASE_DARK,
DEFAULT_INDICATOR_STYLE
} from '@/views/chart/components/editor/util/chart'
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { useEmitt } from '@/hooks/web/useEmitt'
import { merge } from 'lodash-es'
import { defaultTo, merge } from 'lodash-es'
const dvMainStore = dvMainStoreWithOut()
export const LIGHT_THEME_COLOR_MAIN = '#000000'
@ -424,7 +427,10 @@ export function adaptCurTheme(customStyle, customAttr) {
export function adaptTitleFontFamily(fontFamily, viewInfo) {
if (viewInfo) {
viewInfo.customStyle['text']['fontFamily'] = fontFamily
viewInfo.customStyle['text']['fontFamily'] = defaultTo(
CHART_FONT_FAMILY_MAP_TRANS[fontFamily],
fontFamily
)
}
}

View File

@ -1112,6 +1112,20 @@ export const BASE_ECHARTS_SELECT = {
}
}
export const CHART_FONT_FAMILY_ORIGIN = [
{ name: '微软雅黑', value: 'Microsoft YaHei' },
{ name: '宋体', value: 'SimSun, "Songti SC", STSong' },
{ name: '黑体', value: 'SimHei, Helvetica' },
{ name: '楷体', value: 'KaiTi, "Kaiti SC", STKaiti' }
]
export const CHART_FONT_FAMILY_MAP_TRANS = {
'Microsoft YaHei': 'Microsoft YaHei',
'SimSun, "Songti SC", STSong': 'SimSun',
'SimHei, Helvetica': 'SimHei',
'KaiTi, "Kaiti SC", STKaiti': 'KaiTi'
}
export const CHART_FONT_FAMILY = [
{ name: '微软雅黑', value: 'Microsoft YaHei' },
{ name: '宋体', value: 'SimSun' },