From e277a6abac874d0c06db1a21bfdbfcadc84faa02 Mon Sep 17 00:00:00 2001 From: zxc <1171051090@qq.com> Date: Sat, 10 Aug 2024 21:37:11 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=B0=86=E6=B8=90=E5=8F=98=E8=89=B2?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=B0=E4=B8=BB=E9=A2=98=E6=8F=90=E5=8F=96?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/GradientBar.vue | 1 + src/hooks/useSlideTheme.ts | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/GradientBar.vue b/src/components/GradientBar.vue index 9d81ec58..48185cb4 100644 --- a/src/components/GradientBar.vue +++ b/src/components/GradientBar.vue @@ -139,6 +139,7 @@ const addPoint = (e: MouseEvent) => { outline: 1px solid #d9d9d9; box-shadow: 0 0 2px 2px #d9d9d9; border-radius: 1px; + cursor: pointer; &.active { outline: 1px solid $themeColor; diff --git a/src/hooks/useSlideTheme.ts b/src/hooks/useSlideTheme.ts index ba5a16d7..5a0f0fa3 100644 --- a/src/hooks/useSlideTheme.ts +++ b/src/hooks/useSlideTheme.ts @@ -31,8 +31,9 @@ export default () => { backgroundColorValues.push({ area: 1, value: slide.background.color }) } else if (slide.background.type === 'gradient' && slide.background.gradient) { + const len = slide.background.gradient.colors.length backgroundColorValues.push(...slide.background.gradient.colors.map(item => ({ - area: 1, + area: 1 / len, value: item.color, }))) } @@ -54,6 +55,13 @@ export default () => { if (el.fill) { themeColorValues.push({ area, value: el.fill }) } + if (el.type === 'shape' && el.gradient) { + const len = el.gradient.colors.length + themeColorValues.push(...el.gradient.colors.map(item => ({ + area: 1 / len * area, + value: item.color, + }))) + } const text = (el.type === 'shape' ? el.text?.content : el.content) || '' if (!text) continue @@ -160,8 +168,8 @@ export default () => { for (const item of backgroundColorValues) { const color = tinycolor(item.value).toRgbString() if (color === 'rgba(0, 0, 0, 0)') continue - if (!backgroundColors[color]) backgroundColors[color] = 1 - else backgroundColors[color] += 1 + if (!backgroundColors[color]) backgroundColors[color] = item.area + else backgroundColors[color] += item.area } const themeColors: { [key: string]: number } = {}