refactor(types): 移除已弃用的 onGetNodePathsIsIncludeOneself 和 callback 参数
- 删除 Cascader、LeftTree、SelectTree 组件中已弃用的 onGetNodePathsIsIncludeOneself 类型定义 - 删除 useTable hook 中已弃用的 callback 类型定义 - 组件实现中移除对 onGetNodePathsIsIncludeOneself 参数的支持和警告提示 - 统一使用 getNodePathsIsIncludeOneself 参数代替已废弃参数 - 移除 useTable hook 中对 callback 参数的警告和调用,建议使用 onSuccess2.0
parent
c3268aff48
commit
585b03329b
|
|
@ -11,8 +11,6 @@ export interface BasicCascaderProps extends Omit<CascaderProps, "fieldNames"> {
|
|||
idKey?: string;
|
||||
/** 树形数据 children 字段,默认 children */
|
||||
childrenKey?: string;
|
||||
/** @deprecated 已弃用,请使用 getNodePathsIsIncludeOneself */
|
||||
onGetNodePathsIsIncludeOneself?: boolean;
|
||||
/** 决定 onGetNodePaths 是否包含自身节点,默认 true */
|
||||
getNodePathsIsIncludeOneself?: boolean;
|
||||
/** 获取父级节点 */
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ function BasicCascader(props) {
|
|||
onGetData,
|
||||
onChange,
|
||||
onGetNodePaths,
|
||||
onGetNodePathsIsIncludeOneself,
|
||||
getNodePathsIsIncludeOneself = true,
|
||||
placeholder = "",
|
||||
data = [],
|
||||
|
|
@ -21,14 +20,6 @@ function BasicCascader(props) {
|
|||
...restProps
|
||||
} = props;
|
||||
|
||||
// 如果使用了已弃用的参数给出警告
|
||||
if (onGetNodePathsIsIncludeOneself !== undefined) {
|
||||
console.warn("【BasicCascader】 onGetNodePathsIsIncludeOneself 参数已弃用,请使用 getNodePathsIsIncludeOneself 参数");
|
||||
}
|
||||
|
||||
// 向后兼容,如果传入了旧参数,使用旧参数
|
||||
const finalGetNodePathsIsIncludeOneself = onGetNodePathsIsIncludeOneself !== undefined ? onGetNodePathsIsIncludeOneself : getNodePathsIsIncludeOneself;
|
||||
|
||||
// 根据 level 处理树数据
|
||||
const processedData = useMemo(() => {
|
||||
return level
|
||||
|
|
@ -43,7 +34,7 @@ function BasicCascader(props) {
|
|||
|
||||
const getNodePaths = (selectedOptions) => {
|
||||
let nodePaths = selectedOptions;
|
||||
if (!finalGetNodePathsIsIncludeOneself && selectedOptions) {
|
||||
if (!getNodePathsIsIncludeOneself && selectedOptions) {
|
||||
nodePaths = selectedOptions.slice(0, -1);
|
||||
}
|
||||
return nodePaths || [];
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ export interface BasicLeftTreeProps extends Omit<TreeProps, "fieldNames"> {
|
|||
idKey?: string;
|
||||
/** 树形数据 children 字段,默认 children */
|
||||
childrenKey?: string;
|
||||
/** @deprecated 已弃用,请使用 getNodePathsIsIncludeOneself */
|
||||
onGetNodePathsIsIncludeOneself?: boolean;
|
||||
/** 决定 onGetNodePaths 是否包含自身节点,默认 true */
|
||||
getNodePathsIsIncludeOneself?: boolean;
|
||||
/** 获取父级节点 */
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ const BasicLeftTree = (props) => {
|
|||
onGetData,
|
||||
onSelect,
|
||||
onGetNodePaths,
|
||||
onGetNodePathsIsIncludeOneself,
|
||||
getNodePathsIsIncludeOneself = true,
|
||||
expandedKeys: externalExpandedKeys,
|
||||
treeData = [],
|
||||
|
|
@ -22,14 +21,6 @@ const BasicLeftTree = (props) => {
|
|||
...restProps
|
||||
} = props;
|
||||
|
||||
// 如果使用了已弃用的参数给出警告
|
||||
if (onGetNodePathsIsIncludeOneself !== undefined) {
|
||||
console.warn("【BasicLeftTree】 onGetNodePathsIsIncludeOneself 参数已弃用,请使用 getNodePathsIsIncludeOneself 参数");
|
||||
}
|
||||
|
||||
// 向后兼容,如果传入了旧参数,使用旧参数
|
||||
const finalGetNodePathsIsIncludeOneself = onGetNodePathsIsIncludeOneself !== undefined ? onGetNodePathsIsIncludeOneself : getNodePathsIsIncludeOneself;
|
||||
|
||||
const [expandedKeys, setExpandedKeys] = useState([]);
|
||||
const [searchValue, setSearchValue] = useState("");
|
||||
const [autoExpandParent, setAutoExpandParent] = useState(true);
|
||||
|
|
@ -90,7 +81,7 @@ const BasicLeftTree = (props) => {
|
|||
targetId: selectedNodeId,
|
||||
idKey,
|
||||
childrenKey,
|
||||
isIncludeOneself: finalGetNodePathsIsIncludeOneself,
|
||||
isIncludeOneself: getNodePathsIsIncludeOneself,
|
||||
});
|
||||
onGetNodePaths?.(parentNodes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ export interface BasicSelectTreeProps extends Omit<TreeSelectProps, "fieldNames"
|
|||
idKey?: string;
|
||||
/** 树形数据 children 字段,默认 children */
|
||||
childrenKey?: string;
|
||||
/** @deprecated 已弃用,请使用 getNodePathsIsIncludeOneself */
|
||||
onGetNodePathsIsIncludeOneself?: boolean;
|
||||
/** 决定 onGetNodePaths 是否包含自身节点,默认 true */
|
||||
getNodePathsIsIncludeOneself?: boolean;
|
||||
/** 获取父级节点 */
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ function BasicSelectTree(props) {
|
|||
onChange,
|
||||
onGetLabel,
|
||||
onGetNodePaths,
|
||||
onGetNodePathsIsIncludeOneself,
|
||||
getNodePathsIsIncludeOneself = true,
|
||||
placeholder = "",
|
||||
treeData = [],
|
||||
|
|
@ -23,14 +22,6 @@ function BasicSelectTree(props) {
|
|||
...restProps
|
||||
} = props;
|
||||
|
||||
// 如果使用了已弃用的参数给出警告
|
||||
if (onGetNodePathsIsIncludeOneself !== undefined) {
|
||||
console.warn("【BasicSelectTree】 onGetNodePathsIsIncludeOneself 参数已弃用,请使用 getNodePathsIsIncludeOneself 参数");
|
||||
}
|
||||
|
||||
// 向后兼容,如果传入了旧参数,使用旧参数
|
||||
const finalGetNodePathsIsIncludeOneself = onGetNodePathsIsIncludeOneself !== undefined ? onGetNodePathsIsIncludeOneself : getNodePathsIsIncludeOneself;
|
||||
|
||||
const processedTreeData = useMemo(() => {
|
||||
// 根据 level 处理树数据
|
||||
let result = level
|
||||
|
|
@ -64,7 +55,7 @@ function BasicSelectTree(props) {
|
|||
targetId,
|
||||
idKey,
|
||||
childrenKey,
|
||||
isIncludeOneself: finalGetNodePathsIsIncludeOneself,
|
||||
isIncludeOneself: getNodePathsIsIncludeOneself,
|
||||
});
|
||||
parentNodes.push(...currentParentNodes);
|
||||
}
|
||||
|
|
@ -81,7 +72,7 @@ function BasicSelectTree(props) {
|
|||
targetId,
|
||||
idKey,
|
||||
childrenKey,
|
||||
isIncludeOneself: finalGetNodePathsIsIncludeOneself,
|
||||
isIncludeOneself: getNodePathsIsIncludeOneself,
|
||||
});
|
||||
onGetNodePaths?.(parentNodes);
|
||||
onGetLabel?.(parentNodes[parentNodes.length - 1][nameKey]);
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ export interface UseTableOptions<TData extends Data, TParams extends Params> ext
|
|||
params?: Record<string, any> | (() => Record<string, any>);
|
||||
/** 表单数据转换函数,在每次请求之前调用,接收当前搜索的表单项,要求返回一个对象 */
|
||||
transform?: (formData: FormValues) => FormValues;
|
||||
/** @deprecated 已弃用,请使用 onSuccess */
|
||||
callback?: (list: any[], data: any) => void;
|
||||
/** 表单实例(通过 Form.useForm() 创建) */
|
||||
form?: FormInstance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,13 +96,6 @@ function useTable(service, options) {
|
|||
},
|
||||
);
|
||||
|
||||
if (restOptions.callback !== undefined) {
|
||||
console.warn("【useTable】 callback 参数已弃用,请使用 onSuccess 参数");
|
||||
}
|
||||
|
||||
// 执行回调函数
|
||||
restOptions.callback && restOptions.callback(res?.data?.list || [], res?.data || {});
|
||||
|
||||
// 返回结果
|
||||
return {
|
||||
...res,
|
||||
|
|
|
|||
Loading…
Reference in New Issue