mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
fix: 图表元素导出图片后显示异常(#98)
This commit is contained in:
parent
72fa220cf3
commit
56fadef948
@ -16,7 +16,6 @@ import { message } from 'ant-design-vue'
|
|||||||
interface ExportImageConfig {
|
interface ExportImageConfig {
|
||||||
quality: number;
|
quality: number;
|
||||||
width: number;
|
width: number;
|
||||||
filter: (node: HTMLElement) => boolean;
|
|
||||||
fontEmbedCSS?: string;
|
fontEmbedCSS?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,18 +29,13 @@ export default () => {
|
|||||||
exporting.value = true
|
exporting.value = true
|
||||||
const toImage = format === 'png' ? toPng : toJpeg
|
const toImage = format === 'png' ? toPng : toJpeg
|
||||||
|
|
||||||
|
const foreignObjectSpans = domRef.querySelectorAll('foreignObject [xmlns]')
|
||||||
|
foreignObjectSpans.forEach(spanRef => spanRef.removeAttribute('xmlns'))
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!domRef) return
|
|
||||||
|
|
||||||
const filter = (node: HTMLElement) => {
|
|
||||||
if (node.tagName && node.tagName.toUpperCase() === 'FOREIGNOBJECT') return false
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
const config: ExportImageConfig = {
|
const config: ExportImageConfig = {
|
||||||
quality,
|
quality,
|
||||||
width: 1600,
|
width: 1600,
|
||||||
filter,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ignoreWebfont) config.fontEmbedCSS = ''
|
if (ignoreWebfont) config.fontEmbedCSS = ''
|
||||||
|
@ -40,8 +40,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent, PropType } from 'vue'
|
import { computed, defineComponent, inject, PropType, ref } from 'vue'
|
||||||
import { PPTChartElement } from '@/types/slides'
|
import { PPTChartElement } from '@/types/slides'
|
||||||
|
import { injectKeySlideScale } from '@/types/injectKey'
|
||||||
|
|
||||||
import ElementOutline from '@/views/components/element/ElementOutline.vue'
|
import ElementOutline from '@/views/components/element/ElementOutline.vue'
|
||||||
import Chart from './Chart.vue'
|
import Chart from './Chart.vue'
|
||||||
@ -57,15 +58,18 @@ export default defineComponent({
|
|||||||
type: Object as PropType<PPTChartElement>,
|
type: Object as PropType<PPTChartElement>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
needScaleSize: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
|
const slideScale = inject(injectKeySlideScale) || ref(1)
|
||||||
|
|
||||||
|
const needScaleSize = computed(() => slideScale.value < 1)
|
||||||
|
const chartWidth = computed(() => needScaleSize.value ? props.elementInfo.width * 10 : props.elementInfo.width)
|
||||||
|
const chartHeight = computed(() => needScaleSize.value ? props.elementInfo.height * 10 : props.elementInfo.height)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
chartWidth: computed(() => props.needScaleSize ? props.elementInfo.width * 10 : props.elementInfo.width),
|
needScaleSize,
|
||||||
chartHeight: computed(() => props.needScaleSize ? props.elementInfo.height * 10 : props.elementInfo.height),
|
chartWidth,
|
||||||
|
chartHeight,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<BaseChartElement
|
<BaseChartElement class="screen-element-chart" :elementInfo="elementInfo" />
|
||||||
class="screen-element-chart"
|
|
||||||
:elementInfo="elementInfo"
|
|
||||||
:needScaleSize="false"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user