@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.1 → 1.0.0-beta.10

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/.versionrc CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "tagPrefix": "@lambo-design-mobile/js-bridge@",
3
- "releaseCommitMessageFormat": "chore(release): @lambo-design-mobile/js-bridge@{{currentTag}}",
2
+ "tagPrefix": "@lambo-design-mobile/lambo-js-bridge@",
3
+ "releaseCommitMessageFormat": "chore(release): @lambo-design-mobile/lambo-js-bridge@{{currentTag}}",
4
4
  "path": ".",
5
5
  "header": "# Changelog",
6
6
  "types": [
package/CHANGELOG.md CHANGED
@@ -1,4 +1,151 @@
1
1
  # Changelog
2
+ ## 1.0.0-beta.10 (2024-09-12)
3
+
4
+
5
+ ### ✅ Tests | 测试
6
+
7
+ * **@lambo-design-mobile/js-bridge:** 测试图片预览代码 ([21580d0](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/21580d0940ed11f8911f5cd1ab35782c64b7d4e8))
8
+ * **@lambo-design-mobile/js-bridge:** 测试图片预览代码 ([0f34ad8](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/0f34ad833be581f5345ebe758c062a9cb8e4c770))
9
+ * **@lambo-design-mobile/js-bridge:** oss上传图片测试 ([2b96afb](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/2b96afb1d153afaf251f169a1679cef5b95ca6c6))
10
+
11
+
12
+ ### ⚡ Performance Improvements | 性能优化
13
+
14
+ * **@lambo-design-mobile/js-bridge:** 删除代码中的日志输出 ([2787cae](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/2787caed31dadcf764aa89234fdc63ef63b5633e))
15
+ * **@lambo-design-mobile/js-bridge:** 修改script加载方式 ([dc7bd53](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/dc7bd533f6bde2a25700f05bb7293562400ecb70))
16
+
17
+
18
+ ### 📝 Documentation | 文档
19
+
20
+ * **@lambo-design-mobile/js-bridge:** 新增初始化函数入参出参文档说明 ([6398076](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/6398076b85c76d9fc86a0e964eb0d8224bd86721))
21
+ * **@lambo-design-mobile/js-bridge:** 新增openLocation相关文档 ([8b6d76f](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/8b6d76f876ccf792770d39e0d2ef110a34bce16e))
22
+ * **@lambo-design-mobile/js-bridge:** 修改文档内容 ([76d2d4f](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/76d2d4f2b6b0e76056566986c75048564c4b6ccc))
23
+ * **@lambo-design-mobile/js-bridge:** 修改README说明 ([bfc7255](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/bfc7255ed88289fc366e4c5fbf1f9bc5584b1c1a))
24
+ * **lambo-design-mobile/js-bridge:** 说明文档修改 ([5232d53](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/5232d53e97c7a94414b270104bda52c3dd530428))
25
+
26
+
27
+ ### '🎫 Chores | 其他更新
28
+
29
+ * **release:** @lambo-design-mobile/js-bridge@1.0.0-beta.1 ([ed261cb](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/ed261cbbf8f6b3525be65a48a7b0a25b96ca5404))
30
+ * **release:** @lambo-design-mobile/js-bridge@1.0.0-beta.2 ([4a908df](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/4a908dfe98546a0b29ae287dcbe45bb25a3c6ba6))
31
+ * **release:** @lambo-design-mobile/js-bridge@1.0.0-beta.3 ([d358f84](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/d358f84119e8d46c1c2fdb1d1500bb4d52ac91cd))
32
+ * **release:** @lambo-design-mobile/js-bridge@1.0.0-beta.4 ([aab48e5](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/aab48e54c1a621e17617e0a20e91bb648715df24))
33
+ * **release:** @lambo-design-mobile/js-bridge@1.0.0-beta.5 ([7312357](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/7312357ac09ee77e496dcd4e73de5bfe4599ada4))
34
+ * **release:** @lambo-design-mobile/js-bridge@1.0.0-beta.6 ([16b78d0](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/16b78d010d1b65c45b5ce38e7f91fb64c381fadc))
35
+ * **release:** @lambo-design-mobile/js-bridge@1.0.0-beta.7 ([7e90baa](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/7e90baa620acc9929af94206d57bbe131414c24a))
36
+ * **release:** @lambo-design-mobile/js-bridge@1.0.0-beta.8 ([1aaabba](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/1aaabba947b60f67bca013123c10058b908b9f35))
37
+ * **release:** @lambo-design-mobile/js-bridge@1.0.0-beta.9 ([56775d7](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/56775d70d5b136e47186f91a1133186704080409))
38
+
39
+
40
+ ### 🐛 Bug Fixes | Bug 修复
41
+
42
+ * **@lambo-design-mobile/js-bridge:** 完善全局调用文档,删除未使用代码 ([309c4af](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/309c4af613be0f8543a53e2d24c3702e44474134))
43
+ * **@lambo-design-mobile/js-bridge:** 完善文档 ([5d3b7b9](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/5d3b7b928e05b65ec21008b23f9e07ddd0deff1f))
44
+ * **@lambo-design-mobile/js-bridge:** 修复 js-bridge Vueuse注册方式 ([b5700a4](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/b5700a41bef48f174624f9bdbd9bb1e7bde26c0b))
45
+ * **@lambo-design-mobile/js-bridge:** 修复安卓上传图片至oss报错 ([89b4c3e](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/89b4c3e46ddc1d99f84a73b8a87609414ac2113d))
46
+ * **@lambo-design-mobile/js-bridge:** 修改脚本加载方式 ([c54550d](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/c54550d5698fe8f35f055fa6ab0bcf85429d138c))
47
+ * **@lambo-design-mobile/js-bridge:** 修正flutter环境下插件初始化问题 ([680e188](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/680e188449516e15a0355a3017b70a5eeea7c2d2))
48
+ * **@lambo-design-mobile/js-bridge:** 修正flutter环境下插件初始化问题 ([c5a7fba](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/c5a7fba9af2b2cd2abb20bc6bca1eec636c0c092))
49
+ * **@lambo-dsign-mobile/js-bridge:** 修复filePreview报错 ([5d19e45](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/5d19e45f14f558323aee06dedbe6462068469e66))
50
+
51
+
52
+ ### ✨ Features | 新功能
53
+
54
+ * **@lambo-design-mobile/js-bridge:** 更新浏览器页面接口 ([f7ebb25](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/f7ebb25794c1aded131ca4465e6dddf61758ce1b))
55
+ * **@lambo-design-mobile/js-bridge:** 更新浏览器页面接口 ([9c886d8](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/9c886d8ca970f3030264369a3a6a11b28de08a8d))
56
+ * **@lambo-design-mobile/js-bridge:** 更新企业微信接口 ([4bb321c](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/4bb321cc0d05058560f5d79d1f1a80f0233f20b7))
57
+ * **@lambo-design-mobile/js-bridge:** 更新ossServerContext接口地址 ([af9f153](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/af9f153ab5aec110ac62343db5089fe35bd59e6b))
58
+ * **@lambo-design-mobile/js-bridge:** 更新takePhoto接口outputType ([6a686d5](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/6a686d5f64d2cdd771ac02201da4103d7560ac35))
59
+ * **@lambo-design-mobile/js-bridge:** 更新takePhoto接口sourceType ([035b16e](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/035b16ef2afe5887829679344cf70caf49baf394))
60
+ * **@lambo-design-mobile/js-bridge:** 添加appId为入参 ([5da0d99](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/5da0d993e1734e9519e73ada8e002f07006bd980))
61
+ * **@lambo-design-mobile/js-bridge:** 微信接口拍照功能新增上传多张图片功能 ([9410191](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/941019106c18c0bec214f17e2e0b35a662d0288a))
62
+ * **@lambo-design-mobile/js-bridge:** 微信接口拍照功能新增上传多张图片预览功能 ([9cc5088](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/9cc5088858c98d33bc0cb0bd88cc4a689618fa6e))
63
+ * **@lambo-design-mobile/js-bridge:** 微信接口新增openLocation方法 ([8567b78](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/8567b78c87dd4f50131b67c3e7d1100ac18549c1))
64
+ * **@lambo-design-mobile/js-bridge:** 微信上传照片新增oss接口 ([60347db](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/60347db9ae7d61dcae77a25f4f1b0aa2d58d2e41))
65
+ * **@lambo-design-mobile/js-bridge:** 新增企业微信openLocation接口 ([3ec0d0f](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/3ec0d0f0d7de394194dec45d161ce0de1dcf25bc))
66
+ * **@lambo-design-mobile/js-bridge:** 新增上传图片预览 ([b33e525](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/b33e5251d8fb17c82ab1c2ccbb3038de801c60ee))
67
+ * **@lambo-design-mobile/js-bridge:** 新增BrowserAdapter Mock数据 ([56160de](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/56160deb375747ef7611be449db6f031ea2fa541))
68
+ * **@lambo-design-mobile/js-bridge:** 新增Flutter JsBridge接口 ([96ed86c](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/96ed86c9a530194d43290a23b0df9afbebe383d2))
69
+ * **@lambo-design-mobile/js-bridge:** 新增mixin全局声明 ([b7abf59](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/b7abf5976e3ee850a49e2ea2386fe2dec110a89c))
70
+ * **@lambo-design-mobile/js-bridge:** 修改变量默认值 ([c813d63](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/c813d635832bcff59d059288f77745404e71f060))
71
+ * **@lambo-design-mobile/js-bridge:** 修改图片预览布局 ([5176b51](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/5176b517d61e19536a4cbe2b0284e4402c84cdfc))
72
+ * **@lambo-design-mobile/js-bridge:** 修改微信scanCode接口返回值 ([08eec00](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/08eec00882059839b1d207b98ffec201a181f3d9))
73
+ * **@lambo-design-mobile/js-bridge:** 修改jsBridge默认参数值 ([7caeb91](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/7caeb919d4ace6d198c047bab4a564561e8e4502))
74
+ * **@lambo-design-mobile/js-bridge:** 修改takePhoto接口返回 ([177f92e](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/177f92e28251179e2c514414381ccd513d25301d))
75
+ * **@lambo-design-mobile/js-bridge:** 修改WeChat接口脚本加载方式 ([93445d3](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/93445d3779d6b734602003f0c86c9d9d4210b623))
76
+ * **@lambo-design-mobile/js-bridge:** 注释企业微信debug模式相关代码 ([ad3e2d7](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/ad3e2d732de2d7d4806f6c0a7d3718cb9f92895d))
77
+ * **@lambo-design-mobile/js-bridge:** getLocation接口新增支持百度bd09坐标系 ([9869b06](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/9869b06a0e455e5ddd994da0dcf2efb3e0479fb9))
78
+ * **@lambo-design-mobile/lambo-js-bridge:** 版本说明修改 ([a42d394](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/a42d394993a2cfbe72e61cfee58b8fe7ca13df49))
79
+ * **@lambo-design-mobile/lambo-js-picker:** 修改云途 ([0d8dd53](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/0d8dd5347c349787a1705e0d83531677e34159b2))
80
+ * **@lambo-dsign-mobile/js-bridge:** 新增filepreview ([80de1a1](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/80de1a1b7c7c690ea55895f2c6c9acfbf1859fda))
81
+ * **js-bridge:** 部分提交 ([2018f4e](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/2018f4eea620056036de0b73174999692b2e209d))
82
+ * **js-bridge:** 定位调试跑通 ([447623a](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/447623a97c0dac8e01407f07406676705ce94e83))
83
+ * **js-bridge:** init ([308e8f3](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/308e8f349b8098cdb789448813c9bd612fe3e18a))
84
+ * **lambo-design-mobile/js-bridge:** 新增BrowserAdapter ([6c25393](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/6c25393c3cf7d6a2b4316dcf913a6064bd92c7b1))
85
+
86
+ ## [1.0.0-beta.9](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/js-bridge@1.0.0-beta.8...@lambo-design-mobile/js-bridge@1.0.0-beta.9) (2024-09-12)
87
+
88
+
89
+ ### 🐛 Bug Fixes | Bug 修复
90
+
91
+ * **@lambo-design-mobile/js-bridge:** 修正flutter环境下插件初始化问题 ([680e188](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/680e188449516e15a0355a3017b70a5eeea7c2d2))
92
+ * **@lambo-design-mobile/js-bridge:** 修正flutter环境下插件初始化问题 ([c5a7fba](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/c5a7fba9af2b2cd2abb20bc6bca1eec636c0c092))
93
+
94
+
95
+ ### 📝 Documentation | 文档
96
+
97
+ * **@lambo-design-mobile/js-bridge:** 修改README说明 ([bfc7255](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/bfc7255ed88289fc366e4c5fbf1f9bc5584b1c1a))
98
+
99
+ ## [1.0.0-beta.8](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/js-bridge@1.0.0-beta.7...@lambo-design-mobile/js-bridge@1.0.0-beta.8) (2024-09-09)
100
+
101
+
102
+ ### ✨ Features | 新功能
103
+
104
+ * **@lambo-design-mobile/js-bridge:** 新增mixin全局声明 ([b7abf59](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/b7abf5976e3ee850a49e2ea2386fe2dec110a89c))
105
+
106
+
107
+ ### 🐛 Bug Fixes | Bug 修复
108
+
109
+ * **@lambo-design-mobile/js-bridge:** 修改脚本加载方式 ([c54550d](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/c54550d5698fe8f35f055fa6ab0bcf85429d138c))
110
+
111
+ ## [1.0.0-beta.7](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/js-bridge@1.0.0-beta.6...@lambo-design-mobile/js-bridge@1.0.0-beta.7) (2024-08-30)
112
+
113
+
114
+ ### 🐛 Bug Fixes | Bug 修复
115
+
116
+ * **@lambo-design-mobile/js-bridge:** 完善文档 ([5d3b7b9](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/5d3b7b928e05b65ec21008b23f9e07ddd0deff1f))
117
+ * **@lambo-dsign-mobile/js-bridge:** 修复filePreview报错 ([5d19e45](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/5d19e45f14f558323aee06dedbe6462068469e66))
118
+
119
+ ## [1.0.0-beta.6](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/js-bridge@1.0.0-beta.5...@lambo-design-mobile/js-bridge@1.0.0-beta.6) (2024-08-29)
120
+
121
+
122
+ ### 🐛 Bug Fixes | Bug 修复
123
+
124
+ * **@lambo-design-mobile/js-bridge:** 完善全局调用文档,删除未使用代码 ([309c4af](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/309c4af613be0f8543a53e2d24c3702e44474134))
125
+
126
+ ## [1.0.0-beta.5](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/js-bridge@1.0.0-beta.4...@lambo-design-mobile/js-bridge@1.0.0-beta.5) (2024-08-29)
127
+
128
+
129
+ ### ✨ Features | 新功能
130
+
131
+ * **@lambo-dsign-mobile/js-bridge:** 新增filepreview ([80de1a1](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/80de1a1b7c7c690ea55895f2c6c9acfbf1859fda))
132
+
133
+ ## [1.0.0-beta.4](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/js-bridge@1.0.0-beta.3...@lambo-design-mobile/js-bridge@1.0.0-beta.4) (2024-08-23)
134
+
135
+
136
+ ### ✨ Features | 新功能
137
+
138
+ * **@lambo-design-mobile/lambo-js-picker:** 修改云途 ([0d8dd53](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/0d8dd5347c349787a1705e0d83531677e34159b2))
139
+
140
+ ## [1.0.0-beta.3](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/js-bridge@1.0.0-beta.2...@lambo-design-mobile/js-bridge@1.0.0-beta.3) (2024-08-22)
141
+
142
+ ## [1.0.0-beta.2](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/js-bridge@1.0.0-beta.1...@lambo-design-mobile/js-bridge@1.0.0-beta.2) (2024-08-22)
143
+
144
+
145
+ ### ✨ Features | 新功能
146
+
147
+ * **@lambo-design-mobile/js-bridge:** 新增Flutter JsBridge接口 ([96ed86c](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/96ed86c9a530194d43290a23b0df9afbebe383d2))
148
+
2
149
  ## 1.0.0-beta.1 (2024-08-21)
3
150
 
4
151
 
package/README.md CHANGED
@@ -4,6 +4,47 @@
4
4
 
5
5
  LamboJsBridge 是一个js 适配sdk 用于处理H5应用和运行时环境的能力调用。支持微信、钉钉等环境。目前已适配微信(WechatAdapter)和企业微信(WeComAdapter)
6
6
 
7
+ ### Vue 全局引入
8
+
9
+ ``` javascript
10
+ /**
11
+ * Vue main.js 中加入如下代码
12
+ */
13
+ console.log("------ 初始化 LamboJsBridge -------")
14
+ import LamboJsBridge from "@lambo-design-mobile/lambo-js-bridge";
15
+ Vue.use(LamboJsBridge);
16
+ ```
17
+ ### 调用
18
+
19
+ ``` javascript
20
+ // 直接调用扫码功能
21
+ // Vue方法中
22
+ this.$lamboJsBridge.scanCode()
23
+
24
+ //其他Js界面
25
+ Vue.prototype.$lamboJsBridge.scanCode();
26
+ /**
27
+ * 也可以自己封装一层工具类
28
+ * 扫描二维码并返回结果。(需要在APP环境下测试)
29
+ * 此函数通过调用 Flutter scanCode.startScan 方法来启动二维码扫描。
30
+ * 扫描成功后返回扫描结果,若扫描失败则返回错误信息。
31
+ *
32
+ * @returns {Promise<String>} - 返回一个 Promise,当扫描成功时 resolve,返回扫描的结果字符串;如果失败,reject 返回错误信息。
33
+ * @example
34
+ * flutterUtil.scanCode()
35
+ * .then(result => {
36
+ * console.log('扫描结果:', result.msg);
37
+ * })
38
+ * .catch(error => {
39
+ * console.error('扫描失败:', error.msg);
40
+ * });
41
+ */
42
+ flutterUtil.scanCode = function() {
43
+ return Vue.prototype.$lamboJsBridge.scanCode();
44
+ };
45
+ ```
46
+
47
+
7
48
  ### 引入
8
49
 
9
50
  ``` javascript
@@ -23,14 +64,14 @@ import LamboJsBridge from '@lambo-design-mobile/lambo-js-bridge';
23
64
  weComId:this.weComId,
24
65
  dingTalkId:this.dingTalkId,
25
66
  };
26
- this.lamboBridge = new LamboJsBridge(options);
67
+ this.$lamboJsBridge = new LamboJsBridge(options);
27
68
  await this.getPlatform();
28
69
  },
29
70
 
30
71
  methods: {
31
72
  async getPlatform() {
32
73
  try {
33
- const info = await this.lamboBridge.getPlatform(); // 获取初始化信息
74
+ const info = await this.$lamboJsBridge.getPlatform(); // 获取初始化信息
34
75
  this.initInfo = JSON.stringify(info, null, 2); // 美化输出
35
76
  console.log('Init Info:', info);
36
77
  } catch (error) {
@@ -68,7 +109,7 @@ import LamboJsBridge from '@lambo-design-mobile/lambo-js-bridge';
68
109
  const options ={
69
110
  // 初始化参数,根据需要填写
70
111
  };
71
- const location = await this.lamboBridge.getLocation(options);
112
+ const location = await this.$lamboJsBridge.getLocation(options);
72
113
  console.log("location",location)
73
114
  this.location += `${JSON.stringify(location)}\n`; // 追加新数据
74
115
  this.latitude = location.latitude; // 存储纬度
@@ -115,7 +156,7 @@ import LamboJsBridge from '@lambo-design-mobile/lambo-js-bridge';
115
156
  const options ={
116
157
  // 初始化参数,根据需要填写
117
158
  };
118
- const result = await this.lamboBridge.scanCode(options);
159
+ const result = await this.$lamboJsBridge.scanCode(options);
119
160
  this.scanResult += `${JSON.stringify(result)}\n`; // 追加新数据
120
161
  console.log('Scan result:', result);
121
162
  } catch (error) {
@@ -155,7 +196,7 @@ import LamboJsBridge from '@lambo-design-mobile/lambo-js-bridge';
155
196
  ossImgPutUrl: this.ossImgPutUrl,
156
197
  ossImgGetUrl: this.ossImgGetUrl
157
198
  };
158
- const photo = await this.lamboBridge.takePhoto(options);
199
+ const photo = await this.$lamboJsBridge.takePhoto(options);
159
200
  this.photoResult += `${JSON.stringify(photo)}\n`; // 追加新数据
160
201
  console.log('Photo result:', photo);
161
202
  } catch (error) {
@@ -206,7 +247,7 @@ async openLocation() {
206
247
  address: this.address,
207
248
  scale: this.scale
208
249
  };
209
- await this.lamboBridge.openLocation(options);
250
+ await this.$lamboJsBridge.openLocation(options);
210
251
  this.openLocationResult = '位置已成功打开'; // 成功打开位置时存储信息
211
252
  console.log('Location opened successfully');
212
253
  } else {
package/demo/index.vue CHANGED
@@ -24,6 +24,9 @@
24
24
  <van-button @click="openLocation">打开位置</van-button>
25
25
  <pre v-if="openLocationResult"><code>{{ openLocationResult }}</code></pre>
26
26
  </demo-block>
27
+ <demo-block title="文件预览">
28
+ <a href="javascript:void(0);" @click="previewFile">点击这里预览文件</a>
29
+ </demo-block>
27
30
  </demo-section>
28
31
  </template>
29
32
 
@@ -43,8 +46,8 @@ export default {
43
46
  scanResult: '',
44
47
  photoResult: '',
45
48
  openLocationResult: '', // 添加用于存储打开位置的返回值
46
- latitude: null, // 存储纬度
47
- longitude: null, // 存储经度
49
+ latitude: 117.129, // 存储纬度
50
+ longitude: 36.662, // 存储经度
48
51
  ossServerContext: 'ibp-upms-server',
49
52
  ossImgPutUrl: '/oss/file/put',
50
53
  ossImgGetUrl: '/oss/file/get/',
@@ -81,13 +84,13 @@ export default {
81
84
  weComId:this.weComId,
82
85
  dingTalkId:this.dingTalkId,
83
86
  };
84
- this.lamboBridge = new LamboJsBridge(options);
87
+ this.$lamboJsBridge = new LamboJsBridge(options);
85
88
  await this.getPlatform();
86
89
  },
87
90
  methods: {
88
91
  async getPlatform() {
89
92
  try {
90
- const info = await this.lamboBridge.getPlatform(); // 获取初始化信息
93
+ const info = await this.$lamboJsBridge.getPlatform(); // 获取初始化信息
91
94
  this.initInfo = JSON.stringify(info, null, 2); // 美化输出
92
95
  console.log('Init Info:', info);
93
96
  } catch (error) {
@@ -99,12 +102,14 @@ export default {
99
102
  const options ={
100
103
  // 初始化参数,根据需要填写
101
104
  };
102
- const location = await this.lamboBridge.getLocation(options);
103
- console.log("location",location)
105
+ const location = await this.$lamboJsBridge.getLocation(options);
106
+ // console.log("location",location)
104
107
  this.location += `${JSON.stringify(location)}\n`; // 追加新数据
105
108
  this.latitude = location.latitude; // 存储纬度
106
109
  this.longitude = location.longitude; // 存储经度
107
- console.log('Location:', location);
110
+ console.log("this.latitude:",this.latitude);
111
+ console.log("this.longitude:",this.longitude);
112
+ // console.log('Location:', location);
108
113
  } catch (error) {
109
114
  console.error('Error getting location:', error);
110
115
  }
@@ -114,7 +119,7 @@ export default {
114
119
  const options ={
115
120
  // 初始化参数,根据需要填写
116
121
  };
117
- const result = await this.lamboBridge.scanCode(options);
122
+ const result = await this.$lamboJsBridge.scanCode(options);
118
123
  this.scanResult += `${JSON.stringify(result)}\n`; // 追加新数据
119
124
  // console.log('Scan result:', result);
120
125
  } catch (error) {
@@ -126,9 +131,10 @@ export default {
126
131
  const options = {
127
132
  ossServerContext: this.ossServerContext,
128
133
  ossImgPutUrl: this.ossImgPutUrl,
129
- ossImgGetUrl: this.ossImgGetUrl
134
+ ossImgGetUrl: this.ossImgGetUrl,
135
+ // sourceType: 'gallery'
130
136
  };
131
- const photos = await this.lamboBridge.takePhoto(options);
137
+ const photos = await this.$lamboJsBridge.takePhoto(options);
132
138
  this.photoResult += `${JSON.stringify(photos)}\n`;
133
139
  console.log("Photo result:", photos); // 调试输出
134
140
 
@@ -156,7 +162,7 @@ export default {
156
162
  address: this.address,
157
163
  scale: this.scale
158
164
  };
159
- await this.lamboBridge.openLocation(options);
165
+ await this.$lamboJsBridge.openLocation(options);
160
166
  this.openLocationResult = '位置已成功打开'; // 成功打开位置时存储信息
161
167
  console.log('Location opened successfully');
162
168
  } else {
@@ -167,6 +173,18 @@ export default {
167
173
  this.openLocationResult = `打开位置时出错: ${error.message}`; // 存储错误信息
168
174
  console.error('Error opening location:', error);
169
175
  }
176
+ },
177
+ async previewFile() {
178
+ try {
179
+ const options = {
180
+ title: '预览文件.txt', // 文件的标题
181
+ path: 'http://160.mall.eap.lambo.top/ecm-runtime-server/api/file/get/123456' // 文件的URL路径
182
+ };
183
+ const result = await this.$lamboJsBridge.filePreview(options);
184
+ console.log('File preview result:', result);
185
+ } catch (error) {
186
+ console.error('Error previewing file:', error);
187
+ }
170
188
  }
171
189
  },
172
190
  beforeRouteEnter (to, from, next) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design-mobile/lambo-js-bridge",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.10",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -9,7 +9,9 @@
9
9
  "access": "public",
10
10
  "registry": "https://registry.npmjs.org/"
11
11
  },
12
- "dependencies": {},
12
+ "dependencies": {
13
+ "coordtransform": "^2.1.2"
14
+ },
13
15
  "scripts": {
14
16
  "release-js-bridge": "pnpm release-beta && git push --follow-tags && pnpm re-publish",
15
17
  "release-major": "standard-version --release-as major",
@@ -0,0 +1,74 @@
1
+ import config from "@lambo-design-mobile/shared/config/config";
2
+ import coordtransform from "coordtransform";
3
+
4
+ const addScript = function (src, cb) {
5
+ const script = document.createElement('script')
6
+ script.src = src
7
+ document.getElementsByTagName('head')[0].appendChild(script)
8
+ script.onload = function () {
9
+ if (!!cb) {
10
+ cb()
11
+ }
12
+ }
13
+ }
14
+
15
+ export function initBdMap() {
16
+ let tempAk = 'AWZBggDSk8Zsv2STX7S2SBYO6wsH7BVT'
17
+ if (config.akList) {
18
+ tempAk = config.akList[Math.random() * config.akList.length]
19
+ }
20
+ addScript('https://api.map.baidu.com/api?v=1.0&&type=webgl&ak=' + tempAk)
21
+ addScript('https://api.map.baidu.com/getscript?type=webgl&v=1.0&ak=' + tempAk)
22
+ }
23
+
24
+ export function getAddress(longitude, latitude) {
25
+ const myGeo = new BMap.Geocoder({extensions_town: false});
26
+ let city = ''
27
+ let province = ''
28
+ let address = ''
29
+
30
+ // 根据坐标得到地址描述
31
+ myGeo.getLocation(new BMap.Point(longitude, latitude), function(result){
32
+ if (result){
33
+ city = result.addressComponents.city
34
+ province = result.addressComponents.province
35
+ address = result.address
36
+ }
37
+ });
38
+ return {
39
+ city,
40
+ province,
41
+ address
42
+ }
43
+ }
44
+
45
+ export function getAxisByType(unifiedLocation, locationType) {
46
+ // 目前只有wgs84 bd09 gcj02 默认传进unifiedLocation 坐标系为gcj02 不转换
47
+ if(locationType === 'bd09') {
48
+ // 将 gcj02 坐标转换为 bd09
49
+ const [bd09Lng, bd09Lat] = coordtransform.gcj02tobd09(unifiedLocation.longitude, unifiedLocation.latitude);
50
+ unifiedLocation.longitude = bd09Lng;
51
+ unifiedLocation.latitude = bd09Lat;
52
+ }
53
+ else if(locationType === 'wgs84'){
54
+ // 将 gcj02 坐标转换为 bd09
55
+ const [wgs84Lng, wgs84Lat] = coordtransform.gcj02towgs84(unifiedLocation.longitude, unifiedLocation.latitude);
56
+ unifiedLocation.longitude = wgs84Lng;
57
+ unifiedLocation.latitude = wgs84Lat;
58
+ }
59
+ if (!unifiedLocation.latitude || !unifiedLocation.longitude) {
60
+ return false;
61
+ }
62
+ return unifiedLocation
63
+ }
64
+
65
+ export function getAddressByType(unifiedLocation, locationType) {
66
+
67
+ const [bd09Lng, bd09Lat] = coordtransform.gcj02tobd09(unifiedLocation.longitude, unifiedLocation.latitude);
68
+ // 根据坐标得到地址描述
69
+ const res = getAddress(bd09Lng, bd09Lat)
70
+ unifiedLocation.city = res.addressComponents.city
71
+ unifiedLocation.province = res.addressComponents.province
72
+ unifiedLocation.address = res.address
73
+ getAxisByType(unifiedLocation, locationType)
74
+ }
@@ -4,26 +4,10 @@ import CordovaAdapter from './CordovaAdapter';
4
4
  import YunTuAdapter from './YunTuAdapter';
5
5
  import WeComAdapter from './WeComAdapter';
6
6
  import BrowserAdapter from './BrowserAdapter';
7
+ import MobileIMAdaoter from './MobileIMAdaoter';
7
8
 
8
9
  class LamboJsBridge {
9
10
  constructor(param) {
10
- // param.isBdNiJieXi 需要百度地图逆地址解析
11
- if(param.isBdNiJieXi) {
12
- const addScript = function (src, cb) {
13
- const script = document.createElement('script')
14
- script.src = src
15
- document.getElementsByTagName('head')[0].appendChild(script)
16
- script.onload = function () {
17
- if (!!cb) {
18
- cb()
19
- }
20
- }
21
- }
22
- addScript('https://api.map.baidu.com/api?v=1.0&&type=webgl&ak=AWZBggDSk8Zsv2STX7S2SBYO6wsH7BVT')
23
- addScript(
24
- 'https://api.map.baidu.com/getscript?type=webgl&v=1.0&ak=AWZBggDSk8Zsv2STX7S2SBYO6wsH7BVT',
25
- )
26
- }
27
11
  this._detectPlatform(param);
28
12
  }
29
13
 
@@ -33,41 +17,56 @@ class LamboJsBridge {
33
17
  this.platform = new WeComAdapter(param);
34
18
  } else if (/micromessenger/.test(userAgent)) {
35
19
  this.platform = new WechatAdapter(param);
36
- }else if (/dingtalk/.test(userAgent)) {
20
+ } else if (/dingtalk/.test(userAgent)) {
37
21
  this.platform = new DingTalkAdapter(param);
38
22
  } else if (/cordova/.test(userAgent)) {
39
23
  this.platform = new CordovaAdapter(param);
40
24
  } else if (/yuntu/.test(userAgent)) {
41
25
  this.platform = new YunTuAdapter(param);
26
+ } else if (/mobileim/.test(userAgent)) {
27
+ this.platform = new MobileIMAdaoter(param);
42
28
  } else {
43
29
  this.platform = new BrowserAdapter();
44
30
  }
31
+ }
45
32
 
33
+ async initializePlugin(pluginConfig = []) {
34
+ if (this.platform instanceof YunTuAdapter) {
35
+ return this.platform.initializePlugin(pluginConfig);
36
+ } else {
37
+ return Promise.resolve();
38
+ }
46
39
  }
47
40
 
48
- //通用接口:获取初始化信息
49
41
  async getPlatform(options = {}) {
50
42
  return this.platform.getPlatform(options);
51
43
  }
52
44
 
53
- // 通用接口:获取位置信息
54
45
  async getLocation(options = {}) {
55
- // options = {type:'wgs84'};
56
46
  return this.platform.getLocation(options);
57
47
  }
58
48
 
59
- // 通用接口:扫码
60
49
  async scanCode(options = {}) {
61
50
  return this.platform.scanCode(options);
62
51
  }
63
52
 
64
- // 通用接口:拍照或选择图片
65
53
  async takePhoto(options = {}) {
66
54
  return this.platform.takePhoto(options);
67
55
  }
68
56
 
69
- async openLocation(options = {}){
57
+ async openLocation(options = {}) {
70
58
  return this.platform.openLocation(options);
71
59
  }
60
+
61
+ async filePreview(options = {}) {
62
+ return this.platform.filePreview(options);
63
+ }
64
+
65
+ // 创建一个 Vue 插件
66
+ static install(Vue) {
67
+ // 将 LamboJsBridge 实例挂载到 Vue 原型上,全局可用
68
+ Vue.prototype.$lamboJsBridge = new LamboJsBridge({});
69
+ }
72
70
  }
71
+
73
72
  export default LamboJsBridge;
@@ -0,0 +1,64 @@
1
+ class MobileIMAdaoter {
2
+ constructor(_options) {
3
+ function loadScript(src) {
4
+ return new Promise((resolve, reject) => {
5
+ const script = document.createElement('script');
6
+ script.src = src;
7
+ script.onload = () => resolve(script);
8
+ script.onerror = () => reject(new Error('Failed to load script'));
9
+ document.head.appendChild(script);
10
+ });
11
+ }
12
+ loadScript('/ind-uc-ext/native.js')
13
+ .then((script) => console.log('Script loaded'))
14
+ .catch((err) => console.error(err));
15
+ }
16
+
17
+ async getLocation(options) {
18
+ return new Promise((resolve, reject) => {
19
+ try {
20
+ let args = {
21
+ // 是否获取地址信息
22
+ isNeedAddress: true,
23
+ };
24
+ window.native.getLocation(args, (res) => {
25
+ console.error('getLocation success:', res);
26
+ resolve({
27
+ latitude: res.point.latitude,
28
+ longitude: res.point.longitude,
29
+ accuracy: res.point.horizontalAccuracy,
30
+ address: res.address,
31
+ province: res.addressComponents.province,
32
+ city: res.addressComponents.city,
33
+ });
34
+ });
35
+ } catch (err) {
36
+ console.error('getLocation failed:', err);
37
+ reject(err);
38
+ }
39
+ });
40
+ }
41
+
42
+ async scanCode(options) {
43
+ return new Promise((resolve, reject) => {
44
+ try {
45
+ window.native.qrScan((res) => {
46
+ console.log('scanQRCode success:', res);
47
+ resolve(res);
48
+ });
49
+ } catch (err) {
50
+ console.error('scanQRCode failed:', err);
51
+ reject(err);
52
+ }
53
+ });
54
+ }
55
+
56
+ async getInitInfo(options = {}) {
57
+ // 获取初始化信息
58
+ return {
59
+ platform: 'MobileIM',
60
+ };
61
+ }
62
+ }
63
+
64
+ export default MobileIMAdaoter;
@@ -3,7 +3,8 @@
3
3
 
4
4
  import ajax from "@lambo-design-mobile/shared/utils/ajax";
5
5
  import config from "@lambo-design-mobile/shared/config/config";
6
- import coordtransform from "coordtransform";
6
+ // import coordtransform from "coordtransform";
7
+ import { getAddress, initBdMap, getAddressByType, getAxisByType } from './BdMapUtils';
7
8
 
8
9
  class WechatAdapter {
9
10
  constructor(_options) {
@@ -87,16 +88,14 @@ class WechatAdapter {
87
88
  if (!unifiedLocation.latitude || !unifiedLocation.longitude) {
88
89
  return reject(new Error('Invalid location data'));
89
90
  }
90
-
91
- const myGeo = new BMap.Geocoder({extensions_town: false});
92
- // 根据坐标得到地址描述
93
- myGeo.getLocation(new BMap.Point(unifiedLocation.longitude, unifiedLocation.latitude), function(result){
94
- if (result){
95
- unifiedLocation.city = result.addressComponents.city
96
- unifiedLocation.province = result.addressComponents.province
97
- unifiedLocation.address = result.address
98
- }
99
- });
91
+ // options.needAddress 是否需要地址信息
92
+ // if(options.needAddress && !unifiedLocation.address) {
93
+ // // 根据坐标得到地址描述
94
+ // const res = getAddress(unifiedLocation.longitude, unifiedLocation.latitude)
95
+ // unifiedLocation.city = res.addressComponents.city
96
+ // unifiedLocation.province = res.addressComponents.province
97
+ // unifiedLocation.address = res.address
98
+ // }
100
99
 
101
100
  resolve(unifiedLocation);
102
101
  },
@@ -108,31 +107,67 @@ class WechatAdapter {
108
107
  });
109
108
  };
110
109
 
111
- if (locationType === 'bd09') {
112
- // 先获取 gcj02 坐标
113
- fetchLocation('gcj02').then(unifiedLocation => {
114
- // gcj02 坐标转换为 bd09
115
- const [bd09Lng, bd09Lat] = coordtransform.gcj02tobd09(unifiedLocation.longitude, unifiedLocation.latitude);
116
- unifiedLocation.longitude = bd09Lng;
117
- unifiedLocation.latitude = bd09Lat;
110
+ // 先判断是否需要地理位置 如不需要 直接返回坐标
111
+ if(options.needAddress) {
112
+ fetchLocation('gcj02'.then(unifiedLocation => {
113
+ const result = getAddressByType(unifiedLocation, locationType)
114
+ if(!result) {
115
+ return reject(new Error('Invalid location data'));
116
+ }
117
+ resolve(unifiedLocation);
118
+ }))
119
+ .catch(err => { reject(err) })
120
+ }
121
+ else {
122
+ resolve(fetchLocation(locationType))
123
+ }
118
124
 
119
- const myGeo = new BMap.Geocoder({extensions_town: false});
120
- // 根据坐标得到地址描述
121
- myGeo.getLocation(new BMap.Point(unifiedLocation.longitude, unifiedLocation.latitude), function(result){
122
- if (result){
123
- unifiedLocation.city = result.addressComponents.city
124
- unifiedLocation.province = result.addressComponents.province
125
- unifiedLocation.address = result.address
126
- }
127
- });
125
+ // // 先取gcj02 再根据type转成不同坐标系
126
+ // fetchLocation('gcj02').then(unifiedLocation => {
127
+ // // options.needAddress 是否需要地址信息
128
+ // if(options.needAddress && !unifiedLocation.address) {
129
+ // const result = getAddressByType(unifiedLocation, locationType)
130
+ // if(!result) {
131
+ // return reject(new Error('Invalid location data'));
132
+ // }
133
+ // resolve(unifiedLocation);
134
+ // }
135
+ // else {
136
+ // const result = getAxisByType(unifiedLocation, locationType)
137
+ // if(!result) {
138
+ // return reject(new Error('Invalid location data'));
139
+ // }
140
+ // resolve(unifiedLocation);
141
+ // }
142
+ // }).catch(err => {
143
+ // reject(err);
144
+ // });
128
145
 
129
- resolve(unifiedLocation);
130
- }).catch(err => {
131
- reject(err);
132
- });
133
- } else {
134
- fetchLocation(locationType).then(resolve).catch(reject);
135
- }
146
+
147
+ // if (locationType === 'bd09') {
148
+ // // 先获取 gcj02 坐标
149
+ // fetchLocation('gcj02').then(unifiedLocation => {
150
+ // // gcj02 坐标转换为 bd09
151
+ // const [bd09Lng, bd09Lat] = coordtransform.gcj02tobd09(unifiedLocation.longitude, unifiedLocation.latitude);
152
+ // unifiedLocation.longitude = bd09Lng;
153
+ // unifiedLocation.latitude = bd09Lat;
154
+ // if (!unifiedLocation.latitude || !unifiedLocation.longitude) {
155
+ // return reject(new Error('Invalid location data'));
156
+ // }
157
+ // // options.needAddress 是否需要地址信息
158
+ // if(options.needAddress && !unifiedLocation.address) {
159
+ // // 根据坐标得到地址描述
160
+ // const res = getAddress(unifiedLocation.longitude, unifiedLocation.latitude)
161
+ // unifiedLocation.city = res.addressComponents.city
162
+ // unifiedLocation.province = res.addressComponents.province
163
+ // unifiedLocation.address = res.address
164
+ // }
165
+
166
+ // resolve(unifiedLocation);
167
+ // }).catch(err => {
168
+ // reject(err);
169
+ // });
170
+ // }
136
171
  });
137
172
  });
138
173
  }
@@ -1,21 +1,187 @@
1
+ import './yuntu';
2
+
1
3
  class YunTuAdapter {
4
+ constructor() {
5
+ // 标志插件是否已初始化
6
+ this.isInitialized = false;
7
+ this.initializePlugin();
8
+ }
9
+
10
+ async initializePlugin(pluginConfig) {
11
+ try {
12
+ const configToUse = Array.isArray(pluginConfig) && pluginConfig.length > 0
13
+ ? JSON.stringify(pluginConfig)
14
+ : '["myPlugin","tabBarPlugin","scanCodePlugin","filePreviewPlugin","imagePickerPlugin"]';
15
+ await yuntuConfig(configToUse); // 确保等待 yuntuConfig 执行完成
16
+ this.isInitialized = true;
17
+ this.plugins = JSON.parse(configToUse);
18
+ console.log("Initialized plugins:", this.plugins);
19
+ return this.plugins;
20
+ } catch (error) {
21
+ console.error("Plugin initialization failed:", error);
22
+ this.isInitialized = false;
23
+ return "Plugin initialization failed:" + error;
24
+ }
25
+ }
26
+
27
+ // 其余代码保持不变
28
+ async getPlatform() {
29
+ return {
30
+ platform: 'Yuntu'
31
+ };
32
+ }
33
+
2
34
  async getLocation(options) {
3
- // 实现云途移动平台获取位置逻辑
4
- console.log('Yu n Tu: Getting location with options', options);
5
- // 这里应替换为云途移动平台API的实际调用
35
+ if (!this.isInitialized) {
36
+ await this.initializePlugin(); // 确保插件初始化
37
+ }
38
+
39
+ return new Promise((resolve, reject) => {
40
+
41
+ if (window.geolocation && typeof window.geolocation.getCurrentPosition === 'function') {
42
+ window.geolocation.getCurrentPosition(
43
+ (res) => {
44
+ console.log('YunTu: Location obtained', JSON.stringify(res));
45
+ resolve(res); // 成功获取位置
46
+ },
47
+ (err) => {
48
+ console.error('YunTu: Failed to obtain location', err);
49
+ reject(err); // 获取位置失败
50
+ },
51
+ options
52
+ );
53
+ } else {
54
+ const errorMessage = 'Geolocation is not initialized or not available';
55
+ console.error('YunTu:', errorMessage);
56
+ reject(new Error(errorMessage)); // Geolocation 未初始化或不可用
57
+ }
58
+ });
59
+ }
60
+
61
+ async openLocation(options) {
62
+ if (!this.isInitialized) {
63
+ await this.initializePlugin(); // 确保插件初始化
64
+ }
65
+
66
+ return new Promise((resolve, reject) => {
67
+ if (window.geolocation && typeof window.geolocation.openLocation === 'function') {
68
+ console.log("1")
69
+ window.geolocation.openLocation(
70
+ (res) => {
71
+ console.log('YunTu: Open location success', res);
72
+ resolve(res); // 成功打开地图
73
+ },
74
+ (err) => {
75
+ console.error('YunTu: Failed to open location', err);
76
+ reject(err); // 打开地图失败
77
+ },
78
+ {
79
+ latitude: options.latitude,
80
+ longitude: options.longitude,
81
+ type: options.type || 'amap' // 默认为高德地图
82
+ }
83
+ );
84
+ } else {
85
+ const errorMessage = 'Geolocation is not initialized or not available';
86
+ console.error('YunTu:', errorMessage);
87
+ reject(new Error(errorMessage)); // Geolocation 未初始化或不可用
88
+ }
89
+ });
6
90
  }
7
91
 
8
92
  async scanCode(options) {
9
- // 实现云途移动平台扫码逻辑
10
- console.log('YunTu: Scanning code with options', options);
11
- // 这里应替换为云途移动平台API的实际调用
93
+ if (!this.isInitialized) {
94
+ await this.initializePlugin(); // 确保插件初始化
95
+ }
96
+
97
+ return new Promise((resolve, reject) => {
98
+ if (window.scanCode && typeof window.scanCode.startScan === 'function') {
99
+ window.scanCode.startScan(
100
+ (res) => {
101
+ console.log('YunTu: Scan code success', res);
102
+ resolve(res); // 成功获取扫码结果
103
+ },
104
+ (err) => {
105
+ console.error('YunTu: Failed to scan code', err);
106
+ reject(err); // 扫码失败
107
+ },
108
+ options // 传递给扫码方法的选项
109
+ );
110
+ } else {
111
+ const errorMessage = 'ScanCode is not initialized or not available';
112
+ console.error('YunTu:', errorMessage);
113
+ reject(new Error(errorMessage)); // ScanCode 未初始化或不可用
114
+ }
115
+ });
12
116
  }
13
117
 
118
+
14
119
  async takePhoto(options) {
15
- // 实现云途移动平台拍照或选择图片逻辑
16
120
  console.log('YunTu: Taking photo with options', options);
17
- // 这里应替换为云途移动平台API的实际调用
121
+
122
+ if (!this.isInitialized) {
123
+ await this.initializePlugin(); // 确保插件初始化
124
+ }
125
+
126
+ return new Promise((resolve, reject) => {
127
+ if (window.imagePicker) {
128
+ const sourceType = options && options.sourceType === 'gallery' ? 'gallery' : 'camera';
129
+ const pickerFunction = window.imagePicker[sourceType];
130
+
131
+ if (typeof pickerFunction === 'function') {
132
+ pickerFunction(
133
+ (res) => {
134
+ console.log('YunTu: Photo selection success', res);
135
+ resolve(JSON.parse(res)); // 成功获取照片
136
+ },
137
+ (err) => {
138
+ console.error('YunTu: Failed to select photo', err);
139
+ reject(JSON.parse(err)); // 选择照片失败
140
+ },
141
+ options // 传递给选取照片方法的选项(如果有需要的话)
142
+ );
143
+ } else {
144
+ const errorMessage = `${sourceType} function is not available in ImagePicker`;
145
+ console.error('YunTu:', errorMessage);
146
+ reject(new Error(errorMessage)); // 相应的接口未初始化或不可用
147
+ }
148
+ } else {
149
+ const errorMessage = 'ImagePicker is not initialized or not available';
150
+ console.error('YunTu:', errorMessage);
151
+ reject(new Error(errorMessage)); // ImagePicker 未初始化或不可用
152
+ }
153
+ });
154
+ };
155
+
156
+ async filePreview(options) {
157
+ console.log('YunTu: File preview with options', options);
158
+
159
+ if (!this.isInitialized) {
160
+ await this.initializePlugin(); // Ensure the plugin is initialized
161
+ }
162
+
163
+ return new Promise((resolve, reject) => {
164
+ if (window.filePreview && typeof window.filePreview.openFile === 'function') {
165
+ window.filePreview.openFile(
166
+ (res) => {
167
+ console.log('YunTu: File preview success', res);
168
+ resolve(res); // Successfully previewed the file
169
+ },
170
+ (err) => {
171
+ console.error('YunTu: File preview failed', err);
172
+ reject(err); // Failed to preview the file
173
+ },
174
+ JSON.stringify(options) // Pass the options as a string
175
+ );
176
+ } else {
177
+ const errorMessage = 'FilePreview is not initialized or not available';
178
+ console.error('YunTu:', errorMessage);
179
+ reject(new Error(errorMessage)); // FilePreview interface is not available
180
+ }
181
+ });
18
182
  }
183
+
184
+
19
185
  }
20
186
 
21
- export default YunTuAdapter;
187
+ export default YunTuAdapter;
@@ -0,0 +1,55 @@
1
+ (function(global) {
2
+ global.yuntu = {
3
+ config: function (options) {
4
+ global.flutter_inappwebview.callHandler(
5
+ "yuntu",
6
+ "init",
7
+ options
8
+ );
9
+ },
10
+ exec: function(plugin, action, successCallback, errorCallback, options) {
11
+ global.flutter_inappwebview.callHandler(
12
+ plugin,
13
+ action,
14
+ options
15
+ ).then((result) => {
16
+ successCallback(result);
17
+ }).catch((error) => {
18
+ errorCallback(error);
19
+ });
20
+ }
21
+ };
22
+
23
+ // 等待一个全局函数或变量加载完成
24
+ function waitForGlobalVariableOrFunction(globalName, callHandler) {
25
+ return new Promise((resolve, reject) => {
26
+ var interval = 1000; // 每1000毫秒检查一次
27
+ var timeout = 10000; // 设定最大等待时间 10 秒
28
+ var elapsedTime = 0;
29
+
30
+ var timer = setInterval(function () {
31
+ elapsedTime += interval;
32
+ if (global[globalName] && global[globalName][callHandler] !== undefined) {
33
+ clearInterval(timer); // 停止定时器
34
+ resolve(); // 执行回调函数,表示成功
35
+ console.log("yuntu 插件加载成功");
36
+ } else if (elapsedTime >= timeout) {
37
+ clearInterval(timer); // 停止定时器
38
+ console.log("yuntu 插件加载失败");
39
+ reject(new Error(`Timeout: ${globalName}.${callHandler} not found within ${timeout}ms`));
40
+ }
41
+ }, interval);
42
+ });
43
+ }
44
+
45
+ global.yuntuConfig = async function(options) {
46
+ try {
47
+ await waitForGlobalVariableOrFunction('flutter_inappwebview', 'callHandler');
48
+ global.yuntu.config(options);
49
+ } catch (error) {
50
+ console.error("yuntuConfig 初始化失败:", error);
51
+ throw error; // 如果失败则抛出错误
52
+ }
53
+ };
54
+
55
+ })(window);