@foundbyte/uni-libs 0.0.9-alpha.1 → 0.0.9-alpha.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.
@@ -1,3 +1,5 @@
1
+ import "../../assets/js/webview/uni.webview.1.5.6.js";
2
+
1
3
  //#region src/utils/web-view/index.d.ts
2
4
  declare enum EMessagesType {
3
5
  pay = "pay",
@@ -1,10 +1,7 @@
1
- import uni1 from "../../assets/js/webview/uni.webview.1.5.5.js";
2
- import uni2 from "../../assets/js/webview/uni.webview.1.5.6.js";
1
+ import "../../assets/js/webview/uni.webview.1.5.6.js";
3
2
  import wx from "weixin-js-sdk";
4
3
 
5
4
  //#region src/utils/web-view/index.ts
6
- const userAgent = navigator.userAgent.toLowerCase();
7
- const isIosOrAndroid = !userAgent.includes("miniprogram") && (userAgent.includes("android") || userAgent.includes("iphone") || userAgent.includes("ipad"));
8
5
  document.addEventListener("UniAppJSBridgeReady", function() {
9
6
  uni.webView.getEnv(function(res) {});
10
7
  });
@@ -20,8 +17,7 @@ const navigateTo = (parameters) => {
20
17
  const { src, params } = parameters;
21
18
  const url = `${src}${params ? `?${objectToQueryString(params)}` : ""}`;
22
19
  try {
23
- if (isIosOrAndroid) uni2?.webView?.navigateTo?.({ url });
24
- else uni1?.webView?.navigateTo?.({ url });
20
+ uni?.webView?.navigateTo?.({ url });
25
21
  /** 不兼容上面的方法会自动往下执行 */
26
22
  wx.miniProgram.navigateTo({ url });
27
23
  } catch (error) {
@@ -36,8 +32,7 @@ const redirectTo = (parameters) => {
36
32
  const { src, params } = parameters;
37
33
  const url = `${src}${params ? `?${objectToQueryString(params)}` : ""}`;
38
34
  try {
39
- if (isIosOrAndroid) uni2?.webView?.redirectTo?.({ url });
40
- else uni1?.webView?.redirectTo?.({ url });
35
+ uni?.webView?.redirectTo?.({ url });
41
36
  /** 不兼容上面的方法会自动往下执行 */
42
37
  wx.miniProgram.redirectTo({ url });
43
38
  } catch (error) {
@@ -50,8 +45,7 @@ const redirectTo = (parameters) => {
50
45
  */
51
46
  const navigateBack = (parameters) => {
52
47
  try {
53
- if (isIosOrAndroid) uni2?.webView?.navigateBack?.(parameters);
54
- else uni1?.webView?.navigateBack?.(parameters);
48
+ uni?.webView?.navigateBack?.(parameters);
55
49
  /** 不兼容上面的方法会自动往下执行 */
56
50
  wx.miniProgram.navigateBack(parameters);
57
51
  } catch (error) {
@@ -70,8 +64,7 @@ const postMessage = (data) => {
70
64
  });
71
65
  return;
72
66
  }
73
- if (isIosOrAndroid) uni2?.webView?.postMessage({ data });
74
- else uni1?.webView?.postMessage({ data });
67
+ uni?.webView?.postMessage({ data });
75
68
  };
76
69
  function objectToQueryString(obj) {
77
70
  const params = Object.entries(obj).map(([key, value]) => {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@foundbyte/uni-libs",
3
3
  "description": "FoundByte Uni Libs",
4
4
  "author": "yangshuai <704807396@qq.com>",
5
- "version": "0.0.9-alpha.01",
5
+ "version": "0.0.9-alpha.02",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",