|
@@ -1,4 +1,4 @@
|
|
|
-import { CombineService, Mutate } from '@ahooksjs/use-request/lib/types'
|
|
|
+import { CombineService, Mutate } from '@ahooksjs/use-request/lib/types'
|
|
|
import { message } from 'antd'
|
|
|
import moment from 'moment'
|
|
|
import { useRequest } from 'umi'
|
|
@@ -33,14 +33,14 @@ interface Options {
|
|
|
* @param msgNmae?: string,//操作完成提示文字
|
|
|
*
|
|
|
*/
|
|
|
-export interface FnAjax<T>{
|
|
|
- loading:boolean,
|
|
|
- data:T,
|
|
|
- run:(...args:any)=>Promise<any>,
|
|
|
- refresh:()=>Promise<any>,
|
|
|
+export interface FnAjax<T> {
|
|
|
+ loading: boolean,
|
|
|
+ data: T,
|
|
|
+ run: (...args: any) => Promise<any>,
|
|
|
+ refresh: () => Promise<any>,
|
|
|
mutate: Mutate<any>
|
|
|
}
|
|
|
-export function useAjax(fnc: CombineService<any, any>, options?: Options){
|
|
|
+export function useAjax(fnc: CombineService<any, any>, options?: Options) {
|
|
|
const ajax = useRequest(fnc, {
|
|
|
manual: options?.manual || true,
|
|
|
cacheKey: options?.cacheKey,
|
|
@@ -50,8 +50,8 @@ export function useAjax(fnc: CombineService<any, any>, options?: Options){
|
|
|
formatResult: (res) => {
|
|
|
let reqTime = moment().format('YYYY-MM-DD HH:mm:ss')
|
|
|
res['reqTime'] = reqTime
|
|
|
- return options?.formatResult ? {...res,reqTime} :res
|
|
|
-
|
|
|
+ return options?.formatResult ? { ...res, reqTime } : res.data
|
|
|
+
|
|
|
},
|
|
|
onSuccess: (res) => {
|
|
|
if (res) {
|