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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zydx-plus",
3
- "version": "1.35.605",
3
+ "version": "1.35.606",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -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.throttle(this.resizeCallback, 300));
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 (entries) {
150
+ resizeCallback(entries) {
151
151
  entries.forEach(entry => {
152
152
  this.mindMap?.resize()
153
153
  });
154
154
  },
155
- throttle(fn, delay = 300) {
156
- let lastExecuteTime = 0; // 上一次函数执行的时间戳
157
- let timer = null; // 定时器标识
155
+ debounce(fn, delay = 500) {
156
+ let timer = null; // 定时器标识,用于重置延迟
158
157
 
159
158
  return function (...args) {
160
- const currentTime = Date.now(); // 当前时间戳
161
- const remainingTime = delay - (currentTime - lastExecuteTime); // 距离下次可执行的剩余时间
162
-
163
- // 清除之前的定时器(避免重复触发)
159
+ // 每次触发时,清除之前的定时器(重置延迟)
164
160
  clearTimeout(timer);
165
-
166
- // 1. 如果剩余时间 <= 0,说明已经过了节流间隔,直接执行函数
167
- if (remainingTime <= 0) {
168
- fn.apply(this, args);
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) {
package/src/index.js CHANGED
@@ -87,7 +87,7 @@ function install(app) {
87
87
  }
88
88
 
89
89
  export default {
90
- version: '1.35.605',
90
+ version: '1.35.606',
91
91
  install,
92
92
  Calendar,
93
93
  Message,