refactor(types): 移除已弃用的 onGetNodePathsIsIncludeOneself 和 callback 参数

- 删除 Cascader、LeftTree、SelectTree 组件中已弃用的 onGetNodePathsIsIncludeOneself 类型定义
- 删除 useTable hook 中已弃用的 callback 类型定义
- 组件实现中移除对 onGetNodePathsIsIncludeOneself 参数的支持和警告提示
- 统一使用 getNodePathsIsIncludeOneself 参数代替已废弃参数
- 移除 useTable hook 中对 callback 参数的警告和调用,建议使用 onSuccess
2.0
LiuJiaNan 2026-06-23 13:50:34 +08:00
parent c3268aff48
commit 585b03329b
8 changed files with 4 additions and 46 deletions

View File

@ -11,8 +11,6 @@ export interface BasicCascaderProps extends Omit<CascaderProps, "fieldNames"> {
idKey?: string; idKey?: string;
/** 树形数据 children 字段,默认 children */ /** 树形数据 children 字段,默认 children */
childrenKey?: string; childrenKey?: string;
/** @deprecated 已弃用,请使用 getNodePathsIsIncludeOneself */
onGetNodePathsIsIncludeOneself?: boolean;
/** 决定 onGetNodePaths 是否包含自身节点,默认 true */ /** 决定 onGetNodePaths 是否包含自身节点,默认 true */
getNodePathsIsIncludeOneself?: boolean; getNodePathsIsIncludeOneself?: boolean;
/** 获取父级节点 */ /** 获取父级节点 */

View File

@ -10,7 +10,6 @@ function BasicCascader(props) {
onGetData, onGetData,
onChange, onChange,
onGetNodePaths, onGetNodePaths,
onGetNodePathsIsIncludeOneself,
getNodePathsIsIncludeOneself = true, getNodePathsIsIncludeOneself = true,
placeholder = "", placeholder = "",
data = [], data = [],
@ -21,14 +20,6 @@ function BasicCascader(props) {
...restProps ...restProps
} = props; } = props;
// 如果使用了已弃用的参数给出警告
if (onGetNodePathsIsIncludeOneself !== undefined) {
console.warn("【BasicCascader】 onGetNodePathsIsIncludeOneself 参数已弃用,请使用 getNodePathsIsIncludeOneself 参数");
}
// 向后兼容,如果传入了旧参数,使用旧参数
const finalGetNodePathsIsIncludeOneself = onGetNodePathsIsIncludeOneself !== undefined ? onGetNodePathsIsIncludeOneself : getNodePathsIsIncludeOneself;
// 根据 level 处理树数据 // 根据 level 处理树数据
const processedData = useMemo(() => { const processedData = useMemo(() => {
return level return level
@ -43,7 +34,7 @@ function BasicCascader(props) {
const getNodePaths = (selectedOptions) => { const getNodePaths = (selectedOptions) => {
let nodePaths = selectedOptions; let nodePaths = selectedOptions;
if (!finalGetNodePathsIsIncludeOneself && selectedOptions) { if (!getNodePathsIsIncludeOneself && selectedOptions) {
nodePaths = selectedOptions.slice(0, -1); nodePaths = selectedOptions.slice(0, -1);
} }
return nodePaths || []; return nodePaths || [];

View File

@ -11,8 +11,6 @@ export interface BasicLeftTreeProps extends Omit<TreeProps, "fieldNames"> {
idKey?: string; idKey?: string;
/** 树形数据 children 字段,默认 children */ /** 树形数据 children 字段,默认 children */
childrenKey?: string; childrenKey?: string;
/** @deprecated 已弃用,请使用 getNodePathsIsIncludeOneself */
onGetNodePathsIsIncludeOneself?: boolean;
/** 决定 onGetNodePaths 是否包含自身节点,默认 true */ /** 决定 onGetNodePaths 是否包含自身节点,默认 true */
getNodePathsIsIncludeOneself?: boolean; getNodePathsIsIncludeOneself?: boolean;
/** 获取父级节点 */ /** 获取父级节点 */

View File

@ -12,7 +12,6 @@ const BasicLeftTree = (props) => {
onGetData, onGetData,
onSelect, onSelect,
onGetNodePaths, onGetNodePaths,
onGetNodePathsIsIncludeOneself,
getNodePathsIsIncludeOneself = true, getNodePathsIsIncludeOneself = true,
expandedKeys: externalExpandedKeys, expandedKeys: externalExpandedKeys,
treeData = [], treeData = [],
@ -22,14 +21,6 @@ const BasicLeftTree = (props) => {
...restProps ...restProps
} = props; } = props;
// 如果使用了已弃用的参数给出警告
if (onGetNodePathsIsIncludeOneself !== undefined) {
console.warn("【BasicLeftTree】 onGetNodePathsIsIncludeOneself 参数已弃用,请使用 getNodePathsIsIncludeOneself 参数");
}
// 向后兼容,如果传入了旧参数,使用旧参数
const finalGetNodePathsIsIncludeOneself = onGetNodePathsIsIncludeOneself !== undefined ? onGetNodePathsIsIncludeOneself : getNodePathsIsIncludeOneself;
const [expandedKeys, setExpandedKeys] = useState([]); const [expandedKeys, setExpandedKeys] = useState([]);
const [searchValue, setSearchValue] = useState(""); const [searchValue, setSearchValue] = useState("");
const [autoExpandParent, setAutoExpandParent] = useState(true); const [autoExpandParent, setAutoExpandParent] = useState(true);
@ -90,7 +81,7 @@ const BasicLeftTree = (props) => {
targetId: selectedNodeId, targetId: selectedNodeId,
idKey, idKey,
childrenKey, childrenKey,
isIncludeOneself: finalGetNodePathsIsIncludeOneself, isIncludeOneself: getNodePathsIsIncludeOneself,
}); });
onGetNodePaths?.(parentNodes); onGetNodePaths?.(parentNodes);
} }

View File

@ -11,8 +11,6 @@ export interface BasicSelectTreeProps extends Omit<TreeSelectProps, "fieldNames"
idKey?: string; idKey?: string;
/** 树形数据 children 字段,默认 children */ /** 树形数据 children 字段,默认 children */
childrenKey?: string; childrenKey?: string;
/** @deprecated 已弃用,请使用 getNodePathsIsIncludeOneself */
onGetNodePathsIsIncludeOneself?: boolean;
/** 决定 onGetNodePaths 是否包含自身节点,默认 true */ /** 决定 onGetNodePaths 是否包含自身节点,默认 true */
getNodePathsIsIncludeOneself?: boolean; getNodePathsIsIncludeOneself?: boolean;
/** 获取父级节点 */ /** 获取父级节点 */

View File

@ -11,7 +11,6 @@ function BasicSelectTree(props) {
onChange, onChange,
onGetLabel, onGetLabel,
onGetNodePaths, onGetNodePaths,
onGetNodePathsIsIncludeOneself,
getNodePathsIsIncludeOneself = true, getNodePathsIsIncludeOneself = true,
placeholder = "", placeholder = "",
treeData = [], treeData = [],
@ -23,14 +22,6 @@ function BasicSelectTree(props) {
...restProps ...restProps
} = props; } = props;
// 如果使用了已弃用的参数给出警告
if (onGetNodePathsIsIncludeOneself !== undefined) {
console.warn("【BasicSelectTree】 onGetNodePathsIsIncludeOneself 参数已弃用,请使用 getNodePathsIsIncludeOneself 参数");
}
// 向后兼容,如果传入了旧参数,使用旧参数
const finalGetNodePathsIsIncludeOneself = onGetNodePathsIsIncludeOneself !== undefined ? onGetNodePathsIsIncludeOneself : getNodePathsIsIncludeOneself;
const processedTreeData = useMemo(() => { const processedTreeData = useMemo(() => {
// 根据 level 处理树数据 // 根据 level 处理树数据
let result = level let result = level
@ -64,7 +55,7 @@ function BasicSelectTree(props) {
targetId, targetId,
idKey, idKey,
childrenKey, childrenKey,
isIncludeOneself: finalGetNodePathsIsIncludeOneself, isIncludeOneself: getNodePathsIsIncludeOneself,
}); });
parentNodes.push(...currentParentNodes); parentNodes.push(...currentParentNodes);
} }
@ -81,7 +72,7 @@ function BasicSelectTree(props) {
targetId, targetId,
idKey, idKey,
childrenKey, childrenKey,
isIncludeOneself: finalGetNodePathsIsIncludeOneself, isIncludeOneself: getNodePathsIsIncludeOneself,
}); });
onGetNodePaths?.(parentNodes); onGetNodePaths?.(parentNodes);
onGetLabel?.(parentNodes[parentNodes.length - 1][nameKey]); onGetLabel?.(parentNodes[parentNodes.length - 1][nameKey]);

View File

@ -18,8 +18,6 @@ export interface UseTableOptions<TData extends Data, TParams extends Params> ext
params?: Record<string, any> | (() => Record<string, any>); params?: Record<string, any> | (() => Record<string, any>);
/** 表单数据转换函数,在每次请求之前调用,接收当前搜索的表单项,要求返回一个对象 */ /** 表单数据转换函数,在每次请求之前调用,接收当前搜索的表单项,要求返回一个对象 */
transform?: (formData: FormValues) => FormValues; transform?: (formData: FormValues) => FormValues;
/** @deprecated 已弃用,请使用 onSuccess */
callback?: (list: any[], data: any) => void;
/** 表单实例(通过 Form.useForm() 创建) */ /** 表单实例(通过 Form.useForm() 创建) */
form?: FormInstance; form?: FormInstance;
} }

View File

@ -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 { return {
...res, ...res,