qsh-webview-sdk 2.3.0 → 2.3.2

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/index.d.ts CHANGED
@@ -27,6 +27,27 @@ declare namespace UniWebView {
27
27
  data?: any;
28
28
  }
29
29
 
30
+ interface MiniProgramNavigateResult {
31
+ /** errMsg */
32
+ errMsg?: string;
33
+ [key: string]: any;
34
+ }
35
+
36
+ interface MiniProgramNavigateOptions {
37
+ /** target mini program id */
38
+ appid: string;
39
+ /** target mini program page path */
40
+ path?: string;
41
+ /** target mini program env */
42
+ env?: "release" | "trial" | "develop";
43
+ /** success callback */
44
+ success?: (res: MiniProgramNavigateResult) => void;
45
+ /** fail callback */
46
+ fail?: (error: any) => void;
47
+ /** complete callback */
48
+ complete?: () => void;
49
+ }
50
+
30
51
  /**
31
52
  * 环境信息
32
53
  */
@@ -207,19 +228,68 @@ declare namespace UniWebView {
207
228
  type: "weixin" | "plus" | "nvue" | "uvue" | "UniApp" | "webview" | "h5" | "offline";
208
229
  }
209
230
 
231
+ /** 高阶 toShare:内容类型(与 type 二选一) */
232
+ type ShareUniversalKind = "web" | "text" | "image" | "miniProgram";
233
+
234
+ /** 高阶 toShare:去向 */
235
+ type ShareUniversalScene = "chat" | "timeline";
236
+
237
+ /** 各 kind 对应的 payload(按需传字段) */
238
+ interface ShareUniversalPayloadWeb {
239
+ title: string;
240
+ summary: string;
241
+ imageUrl: string;
242
+ /** 图文链接,与 href 二选一 */
243
+ path?: string;
244
+ href?: string;
245
+ }
246
+
247
+ interface ShareUniversalPayloadText {
248
+ /** 与 text 二选一 */
249
+ summary?: string;
250
+ text?: string;
251
+ }
252
+
253
+ interface ShareUniversalPayloadImage {
254
+ imageUrl: string;
255
+ }
256
+
257
+ interface ShareUniversalPayloadMiniProgram {
258
+ title: string;
259
+ summary: string;
260
+ imageUrl: string;
261
+ miniProgram: {
262
+ /** 小程序原始 ID(gh_ 开头),uni.share type=5 要求 */
263
+ id: string;
264
+ path: string;
265
+ webUrl: string;
266
+ type?: 0 | 1 | 2;
267
+ };
268
+ }
269
+
270
+ type ShareUniversalPayload =
271
+ | ShareUniversalPayloadWeb
272
+ | ShareUniversalPayloadText
273
+ | ShareUniversalPayloadImage
274
+ | ShareUniversalPayloadMiniProgram;
275
+
210
276
  /**
211
- * 微信分享选项
277
+ * 微信分享选项(toShare 仅支持高阶入参)
212
278
  */
213
279
  interface ShareOptions {
214
- /** 分享去向:0 聊天,1 朋友圈 */
215
- scene?: 0 | 1;
216
- /** 分享内容类型:0 图文,1 文字,2 图片,3 音乐,4 视频,5 小程序 */
217
- type: 0 | 1 | 2 | 3 | 4 | 5;
218
- title?: string;
219
- summary?: string;
220
- imageUrl?: string;
221
- path?: string;
222
- miniProgram?: Record<string, any>;
280
+ kind: ShareUniversalKind;
281
+ /** kind 对应字段见 ShareUniversalPayload */
282
+ payload?: ShareUniversalPayload;
283
+ /** true 时不打印 hint 日志 */
284
+ silent?: boolean;
285
+ /**
286
+ * 为 true 且当前为微信 JS-SDK 环境时,走宿主 WebView 桥 toShareData(兼容原 toShareCallBack)
287
+ */
288
+ viaWebViewBridge?: boolean;
289
+ /** @deprecated 等同于 viaWebViewBridge */
290
+ isCallBack?: boolean;
291
+ /** 分享去向:0 / chat 聊天,1 / timeline 朋友圈 */
292
+ scene?: 0 | 1 | ShareUniversalScene;
223
293
  success?: (res: ShareResult) => void;
224
294
  fail?: (error: any) => void;
225
295
  complete?: () => void;
@@ -227,6 +297,14 @@ declare namespace UniWebView {
227
297
 
228
298
  interface ShareResult {
229
299
  errMsg?: string;
300
+ /** 使用 kind 高阶参数时,成功回调会附带 hint / environment / raw */
301
+ hint?: string;
302
+ environment?: {
303
+ type: Environment["type"];
304
+ isWeixinMiniProgram: boolean;
305
+ };
306
+ raw?: ShareResult;
307
+ error?: any;
230
308
  [key: string]: any;
231
309
  }
232
310
 
@@ -340,6 +418,7 @@ declare namespace UniWebView {
340
418
  switchTab(options: NavigateOptions): void;
341
419
  reLaunch(options: NavigateOptions): void;
342
420
  redirectTo(options: NavigateOptions): void;
421
+ navigateToMiniProgram(options: MiniProgramNavigateOptions): void;
343
422
  postMessage(options?: PostMessageOptions): void;
344
423
  getEnv(callback: (info: EnvironmentInfo) => void): void;
345
424
  chooseImage(options?: ChooseImageOptions): void;
@@ -358,6 +437,13 @@ declare namespace UniWebView {
358
437
  /** WebView 对象(兼容旧版本) */
359
438
  webView: WebView | null;
360
439
 
440
+ navigateToMiniProgram(
441
+ options: MiniProgramNavigateOptions,
442
+ ): Promise<MiniProgramNavigateResult> | void;
443
+ navigateToMiniProgramAsync(
444
+ options: Omit<MiniProgramNavigateOptions, "success" | "fail" | "complete">,
445
+ ): Promise<MiniProgramNavigateResult>;
446
+
361
447
  weixin: WeixinNamespace;
362
448
 
363
449
  /** 图片选择(Promise版本) */
@@ -385,6 +471,13 @@ declare namespace UniWebView {
385
471
  options: Omit<ShareOptions, "success" | "fail" | "complete">,
386
472
  ): Promise<ShareResult>;
387
473
 
474
+ /** toShare 参数说明(结构化,可 JSON 展示) */
475
+ readonly TO_SHARE_PARAM_HELP: Readonly<Record<string, unknown>>;
476
+ /** 返回 toShare 参数说明对象 */
477
+ getToShareParamHelp(): Readonly<Record<string, unknown>>;
478
+ /** 在控制台打印 toShare 参数说明,并返回文本 */
479
+ printToShareParamHelp(): string;
480
+
388
481
  /** 蓝牙 API */
389
482
  openBluetoothAdapter(options?: BluetoothOptions): Promise<any> | void;
390
483
  openBluetoothAdapterAsync(options?: BluetoothOptions): Promise<any>;