lw-cdp-ui 1.5.55 → 1.5.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,12 +5,13 @@
5
5
  :key="index"
6
6
  :target="step.target"
7
7
  :title="step.title"
8
- :description="step.description" />
8
+ :description="step.description"
9
+ @change="changeStep" />
9
10
  </el-tour>
10
11
  </template>
11
12
 
12
13
  <script>
13
- import { ref, getCurrentInstance, onMounted, nextTick, onUnmounted } from 'vue'
14
+ import { getCurrentInstance, nextTick, onMounted, onUnmounted, ref } from 'vue'
14
15
  import { useRouter } from 'vue-router'
15
16
 
16
17
  export default {
@@ -65,14 +66,6 @@ export default {
65
66
  return document.querySelector(step.css)
66
67
  })
67
68
 
68
- if (!allElementsExist) {
69
- console.warn('元素未加载完成')
70
- setTimeout(() => {
71
- startTour()
72
- }, 100)
73
- return
74
- }
75
-
76
69
  formattedSteps.value = props.steps.map((step) => {
77
70
  const targetElement = document.querySelector(step.css)
78
71
  return {
@@ -108,10 +101,25 @@ export default {
108
101
  $bus.$emit(`lwTourOpen`, true)
109
102
  })
110
103
 
104
+ // 步骤变化时
105
+ const changeStep = (step) => {
106
+ emit('change', step)
107
+ formattedSteps.value = props.steps.map((step) => {
108
+ const targetElement = document.querySelector(step.css)
109
+ return {
110
+ target: targetElement || undefined,
111
+ title: step.title,
112
+ description: step.description,
113
+ placement: 'bottom'
114
+ }
115
+ })
116
+ }
117
+
111
118
  return {
112
119
  formattedSteps,
113
120
  isOpen,
114
- startTour
121
+ startTour,
122
+ changeStep
115
123
  }
116
124
  }
117
125
  }