mirror of
https://github.com/jekip/naive-ui-admin.git
synced 2026-03-01 00:23:11 +08:00
Merge pull request #136 from Zheng-Changfu/fix/table-fetch-interceptor-statement
fix(function):修复 useDataSource 中请求前请求后回调未在prop中声明、isFunction支持普通、箭头函数判断
This commit is contained in:
@@ -88,10 +88,7 @@ export function useDataSource(
|
|||||||
let resultInfo = res[listField] ? res[listField] : [];
|
let resultInfo = res[listField] ? res[listField] : [];
|
||||||
if (afterRequest && isFunction(afterRequest)) {
|
if (afterRequest && isFunction(afterRequest)) {
|
||||||
// can modify the data returned by the interface for processing
|
// can modify the data returned by the interface for processing
|
||||||
resultInfo = (await afterRequest(resultInfo));
|
resultInfo = (await afterRequest(resultInfo)) || resultInfo;
|
||||||
if (!isArray(resultInfo)) {
|
|
||||||
resultInfo = []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dataSourceRef.value = resultInfo;
|
dataSourceRef.value = resultInfo;
|
||||||
setPagination({
|
setPagination({
|
||||||
|
|||||||
@@ -25,17 +25,25 @@ export const basicProps = {
|
|||||||
default: () => [],
|
default: () => [],
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
beforeRequest: {
|
||||||
|
type: Function as PropType<(...arg: any[]) => void | Promise<any>>,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
request: {
|
request: {
|
||||||
type: Function as PropType<(...arg: any[]) => Promise<any>>,
|
type: Function as PropType<(...arg: any[]) => Promise<any>>,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
afterRequest: {
|
||||||
|
type: Function as PropType<(...arg: any[]) => void | Promise<any>>,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
rowKey: {
|
rowKey: {
|
||||||
type: [String, Function] as PropType<string | ((record) => string)>,
|
type: [String, Function] as PropType<string | ((record) => string)>,
|
||||||
default: undefined,
|
default: undefined,
|
||||||
},
|
},
|
||||||
pagination: {
|
pagination: {
|
||||||
type: [Object, Boolean],
|
type: [Object, Boolean],
|
||||||
default: () => {},
|
default: () => { },
|
||||||
},
|
},
|
||||||
//废弃
|
//废弃
|
||||||
showPagination: {
|
showPagination: {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export function is(val: unknown, type: string) {
|
|||||||
* @description: 是否为函数
|
* @description: 是否为函数
|
||||||
*/
|
*/
|
||||||
export function isFunction<T = Function>(val: unknown): val is T {
|
export function isFunction<T = Function>(val: unknown): val is T {
|
||||||
return is(val, 'Function');
|
return is(val, 'Function') || is(val, 'AsyncFunction');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user