Przeglądaj źródła

裁切图按照比率裁切的数值里,h为1导致的bug修复

刘洋 2 lat temu
rodzic
commit
fb09022bf5
5 zmienionych plików z 59 dodań i 43 usunięć
  1. 0 6
      components.d.ts
  2. 20 17
      src/devLoginParams.ts
  3. 15 13
      src/features/mark/CommonMarkBody.vue
  4. 22 5
      src/utils/utils.ts
  5. 2 2
      vite.config.ts

+ 0 - 6
components.d.ts

@@ -8,7 +8,6 @@ export {}
 declare module '@vue/runtime-core' {
   export interface GlobalComponents {
     AButton: typeof import('ant-design-vue/es')['Button']
-    ACol: typeof import('ant-design-vue/es')['Col']
     AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider']
     ADropdown: typeof import('ant-design-vue/es')['Dropdown']
     AForm: typeof import('ant-design-vue/es')['Form']
@@ -19,14 +18,9 @@ declare module '@vue/runtime-core' {
     AModal: typeof import('ant-design-vue/es')['Modal']
     APopconfirm: typeof import('ant-design-vue/es')['Popconfirm']
     APopover: typeof import('ant-design-vue/es')['Popover']
-    ARadio: typeof import('ant-design-vue/es')['Radio']
-    ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup']
-    ARow: typeof import('ant-design-vue/es')['Row']
-    ASelect: typeof import('ant-design-vue/es')['Select']
     ASlider: typeof import('ant-design-vue/es')['Slider']
     ASpin: typeof import('ant-design-vue/es')['Spin']
     ASwitch: typeof import('ant-design-vue/es')['Switch']
-    ATextarea: typeof import('ant-design-vue/es')['Textarea']
     ATooltip: typeof import('ant-design-vue/es')['Tooltip']
     CommonMarkHeader: typeof import('./src/components/CommonMarkHeader.vue')['default']
     PageError404: typeof import('./src/components/PageError404.vue')['default']

+ 20 - 17
src/devLoginParams.ts

@@ -37,28 +37,31 @@
 // };
 
 //线上数据
+// export const LOGIN_CONFIG = {
+//   isAdmin: true,
+//   forceChange: true,
+//   loginName: "6-101-6",
+//   // loginName: "spj432-01",
+//   // loginName: "liuyang",
+//   password: "1234567",
+//   examId: "611",
+//   // markerId: "17125",
+//   // markerId: "2692",
+//   markerId: "482",
+//   // markerId: "483",
+// };
+/** 224 管理员 */
 export const LOGIN_CONFIG = {
-  isAdmin: true,
+  isAdmin: false,
   forceChange: true,
-  loginName: "6-101-6",
-  // loginName: "spj432-01",
+  loginName: "6-X-M_pj01",
   // loginName: "liuyang",
-  password: "1234567",
-  examId: "611",
-  // markerId: "17125",
-  // markerId: "2692",
-  markerId: "482",
+  password: "123456",
+  examId: "432",
+  markerId: "3123",
+  // markerId: "482",
   // markerId: "483",
 };
-/** 224 管理员 */
-// export const LOGIN_CONFIG = {
-//   isAdmin: true,
-//   forceChange: true,
-//   loginName: "admin-test",
-//   password: "123456",
-//   examId: "1",
-//   markerId: "339",
-// };
 
 /** 255 评卷员 */
 // export const LOGIN_CONFIG = {

+ 15 - 13
src/features/mark/CommonMarkBody.vue

@@ -70,9 +70,11 @@
         {{ store.currentQuestion?.mainNumber }}-{{
           store.currentQuestion?.subNumber
         }}({{
-          store.currentTask?.markResult?store.currentTask?.markResult.scoreList[
-            store.currentQuestion?.__index || 0
-          ] : " "
+          store.currentTask?.markResult
+            ? store.currentTask?.markResult.scoreList[
+                store.currentQuestion?.__index || 0
+              ]
+            : " "
         }})
       </div>
       <div class="text">
@@ -203,20 +205,20 @@ async function processSliceConfig() {
     const image = await loadImage(url);
     images[sliceConfig.i] = image;
     const { x, y, w, h } = sliceConfig;
-    
+    x < 0 && (sliceConfig.x = 0);
+    y < 0 && (sliceConfig.y = 0);
     if (sliceConfig.w === 0 && sliceConfig.h === 0) {
       // 选择整图时,w/h 为0
       sliceConfig.w = image.naturalWidth;
       sliceConfig.h = image.naturalHeight;
     }
 
-    if (x < 1 && y < 1 && w < 1 && h < 1) {
-      sliceConfig.x = (image.naturalWidth * x);
-      sliceConfig.y = (image.naturalHeight * y);
-      sliceConfig.w = (image.naturalWidth * w);
-      sliceConfig.h = (image.naturalHeight * h);
+    if (x <= 1 && y <= 1 && w <= 1 && h <= 1) {
+      sliceConfig.x = image.naturalWidth * x;
+      sliceConfig.y = image.naturalHeight * y;
+      sliceConfig.w = image.naturalWidth * w;
+      sliceConfig.h = image.naturalHeight * h;
     }
-    
   }
 
   theFinalHeight = store.currentTask.sliceConfig
@@ -460,8 +462,8 @@ async function processSplitConfig() {
 // should not render twice at the same time
 let renderLock = false;
 const renderPaperAndMark = async () => {
-  console.log('renderPagerAndMark=>store.curTask:',store.currentTask);
-  
+  console.log("renderPagerAndMark=>store.curTask:", store.currentTask);
+
   if (!store.currentTask) return;
   if (!store.isScanImage) return;
   if (renderLock) {
@@ -515,7 +517,7 @@ const renderPaperAndMark = async () => {
 watch(
   () => store.currentTask,
   () => {
-    setTimeout(renderPaperAndMark,50)
+    setTimeout(renderPaperAndMark, 50);
   }
 );
 //#endregion : 计算裁切图和裁切图上的分数轨迹和特殊标记轨迹

+ 22 - 5
src/utils/utils.ts

@@ -168,8 +168,8 @@ export async function getDataUrlForSplitConfig(
 }
 
 export async function preDrawImage(_currentTask: Task | undefined) {
-  console.log('preDrawImage=>curTask:',store.currentTask);
-  
+  console.log("preDrawImage=>curTask:", store.currentTask);
+
   if (!_currentTask?.libraryId) return;
 
   let maxSliceWidth = 0; // 最大的裁切块宽度,图片容器以此为准
@@ -192,11 +192,20 @@ export async function preDrawImage(_currentTask: Task | undefined) {
       const url = _currentTask.sliceUrls[sliceConfig.i - 1];
       const image = await loadImage(url);
       images[sliceConfig.i] = image;
+      const { x, y, w, h } = sliceConfig;
+      x < 0 && (sliceConfig.x = 0);
+      y < 0 && (sliceConfig.y = 0);
       if (sliceConfig.w === 0 && sliceConfig.h === 0) {
         // 选择整图时,w/h 为0
         sliceConfig.w = image.naturalWidth;
         sliceConfig.h = image.naturalHeight;
       }
+      if (x <= 1 && y <= 1 && w <= 1 && h <= 1) {
+        sliceConfig.x = image.naturalWidth * x;
+        sliceConfig.y = image.naturalHeight * y;
+        sliceConfig.w = image.naturalWidth * w;
+        sliceConfig.h = image.naturalHeight * h;
+      }
     }
 
     maxSliceWidth = Math.max(..._currentTask.sliceConfig.map((v) => v.w));
@@ -245,8 +254,8 @@ export async function preDrawImage(_currentTask: Task | undefined) {
 }
 
 export async function preDrawImageHistory(_currentTask: Task | undefined) {
-  console.log('preDrawImageHistory=>curTask:',store.currentTask);
-  
+  console.log("preDrawImageHistory=>curTask:", store.currentTask);
+
   if (!_currentTask?.libraryId) return;
 
   let maxSliceWidth = 0; // 最大的裁切块宽度,图片容器以此为准
@@ -269,11 +278,20 @@ export async function preDrawImageHistory(_currentTask: Task | undefined) {
       const url = _currentTask.sliceUrls[sliceConfig.i - 1];
       const image = await loadImage(url);
       images[sliceConfig.i] = image;
+      const { x, y, w, h } = sliceConfig;
+      x < 0 && (sliceConfig.x = 0);
+      y < 0 && (sliceConfig.y = 0);
       if (sliceConfig.w === 0 && sliceConfig.h === 0) {
         // 选择整图时,w/h 为0
         sliceConfig.w = image.naturalWidth;
         sliceConfig.h = image.naturalHeight;
       }
+      if (x <= 1 && y <= 1 && w <= 1 && h <= 1) {
+        sliceConfig.x = image.naturalWidth * x;
+        sliceConfig.y = image.naturalHeight * y;
+        sliceConfig.w = image.naturalWidth * w;
+        sliceConfig.h = image.naturalHeight * h;
+      }
     }
 
     maxSliceWidth = Math.max(..._currentTask.sliceConfig.map((v) => v.w));
@@ -321,7 +339,6 @@ export async function preDrawImageHistory(_currentTask: Task | undefined) {
   }
 }
 
-
 export function addFileServerPrefixToTask(rawTask: Task): Task {
   const newTask = JSON.parse(JSON.stringify(rawTask)) as Task;
 

+ 2 - 2
vite.config.ts

@@ -3,8 +3,8 @@ import vue from "@vitejs/plugin-vue";
 import ViteComponents from "unplugin-vue-components/vite";
 import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
 
-// const SERVER_URL = "http://192.168.10.224";
-const SERVER_URL = "https://www.markingcloud.com";
+const SERVER_URL = "http://192.168.10.225";
+// const SERVER_URL = "https://www.markingcloud.com";
 const path = require("path");
 
 function mockDevLogin(): Plugin {