qsh-webview-sdk 2.3.8 → 2.4.0

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
@@ -58,7 +58,7 @@ import qsh from 'qsh-webview-sdk';
58
58
 
59
59
  if(qsh.environment.isWeixinMiniProgram) {
60
60
  qsh.config({
61
- clientId: 'your-client-id',
61
+ clientId: 'your-client-id', // 注意区分生产和测试的clientId
62
62
  isProd: false
63
63
  })
64
64
  }
@@ -478,7 +478,7 @@ qsh.getLocation({
478
478
  // Promise 版本
479
479
  try {
480
480
  const location = await qsh.getLocationAsync({
481
- type: 'gcj02',
481
+ type: 'wgs84',
482
482
  altitude: true
483
483
  });
484
484
  console.log('位置:', location.latitude, location.longitude);
@@ -511,7 +511,7 @@ await qsh.openLocationAsync({
511
511
  ```
512
512
 
513
513
  #### 坐标类型
514
-
514
+ 目前定位相关接口仅支持wgs84
515
515
  | 类型 | 说明 | 常量 |
516
516
  |------|------|------|
517
517
  | `wgs84` | GPS 坐标 | `qsh.CoordinateTypes.WGS84` |
@@ -588,37 +588,6 @@ qsh.createBLEConnection({
588
588
  });
589
589
  ```
590
590
 
591
-
592
- ### 微信分享(仅 APP)
593
-
594
- ```javascript
595
- // 分享到微信
596
- qsh.shareToWeixin({
597
- type: 'webpage', // 分享类型:text, image, webpage, music, video
598
- title: '分享标题',
599
- description: '分享描述',
600
- webpageUrl: 'https://example.com',
601
- imageUrl: 'https://example.com/image.jpg',
602
- success: () => console.log('分享成功'),
603
- fail: (err) => console.error('分享失败:', err)
604
- });
605
- ```
606
-
607
- ### 文件选择(仅 APP)
608
-
609
- ```javascript
610
- // 选择文件
611
- qsh.chooseFile({
612
- type: 'all', // 文件类型:all, image, video, audio, file
613
- count: 1,
614
- success: (res) => {
615
- console.log('文件路径:', res.tempFilePaths);
616
- console.log('文件信息:', res.tempFiles);
617
- },
618
- fail: (err) => console.error(err)
619
- });
620
- ```
621
-
622
591
  ### 地图选择位置(仅 APP)
623
592
 
624
593
  ```javascript
@@ -665,6 +634,40 @@ qsh.printPdf({
665
634
  - NVUE 页面
666
635
  - UVUE 页面 (UniApp X)
667
636
 
637
+ ### 跳转其他微信小程序
638
+
639
+ ```javascript
640
+ qsh.navigateToMiniProgram({
641
+ appid: ',
642
+ path: ',
643
+ // release/trial/develop
644
+ env: 'release',
645
+ success: (res) => console.log('跳转成功', res),
646
+ fail: (err) => console.error('跳转失败:', err),
647
+ });
648
+ ```
649
+
650
+ > `appid` 在微信小程序环境下传目标小程序 `AppID`,在 App-plus 环境下传微信小程序原始 ID。
651
+ > `env` 为可选参数,取值 `release` / `trial` / `develop`,不传时由基座按默认逻辑处理。
652
+ > 微信小程序 `web-view` 下,SDK 会先通过 `wx.miniProgram.postMessage` 把跳转请求投递给宿主,再调用 `wx.miniProgram.navigateBack` 触发宿主处理,因此当前 H5 页面会退出,且只能拿到“请求已投递”的结果,不能拿到宿主侧实时回调。
653
+
654
+ ### 在小程序中通过弹出层分享(仅小程序)
655
+
656
+ ```javascript
657
+ qsh.manualShare({
658
+ title: '分享标题',
659
+ h5Url: 'https://example.com/activity?id=123', // 要通过分享打开的h5页面地址
660
+ clientId: 'your-client-id', // 注意区分生产和测试的clientId
661
+ isPublic: false, // 默认false 分享打开的h5页面如果不需要登录权限可直接打开则传true
662
+ imageUrl: 'https://example.com/share.png',
663
+ description: '分享描述',
664
+ success: (res) => console.log('分享成功', res),
665
+ fail: (err) => console.error('分享失败:', err)
666
+ });
667
+ ```
668
+ 对于isPublic:true时 用户点击分享的内容后会直接从基座首页跳转到h5Url, 对于isPublic:false时,基座完成登录流程后会携带参数h5Url=${encodeURIComponent(h5Url)}跳转到业务配置的h5首页, 在h5首页获取code和h5Url后根据需要自行处理登录逻辑和跳转
669
+ 此方法会销毁当前H5页面并返回小程序基座
670
+
668
671
  ## License
669
672
 
670
673
  MIT
@@ -695,7 +698,7 @@ onMounted(async () => {
695
698
  // 小程序环境下要先进行签名
696
699
  if (qsh.environment.isWeixinMiniProgram) {
697
700
  qsh.config({
698
- clientId: '',
701
+ clientId: '', // 注意区分生产和测试的clientId
699
702
  isProd: import.meta.env.MODE === 'production'
700
703
  })
701
704
  }
package/dist/index.d.ts CHANGED
@@ -301,6 +301,8 @@ declare namespace UniWebView {
301
301
  kind: "web" | "text" | "image";
302
302
  scene?: 0 | 1 | ShareUniversalScene;
303
303
  payload: ShareUniversalPayload;
304
+ /** 原样透传给宿主 message 的自定义字段,不参与 SDK 默认分享参数组装 */
305
+ rowCustom?: any;
304
306
  success?: (res: ShareResult) => void;
305
307
  fail?: (error: any) => void;
306
308
  complete?: () => void;
@@ -328,11 +330,29 @@ declare namespace UniWebView {
328
330
 
329
331
  interface ShareMiniProgramCardOptions {
330
332
  payload: ShareMiniProgramCardPayload;
333
+ /** 原样透传给宿主 message 的自定义字段,不参与 SDK 默认分享参数组装 */
334
+ rowCustom?: any;
331
335
  success?: (res: ShareResult) => void;
332
336
  fail?: (error: any) => void;
333
337
  complete?: () => void;
334
338
  }
335
339
 
340
+ interface ManualSharePayload {
341
+ title: string;
342
+ /** 分享后打开的 H5 地址,基座会自动包装为小程序 webview 页面 */
343
+ h5Url: string;
344
+ clientId: string;
345
+ isPublic?: boolean;
346
+ imageUrl?: string;
347
+ description?: string;
348
+ }
349
+
350
+ interface ManualShareOptions extends ManualSharePayload {
351
+ success?: (res: ShareResult) => void;
352
+ fail?: (error: any) => void;
353
+ complete?: (res?: ShareResult | any) => void;
354
+ }
355
+
336
356
  interface BluetoothOptions {
337
357
  success?: (res: any) => void;
338
358
  fail?: (error: any) => void;
@@ -498,6 +518,12 @@ declare namespace UniWebView {
498
518
  options: Omit<ShareDirectedOptions, "success" | "fail" | "complete">,
499
519
  ): Promise<ShareResult>;
500
520
 
521
+ /** 手动分享预览:仅微信小程序 web-view,触发宿主分享弹窗 */
522
+ manualShare(options: ManualShareOptions): Promise<ShareResult> | void;
523
+ manualShareAsync(
524
+ options: Omit<ManualShareOptions, "success" | "fail" | "complete">,
525
+ ): Promise<ShareResult>;
526
+
501
527
  /** 蓝牙 API */
502
528
  openBluetoothAdapter(options?: BluetoothOptions): Promise<any> | void;
503
529
  openBluetoothAdapterAsync(options?: BluetoothOptions): Promise<any>;