Przeglądaj źródła

fix: halfFrame形状根据fmla计算

李志伟 2 miesięcy temu
rodzic
commit
22a651f267
2 zmienionych plików z 220 dodań i 654 usunięć
  1. 203 642
      pnpm-lock.yaml
  2. 17 12
      src/components/view_file/vendors/pptx/PPT.vue

Plik diff jest za duży
+ 203 - 642
pnpm-lock.yaml


+ 17 - 12
src/components/view_file/vendors/pptx/PPT.vue

@@ -2,7 +2,7 @@
  * @Author: LiZhiWei
  * @Date: 2025-04-10 14:38:27
  * @LastEditors: LiZhiWei
- * @LastEditTime: 2025-04-29 10:28:45
+ * @LastEditTime: 2025-04-29 14:27:00
  * @Description:
 -->
 <template>
@@ -20,6 +20,7 @@ const pptxContainer = ref(null)
 
 // 渲染幻灯片
 const renderSlides = () => {
+  console.log("pptxJson", props.pptxJson)
   if (!pptxContainer.value || !props.pptxJson) return
 
   pptxContainer.value.innerHTML = ""
@@ -1490,10 +1491,10 @@ const createShapeElement = (element) => {
         "http://www.w3.org/2000/svg",
         "path"
       )
-
-      // 计算内框的边距
-      const frameWidth2 = element.width / 9
-
+      const halfFrameFmlaTop = element.formulas[0].split(" ")[1]
+      const halfFrameFmlaLeft = element.formulas[1].split(" ")[1] 
+      const frameWidthTop = element.height * (halfFrameFmlaTop/100000)
+      const frameWidthLeft = element.width * (halfFrameFmlaLeft/100000)
       // 绘制外框的左边和上边
       outerRect2.setAttribute(
         "d",
@@ -1503,9 +1504,9 @@ const createShapeElement = (element) => {
       // 绘制内框的左边和上边,注意起点位置调整
       innerRect2.setAttribute(
         "d",
-        `M${frameWidth2},${element.height - frameWidth2} ` +
-          `L${frameWidth2},${frameWidth2} ` +
-          `L${element.width - frameWidth2},${frameWidth2}`
+        `M${frameWidthLeft},${element.height - frameWidthLeft} ` +
+          `L${frameWidthLeft},${frameWidthTop} ` +
+          `L${element.width - frameWidthTop},${frameWidthTop}`
       )
 
       // 设置填充色
@@ -1517,12 +1518,12 @@ const createShapeElement = (element) => {
         )
         fillPath.setAttribute(
           "d",
-          `M${frameWidth2},${frameWidth2} ` +
-            `L${element.width - frameWidth2},${frameWidth2} ` +
+          `M${frameWidthLeft},${frameWidthTop} ` +
+            `L${element.width - frameWidthTop},${frameWidthTop} ` +
             `L${element.width},0 ` +
             `L0,0 ` +
             `L0,${element.height} ` +
-            `L${frameWidth2},${element.height - frameWidth2} Z`
+            `L${frameWidthLeft},${element.height - frameWidthLeft} Z`
         )
         fillPath.setAttribute("fill", element.fill.value || "transparent")
         svg.appendChild(fillPath)
@@ -1998,7 +1999,11 @@ const createShapeElement = (element) => {
       const fmla = element?.formulas[0].split(" ")[1]
       innerCircle.setAttribute("cx", element.width / 2)
       innerCircle.setAttribute("cy", element.height / 2)
-      innerCircle.setAttribute("r", Math.min(element.width, element.height)/2 * (1- Math.sqrt(fmla/100000)/2))
+      innerCircle.setAttribute(
+        "r",
+        (Math.min(element.width, element.height) / 2) *
+          (1 - Math.sqrt(fmla / 100000) / 2)
+      )
 
       // 设置填充色
       setBackground(element, outerCircle)

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików