Sfoglia il codice sorgente

fix: copy component exception

Casper Dai 3 anni fa
parent
commit
da7dcb2aed

+ 5 - 1
src/views/bigscreen/core/base.js

@@ -6,7 +6,11 @@ import {
   updateProgram
 } from '@/api/program'
 import { getAssetUrl } from '@/api/asset'
-import { create, check, toJSON } from './utils'
+import {
+  create,
+  check,
+  toJSON
+} from './utils'
 
 export default {
   provide () {

+ 1 - 4
src/views/bigscreen/core/config-json/live.js

@@ -15,10 +15,7 @@ export default {
       url: ''
     }
   },
-  copy ({ sources, mute, ...widget }) {
-    widget.sources = sources.map(source => {
-      return { ...source }
-    })
+  copy ({ mute, ...widget }) {
     widget.mute = 1
     return widget
   },

+ 4 - 2
src/views/bigscreen/core/utils.js

@@ -51,9 +51,11 @@ export function toJSON (node) {
   return canvas
 }
 
-export function copy ({ id, ...node }) {
-  const copyNode = getOptions(node.type).copy?.(node) || node
+export function copy ({ id, layerName, ...node }) {
+  const widgetOptions = getWidget(node.type)
+  const copyNode = widgetOptions.copy?.(node) || node
   copyNode.id = createID(copyNode.type)
+  copyNode.layerName = widgetOptions.label
   return copyNode
 }