gzkx-package 0.1.43 → 0.1.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/takeShot.d.ts +60 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +159 -8
- package/dist/index.mjs.map +1 -1
- package/dist/utils/listenner.d.ts +65 -0
- package/dist/utils/takeShot.d.ts +60 -0
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 截图服务配置
|
|
3
|
+
*/
|
|
4
|
+
interface TakeShotConfig {
|
|
5
|
+
/** 服务端口,默认 28081 */
|
|
6
|
+
port?: number;
|
|
7
|
+
/** 主机地址,默认 localhost */
|
|
8
|
+
host?: string;
|
|
9
|
+
/** 超时时间,默认 10000ms */
|
|
10
|
+
timeout?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 截图响应接口
|
|
14
|
+
*/
|
|
15
|
+
export interface TakeShotResponse {
|
|
16
|
+
code: number;
|
|
17
|
+
msg: string;
|
|
18
|
+
data?: {
|
|
19
|
+
imageBase64?: string;
|
|
20
|
+
imagePath?: string;
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 设置截图服务配置
|
|
26
|
+
* @param config 配置项
|
|
27
|
+
* @example
|
|
28
|
+
* setTakeShotConfig({ port: 3000, host: '192.168.1.100' });
|
|
29
|
+
*/
|
|
30
|
+
export declare const setTakeShotConfig: (config: Partial<TakeShotConfig>) => void;
|
|
31
|
+
/**
|
|
32
|
+
* 获取当前配置
|
|
33
|
+
*/
|
|
34
|
+
export declare const getTakeShotConfig: () => {
|
|
35
|
+
port: number;
|
|
36
|
+
host: string;
|
|
37
|
+
timeout: number;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* 调用截图接口
|
|
41
|
+
* @param params 截图参数
|
|
42
|
+
* @param config 可选的临时配置(不修改全局配置)
|
|
43
|
+
* @returns Promise<TakeShotResponse>
|
|
44
|
+
* @example
|
|
45
|
+
* // 使用默认配置
|
|
46
|
+
* const result = await takeShot();
|
|
47
|
+
*
|
|
48
|
+
* // 使用临时配置
|
|
49
|
+
* const result = await takeShot({}, { port: 3000 });
|
|
50
|
+
*/
|
|
51
|
+
export declare const takeShot: (params?: Record<string, any>, config?: TakeShotConfig) => Promise<TakeShotResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* 带重试的截图接口
|
|
54
|
+
* @param params 截图参数
|
|
55
|
+
* @param retries 重试次数,默认 3 次
|
|
56
|
+
* @param retryDelay 重试间隔,默认 1000ms
|
|
57
|
+
* @param config 可选配置
|
|
58
|
+
*/
|
|
59
|
+
export declare const takeShotWithRetry: (params?: Record<string, any>, retries?: number, retryDelay?: number, config?: TakeShotConfig) => Promise<TakeShotResponse>;
|
|
60
|
+
export default takeShot;
|