Jelajahi Sumber

学生端答题卡组件增加跨页标注兼容 修改配置 线上环境不显示日志和源代码

dengshaobo 5 bulan lalu
induk
melakukan
89f790d124
3 mengubah file dengan 325 tambahan dan 136 penghapusan
  1. 310 129
      src/components/PaperImage.vue
  2. 1 1
      version.json
  3. 14 6
      vue.config.js

+ 310 - 129
src/components/PaperImage.vue

@@ -655,146 +655,257 @@ export default {
               const drawLineData=JSON.parse(item.drawLineData);
               console.log("打印drawLineData",drawLineData);
 
-
-              // for(var j=0;j<drawLineData.length;j++)
-              // {
-              //   var drawItem=drawLineData[j];
-
-              //   console.log("打印drawItem",drawItem);
-              //   // 扣分点 加分点 标记// 1:文字 (扣分留痕 显示扣分信息)  2:划线  3:波浪线   4:画笔 5:评语
-              //   if(drawItem.drawType==1)
-              //   {
-                  
-              //     const fontSize = Math.max(12, 40 * this.zoomRate* this.scale); // 最小字体12px,基础字体16px
-              //     ctx.font = `${fontSize}px Arial`; // 让文字大小跟随缩放
-              //     // ctx.font = '30px Arial';
-              //     ctx.fillStyle = '#D81E06';
-              //     ctx.textAlign = 'center';
-              //     ctx.textBaseline = 'middle';
-              //     if(drawItem.type=='reduce')
-              //     {
-              //       ctx.fillText('-'+drawItem.score,(drawItem.x + blockPoint.x) * this.zoomRate * this.scale, (drawItem.y + blockPoint.y) * this.zoomRate * this.scale);  
-              //     }
-              //     if(drawItem.type=='bonus')
-              //     {
-              //       ctx.fillText('+'+drawItem.score, (drawItem.x + blockPoint.x) * this.zoomRate * this.scale, (drawItem.y + blockPoint.y) * this.zoomRate * this.scale);  
-              //     }
+              if(blockList.length>0)
+              {
+                //跨页的
+                blockList.forEach((blockItem,index) => {
+                  console.log("打印blockItem",blockItem);
+                  if(blockItem.page==this.currentPage)
+                  {
+                    drawLineData.forEach((drawlineItem,drawIndex) => {
+                      let findIndex=this.FindBlockIndex(drawlineItem,blockList);
+                      console.log("打印drawIndex",drawIndex);
+                      console.log("打印findIndex",findIndex);
+                      
+                      let drawItem=drawlineItem;
+                      if(findIndex==index)
+                      {
+                        drawItem=this.FindTargetObj(drawlineItem,blockList);
+                        blockPoint=blockList[findIndex];
+      
+        
+                        console.log("打印blockPoint",blockPoint);
+                        console.log("打印drawItem",drawItem);
+                        // 计算通用的缩放因子,避免重复计算
+                        const zoomScale = zoomRate * scale;
+                        const offsetX = blockPoint.x * zoomScale;
+                        const offsetY = blockPoint.y * zoomScale;
+                        // 扣分点 加分点 标记// 1:文字 (扣分留痕 显示扣分信息)  2:划线  3:波浪线   4:画笔 5:评语
+                        switch(drawItem.drawType) {
+                          case 1: {
+                            // 文字类型(扣分点/加分点标记)
+                            const fontSize = Math.max(12, 40 * zoomScale);
+                            ctx.font = `${fontSize}px Arial`;
+                            ctx.fillStyle = '#D81E06';
+                            ctx.textAlign = 'center';
+                            ctx.textBaseline = 'middle';
+                            
+                            const x = drawItem.x * zoomScale + offsetX;
+                            const y = drawItem.y * zoomScale + offsetY;
+                            
+                            if(drawItem.type==='reduce') {
+                              ctx.fillText('-'+drawItem.score, x, y);  
+                            } else if(drawItem.type==='bonus') {
+                              ctx.fillText('+'+drawItem.score, x, y);  
+                            }
+                            break;
+                          }
+                          
+                          case 2: {
+                            // 绘制横线
+                            console.log("打印需要减去的高度",jHeight);
+                            jHeight=0;
+                            console.log("打印blockList",blockList);
+                            const coords = {
+                              x: this.GetInteger(drawItem.x * zoomScale + offsetX),
+                              y: this.GetInteger(drawItem.y * zoomScale + offsetY - jHeight * zoomScale),
+                              endX: this.GetInteger(drawItem.endX * zoomScale + offsetX),
+                              endY: this.GetInteger(drawItem.endY * zoomScale + offsetY - jHeight * zoomScale)
+                            };
+                            this.DrawHorizontalLine(coords.x, coords.y, coords.endX, coords.endY,ctx);
+                            break;
+                          }
+                          
+                          case 3: {
+                            // 绘制波浪线
+                            const coords = {
+                              startX: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
+                              startY: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2)),
+                              endX: parseFloat((drawItem.endX * zoomScale + offsetX).toFixed(2)),
+                              endY: parseFloat((drawItem.endY * zoomScale + offsetY).toFixed(2))
+                            };
+                            this.DrawWaveLine(coords.startX, coords.startY, coords.endX, coords.endY,ctx);
+                            break;
+                          }
+                          
+                          case 4:
+                            // 绘制画笔数据
+                            this.DrawPenLine(drawItem,blockPoint,zoomRate,scale,ctx);
+                            break;
+                          
+                          case 5: {
+                            // 绘制评语
+                            const coords = {
+                              x: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
+                              y: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2))
+                            };
+                            this.DrawText(coords.x, coords.y, drawItem.text,ctx);
+                            break;
+                          }
+                          
+                          default:
+                            console.warn('未知的绘图类型:', drawItem.drawType);
+                        }
+                      }
+                      
+                    })
+                  }
                   
