|
1 |
| -import { ref, reactive, toRefs, onUnmounted, inject, UnwrapRef, watchEffect, computed, isRef, onMounted, unref } from 'vue' |
| 1 | +import { |
| 2 | + ref, |
| 3 | + reactive, |
| 4 | + toRefs, |
| 5 | + onUnmounted, |
| 6 | + inject, |
| 7 | + UnwrapRef, |
| 8 | + watchEffect, |
| 9 | + computed, |
| 10 | + isRef, |
| 11 | + onMounted, |
| 12 | + unref, |
| 13 | +} from 'vue' |
2 | 14 |
|
3 | 15 | import Fetch from './Fetch'
|
4 | 16 | import { USEREQUEST_GLOBAL_OPTIONS_PROVIDE_KEY } from './config'
|
@@ -28,7 +40,7 @@ function useRequestImplement<TData, TParams extends any[]>(
|
28 | 40 | service: UseRequestService<TData, TParams>,
|
29 | 41 | options: UseRequestOptions<TData, TParams, any> = {},
|
30 | 42 | plugins: UseRequestPlugin<TData, TParams>[] = [],
|
31 |
| -) { |
| 43 | +): useRequestResult<TData, TParams> { |
32 | 44 | // global option
|
33 | 45 | const USEREQUEST_GLOBAL_OPTIONS = inject<Record<string, any>>(
|
34 | 46 | USEREQUEST_GLOBAL_OPTIONS_PROVIDE_KEY,
|
@@ -57,7 +69,7 @@ function useRequestImplement<TData, TParams extends any[]>(
|
57 | 69 | error: undefined,
|
58 | 70 | })
|
59 | 71 |
|
60 |
| - const setState = (currentState: unknown, field?: keyof typeof state) => { |
| 72 | + const setState = (currentState: unknown, field?: keyof typeof state): void => { |
61 | 73 | if (field) {
|
62 | 74 | // if (isUseRequestFetchStateKey<UnwrapRef<TData>, UnwrapRef<TParams>>(field, currentState)) {
|
63 | 75 | // state[field] = currentState as any
|
@@ -89,7 +101,7 @@ function useRequestImplement<TData, TParams extends any[]>(
|
89 | 101 | return p(fetchInstance, fetchOptions)
|
90 | 102 | })
|
91 | 103 |
|
92 |
| - const readyComputed = computed(() => isRef(ready) ? ready.value : ready) |
| 104 | + const readyComputed = computed(() => (isRef(ready) ? ready.value : ready)) |
93 | 105 |
|
94 | 106 | // const isMount = ref(false)
|
95 | 107 |
|
|
0 commit comments