@lx-frontend/wrap-element-ui 2.0.0-beta.1 → 2.0.0-beta.2
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,7 +1,52 @@
|
|
|
1
|
-
import debounce from 'lodash/debounce';
|
|
2
|
-
import throttle from 'lodash/throttle';
|
|
3
1
|
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
|
4
2
|
|
|
3
|
+
/** 简单实现 debounce */
|
|
4
|
+
function debounce<T extends (...args: any[]) => any>(fn: T, delay: number) {
|
|
5
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
6
|
+
const debounced = (...args: any[]) => {
|
|
7
|
+
if (timer !== null) clearTimeout(timer);
|
|
8
|
+
timer = setTimeout(() => {
|
|
9
|
+
fn(...args);
|
|
10
|
+
timer = null;
|
|
11
|
+
}, delay);
|
|
12
|
+
};
|
|
13
|
+
debounced.cancel = () => {
|
|
14
|
+
if (timer !== null) clearTimeout(timer);
|
|
15
|
+
timer = null;
|
|
16
|
+
};
|
|
17
|
+
return debounced as T & { cancel: () => void };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** 简单实现 throttle */
|
|
21
|
+
function throttle<T extends (...args: any[]) => any>(fn: T, delay: number) {
|
|
22
|
+
let lastTime = 0;
|
|
23
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
24
|
+
const throttled = (...args: any[]) => {
|
|
25
|
+
const now = Date.now();
|
|
26
|
+
const remaining = delay - (now - lastTime);
|
|
27
|
+
if (remaining <= 0) {
|
|
28
|
+
if (timer !== null) {
|
|
29
|
+
clearTimeout(timer);
|
|
30
|
+
timer = null;
|
|
31
|
+
}
|
|
32
|
+
lastTime = now;
|
|
33
|
+
fn(...args);
|
|
34
|
+
} else if (timer === null) {
|
|
35
|
+
timer = setTimeout(() => {
|
|
36
|
+
lastTime = Date.now();
|
|
37
|
+
timer = null;
|
|
38
|
+
fn(...args);
|
|
39
|
+
}, remaining);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
throttled.cancel = () => {
|
|
43
|
+
if (timer !== null) clearTimeout(timer);
|
|
44
|
+
timer = null;
|
|
45
|
+
lastTime = 0;
|
|
46
|
+
};
|
|
47
|
+
return throttled as T & { cancel: () => void };
|
|
48
|
+
}
|
|
49
|
+
|
|
5
50
|
export function useCellHover(tableDomRef) {
|
|
6
51
|
|
|
7
52
|
// 鼠标悬浮的行
|
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
import { onBeforeUnmount, onMounted, ref, Ref } from 'vue';
|
|
2
2
|
import { IColumnConfig, IDraggingData, IEmits, IProps } from "../types"
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
/** 简单实现 throttle */
|
|
5
|
+
function throttle<T extends (...args: any[]) => any>(fn: T, delay: number) {
|
|
6
|
+
let lastTime = 0;
|
|
7
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
8
|
+
const throttled = (...args: any[]) => {
|
|
9
|
+
const now = Date.now();
|
|
10
|
+
const remaining = delay - (now - lastTime);
|
|
11
|
+
if (remaining <= 0) {
|
|
12
|
+
if (timer !== null) {
|
|
13
|
+
clearTimeout(timer);
|
|
14
|
+
timer = null;
|
|
15
|
+
}
|
|
16
|
+
lastTime = now;
|
|
17
|
+
fn(...args);
|
|
18
|
+
} else if (timer === null) {
|
|
19
|
+
timer = setTimeout(() => {
|
|
20
|
+
lastTime = Date.now();
|
|
21
|
+
timer = null;
|
|
22
|
+
fn(...args);
|
|
23
|
+
}, remaining);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
throttled.cancel = () => {
|
|
27
|
+
if (timer !== null) clearTimeout(timer);
|
|
28
|
+
timer = null;
|
|
29
|
+
lastTime = 0;
|
|
30
|
+
};
|
|
31
|
+
return throttled as T & { cancel: () => void };
|
|
32
|
+
}
|
|
4
33
|
|
|
5
34
|
interface IUseDragSortParams {
|
|
6
35
|
props: IProps
|
|
@@ -332,7 +332,6 @@ import BizTableOperatePopover from './features/bizTableOperatePopover.vue'
|
|
|
332
332
|
import { computed, nextTick, ref, watch } from 'vue';
|
|
333
333
|
import { ElMessage as Message, ElConfigProvider } from 'element-plus';
|
|
334
334
|
import zhCn from 'element-plus/es/locale/lang/zh-cn';
|
|
335
|
-
import omit from 'lodash/omit';
|
|
336
335
|
|
|
337
336
|
import {
|
|
338
337
|
usePagination,
|
|
@@ -461,6 +460,15 @@ const returnAnyType = (params): any => {
|
|
|
461
460
|
return params
|
|
462
461
|
}
|
|
463
462
|
|
|
463
|
+
/** 简单实现 omit,排除对象中指定的 key */
|
|
464
|
+
const omit = <T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> => {
|
|
465
|
+
const result = { ...obj } as T;
|
|
466
|
+
for (const key of keys) {
|
|
467
|
+
delete result[key];
|
|
468
|
+
}
|
|
469
|
+
return result as Omit<T, K>;
|
|
470
|
+
};
|
|
471
|
+
|
|
464
472
|
const actualColumns = computed(() => {
|
|
465
473
|
const res: IColumnConfig[] = [];
|
|
466
474
|
let cnt = leftFixedColumnCount.value;
|