qsh-webview-sdk 2.0.6 → 2.0.8
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/README.md +32 -9
- package/dist/index.d.ts +86 -17
- package/dist/qsh-webview-sdk.es.js +1152 -892
- package/dist/qsh-webview-sdk.es.js.map +1 -1
- package/dist/qsh-webview-sdk.umd.js +1 -1
- package/dist/qsh-webview-sdk.umd.js.map +1 -1
- package/package.json +47 -47
package/README.md
CHANGED
|
@@ -175,6 +175,12 @@ console.log('是否 APP:', env.isAppPlus);
|
|
|
175
175
|
| `getLocationAsync` | 获取位置(Promise 版) | `{ type?: string; altitude?: boolean }` |
|
|
176
176
|
| `openLocation` | 查看位置(打开地图) | `{ latitude: number; longitude: number; name?: string; address?: string; scale?: number; success?: Function; fail?: Function }` |
|
|
177
177
|
| `openLocationAsync` | 查看位置(Promise 版) | `{ latitude: number; longitude: number; name?: string; address?: string; scale?: number }` |
|
|
178
|
+
| `startLocationUpdate` | 开启前台持续定位(仅 APP) | `{ type?: string; needFullAccuracy?: boolean; success?: Function; fail?: Function }` |
|
|
179
|
+
| `stopLocationUpdate` | 停止前台持续定位(仅 APP) | `{ success?: Function; fail?: Function }` |
|
|
180
|
+
| `onLocationChange` | 监听实时位置变化(仅 APP) | `callback: Function` |
|
|
181
|
+
| `offLocationChange` | 取消监听位置变化(仅 APP) | `callback?: Function` |
|
|
182
|
+
| `onLocationChangeError` | 监听位置更新错误(仅 APP) | `callback: Function` |
|
|
183
|
+
| `offLocationChangeError` | 取消监听位置更新错误(仅 APP) | `callback?: Function` |
|
|
178
184
|
|
|
179
185
|
#### 实现原理
|
|
180
186
|
|
|
@@ -356,7 +362,7 @@ references/ # 开发参考(如原版 uni.webview.1.5.6.js)
|
|
|
356
362
|
- [x] 获取位置 ✅
|
|
357
363
|
- [x] 查看位置 ✅
|
|
358
364
|
- [x] 照片选择 ✅
|
|
359
|
-
- [
|
|
365
|
+
- [x] 持续定位 ✅
|
|
360
366
|
- [ ] 相机
|
|
361
367
|
- [ ] 蓝牙
|
|
362
368
|
- [ ] WiFi
|
|
@@ -503,18 +509,35 @@ await qsh.openLocationAsync({
|
|
|
503
509
|
参考文档:[UniApp getLocation](https://uniapp.dcloud.net.cn/api/location/location.html)
|
|
504
510
|
|
|
505
511
|
#### 持续定位(仅 APP)
|
|
512
|
+
|
|
506
513
|
```javascript
|
|
507
|
-
//
|
|
514
|
+
// 1. 开启前台持续定位服务
|
|
508
515
|
qsh.startLocationUpdate({
|
|
509
|
-
type: 'wgs84',
|
|
510
|
-
|
|
511
|
-
success: (
|
|
512
|
-
|
|
513
|
-
|
|
516
|
+
type: 'wgs84', // 坐标类型
|
|
517
|
+
needFullAccuracy: true, // 是否需要高精度
|
|
518
|
+
success: () => console.log('定位服务已开启'),
|
|
519
|
+
fail: (err) => console.error('开启失败:', err)
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
// 2. 监听位置变化
|
|
523
|
+
qsh.onLocationChange((res) => {
|
|
524
|
+
console.log('位置:', res.latitude, res.longitude);
|
|
525
|
+
console.log('精度:', res.accuracy, '米');
|
|
514
526
|
});
|
|
515
527
|
|
|
516
|
-
//
|
|
517
|
-
qsh.
|
|
528
|
+
// 3. 监听定位错误(可选)
|
|
529
|
+
qsh.onLocationChangeError((err) => {
|
|
530
|
+
console.error('定位出错:', err);
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
// 4. 停止监听
|
|
534
|
+
qsh.offLocationChange();
|
|
535
|
+
qsh.offLocationChangeError();
|
|
536
|
+
|
|
537
|
+
// 5. 停止定位服务
|
|
538
|
+
qsh.stopLocationUpdate({
|
|
539
|
+
success: () => console.log('定位服务已停止')
|
|
540
|
+
});
|
|
518
541
|
```
|
|
519
542
|
|
|
520
543
|
### 相机功能
|
package/dist/index.d.ts
CHANGED
|
@@ -54,9 +54,9 @@ declare namespace UniWebView {
|
|
|
54
54
|
/** 最多选择的图片数量,默认9 */
|
|
55
55
|
count?: number;
|
|
56
56
|
/** 图片质量类型 */
|
|
57
|
-
sizeType?: (
|
|
57
|
+
sizeType?: ("original" | "compressed")[];
|
|
58
58
|
/** 图片来源类型 */
|
|
59
|
-
sourceType?: (
|
|
59
|
+
sourceType?: ("album" | "camera")[];
|
|
60
60
|
/** 成功回调 */
|
|
61
61
|
success?: (res: ChooseImageResult) => void;
|
|
62
62
|
/** 失败回调 */
|
|
@@ -99,16 +99,16 @@ declare namespace UniWebView {
|
|
|
99
99
|
* 图片来源类型枚举
|
|
100
100
|
*/
|
|
101
101
|
interface ImageSourceTypesEnum {
|
|
102
|
-
readonly ALBUM:
|
|
103
|
-
readonly CAMERA:
|
|
102
|
+
readonly ALBUM: "album";
|
|
103
|
+
readonly CAMERA: "camera";
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* 图片大小类型枚举
|
|
108
108
|
*/
|
|
109
109
|
interface ImageSizeTypesEnum {
|
|
110
|
-
readonly ORIGINAL:
|
|
111
|
-
readonly COMPRESSED:
|
|
110
|
+
readonly ORIGINAL: "original";
|
|
111
|
+
readonly COMPRESSED: "compressed";
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
/**
|
|
@@ -200,7 +200,7 @@ declare namespace UniWebView {
|
|
|
200
200
|
/** 是否 Html5Plus 环境 */
|
|
201
201
|
isHtml5Plus: boolean;
|
|
202
202
|
/** 环境类型 */
|
|
203
|
-
type:
|
|
203
|
+
type: "weixin" | "plus" | "nvue" | "uvue" | "UniApp" | "webview" | "h5";
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
/**
|
|
@@ -233,6 +233,57 @@ declare namespace UniWebView {
|
|
|
233
233
|
[key: string]: any;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
+
/**
|
|
237
|
+
* 打印PDF选项
|
|
238
|
+
*/
|
|
239
|
+
interface PrintPdfOptions {
|
|
240
|
+
/** 要打印的文件 */
|
|
241
|
+
url: string;
|
|
242
|
+
/** HTTP 请求 Header,header 中不能设置 Referer 类型 UTSJSONObject */
|
|
243
|
+
header?: Record<string, string>;
|
|
244
|
+
/** 超时时间,单位 ms 默认 120000ms*/
|
|
245
|
+
timeout?: number;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* 打印PDF结果
|
|
250
|
+
*/
|
|
251
|
+
interface PrintPdfResult {
|
|
252
|
+
data: {
|
|
253
|
+
jobId: string;
|
|
254
|
+
};
|
|
255
|
+
message: string;
|
|
256
|
+
/** 0 成功,非0 失败 */
|
|
257
|
+
code: 0 | number;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* 打印PDF结果
|
|
262
|
+
*/
|
|
263
|
+
interface PrintPdfResult {
|
|
264
|
+
/** 错误信息 */
|
|
265
|
+
errMsg?: string;
|
|
266
|
+
[key: string]: any;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* 打印PDF功能能力信息
|
|
271
|
+
*/
|
|
272
|
+
interface PrintPdfCapabilities {
|
|
273
|
+
/** 是否支持打印PDF功能 */
|
|
274
|
+
supported: boolean;
|
|
275
|
+
/** 当前环境类型 */
|
|
276
|
+
environment: string;
|
|
277
|
+
/** 底层实现类型 */
|
|
278
|
+
implementation: string;
|
|
279
|
+
/** 功能特性 */
|
|
280
|
+
features: {
|
|
281
|
+
/** 支持 Promise */
|
|
282
|
+
asyncSupport: boolean;
|
|
283
|
+
[key: string]: any;
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
236
287
|
/**
|
|
237
288
|
* WebView 对象接口
|
|
238
289
|
*/
|
|
@@ -258,17 +309,21 @@ declare namespace UniWebView {
|
|
|
258
309
|
ready(): Promise<void>;
|
|
259
310
|
/** WebView 对象(兼容旧版本) */
|
|
260
311
|
webView: WebView | null;
|
|
261
|
-
|
|
312
|
+
|
|
262
313
|
/** 图片选择(Promise版本) */
|
|
263
|
-
chooseImageAsync(
|
|
314
|
+
chooseImageAsync(
|
|
315
|
+
options?: Omit<ChooseImageOptions, "success" | "fail" | "complete">,
|
|
316
|
+
): Promise<ChooseImageResult>;
|
|
264
317
|
/** 获取图片功能能力信息 */
|
|
265
318
|
getImageCapabilities(): ImageCapabilities;
|
|
266
|
-
|
|
319
|
+
|
|
267
320
|
/** 位置选择(Promise版本) */
|
|
268
|
-
chooseLocationAsync(
|
|
321
|
+
chooseLocationAsync(
|
|
322
|
+
options?: Omit<ChooseLocationOptions, "success" | "fail" | "complete">,
|
|
323
|
+
): Promise<ChooseLocationResult>;
|
|
269
324
|
/** 获取位置选择功能能力信息 */
|
|
270
325
|
getChooseLocationCapabilities(): ChooseLocationCapabilities;
|
|
271
|
-
|
|
326
|
+
|
|
272
327
|
/** 图片来源类型枚举 */
|
|
273
328
|
ImageSourceTypes: ImageSourceTypesEnum;
|
|
274
329
|
/** 图片大小类型枚举 */
|
|
@@ -276,25 +331,39 @@ declare namespace UniWebView {
|
|
|
276
331
|
|
|
277
332
|
/** 微信分享 */
|
|
278
333
|
toShare(options: ShareOptions): Promise<ShareResult> | void;
|
|
279
|
-
toShareAsync(
|
|
334
|
+
toShareAsync(
|
|
335
|
+
options: Omit<ShareOptions, "success" | "fail" | "complete">,
|
|
336
|
+
): Promise<ShareResult>;
|
|
280
337
|
|
|
281
338
|
/** 蓝牙 API */
|
|
282
339
|
openBluetoothAdapter(options?: BluetoothOptions): Promise<any> | void;
|
|
283
340
|
openBluetoothAdapterAsync(options?: BluetoothOptions): Promise<any>;
|
|
284
|
-
startBluetoothDevicesDiscovery(
|
|
285
|
-
|
|
341
|
+
startBluetoothDevicesDiscovery(
|
|
342
|
+
options?: BluetoothOptions,
|
|
343
|
+
): Promise<any> | void;
|
|
344
|
+
startBluetoothDevicesDiscoveryAsync(
|
|
345
|
+
options?: BluetoothOptions,
|
|
346
|
+
): Promise<any>;
|
|
286
347
|
onBluetoothDeviceFound(options?: BluetoothOptions): Promise<any> | void;
|
|
287
348
|
onBluetoothDeviceFoundAsync(options?: BluetoothOptions): Promise<any>;
|
|
288
349
|
createBLEConnection(options?: BluetoothOptions): Promise<any> | void;
|
|
289
350
|
createBLEConnectionAsync(options?: BluetoothOptions): Promise<any>;
|
|
290
351
|
|
|
352
|
+
/** 打印PDF API */
|
|
353
|
+
printPdf(
|
|
354
|
+
options: PrintPdfOptions,
|
|
355
|
+
callback: (result: PrintPdfResult) => void,
|
|
356
|
+
): void;
|
|
357
|
+
printPdfAsync(options: PrintPdfOptions): Promise<PrintPdfResult>;
|
|
358
|
+
/** 获取打印PDF功能能力信息 */
|
|
359
|
+
getPrintCapabilities(): PrintPdfCapabilities;
|
|
360
|
+
|
|
291
361
|
/** 观测指标 */
|
|
292
362
|
metrics: {
|
|
293
363
|
getPerformanceReport(): Record<string, any>;
|
|
294
364
|
clearPerformanceMetrics(): void;
|
|
295
365
|
};
|
|
296
366
|
}
|
|
297
|
-
}
|
|
298
367
|
}
|
|
299
368
|
|
|
300
369
|
/**
|
|
@@ -318,4 +387,4 @@ declare global {
|
|
|
318
387
|
}
|
|
319
388
|
}
|
|
320
389
|
|
|
321
|
-
export as namespace qsh;
|
|
390
|
+
export as namespace qsh;
|