zydx-plus 1.35.605 → 1.35.606
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.
- package/package.json +1 -1
- package/src/components/mind/src/mind.vue +9 -21
- package/src/index.js +1 -1
package/package.json
CHANGED
|
@@ -136,7 +136,7 @@ export default {
|
|
|
136
136
|
this.id = this.randomId()
|
|
137
137
|
setTimeout(() => {
|
|
138
138
|
this.init()
|
|
139
|
-
const resizeObserver = new ResizeObserver(this.
|
|
139
|
+
const resizeObserver = new ResizeObserver(this.debounce(this.resizeCallback, 300));
|
|
140
140
|
resizeObserver.observe(this.$refs[this.id]);
|
|
141
141
|
}, 0)
|
|
142
142
|
window.onresize = () => {
|
|
@@ -147,33 +147,21 @@ export default {
|
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
149
|
methods: {
|
|
150
|
-
resizeCallback
|
|
150
|
+
resizeCallback(entries) {
|
|
151
151
|
entries.forEach(entry => {
|
|
152
152
|
this.mindMap?.resize()
|
|
153
153
|
});
|
|
154
154
|
},
|
|
155
|
-
|
|
156
|
-
let
|
|
157
|
-
let timer = null; // 定时器标识
|
|
155
|
+
debounce(fn, delay = 500) {
|
|
156
|
+
let timer = null; // 定时器标识,用于重置延迟
|
|
158
157
|
|
|
159
158
|
return function (...args) {
|
|
160
|
-
|
|
161
|
-
const remainingTime = delay - (currentTime - lastExecuteTime); // 距离下次可执行的剩余时间
|
|
162
|
-
|
|
163
|
-
// 清除之前的定时器(避免重复触发)
|
|
159
|
+
// 每次触发时,清除之前的定时器(重置延迟)
|
|
164
160
|
clearTimeout(timer);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
lastExecuteTime = currentTime; // 更新上一次执行时间
|
|
170
|
-
} else {
|
|
171
|
-
// 2. 否则,设置定时器,在剩余时间后执行一次(避免最后一次变化不触发)
|
|
172
|
-
timer = setTimeout(() => {
|
|
173
|
-
fn.apply(this, args);
|
|
174
|
-
lastExecuteTime = Date.now();
|
|
175
|
-
}, remainingTime);
|
|
176
|
-
}
|
|
161
|
+
// 重新设置定时器,延迟执行目标函数
|
|
162
|
+
timer = setTimeout(() => {
|
|
163
|
+
fn.apply(this, args); // 保证this指向和参数传递正常
|
|
164
|
+
}, delay);
|
|
177
165
|
};
|
|
178
166
|
},
|
|
179
167
|
lineToolSelect(v) {
|