Browse Source

增加参数

caner 1 year ago
parent
commit
e06e99d64a
1 changed files with 13 additions and 6 deletions
  1. 13 6
      src/pages/views/draw/index.vue

+ 13 - 6
src/pages/views/draw/index.vue

@@ -40,6 +40,7 @@ import {
   h, onMounted, onUnmounted, ref
 } from 'vue'
 import { DrawCanvas } from './assets/js/draw'
+import { useRoute } from 'vue-router'
 
 const drawCanvas = new DrawCanvas()
 const options = [
@@ -204,16 +205,17 @@ const dicTypePath = {
   1: 'M69.4545878,34.6718448 C96.0319839,14.5464002 130.907219,-0.146079872 174.56443,0.522007913 C220.382312,1.22316053 255.607386,15.5063115 281.851378,35.1514114 C318.898628,62.8833568 338.052622,101.292047 343.850748,127.226896 C348.964999,150.102793 350.773132,170.630546 348.624737,186.798399 C346.628206,201.8234 341.223483,213.080679 331.813382,218.873688 C331.442887,219.101769 331.054704,219.344664 330.644655,219.601247 C319.902715,226.322867 294.07793,242.444674 177.407992,247.500112 C92.0383303,246.776789 19.7179823,226.018176 9.91797058,212.791135 C-0.632619328,198.551039 -1.84542038,163.783447 3.98419444,129.673937 C7.51590663,109.009626 28.7726098,65.4778309 69.4545878,34.6718448 Z',
   0: 'M175.000036,0.5 C222.664535,0.5 265.865535,21.1909654 297.358963,54.7296453 C328.90593,88.3253418 348.705559,134.812441 349.476653,186.303442 L349.490723,188.280824 L349.5,247.5 L0.5,247.5 L0.5,188.283766 C0.787224943,136.359137 20.4197058,89.3998566 51.9881066,55.4283849 C83.5364037,21.4785471 127.005458,0.5 175.000036,0.5 Z'
 }
+const dicType = ref(0)
 const angle = ref(0)
 const btns = [
   { name: '撤销', fn: () => drawCanvas.pathBack(), type: 'tertiary' },
   { name: '清空', fn: () => drawCanvas.pathClear(), type: 'tertiary' },
-  {
-    name: '保存',
+  {
+    name: '保存',
     fn: () => drawCanvas.pathSave((data) => {
-      console.log('数据', data)
-    }),
-    type: 'info'
+      console.log('数据', data)
+    }),
+    type: 'info'
   }
 ]
 
@@ -246,10 +248,15 @@ function changeOption(_: null, option: { label: string; icon: string; value: num
 
 onMounted(() => {
   document.title = 'H5 canvas画图'
+  const route = useRoute()
+  const { query } = route
+  if (query.type) {
+    dicType.value = +query.type
+  }
   const canvas = document.getElementById('CANVAS')
   drawCanvas._init({
     canvas,
-    dicTypePath: dicTypePath[0],
+    dicTypePath: dicTypePath[dicType.value],
     callBack: () => {
       changeOption(null, options[check.value])
     }