From 96f9029b54895a7237567da1469e1bcb49db744e Mon Sep 17 00:00:00 2001 From: zxc <1171051090@qq.com> Date: Fri, 14 Mar 2025 22:31:37 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=9B=BE=E8=A1=A8=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChartStylePanel/ThemeColorsSetting.vue | 108 +++++++++++++ .../ChartStylePanel/index.vue | 153 +++++++----------- 2 files changed, 166 insertions(+), 95 deletions(-) create mode 100644 src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/ThemeColorsSetting.vue diff --git a/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/ThemeColorsSetting.vue b/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/ThemeColorsSetting.vue new file mode 100644 index 00000000..41e97e8c --- /dev/null +++ b/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/ThemeColorsSetting.vue @@ -0,0 +1,108 @@ + + + + + diff --git a/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue b/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue index a52a683e..de5258a5 100644 --- a/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue +++ b/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue @@ -49,52 +49,40 @@ - - -
-
{{index === 0 ? '主题配色:' : ''}}
- +
+
主题配色:
+ -
- -
-
-
-
- - - - + - - +
@@ -111,6 +99,14 @@ @save="value => updateData(value)" /> + + + + @@ -125,13 +121,14 @@ import { CHART_PRESET_THEMES } from '@/configs/chart' import ElementOutline from '../../common/ElementOutline.vue' import ChartDataEditor from './ChartDataEditor.vue' +import ThemeColorsSetting from './ThemeColorsSetting.vue' import ColorButton from '@/components/ColorButton.vue' +import ColorListButton from '@/components/ColorListButton.vue' import ColorPicker from '@/components/ColorPicker/index.vue' import Modal from '@/components/Modal.vue' import Divider from '@/components/Divider.vue' import Checkbox from '@/components/Checkbox.vue' import Button from '@/components/Button.vue' -import ButtonGroup from '@/components/ButtonGroup.vue' import Popover from '@/components/Popover.vue' const mainStore = useMainStore() @@ -142,8 +139,8 @@ const { theme } = storeToRefs(slidesStore) const handleChartElement = handleElement as Ref const chartDataEditorVisible = ref(false) -const presetThemesVisible = ref(false) -const presetThemeColorHoverIndex = ref<[number, number]>([-1, -1]) +const themesVisible = ref(false) +const themeColorsSettingVisible = ref(false) const { addHistorySnapshot } = useHistorySnapshot() @@ -202,35 +199,11 @@ const updateOptions = (optionProps: ChartOptions) => { updateElement({ options: newOptions }) } -// 设置主题色 -const updateTheme = (color: string, index: number) => { - const props = { - themeColors: themeColors.value.map((c, i) => i === index ? color : c), - } - updateElement(props) -} - -// 添加主题色 -const addThemeColor = () => { - const props = { - themeColors: [...themeColors.value, theme.value.themeColors[0]], - } - updateElement(props) -} - // 使用预置主题配色 -const applyPresetTheme = (colors: string[], index: number) => { - const themeColors = colors.slice(0, index + 1) - updateElement({ themeColors }) - presetThemesVisible.value = false -} - -// 删除主题色 -const deleteThemeColor = (index: number) => { - const props = { - themeColors: themeColors.value.filter((c, i) => i !== index), - } - updateElement(props) +const setThemeColors = (colors: string[]) => { + updateElement({ themeColors: colors }) + themesVisible.value = false + themeColorsSettingVisible.value = false } // 设置文字颜色 @@ -262,41 +235,31 @@ onUnmounted(() => { .btn-icon { margin-right: 3px; } -.color-btn-wrap { - position: relative; -} -.delete-color-btn { - position: absolute; - width: 30px; - right: 2px; - top: 2px; - bottom: 2px; - display: flex; - justify-content: center; - align-items: center; - background-color: #fff; - cursor: pointer; +.label { + font-size: 12px; + margin-bottom: 4px; } .preset-themes { width: 250px; display: flex; - margin-bottom: -10px; @include flex-grid-layout(); } .preset-theme { display: flex; cursor: pointer; - + border: 1px solid #ccc; + padding: 2px; + border-radius: $borderRadius; @include flex-grid-layout-children(2, 48%); -} -.preset-theme-color { - width: 20px; - height: 20px; - &.select { - transform: scale(1.2); - transition: transform $transitionDelayFast; + &:hover { + border-color: $themeColor; + transition: border-color $transitionDelayFast; } } +.preset-theme-color { + height: 20px; + flex: 1; +} \ No newline at end of file