perf: 优化自定义颜色交互

This commit is contained in:
奔跑的面条 2023-02-27 00:24:19 +08:00
parent 8b6c616a15
commit 97899f275a

View File

@ -183,6 +183,7 @@ const createColor = () => {
colorList.push(newData) colorList.push(newData)
selectHandle(newData) selectHandle(newData)
updateColor.value = newData updateColor.value = newData
saveHandle(false)
} }
if (updateColor.value !== undefined) { if (updateColor.value !== undefined) {
goDialog({ goDialog({
@ -235,11 +236,11 @@ const updateColorHandle = (newColor: ColorType) => {
} }
// //
const saveHandle = () => { const saveHandle = (onMessage = true) => {
if (!updateColor.value) return if (!updateColor.value) return
const index = colorList.findIndex(item => item.id === updateColor.value?.id) const index = colorList.findIndex(item => item.id === updateColor.value?.id)
if (index !== -1) { if (index !== -1) {
window.$message.success('颜色应用成功!') onMessage && window.$message.success('数据应用成功!')
const updateColorPrefix = cloneDeep({ ...updateColor.value, name: updateColor.value.name || '未定义' }) const updateColorPrefix = cloneDeep({ ...updateColor.value, name: updateColor.value.name || '未定义' })
colorList.splice(index, 1, updateColorPrefix) colorList.splice(index, 1, updateColorPrefix)
updateColor.value = undefined updateColor.value = undefined
@ -252,7 +253,7 @@ const saveHandle = () => {
chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.CHART_THEME_COLOR, selectTheme) chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.CHART_THEME_COLOR, selectTheme)
}) })
} else { } else {
window.$message.error('颜色应用失败!') window.$message.error('数据应用失败!')
} }
} }