Jelajahi Sumber

feat(devicetree): support custom-transform prop

Casper Dai 2 tahun lalu
induk
melakukan
8497b9e353
1 mengubah file dengan 15 tambahan dan 2 penghapusan
  1. 15 2
      src/components/tree/DeviceTree/index.vue

+ 15 - 2
src/components/tree/DeviceTree/index.vue

@@ -74,6 +74,10 @@ export default {
     filter: {
       type: Function,
       default: null
+    },
+    customTransform: {
+      type: Function,
+      default: null
     }
   },
   data () {
@@ -199,9 +203,18 @@ export default {
         ]
       }
     },
-    transform ({ id, name, productId }) {
+    transform (device) {
+      const { id, name, productId } = device
+      if (this.customTransform) {
+        return {
+          id, name, productId,
+          ...this.customTransform(device)
+        }
+      }
       return {
-        id, name, productId
+        id,
+        name,
+        productId
       }
     },
     setCache (device, { key, ids, map, cache }) {