-              //   }
-              //   else if(drawItem.drawType==2)
-              //   {
-              //     //绘制横线
-              //     console.log("打印需要减去的高度",jHeight);
-              //     jHeight=0;
-              //     console.log("打印blockList",blockList);
-              //     let drawX=this.GetInteger((drawItem.x+ blockPoint.x)* this.zoomRate * this.scale);
-              //     let drawY=this.GetInteger((drawItem.y+blockPoint.y - jHeight)* this.zoomRate * this.scale);
-              //     let drawEndX=this.GetInteger((drawItem.endX+ blockPoint.x)* this.zoomRate * this.scale);
-              //     let drawEndY=this.GetInteger((drawItem.endY+blockPoint.y - jHeight)* this.zoomRate * this.scale);
-              //     this.DrawHorizontalLine(drawX,drawY,drawEndX,drawEndY);
-              //     // this.DrawHorizontalLine((drawItem.x+ blockPoint.x)* this.zoomRate * this.scale, (drawItem.y+blockPoint.y)* this.zoomRate * this.scale,(drawItem.endX+ blockPoint.x)* this.zoomRate * this.scale, (drawItem.endY+blockPoint.y)* this.zoomRate * this.scale);
-
-              //   }
-              //   else if(drawItem.drawType==3)
-              //   {
-              //     //绘制波浪线
-              //     let startX=parseFloat(((drawItem.x + blockPoint.x)* this.zoomRate * this.scale).toFixed(2));
-              //     let startY=parseFloat(((drawItem.y + blockPoint.y)* this.zoomRate * this.scale).toFixed(2));
-              //     let endX=parseFloat(((drawItem.endX + blockPoint.x)* this.zoomRate * this.scale).toFixed(2));
-              //     let endY=parseFloat(((drawItem.endY +blockPoint.y)* this.zoomRate * this.scale).toFixed(2));
+                });
+              }
+              else
+              {
+                for(const [index, drawItem] of drawLineData.entries()) {
+                  console.log("打印drawItem",drawItem);
+                  // 计算通用的缩放因子,避免重复计算
+                  const zoomScale = zoomRate * scale;
+                  const offsetX = blockPoint.x * zoomScale;
+                  const offsetY = blockPoint.y * zoomScale;
                   
-              //     this.DrawWaveLine(startX, startY,endX, endY);
-              //   }
-              //   else if(drawItem.drawType==4)
-              //   {
-              //     //绘制画笔数据
-              //     // console.log("打印画笔数据",drawItem);
-              //     this.DrawPenLine(drawItem,blockPoint);
-              //   }
-              //   else if(drawItem.drawType==5)
-              //   {
-              //     //绘制评语
-              //     let startX=parseFloat(((drawItem.x + blockPoint.x)* this.zoomRate * this.scale).toFixed(2));
-              //     let startY=parseFloat(((drawItem.y + blockPoint.y)* this.zoomRate * this.scale).toFixed(2));
-              //     // console.log("打印绘制评语数据",drawItem);
-              //     this.DrawText(startX,startY,drawItem.text);
-              //   }
-              // }
-
-              for(const [index, drawItem] of drawLineData.entries()) {
-                console.log("打印drawItem",drawItem);
-                // 计算通用的缩放因子,避免重复计算
-                const zoomScale = zoomRate * scale;
-                const offsetX = blockPoint.x * zoomScale;
-                const offsetY = blockPoint.y * zoomScale;
-                
-                // 扣分点 加分点 标记// 1:文字 (扣分留痕 显示扣分信息)  2:划线  3:波浪线   4:画笔 5:评语
-                switch(drawItem.drawType) {
-                  case 1: {
-                    // 文字类型(扣分点/加分点标记)
-                    const fontSize = Math.max(12, 40 * zoomScale);
-                    ctx.font = `${fontSize}px Arial`;
-                    ctx.fillStyle = '#D81E06';
-                    ctx.textAlign = 'center';
-                    ctx.textBaseline = 'middle';
+                  // 扣分点 加分点 标记// 1:文字 (扣分留痕 显示扣分信息)  2:划线  3:波浪线   4:画笔 5:评语
+                  switch(drawItem.drawType) {
+                    case 1: {
+                      // 文字类型(扣分点/加分点标记)
+                      const fontSize = Math.max(12, 40 * zoomScale);
+                      ctx.font = `${fontSize}px Arial`;
+                      ctx.fillStyle = '#D81E06';
+                      ctx.textAlign = 'center';
+                      ctx.textBaseline = 'middle';
+                      
+                      const x = drawItem.x * zoomScale + offsetX;
+                      const y = drawItem.y * zoomScale + offsetY;
+                      
+                      if(drawItem.type==='reduce') {
+                        ctx.fillText('-'+drawItem.score, x, y);  
+                      } else if(drawItem.type==='bonus') {
+                        ctx.fillText('+'+drawItem.score, x, y);  
+                      }
+                      break;
+                    }
                     
-                    const x = drawItem.x * zoomScale + offsetX;
-                    const y = drawItem.y * zoomScale + offsetY;
+                    case 2: {
+                      // 绘制横线
+                      console.log("打印需要减去的高度",jHeight);
+                      jHeight=0;
+                      console.log("打印blockList",blockList);
+                      const coords = {
+                        x: this.GetInteger(drawItem.x * zoomScale + offsetX),
+                        y: this.GetInteger(drawItem.y * zoomScale + offsetY - jHeight * zoomScale),
+                        endX: this.GetInteger(drawItem.endX * zoomScale + offsetX),
+                        endY: this.GetInteger(drawItem.endY * zoomScale + offsetY - jHeight * zoomScale)
+                      };
+                      this.DrawHorizontalLine(coords.x, coords.y, coords.endX, coords.endY,ctx);
+                      break;
+                    }
                     
-                    if(drawItem.type==='reduce') {
-                      ctx.fillText('-'+drawItem.score, x, y);  
-                    } else if(drawItem.type==='bonus') {
-                      ctx.fillText('+'+drawItem.score, x, y);  
+                    case 3: {
+                      // 绘制波浪线
+                      const coords = {
+                        startX: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
+                        startY: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2)),
+                        endX: parseFloat((drawItem.endX * zoomScale + offsetX).toFixed(2)),
+                        endY: parseFloat((drawItem.endY * zoomScale + offsetY).toFixed(2))
+                      };
+                      this.DrawWaveLine(coords.startX, coords.startY, coords.endX, coords.endY,ctx);
+                      break;
                     }
-                    break;
+                    
+                    case 4:
+                      // 绘制画笔数据
+                      this.DrawPenLine(drawItem,blockPoint,zoomRate,scale,ctx);
+                      break;
+                    
+                    case 5: {
+                      // 绘制评语
+                      const coords = {
+                        x: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
+                        y: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2))
+                      };
+                      this.DrawText(coords.x, coords.y, drawItem.text,ctx);
+                      break;
+                    }
+                    
+                    default:
+                      console.warn('未知的绘图类型:', drawItem.drawType);
                   }
+                }
+              }
+             
+
+              // for(const [index, drawItem] of drawLineData.entries()) {
+              //   console.log("打印drawItem",drawItem);
+              //   // 计算通用的缩放因子,避免重复计算
+              //   const zoomScale = zoomRate * scale;
+              //   const offsetX = blockPoint.x * zoomScale;
+              //   const offsetY = blockPoint.y * zoomScale;
+                
+              //   // 扣分点 加分点 标记// 1:文字 (扣分留痕 显示扣分信息)  2:划线  3:波浪线   4:画笔 5:评语
+              //   switch(drawItem.drawType) {
+              //     case 1: {
+              //       // 文字类型(扣分点/加分点标记)
+              //       const fontSize = Math.max(12, 40 * zoomScale);
+              //       ctx.font = `${fontSize}px Arial`;
+              //       ctx.fillStyle = '#D81E06';
+              //       ctx.textAlign = 'center';
+              //       ctx.textBaseline = 'middle';
+                    
+              //       const x = drawItem.x * zoomScale + offsetX;
+              //       const y = drawItem.y * zoomScale + offsetY;
+                    
+              //       if(drawItem.type==='reduce') {
+              //         ctx.fillText('-'+drawItem.score, x, y);  
+              //       } else if(drawItem.type==='bonus') {
+              //         ctx.fillText('+'+drawItem.score, x, y);  
+              //       }
+              //       break;
+              //     }
                   
