Sfoglia il codice sorgente

feat(draw): update

gemercheung 1 anno fa
parent
commit
f7a3da41d2
3 ha cambiato i file con 26 aggiunte e 111 eliminazioni
  1. 10 8
      src/core/player/Player.js
  2. 5 98
      src/core/save.json
  3. 11 5
      src/view/case/photos/index.vue

+ 10 - 8
src/core/player/Player.js

@@ -399,18 +399,20 @@ export default class Player {
     if (this.scene.sceneType === 1) {
       data = {
         hor_lines: this.renderLines,
-        activeEdges: this.activeEdges,
-        vir_lines: [],
+        hor_activeEdges: this.activeEdges,
         hor_markers: this.renderMarkers,
+        vir_lines: [],
+        vir_activeEdges: [],
         vir_markers: [],
       };
     } else {
       data = {
         hor_lines: [],
+        hor_activeEdges: [],
+        hor_markers: [],
         vir_lines: this.renderLines,
-        activeEdges: this.activeEdges,
+        vir_activeEdges: this.activeEdges,
         vir_markers: this.renderMarkers,
-        hor_markers: [],
       };
     }
 
@@ -425,8 +427,8 @@ export default class Player {
   load(type, data) {
     if (type === 1) {
       console.log("data1", data);
-      const { activeEdges, hor_lines, hor_markers } = data;
-      activeEdges && (this.activeEdges = activeEdges);
+      const { hor_activeEdges, hor_lines, hor_markers } = data;
+      hor_activeEdges && (this.activeEdges = hor_activeEdges);
       if (hor_lines && Array.isArray(hor_lines)) {
         this.renderLines = hor_lines;
         hor_lines.forEach((line) => {
@@ -446,8 +448,8 @@ export default class Player {
     }
 
     if (type === 2) {
-      const { activeEdges, vir_lines, vir_markers } = data;
-      activeEdges && (this.activeEdges = activeEdges);
+      const { vir_activeEdges, vir_lines, vir_markers } = data;
+      vir_activeEdges && (this.activeEdges = vir_activeEdges);
       if (vir_lines && Array.isArray(vir_lines)) {
         this.renderLines = vir_lines;
         vir_lines.forEach((line) => {

+ 5 - 98
src/core/save.json

@@ -1,101 +1,8 @@
 {
-    "hor_lines": [
-        [
-            -1.6917142333984378,
-            5,
-            -0.7278826776845879,
-            -1.1831426391601565,
-            5,
-            -0.7278826776845879,
-            -1.1831426391601565,
-            5,
-            -0.7873111444814335,
-            -0.8250000000000002,
-            5,
-            -0.7873111444814335
-        ],
-        [
-            -1.6962850341796878,
-            5,
-            0.4675462773929395,
-            -1.2345708618164064,
-            5,
-            0.4675462773929395,
-            -1.2345708618164064,
-            5,
-            0.55668909965852,
-            -0.8250000000000002,
-            5,
-            0.55668909965852
-        ],
-        [
-            0.4934287109375,
-            5,
-            -0.8261686273915703,
-            0.92771435546875,
-            5,
-            -0.8261686273915703,
-            0.92771435546875,
-            5,
-            -0.8513112055165577,
-            1.2999999999999998,
-            5,
-            -0.8513112055165577
-        ],
-        [
-            -2.004857055664063,
-            5,
-            -1.1964540888171664,
-            -2.004857055664063,
-            5,
-            -1.475,
-            1.6340000000000006,
-            5,
-            -1.475,
-            1.6340000000000006,
-            5,
-            -1.225
-        ]
-    ],
-    "activeEdges": [
-        {
-            "id": 28,
-            "dir": [
-                1
-            ]
-        },
-        {
-            "id": 26,
-            "dir": [
-                1
-            ]
-        },
-        {
-            "id": 12,
-            "dir": [
-                1,
-                0
-            ]
-        }
-    ],
+    "hor_lines": [],
     "vir_lines": [],
-    "hor_markers": [
-        {
-            "id": 8,
-            "point": [
-                -1.7762850341796879,
-                5,
-                -0.9815972162586799
-            ]
-        },
-        {
-            "id": 28,
-            "point": [
-                -0.587714111328125,
-                5,
-                -1.0341686273914663
-            ]
-        }
-    ],
-    "vir_markers": []
+    "hor_markers": [],
+    "vir_markers": [],
+    "hor_activeEdges": [],
+    "vir_activeEdges": []
 }

+ 11 - 5
src/view/case/photos/index.vue

@@ -81,6 +81,7 @@ import { addCaseImgFile } from "../quisk";
 import { saveCaseImgTagData, getCaseImgTagData } from "@/store/case";
 import Scene from "@/core/Scene.js";
 import draggable from "./draggable.vue";
+import { ElMessage } from "element-plus";
 const props = defineProps({ caseId: Number });
 const newlist = ref([]);
 const swiperRef = ref(null);
@@ -89,7 +90,7 @@ const caseId = ref(props.caseId);
 const sortType = ref(false);
 const drawMode = ref(0);
 const isShowExitEdit = computed(() => drawMode.value > 0);
-import { ElMessage } from "element-plus";
+const loadedDrawData = ref();
 const hasDrawData = ref(false);
 let scene = null;
 
@@ -127,11 +128,10 @@ const changeList = async (list) => {
   const arr = [];
   newList.map((i) => arr.push(JSON.parse(JSON.stringify(i))));
   const type = sortType.value ? 2 : 1;
-  const res = await getCaseImgTagData(caseId.value);
 
   if (scene) {
-    scene.load(arr, type, res.data.data || []);
-    console.log("changeList", arr, type, res.data.data);
+    scene.load(arr, type, loadedDrawData.value || []);
+    console.log("changeList", arr, type, data);
   }
 };
 const renderCanvas = () => {
@@ -211,7 +211,13 @@ const handleClear = () => {
   }
 };
 
-onMounted(() => {
+onMounted(async () => {
+  try {
+    const res = await getCaseImgTagData(caseId.value);
+    const { isHorizontal, data } = res.data;
+    sortType.value = !isHorizontal;
+    loadedDrawData.value = data;
+  } catch (error) {}
   renderCanvas();
 });
 </script>