cnf
2025-05-10 386fa0eca75ddc88165f9b73038f2a2239e1072e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
declare namespace UniCloudNamespace {
  interface Interceptor {
    invoke?: (result: any) => void;
    success?: (result: any) => void;
    fail?: (result: any) => void;
    complete?: (result: any) => void;
  }
 
  interface BaseObjectInterceptorArgs {
    objectName: string;
    methodName: string;
    params: string;
  }
 
  interface SuccessObjectInterceptorArgs extends BaseObjectInterceptorArgs {
    result: any;
  }
 
  interface FailObjectInterceptorArgs extends BaseObjectInterceptorArgs {
    error: UniError;
  }
 
  type CompleteObjectInterceptorArgs = SuccessObjectInterceptorArgs | FailObjectInterceptorArgs;
 
  interface ObjectInterceptor {
    invoke?: (result: BaseObjectInterceptorArgs) => void;
    success?: (result: SuccessObjectInterceptorArgs) => void;
    fail?: (result: FailObjectInterceptorArgs) => void;
    complete?: (result: CompleteObjectInterceptorArgs) => void;
  }
 
  interface UniCloud {
    /**
     * 添加拦截器
     *
     * 文档: [https://uniapp.dcloud.io/uniCloud/client-sdk.html#add-interceptor](https://uniapp.dcloud.io/uniCloud/client-sdk.html#add-interceptor)
     */
    addInterceptor(apiName: string, interceptor: Interceptor): void;
    /**
     * 移除拦截器
     *
     * 文档: [https://uniapp.dcloud.io/uniCloud/client-sdk.html#remove-interceptor](https://uniapp.dcloud.io/uniCloud/client-sdk.html#remove-interceptor)
     */
    removeInterceptor(apiName: string, interceptor?: Interceptor): void;
    /**
     * 拦截云对象请求
     *
     * 文档: [https://uniapp.dcloud.io/uniCloud/client-sdk.html#intercept-object](https://uniapp.dcloud.io/uniCloud/client-sdk.html#intercept-object)
     */
    interceptObject(interceptor: ObjectInterceptor): void;
  }
}