bill 1 年之前
父節點
當前提交
0c12766e6e
共有 2 個文件被更改,包括 17 次插入12 次删除
  1. 2 0
      src/hook/useGraphic.ts
  2. 15 12
      src/views/graphic/container.vue

+ 2 - 0
src/hook/useGraphic.ts

@@ -15,6 +15,7 @@ import type { AccidentPhoto } from "@/store/accidentPhotos";
 import { api } from "@/store/sync";
 import { genUseLoading } from "./useLoading.js";
 import mitt from "mitt";
+import router from "@/router/index.js";
 
 export const bus = mitt();
 export type UITypeT = typeof UIType;
@@ -68,6 +69,7 @@ export const loadData = genUseLoading(
       graphicState.value.canRevoke = false;
     } else {
       drawRef.value.load.clear();
+      router.back();
     }
   }
 );

+ 15 - 12
src/views/graphic/container.vue

@@ -7,32 +7,35 @@
 </template>
 
 <script setup lang="ts">
-import {computed, nextTick, onMounted, ref, watchEffect} from "vue";
-import {setCanvas} from "@/hook/useGraphic";
-import { useData } from './data'
+import { computed, nextTick, onMounted, ref, watchEffect } from "vue";
+import { setCanvas } from "@/hook/useGraphic";
+import { useData } from "./data";
+import router from "@/router";
 
 const drawCanvasRef = ref<HTMLCanvasElement>();
-const data = useData()
+const data = useData();
 
-const stop = watchEffect(() => {
+const stop = watchEffect((oncleanup) => {
   if (drawCanvasRef.value && data.value) {
     setCanvas(drawCanvasRef.value, data);
-    nextTick(stop)
+    nextTick(stop);
+  } else if (!data.value) {
+    const timeout = setTimeout(() => router.back());
+    oncleanup(() => clearTimeout(timeout));
   }
-})
-
+});
 </script>
 
 <style scoped lang="scss">
 .draw-layout {
-  width  : 100%;
-  height : 100%;
+  width: 100%;
+  height: 100%;
   display: flex;
 }
 
 .canvas-layout,
 .draw-canvas {
-  width : 100%;
+  width: 100%;
   height: 100%;
 }
-</style>
+</style>