测试
This commit is contained in:
7
frontend/node_modules/element-plus/es/hooks/use-throttle-render/index.d.ts
generated
vendored
Normal file
7
frontend/node_modules/element-plus/es/hooks/use-throttle-render/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { Ref } from 'vue';
|
||||
export type ThrottleType = {
|
||||
leading?: number;
|
||||
trailing?: number;
|
||||
initVal?: boolean;
|
||||
} | number;
|
||||
export declare const useThrottleRender: (loading: Ref<boolean>, throttle?: ThrottleType) => Ref<boolean>;
|
||||
46
frontend/node_modules/element-plus/es/hooks/use-throttle-render/index.mjs
generated
vendored
Normal file
46
frontend/node_modules/element-plus/es/hooks/use-throttle-render/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import { ref, onMounted, watch } from 'vue';
|
||||
import { isNumber, isUndefined } from '../../utils/types.mjs';
|
||||
import { isObject } from '@vue/shared';
|
||||
|
||||
const useThrottleRender = (loading, throttle = 0) => {
|
||||
if (throttle === 0)
|
||||
return loading;
|
||||
const initVal = isObject(throttle) && Boolean(throttle.initVal);
|
||||
const throttled = ref(initVal);
|
||||
let timeoutHandle = null;
|
||||
const dispatchThrottling = (timer) => {
|
||||
if (isUndefined(timer)) {
|
||||
throttled.value = loading.value;
|
||||
return;
|
||||
}
|
||||
if (timeoutHandle) {
|
||||
clearTimeout(timeoutHandle);
|
||||
}
|
||||
timeoutHandle = setTimeout(() => {
|
||||
throttled.value = loading.value;
|
||||
}, timer);
|
||||
};
|
||||
const dispatcher = (type) => {
|
||||
if (type === "leading") {
|
||||
if (isNumber(throttle)) {
|
||||
dispatchThrottling(throttle);
|
||||
} else {
|
||||
dispatchThrottling(throttle.leading);
|
||||
}
|
||||
} else {
|
||||
if (isObject(throttle)) {
|
||||
dispatchThrottling(throttle.trailing);
|
||||
} else {
|
||||
throttled.value = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
onMounted(() => dispatcher("leading"));
|
||||
watch(() => loading.value, (val) => {
|
||||
dispatcher(val ? "leading" : "trailing");
|
||||
});
|
||||
return throttled;
|
||||
};
|
||||
|
||||
export { useThrottleRender };
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/hooks/use-throttle-render/index.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/hooks/use-throttle-render/index.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","sources":["../../../../../packages/hooks/use-throttle-render/index.ts"],"sourcesContent":["import { onMounted, ref, watch } from 'vue'\nimport { isNumber, isObject, isUndefined } from '@element-plus/utils'\n\nimport type { Ref } from 'vue'\n\nexport type ThrottleType =\n | { leading?: number; trailing?: number; initVal?: boolean }\n | number\n\nexport const useThrottleRender = (\n loading: Ref<boolean>,\n throttle: ThrottleType = 0\n) => {\n if (throttle === 0) return loading\n const initVal = isObject(throttle) && Boolean(throttle.initVal)\n const throttled = ref(initVal)\n let timeoutHandle: ReturnType<typeof setTimeout> | null = null\n\n const dispatchThrottling = (timer: number | undefined) => {\n if (isUndefined(timer)) {\n throttled.value = loading.value\n return\n }\n if (timeoutHandle) {\n clearTimeout(timeoutHandle)\n }\n timeoutHandle = setTimeout(() => {\n throttled.value = loading.value\n }, timer)\n }\n\n const dispatcher = (type: 'leading' | 'trailing') => {\n if (type === 'leading') {\n if (isNumber(throttle)) {\n dispatchThrottling(throttle)\n } else {\n dispatchThrottling(throttle.leading)\n }\n } else {\n if (isObject(throttle)) {\n dispatchThrottling(throttle.trailing)\n } else {\n throttled.value = false\n }\n }\n }\n\n onMounted(() => dispatcher('leading'))\n\n watch(\n () => loading.value,\n (val) => {\n dispatcher(val ? 'leading' : 'trailing')\n }\n )\n\n return throttled\n}\n"],"names":[],"mappings":";;;;AAEY,MAAC,iBAAiB,GAAG,CAAC,OAAO,EAAE,QAAQ,GAAG,CAAC,KAAK;AAC5D,EAAE,IAAI,QAAQ,KAAK,CAAC;AACpB,IAAI,OAAO,OAAO,CAAC;AACnB,EAAE,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