qsh-webview-sdk 2.2.2 → 2.3.1

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 CHANGED
@@ -460,7 +460,7 @@ qsh.scanCode({
460
460
  ```javascript
461
461
  // 回调方式
462
462
  qsh.getLocation({
463
- type: 'wgs84', // 坐标类型:wgs84(GPS), gcj02(国测局), bd09(百度)
463
+ type: 'wgs84', // 坐标类型:wgs84(GPS) 目前仅支持wgs84
464
464
  altitude: false, // 是否返回高度信息
465
465
  success: (res) => {
466
466
  console.log('纬度:', res.latitude);
@@ -558,19 +558,6 @@ qsh.stopLocationUpdate({
558
558
  });
559
559
  ```
560
560
 
561
- ### 相机功能
562
-
563
- ```javascript
564
- // 相机拍照(小程序/APP)
565
- qsh.takePhoto({
566
- quality: 'high', // 图片质量:low, normal, high
567
- sizeType: 'compressed', // 图片尺寸:original, compressed
568
- success: (res) => {
569
- console.log('照片路径:', res.tempImagePath);
570
- },
571
- fail: (err) => console.error(err)
572
- });
573
- ```
574
561
 
575
562
  ### 蓝牙功能(仅 APP)
576
563
 
@@ -601,26 +588,6 @@ qsh.createBLEConnection({
601
588
  });
602
589
  ```
603
590
 
604
- ### WiFi 功能(仅 APP)
605
-
606
- ```javascript
607
- // 获取 WiFi 信息
608
- qsh.getWifiInfo({
609
- success: (res) => {
610
- console.log('WiFi SSID:', res.wifi.SSID);
611
- console.log('WiFi BSSID:', res.wifi.BSSID);
612
- },
613
- fail: (err) => console.error(err)
614
- });
615
-
616
- // 连接 WiFi
617
- qsh.connectWifi({
618
- SSID: 'wifi-name',
619
- password: 'wifi-password',
620
- success: () => console.log('连接成功'),
621
- fail: (err) => console.error('连接失败:', err)
622
- });
623
- ```
624
591
 
625
592
  ### 微信分享(仅 APP)
626
593
 
@@ -652,10 +619,10 @@ qsh.chooseFile({
652
619
  });
653
620
  ```
654
621
 
655
- ### 地图选择位置
622
+ ### 地图选择位置(仅 APP)
656
623
 
657
624
  ```javascript
658
- // 打开地图选择位置(小程序/APP)
625
+ // 打开地图选择位置(APP)
659
626
  qsh.chooseLocation({
660
627
  latitude: 39.908823, // 初始纬度
661
628
  longitude: 116.397470, // 初始经度
@@ -682,18 +649,9 @@ qsh.faceVerify({
682
649
  ### 打印服务(仅 APP)
683
650
 
684
651
  ```javascript
685
- // 打印文本
686
- qsh.printText({
687
- content: '打印内容',
688
- printerName: '打印机名称',
689
- success: () => console.log('打印成功'),
690
- fail: (err) => console.error('打印失败:', err)
691
- });
692
-
693
- // 打印图片
694
- qsh.printImage({
695
- imagePath: '/path/to/image.jpg',
696
- printerName: '打印机名称',
652
+ // 调用打印服务
653
+ qsh.printPdf({
654
+ url: '', // pdf文件地址
697
655
  success: () => console.log('打印成功'),
698
656
  fail: (err) => console.error('打印失败:', err)
699
657
  });
@@ -734,7 +692,18 @@ import { onMounted } from 'vue';
734
692
  import qsh from 'qsh-webview-sdk';
735
693
 
736
694
  onMounted(async () => {
737
- await qsh.ready();
695
+ // 小程序环境下要先进行签名
696
+ if (qsh.environment.isWeixinMiniProgram) {
697
+ qsh.config({
698
+ clientId: '',
699
+ isProd: import.meta.env.MODE === 'production'
700
+ })
701
+ }
702
+
703
+ qsh.ready().catch((err) => {
704
+ console.error('qsh ready failed', err)
705
+ })
706
+
738
707
  qsh.navigateTo({ url: '/pages/demo/index' });
739
708
  });
740
709
  </script>
package/dist/index.d.ts CHANGED
@@ -43,6 +43,8 @@ declare namespace UniWebView {
43
43
  nvue?: boolean;
44
44
  /** 是否 UVUE 环境 */
45
45
  uvue?: boolean;
46
+ /** 是否离线包 WebView 环境 */
47
+ offline?: boolean;
46
48
  /** 是否 H5 环境 */
47
49
  h5?: boolean;
48
50
  }
@@ -199,23 +201,74 @@ declare namespace UniWebView {
199
201
  isUniApp: boolean;
200
202
  /** 是否 Html5Plus 环境 */
201
203
  isHtml5Plus: boolean;
204
+ /** 是否离线包 WebView 环境 */
205
+ isOfflineWebview: boolean;
202
206
  /** 环境类型 */
203
- type: "weixin" | "plus" | "nvue" | "uvue" | "UniApp" | "webview" | "h5";
207
+ type: "weixin" | "plus" | "nvue" | "uvue" | "UniApp" | "webview" | "h5" | "offline";
204
208
  }
205
209
 
210
+ /** 高阶 toShare:内容类型(与 type 二选一) */
211
+ type ShareUniversalKind = "web" | "text" | "image" | "miniProgram";
212
+
213
+ /** 高阶 toShare:去向 */
214
+ type ShareUniversalScene = "chat" | "timeline";
215
+
216
+ /** 各 kind 对应的 payload(按需传字段) */
217
+ interface ShareUniversalPayloadWeb {
218
+ title: string;
219
+ summary: string;
220
+ imageUrl: string;
221
+ /** 图文链接,与 href 二选一 */
222
+ path?: string;
223
+ href?: string;
224
+ }
225
+
226
+ interface ShareUniversalPayloadText {
227
+ /** 与 text 二选一 */
228
+ summary?: string;
229
+ text?: string;
230
+ }
231
+
232
+ interface ShareUniversalPayloadImage {
233
+ imageUrl: string;
234
+ }
235
+
236
+ interface ShareUniversalPayloadMiniProgram {
237
+ title: string;
238
+ summary: string;
239
+ imageUrl: string;
240
+ miniProgram: {
241
+ /** 小程序原始 ID(gh_ 开头),uni.share type=5 要求 */
242
+ id: string;
243
+ path: string;
244
+ webUrl: string;
245
+ type?: 0 | 1 | 2;
246
+ };
247
+ }
248
+
249
+ type ShareUniversalPayload =
250
+ | ShareUniversalPayloadWeb
251
+ | ShareUniversalPayloadText
252
+ | ShareUniversalPayloadImage
253
+ | ShareUniversalPayloadMiniProgram;
254
+
206
255
  /**
207
- * 微信分享选项
256
+ * 微信分享选项(toShare 仅支持高阶入参)
208
257
  */
209
258
  interface ShareOptions {
210
- /** 分享去向:0 聊天,1 朋友圈 */
211
- scene?: 0 | 1;
212
- /** 分享内容类型:0 图文,1 文字,2 图片,3 音乐,4 视频,5 小程序 */
213
- type: 0 | 1 | 2 | 3 | 4 | 5;
214
- title?: string;
215
- summary?: string;
216
- imageUrl?: string;
217
- path?: string;
218
- miniProgram?: Record<string, any>;
259
+ kind: ShareUniversalKind;
260
+ /** kind 对应字段见 ShareUniversalPayload */
261
+ payload?: ShareUniversalPayload;
262
+ /** true 时不打印 hint 日志 */
263
+ silent?: boolean;
264
+ /**
265
+ * 为 true 且当前为微信 JS-SDK 环境时,走宿主 WebView 桥 toShareData(兼容原 toShareCallBack)
266
+ */
267
+ viaWebViewBridge?: boolean;
268
+ /** @deprecated 等同于 viaWebViewBridge */
269
+ isCallBack?: boolean;
270
+ /** 分享去向:0 / chat 聊天,1 / timeline 朋友圈 */
271
+ scene?: 0 | 1 | ShareUniversalScene;
219
272
  success?: (res: ShareResult) => void;
220
273
  fail?: (error: any) => void;
221
274
  complete?: () => void;
@@ -223,6 +276,14 @@ declare namespace UniWebView {
223
276
 
224
277
  interface ShareResult {
225
278
  errMsg?: string;
279
+ /** 使用 kind 高阶参数时,成功回调会附带 hint / environment / raw */
280
+ hint?: string;
281
+ environment?: {
282
+ type: Environment["type"];
283
+ isWeixinMiniProgram: boolean;
284
+ };
285
+ raw?: ShareResult;
286
+ error?: any;
226
287
  [key: string]: any;
227
288
  }
228
289
 
@@ -381,6 +442,13 @@ declare namespace UniWebView {
381
442
  options: Omit<ShareOptions, "success" | "fail" | "complete">,
382
443
  ): Promise<ShareResult>;
383
444
 
445
+ /** toShare 参数说明(结构化,可 JSON 展示) */
446
+ readonly TO_SHARE_PARAM_HELP: Readonly<Record<string, unknown>>;
447
+ /** 返回 toShare 参数说明对象 */
448
+ getToShareParamHelp(): Readonly<Record<string, unknown>>;
449
+ /** 在控制台打印 toShare 参数说明,并返回文本 */
450
+ printToShareParamHelp(): string;
451
+
384
452
  /** 蓝牙 API */
385
453
  openBluetoothAdapter(options?: BluetoothOptions): Promise<any> | void;
386
454
  openBluetoothAdapterAsync(options?: BluetoothOptions): Promise<any>;