feat:业务组加添加主题切换

main
liu.shiyi 2 years ago
parent c6b573c97f
commit 42ad126d9e

@ -19,6 +19,8 @@ import remoteVueLoader from 'remote-vue-loader'
import { mapMutations, mapState } from 'vuex'
import innerRemoteComponents, { getRemoteComponents } from 'data-room-ui/RemoteComponents/remoteComponentsList'
import { getBizComponentInfo } from 'data-room-ui/js/api/bigScreenApi'
import {settingToTheme} from "data-room-ui/js/utils/themeFormatting";
import _ from "lodash";
export default {
name: 'LcdpRemoteComponent',
mixins: [linkageMixins, commonMixins],
@ -43,6 +45,16 @@ export default {
remoteComponent: null
}
},
watch: {
//
'config.option.theme': {
handler (val) {
if (val) {
this.changeStyle(this.config)
}
}
}
},
created () {
this.getRemoteComponent()
},
@ -126,6 +138,9 @@ export default {
...option
}
this.config.setting = setting
// settingtheme
this.config.theme = settingToTheme(this.config, this.customTheme)
return {
option,
setting
@ -183,6 +198,8 @@ export default {
// config
changeStyle (config) {
config = { ...this.config, ...config }
//
config.theme = settingToTheme(_.cloneDeep(config), this.customTheme)
config = this.transformSettingToOption(config, 'custom')
// optionsettingeval,optionHandlerdataHandler
const option = config.option
@ -199,6 +216,10 @@ export default {
this.chart.update(config.option)
}
this.changeChartConfig(config)
if (config.code === this.activeCode) {
this.changeActiveItemConfig(config)
}
// this.changeChartConfig(config)
// this.$refs['remoteComponent' + config.code]customStyle
const componentInstance = this.$refs['remoteComponent' + config.code]
if (componentInstance && componentInstance.$options.methods && componentInstance.$options.methods.customStyle) {

@ -71,7 +71,6 @@ export function handleResData (data) {
let originalConfig = {}
pageInfo.chartList.forEach((chart) => {
if (!['customComponent', 'remoteComponent'].includes(chart.type)) {
// TODO:一般组件也需要添加主题的兼容处理
originalConfig = { option: { ...setModules[chart.type] }, ...dataModules[chart.type] }
// 如果没有版本号,或者版本号修改了则需要进行旧数据兼容
if ((!chart.version) || chart.version !== originalConfig.version) {
@ -93,11 +92,11 @@ export function handleResData (data) {
chart = compatibility(chart, originalConfig)
}
}
// 初始化时应该判断是否存在theme配置没有的话添加默认的两套主题这是为了兼容旧组件
if (!chart.theme) {
chart.theme = settingToTheme(chart, 'dark')
chart.theme = settingToTheme(chart, 'light')
}
}
// 初始化时应该判断是否存在theme配置没有的话添加默认的两套主题这是为了兼容旧组件
if (!chart.theme) {
chart.theme = settingToTheme(chart, 'dark')
chart.theme = settingToTheme(chart, 'light')
}
chart.key = chart.code
})

@ -45,7 +45,7 @@ export function settingToTheme (config, type) {
}
return theme
} else {
return {}
return config?.theme || {dark:{}, light:{}}
}
}
// 将保存的theme主题设置颜色存放到chartList

Loading…
Cancel
Save