优化useIsExistenceDuplicateSelection

master
LiuJiaNan 2025-11-18 15:29:16 +08:00
parent 39b0b6c5f6
commit 9fde31ea88
2 changed files with 5 additions and 3 deletions

View File

@ -20,4 +20,6 @@ interface IsExistenceDuplicateSelectionFunction {
/** /**
* *
*/ */
export default function useIsExistenceDuplicateSelection(): IsExistenceDuplicateSelectionFunction; export default function useIsExistenceDuplicateSelection(): {
isExistenceDuplicateSelection: IsExistenceDuplicateSelectionFunction
};

View File

@ -5,7 +5,7 @@ import { uniqBy } from "lodash-es";
* 检查数组中是否存在重复项 * 检查数组中是否存在重复项
*/ */
export default function useIsExistenceDuplicateSelection() { export default function useIsExistenceDuplicateSelection() {
const IsExistenceDuplicateSelection = (options) => { const isExistenceDuplicateSelection = (options) => {
const { data, key, message = "存在重复项,请勿重复选择" } = options; const { data, key, message = "存在重复项,请勿重复选择" } = options;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (uniqBy(data, key).length !== data.length) { if (uniqBy(data, key).length !== data.length) {
@ -17,5 +17,5 @@ export default function useIsExistenceDuplicateSelection() {
} }
}); });
} }
return IsExistenceDuplicateSelection; return { isExistenceDuplicateSelection };
} }