Commit 0d8ef1936cc64a81425b8a7abb24624ed9b9db1e

Authored by fengwotao
1 parent d8b6a8a4

perf(src/hooks): 增加空保护,tab切换暂时支持单个组件切换

@@ -19,11 +19,9 @@ export const useChartInteract = ( @@ -19,11 +19,9 @@ export const useChartInteract = (
19 interactEventOn: string 19 interactEventOn: string
20 ) => { 20 ) => {
21 /**新增代码 */ 21 /**新增代码 */
22 - let combineData: any = null  
23 const { 22 const {
24 option: { dataset } 23 option: { dataset }
25 } = chartConfig 24 } = chartConfig
26 - combineData = dataset  
27 const { data } = param 25 const { data } = param
28 /**新增代码 */ 26 /**新增代码 */
29 const chartEditStore = useChartEditStore() 27 const chartEditStore = useChartEditStore()
@@ -46,7 +44,8 @@ export const useChartInteract = ( @@ -46,7 +44,8 @@ export const useChartInteract = (
46 } 44 }
47 }) 45 })
48 /**新增代码 */ 46 /**新增代码 */
49 - combineData.forEach((combinItem: any, combinIndex: number) => { 47 + if (!Array.isArray(dataset)) return
  48 + dataset.forEach((combinItem: any, combinIndex: number) => {
50 if (itemIndex === combinIndex) { 49 if (itemIndex === combinIndex) {
51 combinItem.targetItem = chartEditStore.componentList[index] 50 combinItem.targetItem = chartEditStore.componentList[index]
52 } 51 }
@@ -54,14 +53,15 @@ export const useChartInteract = ( @@ -54,14 +53,15 @@ export const useChartInteract = (
54 /**新增代码 */ 53 /**新增代码 */
55 }) 54 })
56 /**新增代码 */ 55 /**新增代码 */
57 - combineData.forEach((item: any) => { 56 + if (!Array.isArray(dataset)) return
  57 + dataset.forEach((item: any) => {
58 try { 58 try {
59 if (item.value === data) item.targetItem.status.hide = false 59 if (item.value === data) item.targetItem.status.hide = false
60 else { 60 else {
61 item.targetItem.status.hide = true 61 item.targetItem.status.hide = true
62 } 62 }
63 } catch (e) { 63 } catch (e) {
64 - console.log(`useChartInteract.hook.ts:${e}`) 64 + console.log(`Error: useChartInteract.hook.ts:${e}`)
65 } 65 }
66 }) 66 })
67 /**新增代码 */ 67 /**新增代码 */