-                  case 2: {
-                    // 绘制横线
-                    console.log("打印需要减去的高度",jHeight);
-                    jHeight=0;
-                    console.log("打印blockList",blockList);
-                    const coords = {
-                      x: this.GetInteger(drawItem.x * zoomScale + offsetX),
-                      y: this.GetInteger(drawItem.y * zoomScale + offsetY - jHeight * zoomScale),
-                      endX: this.GetInteger(drawItem.endX * zoomScale + offsetX),
-                      endY: this.GetInteger(drawItem.endY * zoomScale + offsetY - jHeight * zoomScale)
-                    };
-                    this.DrawHorizontalLine(coords.x, coords.y, coords.endX, coords.endY);
-                    break;
-                  }
+              //     case 2: {
+              //       // 绘制横线
+              //       console.log("打印需要减去的高度",jHeight);
+              //       jHeight=0;
+              //       console.log("打印blockList",blockList);
+              //       const coords = {
+              //         x: this.GetInteger(drawItem.x * zoomScale + offsetX),
+              //         y: this.GetInteger(drawItem.y * zoomScale + offsetY - jHeight * zoomScale),
+              //         endX: this.GetInteger(drawItem.endX * zoomScale + offsetX),
+              //         endY: this.GetInteger(drawItem.endY * zoomScale + offsetY - jHeight * zoomScale)
+              //       };
+              //       this.DrawHorizontalLine(coords.x, coords.y, coords.endX, coords.endY);
+              //       break;
+              //     }
                   
