@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.5 → 1.0.0-beta.7
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/CHANGELOG.md +15 -0
- package/README.md +54 -0
- package/demo/index.vue +1 -1
- package/package.json +1 -1
- package/src/sdk/LamboJsBridge.js +0 -5
- package/src/sdk/YunTuAdapter.js +29 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
## [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)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### 🐛 Bug Fixes | Bug 修复
|
|
6
|
+
|
|
7
|
+
* **@lambo-design-mobile/js-bridge:** 完善文档 ([5d3b7b9](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/5d3b7b928e05b65ec21008b23f9e07ddd0deff1f))
|
|
8
|
+
* **@lambo-dsign-mobile/js-bridge:** 修复filePreview报错 ([5d19e45](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/5d19e45f14f558323aee06dedbe6462068469e66))
|
|
9
|
+
|
|
10
|
+
## [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)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### 🐛 Bug Fixes | Bug 修复
|
|
14
|
+
|
|
15
|
+
* **@lambo-design-mobile/js-bridge:** 完善全局调用文档,删除未使用代码 ([309c4af](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/309c4af613be0f8543a53e2d24c3702e44474134))
|
|
16
|
+
|
|
2
17
|
## [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)
|
|
3
18
|
|
|
4
19
|
|
package/README.md
CHANGED
|
@@ -4,6 +4,60 @@
|
|
|
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
|
+
let lamboJsBridge = new LamboJsBridge();
|
|
16
|
+
try {
|
|
17
|
+
const platformInfo = await lamboJsBridge.getPlatform(); // 获取初始化信息
|
|
18
|
+
console.log('LamboJsBridge Platform Info:', JSON.stringify(platformInfo, null, 2));
|
|
19
|
+
|
|
20
|
+
//yuntu Flutter 平台需要初始化插件
|
|
21
|
+
const pluginConfig = ["scanCodePlugin", "filePreviewPlugin", "imagePickerPlugin"]
|
|
22
|
+
const pluginConfigInfo = await lamboJsBridge.initializePlugin(pluginConfig);
|
|
23
|
+
console.log('LamboJsBridge PluginConfig Info:', pluginConfigInfo);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error('Error getting init info:', error);
|
|
26
|
+
}
|
|
27
|
+
// 将 lamboJsBridge 挂载到 Vue 原型上
|
|
28
|
+
Vue.prototype.$lamboJsBridge = lamboJsBridge;
|
|
29
|
+
```
|
|
30
|
+
### 调用
|
|
31
|
+
|
|
32
|
+
``` javascript
|
|
33
|
+
// 直接调用扫码功能
|
|
34
|
+
// Vue方法中
|
|
35
|
+
this.$lamboJsBridge.scanCode()
|
|
36
|
+
|
|
37
|
+
//其他Js界面
|
|
38
|
+
Vue.prototype.$lamboJsBridge.scanCode();
|
|
39
|
+
/**
|
|
40
|
+
* 也可以自己封装一层工具类
|
|
41
|
+
* 扫描二维码并返回结果。(需要在APP环境下测试)
|
|
42
|
+
* 此函数通过调用 Flutter scanCode.startScan 方法来启动二维码扫描。
|
|
43
|
+
* 扫描成功后返回扫描结果,若扫描失败则返回错误信息。
|
|
44
|
+
*
|
|
45
|
+
* @returns {Promise<String>} - 返回一个 Promise,当扫描成功时 resolve,返回扫描的结果字符串;如果失败,reject 返回错误信息。
|
|
46
|
+
* @example
|
|
47
|
+
* flutterUtil.scanCode()
|
|
48
|
+
* .then(result => {
|
|
49
|
+
* console.log('扫描结果:', result.msg);
|
|
50
|
+
* })
|
|
51
|
+
* .catch(error => {
|
|
52
|
+
* console.error('扫描失败:', error.msg);
|
|
53
|
+
* });
|
|
54
|
+
*/
|
|
55
|
+
flutterUtil.scanCode = function() {
|
|
56
|
+
return Vue.prototype.$lamboJsBridge.scanCode();
|
|
57
|
+
};
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
|
|
7
61
|
### 引入
|
|
8
62
|
|
|
9
63
|
``` javascript
|
package/demo/index.vue
CHANGED
|
@@ -177,7 +177,7 @@ export default {
|
|
|
177
177
|
async previewFile() {
|
|
178
178
|
try {
|
|
179
179
|
const options = {
|
|
180
|
-
title: '
|
|
180
|
+
title: '预览文件.txt', // 文件的标题
|
|
181
181
|
path: 'http://160.mall.eap.lambo.top/ecm-runtime-server/api/file/get/123456' // 文件的URL路径
|
|
182
182
|
};
|
|
183
183
|
const result = await this.lamboBridge.filePreview(options);
|
package/package.json
CHANGED
package/src/sdk/LamboJsBridge.js
CHANGED
|
@@ -4,14 +4,9 @@ import CordovaAdapter from './CordovaAdapter';
|
|
|
4
4
|
import YunTuAdapter from './YunTuAdapter';
|
|
5
5
|
import WeComAdapter from './WeComAdapter';
|
|
6
6
|
import BrowserAdapter from './BrowserAdapter';
|
|
7
|
-
import { initBdMap } from './BdMapUtils';
|
|
8
7
|
|
|
9
8
|
class LamboJsBridge {
|
|
10
9
|
constructor(param) {
|
|
11
|
-
// param.isBdNiJieXi 需要百度地图逆地址解析
|
|
12
|
-
if (param.isBdNiJieXi) {
|
|
13
|
-
initBdMap();
|
|
14
|
-
}
|
|
15
10
|
this._detectPlatform(param);
|
|
16
11
|
}
|
|
17
12
|
|
package/src/sdk/YunTuAdapter.js
CHANGED
|
@@ -11,7 +11,7 @@ class YunTuAdapter {
|
|
|
11
11
|
// 如果传入的是非空数组,则直接使用;否则使用默认的全部插件配置
|
|
12
12
|
const configToUse = Array.isArray(pluginConfig) && pluginConfig.length > 0
|
|
13
13
|
? JSON.stringify(pluginConfig)
|
|
14
|
-
: '["myPlugin","
|
|
14
|
+
: '["myPlugin","tabBarPlugin","scanCodePlugin","filePreviewPlugin","imagePickerPlugin"]';
|
|
15
15
|
// 调用插件初始化
|
|
16
16
|
await yuntuConfig(configToUse); // 确保等待 yuntuConfig 执行完成
|
|
17
17
|
|
|
@@ -154,6 +154,34 @@ class YunTuAdapter {
|
|
|
154
154
|
reject(new Error(errorMessage)); // ImagePicker 未初始化或不可用
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
async filePreview(options) {
|
|
160
|
+
console.log('YunTu: File preview with options', options);
|
|
161
|
+
|
|
162
|
+
if (!this.isInitialized) {
|
|
163
|
+
await this.initializePlugin(); // Ensure the plugin is initialized
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return new Promise((resolve, reject) => {
|
|
167
|
+
if (window.filePreview && typeof window.filePreview.openFile === 'function') {
|
|
168
|
+
window.filePreview.openFile(
|
|
169
|
+
(res) => {
|
|
170
|
+
console.log('YunTu: File preview success', res);
|
|
171
|
+
resolve(res); // Successfully previewed the file
|
|
172
|
+
},
|
|
173
|
+
(err) => {
|
|
174
|
+
console.error('YunTu: File preview failed', err);
|
|
175
|
+
reject(err); // Failed to preview the file
|
|
176
|
+
},
|
|
177
|
+
JSON.stringify(options) // Pass the options as a string
|
|
178
|
+
);
|
|
179
|
+
} else {
|
|
180
|
+
const errorMessage = 'FilePreview is not initialized or not available';
|
|
181
|
+
console.error('YunTu:', errorMessage);
|
|
182
|
+
reject(new Error(errorMessage)); // FilePreview interface is not available
|
|
183
|
+
}
|
|
184
|
+
});
|
|
157
185
|
}
|
|
158
186
|
|
|
159
187
|
|