Browse Source

双评功能对userId为0的情况处理

刘洋 1 year ago
parent
commit
121c00792b
3 changed files with 8 additions and 4 deletions
  1. 1 1
      package.json
  2. 4 1
      src/features/ImageDownload/ImageDownload.vue
  3. 3 2
      src/lib/watermark.ts

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "stmmsproxy",
   "name": "stmmsproxy",
-  "version": "1.3.2",
+  "version": "1.3.3",
   "private": true,
   "private": true,
   "scripts": {
   "scripts": {
     "start": "vue-cli-service serve",
     "start": "vue-cli-service serve",

+ 4 - 1
src/features/ImageDownload/ImageDownload.vue

@@ -131,7 +131,8 @@ onMounted(async () => {
         for (const student of students) {
         for (const student of students) {
           let allTags = Object.values(student.tags || {})
           let allTags = Object.values(student.tags || {})
             .filter((x) => !!x)
             .filter((x) => !!x)
-            .flat();
+            .flat()
+            .filter((v: any) => v.userId != 0);
           allTags.forEach((item: any) => {
           allTags.forEach((item: any) => {
             if (
             if (
               allTags.find((v: any) => {
               allTags.find((v: any) => {
@@ -199,6 +200,7 @@ onMounted(async () => {
               // colorMap[groupNumber + ""][tag.userId + ""] = c;
               // colorMap[groupNumber + ""][tag.userId + ""] = c;
             }
             }
           }
           }
+          console.log("allTags:", allTags);
           // console.log("colorMap:", colorMap);
           // console.log("colorMap:", colorMap);
           let resultImgList: any[] = [];
           let resultImgList: any[] = [];
           let sheetUrlsLength = (student.sheetUrls || []).length;
           let sheetUrlsLength = (student.sheetUrls || []).length;
@@ -240,6 +242,7 @@ onMounted(async () => {
               // console.log(await imageRes.data.arrayBuffer());
               // console.log(await imageRes.data.arrayBuffer());
               // console.log(new Uint8Array(await imageRes.data.arrayBuffer()));
               // console.log(new Uint8Array(await imageRes.data.arrayBuffer()));
               let onlyUsePdf = config.pdf == "2";
               let onlyUsePdf = config.pdf == "2";
+              console.log("colorMap:", colorMap);
               let fileLocation = await window.electron.addWatermark(
               let fileLocation = await window.electron.addWatermark(
                 storePassedToNodeJs,
                 storePassedToNodeJs,
                 arrayBuffer,
                 arrayBuffer,

+ 3 - 2
src/lib/watermark.ts

@@ -253,7 +253,6 @@ export async function addWatermark(
     const height = fontSize + 10;
     const height = fontSize + 10;
     // imgData.font(fontFile, fontSize).fill(color);
     // imgData.font(fontFile, fontSize).fill(color);
     const tags = student.tags[index];
     const tags = student.tags[index];
-
     for (let i = 0; i < tags.length; i++) {
     for (let i = 0; i < tags.length; i++) {
       const tag = tags[i];
       const tag = tags[i];
       if (
       if (
@@ -263,7 +262,9 @@ export async function addWatermark(
       ) {
       ) {
         let top = tag.top;
         let top = tag.top;
         const c =
         const c =
-          tag.userRole && tag.userRole !== "MARKER"
+          tag.userId == 0
+            ? color
+            : tag.userRole && tag.userRole !== "MARKER"
             ? headerColorMap[tag.groupNumber + ""][tag.userId + ""]
             ? headerColorMap[tag.groupNumber + ""][tag.userId + ""]
             : colorMap[tag.groupNumber + ""][tag.userId + ""];
             : colorMap[tag.groupNumber + ""][tag.userId + ""];
         imgData.font(fontFile, fontSize).fill(c);
         imgData.font(fontFile, fontSize).fill(c);