-                  case 3: {
-                    // 绘制波浪线
-                    const coords = {
-                      startX: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
-                      startY: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2)),
-                      endX: parseFloat((drawItem.endX * zoomScale + offsetX).toFixed(2)),
-                      endY: parseFloat((drawItem.endY * zoomScale + offsetY).toFixed(2))
-                    };
-                    this.DrawWaveLine(coords.startX, coords.startY, coords.endX, coords.endY);
-                    break;
-                  }
+              //     case 3: {
+              //       // 绘制波浪线
+              //       const coords = {
+              //         startX: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
+              //         startY: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2)),
+              //         endX: parseFloat((drawItem.endX * zoomScale + offsetX).toFixed(2)),
+              //         endY: parseFloat((drawItem.endY * zoomScale + offsetY).toFixed(2))
+              //       };
+              //       this.DrawWaveLine(coords.startX, coords.startY, coords.endX, coords.endY);
+              //       break;
+              //     }
                   
-                  case 4:
-                    // 绘制画笔数据
-                    this.DrawPenLine(drawItem,blockPoint);
-                    break;
+              //     case 4:
+              //       // 绘制画笔数据
+              //       this.DrawPenLine(drawItem,blockPoint);
+              //       break;
                   
-                  case 5: {
-                    // 绘制评语
-                    const coords = {
-                      x: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
-                      y: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2))
-                    };
-                    this.DrawText(coords.x, coords.y, drawItem.text);
-                    break;
-                  }
+              //     case 5: {
+              //       // 绘制评语
+              //       const coords = {
+              //         x: parseFloat((drawItem.x * zoomScale + offsetX).toFixed(2)),
+              //         y: parseFloat((drawItem.y * zoomScale + offsetY).toFixed(2))
+              //       };
+              //       this.DrawText(coords.x, coords.y, drawItem.text);
+              //       break;
+              //     }
                   
-                  default:
-                    console.warn('未知的绘图类型:', drawItem.drawType);
-                }
-              }
+              //     default:
+              //       console.warn('未知的绘图类型:', drawItem.drawType);
+              //   }
+              // }
 
               
             }
