nhanh-pure-function 1.2.2 → 1.2.4
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/lib/User.js +22 -26
- package/package.json +1 -1
package/lib/User.js
CHANGED
|
@@ -394,20 +394,33 @@ export class _LoadingController {
|
|
|
394
394
|
* @param options.uiLibrary 项目使用的 ui库 , 用于排除 ui库 创建的元素 , 避免点击 ui库 创建的元素时意外的执行 callback
|
|
395
395
|
* @param options.isClickAllowed 是否允许该点击 ( 如果不确定可以返回 undefined )
|
|
396
396
|
*/
|
|
397
|
-
export function _CloseOnOutsideClick(
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
) {
|
|
397
|
+
export function _CloseOnOutsideClick(querySelector, callback, options) {
|
|
398
|
+
const { isClickAllowed, uiLibrary = ["naiveUI", "ElementPlus", "Element"] } =
|
|
399
|
+
options || {};
|
|
400
|
+
|
|
401
|
+
const UI = (function (obj) {
|
|
402
|
+
const arr = [];
|
|
403
|
+
for (const key in obj) {
|
|
404
|
+
if (Object.hasOwnProperty.call(obj, key)) {
|
|
405
|
+
if (uiLibrary.includes(key)) arr.push(...obj[key]);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return arr;
|
|
409
|
+
})({
|
|
410
|
+
naiveUI: [
|
|
411
|
+
".v-binder-follower-container",
|
|
412
|
+
".n-image-preview-container",
|
|
413
|
+
".n-modal-container",
|
|
414
|
+
],
|
|
415
|
+
ElementPlus: [".el-popper"],
|
|
416
|
+
Element: [".el-popper"],
|
|
417
|
+
});
|
|
418
|
+
|
|
404
419
|
function end() {
|
|
405
420
|
callback();
|
|
406
421
|
document.removeEventListener("mousedown", mousedown);
|
|
407
422
|
}
|
|
408
423
|
function mousedown(event) {
|
|
409
|
-
const { isClickAllowed, uiLibrary } = options;
|
|
410
|
-
|
|
411
424
|
if (isClickAllowed) {
|
|
412
425
|
const bool = isClickAllowed(event);
|
|
413
426
|
if (bool) return;
|
|
@@ -419,23 +432,6 @@ export function _CloseOnOutsideClick(
|
|
|
419
432
|
/** 元素这时可能已经被删除了 */
|
|
420
433
|
if (!target?.closest("body")) return;
|
|
421
434
|
|
|
422
|
-
const UI = (function (obj) {
|
|
423
|
-
const arr = [];
|
|
424
|
-
for (const key in obj) {
|
|
425
|
-
if (Object.hasOwnProperty.call(obj, key)) {
|
|
426
|
-
if (uiLibrary.includes(key)) arr.concat(obj[key]);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
return arr;
|
|
430
|
-
})({
|
|
431
|
-
naiveUI: [
|
|
432
|
-
".v-binder-follower-container",
|
|
433
|
-
".n-image-preview-container",
|
|
434
|
-
".n-modal-container",
|
|
435
|
-
],
|
|
436
|
-
ElementPlus: ["el-popper"],
|
|
437
|
-
Element: ["el-popper"],
|
|
438
|
-
});
|
|
439
435
|
const isClickable = querySelector
|
|
440
436
|
.concat(UI)
|
|
441
437
|
.some((className) => Boolean(target?.closest(className)));
|