From 727bdb7bc5ef66c12432b58f88b8eabcc9c624b8 Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Tue, 26 Apr 2022 22:17:01 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=AF=BC=E5=87=BAPPTX=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=88=E8=BD=AC=E4=B9=89=E5=AD=97=E7=AC=A6=E3=80=81?= =?UTF-8?q?=E7=BA=BF=E6=9D=A1=E9=80=8F=E6=98=8E=E5=BA=A6=E3=80=81=E8=BE=B9?= =?UTF-8?q?=E6=A1=86=E9=80=8F=E6=98=8E=E5=BA=A6=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useExport.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/hooks/useExport.ts b/src/hooks/useExport.ts index 12d28bb7..1dc78ea1 100644 --- a/src/hooks/useExport.ts +++ b/src/hooks/useExport.ts @@ -127,7 +127,7 @@ export default () => { slices.push({ text: '', options: { breakLine: true } }) } else if ('content' in item) { - const text = item.content.replace(/\n/g, '').replace(/ /g, ' ') + const text = item.content.replace(/ /g, ' ').replace(/>/g, '>').replace(/</g, '<').replace(/&/g, '&').replace(/\n/g, '') const options: pptxgen.TextPropsOptions = {} if (styleObj['font-size']) { @@ -281,10 +281,12 @@ export default () => { fontFace: '微软雅黑', color: '#000000', valign: 'middle', + margin: 10 * 0.75, + lineSpacingMultiple: 1.5 / 1.2, } if (el.rotate) options.rotate = el.rotate if (el.wordSpace) options.charSpacing = el.wordSpace * 0.75 - if (el.lineHeight) options.lineSpacingMultiple = el.lineHeight * 0.75 + if (el.lineHeight) options.lineSpacingMultiple = el.lineHeight / 1.2 if (el.fill) { const c = formatColor(el.fill) const opacity = el.opacity === undefined ? 1 : el.opacity @@ -378,8 +380,10 @@ export default () => { if (el.flipH) options.flipH = el.flipH if (el.flipV) options.flipV = el.flipV if (el.outline?.width) { + const c = formatColor(el.outline?.color || '#000000') options.line = { - color: formatColor(el.outline?.color || '#000000').color, + color: c.color, + transparency: (1 - c.alpha) * 100, width: el.outline.width * 0.75, dashType: el.outline.style === 'solid' ? 'solid' : 'dash', } @@ -431,6 +435,7 @@ export default () => { const path = getLineElementPath(el) const points = formatPoints(toPoints(path)) const { minX, maxX, minY, maxY } = getElementRange(el) + const c = formatColor(el.color) const options: pptxgen.ShapeProps = { x: el.left / 100, @@ -438,7 +443,8 @@ export default () => { w: (maxX - minX) / 100, h: (maxY - minY) / 100, line: { - color: formatColor(el.color).color, + color: c.color, + transparency: (1 - c.alpha) * 100, width: el.width * 0.75, dashType: el.style === 'solid' ? 'solid' : 'dash', beginArrowType: el.points[0] ? 'arrow' : 'none',