@@ -805,6 +916,76 @@ export default {
         }
     },
 
+    //寻找对象在数组中的索引
+    FindBlockIndex(targetObj,arr)
+    {
+       // 累计高度,用来确定对象位于哪个区间
+      let cumulativeHeight = 0;
+      
+      for (let i = 0; i < arr.length; i++) {
+        const item = arr[i];
+        if(targetObj.drawType==4)
+        {
+          //画笔判断
+          if (targetObj.drawlineData[0].y >= cumulativeHeight && targetObj.drawlineData[0].y < cumulativeHeight + item.h) {
+            
+            return i; // 返回匹配的索引
+          }
+        }
+        else
+        {
+           // 检查目标对象的y值是否在当前区间的范围内
+          if (targetObj.y >= cumulativeHeight && targetObj.y < cumulativeHeight + item.h) {
+            return i; // 返回匹配的索引
+          }
+        }
+       
+        
+        // 累计高度,为下一个区间的起始位置
+        cumulativeHeight += item.h;
+      }
+      
+      return -1; // 如果没有找到匹配的区间,返回-1
+    },
+
+    //寻找对象在数组中的对象
+    FindTargetObj(targetObj,arr)
+    {
+       // 累计高度,用来确定对象位于哪个区间
+      let cumulativeHeight = 0;
+      
+      for (let i = 0; i < arr.length; i++) {
+        const item = arr[i];
+        
+       
+        // 判断画笔
+        if(targetObj.drawType==4)
+        {
+          
+          if (targetObj.drawlineData[0].y >= cumulativeHeight && targetObj.drawlineData[0].y < cumulativeHeight + item.h) {
+            
+            targetObj.drawlineData.forEach((item,index) => {
+              item.y=item.y-cumulativeHeight;
+            });
+          }
+        }
+        else
+        {
+           // 检查目标对象的y值是否在当前区间的范围内
+          if (targetObj.y >= cumulativeHeight && targetObj.y < cumulativeHeight + item.h) {
+            targetObj.y=targetObj.y-cumulativeHeight;
+          
+          }
+        }
+
+        
+        // 累计高度,为下一个区间的起始位置
+        cumulativeHeight += item.h;
+      }
+      
+      return targetObj;  
+    },
+
 
 
     //初始数据加载

+ 1 - 1
version.json

@@ -1,5 +1,5 @@
 {
-  "version": "0.1.3_2025_12_26_0",
+  "version": "0.1.3_2026_1_9_0",
   "content": [
     {
       "time": "2024-11-1",

+ 14 - 6
vue.config.js

@@ -17,6 +17,14 @@ module.exports = {
       args[0].title = "慧教研-大数据精准教学诊断平台";
       return args
     }) 
+    // 根据环境配置是否移除 console
+    if (process.env.NODE_ENV === 'production') {
+      config.optimization.minimizer('terser').tap((args) => {
+        args[0].terserOptions.compress.drop_console = true;
+        args[0].terserOptions.compress.drop_debugger = true;
+        return args;
+      });
+    }
   },
   publicPath: process.env.NODE_ENV === 'production' ? '/stu/' : '/',// /studata/ 生产环境(打包后)使用目标路径;/ 开发环境(npm run serve)使用根路径,不影响本地开发
   configureWebpack: {
@@ -26,16 +34,16 @@ module.exports = {
         new TerserPlugin({
           terserOptions: {
             compress: {
-              drop_console: true,//// 移除所有 console.*
-              drop_debugger: true,//// 移除所有 debugger.*
-              pure_funcs: ["console.log"],
+              drop_console: process.env.NODE_ENV === 'production', // 只在生产环境移除 console
+              drop_debugger: process.env.NODE_ENV === 'production', // 只在生产环境移除 debugger
+              pure_funcs: process.env.NODE_ENV === 'production' ? ['console.log', 'console.info', 'console.warn', 'console.error'] : [],
             },
           },
         }),
       ],
     },
     name: "教学管理大数据平台",
-    devtool: "source-map",
+    // devtool: "source-map",
     // entry:'./public/index.html',
     // resolve:{},
     // output:{
@@ -89,8 +97,8 @@ module.exports = {
     },
     proxy: {
       "/api": {
-        target: "https://dev3.k12100.net/student/api/",
-        // target: "https://www.k12100.com/student/api/",
+        // target: "https://dev3.k12100.net/student/api/",
+        target: "https://www.k12100.com/student/api/",
         changeOrigin: true,
         pathRewrite: {
           "^/api": "/",