@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.7 → 1.0.0-beta.9
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 +25 -0
- package/README.md +6 -17
- package/demo/index.vue +7 -7
- package/package.json +1 -1
- package/src/sdk/LamboJsBridge.js +13 -0
- package/src/sdk/MobileIMAdaoter.js +64 -0
- package/src/sdk/WechatAdapter.js +4 -2
- package/src/sdk/YunTuAdapter.js +1 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
## [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)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### 🐛 Bug Fixes | Bug 修复
|
|
6
|
+
|
|
7
|
+
* **@lambo-design-mobile/js-bridge:** 修正flutter环境下插件初始化问题 ([680e188](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/680e188449516e15a0355a3017b70a5eeea7c2d2))
|
|
8
|
+
* **@lambo-design-mobile/js-bridge:** 修正flutter环境下插件初始化问题 ([c5a7fba](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/c5a7fba9af2b2cd2abb20bc6bca1eec636c0c092))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### 📝 Documentation | 文档
|
|
12
|
+
|
|
13
|
+
* **@lambo-design-mobile/js-bridge:** 修改README说明 ([bfc7255](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/bfc7255ed88289fc366e4c5fbf1f9bc5584b1c1a))
|
|
14
|
+
|
|
15
|
+
## [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)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### ✨ Features | 新功能
|
|
19
|
+
|
|
20
|
+
* **@lambo-design-mobile/js-bridge:** 新增mixin全局声明 ([b7abf59](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/b7abf5976e3ee850a49e2ea2386fe2dec110a89c))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### 🐛 Bug Fixes | Bug 修复
|
|
24
|
+
|
|
25
|
+
* **@lambo-design-mobile/js-bridge:** 修改脚本加载方式 ([c54550d](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/c54550d5698fe8f35f055fa6ab0bcf85429d138c))
|
|
26
|
+
|
|
2
27
|
## [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
28
|
|
|
4
29
|
|
package/README.md
CHANGED
|
@@ -13,17 +13,6 @@ LamboJsBridge 是一个js 适配sdk 用于处理H5应用和运行时环境的能
|
|
|
13
13
|
console.log("------ 初始化 LamboJsBridge -------")
|
|
14
14
|
import LamboJsBridge from "@lambo-design-mobile/lambo-js-bridge";
|
|
15
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
16
|
// 将 lamboJsBridge 挂载到 Vue 原型上
|
|
28
17
|
Vue.prototype.$lamboJsBridge = lamboJsBridge;
|
|
29
18
|
```
|
|
@@ -77,14 +66,14 @@ import LamboJsBridge from '@lambo-design-mobile/lambo-js-bridge';
|
|
|
77
66
|
weComId:this.weComId,
|
|
78
67
|
dingTalkId:this.dingTalkId,
|
|
79
68
|
};
|
|
80
|
-
this
|
|
69
|
+
this.$lamboJsBridge = new LamboJsBridge(options);
|
|
81
70
|
await this.getPlatform();
|
|
82
71
|
},
|
|
83
72
|
|
|
84
73
|
methods: {
|
|
85
74
|
async getPlatform() {
|
|
86
75
|
try {
|
|
87
|
-
const info = await this.
|
|
76
|
+
const info = await this.$lamboJsBridge.getPlatform(); // 获取初始化信息
|
|
88
77
|
this.initInfo = JSON.stringify(info, null, 2); // 美化输出
|
|
89
78
|
console.log('Init Info:', info);
|
|
90
79
|
} catch (error) {
|
|
@@ -122,7 +111,7 @@ import LamboJsBridge from '@lambo-design-mobile/lambo-js-bridge';
|
|
|
122
111
|
const options ={
|
|
123
112
|
// 初始化参数,根据需要填写
|
|
124
113
|
};
|
|
125
|
-
const location = await this.
|
|
114
|
+
const location = await this.$lamboJsBridge.getLocation(options);
|
|
126
115
|
console.log("location",location)
|
|
127
116
|
this.location += `${JSON.stringify(location)}\n`; // 追加新数据
|
|
128
117
|
this.latitude = location.latitude; // 存储纬度
|
|
@@ -169,7 +158,7 @@ import LamboJsBridge from '@lambo-design-mobile/lambo-js-bridge';
|
|
|
169
158
|
const options ={
|
|
170
159
|
// 初始化参数,根据需要填写
|
|
171
160
|
};
|
|
172
|
-
const result = await this.
|
|
161
|
+
const result = await this.$lamboJsBridge.scanCode(options);
|
|
173
162
|
this.scanResult += `${JSON.stringify(result)}\n`; // 追加新数据
|
|
174
163
|
console.log('Scan result:', result);
|
|
175
164
|
} catch (error) {
|
|
@@ -209,7 +198,7 @@ import LamboJsBridge from '@lambo-design-mobile/lambo-js-bridge';
|
|
|
209
198
|
ossImgPutUrl: this.ossImgPutUrl,
|
|
210
199
|
ossImgGetUrl: this.ossImgGetUrl
|
|
211
200
|
};
|
|
212
|
-
const photo = await this.
|
|
201
|
+
const photo = await this.$lamboJsBridge.takePhoto(options);
|
|
213
202
|
this.photoResult += `${JSON.stringify(photo)}\n`; // 追加新数据
|
|
214
203
|
console.log('Photo result:', photo);
|
|
215
204
|
} catch (error) {
|
|
@@ -260,7 +249,7 @@ async openLocation() {
|
|
|
260
249
|
address: this.address,
|
|
261
250
|
scale: this.scale
|
|
262
251
|
};
|
|
263
|
-
await this.
|
|
252
|
+
await this.$lamboJsBridge.openLocation(options);
|
|
264
253
|
this.openLocationResult = '位置已成功打开'; // 成功打开位置时存储信息
|
|
265
254
|
console.log('Location opened successfully');
|
|
266
255
|
} else {
|
package/demo/index.vue
CHANGED
|
@@ -84,13 +84,13 @@ export default {
|
|
|
84
84
|
weComId:this.weComId,
|
|
85
85
|
dingTalkId:this.dingTalkId,
|
|
86
86
|
};
|
|
87
|
-
this
|
|
87
|
+
this.$lamboJsBridge = new LamboJsBridge(options);
|
|
88
88
|
await this.getPlatform();
|
|
89
89
|
},
|
|
90
90
|
methods: {
|
|
91
91
|
async getPlatform() {
|
|
92
92
|
try {
|
|
93
|
-
const info = await this.
|
|
93
|
+
const info = await this.$lamboJsBridge.getPlatform(); // 获取初始化信息
|
|
94
94
|
this.initInfo = JSON.stringify(info, null, 2); // 美化输出
|
|
95
95
|
console.log('Init Info:', info);
|
|
96
96
|
} catch (error) {
|
|
@@ -102,7 +102,7 @@ export default {
|
|
|
102
102
|
const options ={
|
|
103
103
|
// 初始化参数,根据需要填写
|
|
104
104
|
};
|
|
105
|
-
const location = await this.
|
|
105
|
+
const location = await this.$lamboJsBridge.getLocation(options);
|
|
106
106
|
// console.log("location",location)
|
|
107
107
|
this.location += `${JSON.stringify(location)}\n`; // 追加新数据
|
|
108
108
|
this.latitude = location.latitude; // 存储纬度
|
|
@@ -119,7 +119,7 @@ export default {
|
|
|
119
119
|
const options ={
|
|
120
120
|
// 初始化参数,根据需要填写
|
|
121
121
|
};
|
|
122
|
-
const result = await this.
|
|
122
|
+
const result = await this.$lamboJsBridge.scanCode(options);
|
|
123
123
|
this.scanResult += `${JSON.stringify(result)}\n`; // 追加新数据
|
|
124
124
|
// console.log('Scan result:', result);
|
|
125
125
|
} catch (error) {
|
|
@@ -134,7 +134,7 @@ export default {
|
|
|
134
134
|
ossImgGetUrl: this.ossImgGetUrl,
|
|
135
135
|
// sourceType: 'gallery'
|
|
136
136
|
};
|
|
137
|
-
const photos = await this.
|
|
137
|
+
const photos = await this.$lamboJsBridge.takePhoto(options);
|
|
138
138
|
this.photoResult += `${JSON.stringify(photos)}\n`;
|
|
139
139
|
console.log("Photo result:", photos); // 调试输出
|
|
140
140
|
|
|
@@ -162,7 +162,7 @@ export default {
|
|
|
162
162
|
address: this.address,
|
|
163
163
|
scale: this.scale
|
|
164
164
|
};
|
|
165
|
-
await this.
|
|
165
|
+
await this.$lamboJsBridge.openLocation(options);
|
|
166
166
|
this.openLocationResult = '位置已成功打开'; // 成功打开位置时存储信息
|
|
167
167
|
console.log('Location opened successfully');
|
|
168
168
|
} else {
|
|
@@ -180,7 +180,7 @@ export default {
|
|
|
180
180
|
title: '预览文件.txt', // 文件的标题
|
|
181
181
|
path: 'http://160.mall.eap.lambo.top/ecm-runtime-server/api/file/get/123456' // 文件的URL路径
|
|
182
182
|
};
|
|
183
|
-
const result = await this.
|
|
183
|
+
const result = await this.$lamboJsBridge.filePreview(options);
|
|
184
184
|
console.log('File preview result:', result);
|
|
185
185
|
} catch (error) {
|
|
186
186
|
console.error('Error previewing file:', error);
|
package/package.json
CHANGED
package/src/sdk/LamboJsBridge.js
CHANGED
|
@@ -4,6 +4,7 @@ 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) {
|
|
@@ -22,6 +23,8 @@ class LamboJsBridge {
|
|
|
22
23
|
this.platform = new CordovaAdapter(param);
|
|
23
24
|
} else if (/yuntu/.test(userAgent)) {
|
|
24
25
|
this.platform = new YunTuAdapter(param);
|
|
26
|
+
} else if (/mobileim/.test(userAgent)) {
|
|
27
|
+
this.platform = new MobileIMAdaoter(param);
|
|
25
28
|
} else {
|
|
26
29
|
this.platform = new BrowserAdapter();
|
|
27
30
|
}
|
|
@@ -66,5 +69,15 @@ class LamboJsBridge {
|
|
|
66
69
|
async filePreview(options={}){
|
|
67
70
|
return this.platform.filePreview(options);
|
|
68
71
|
}
|
|
72
|
+
|
|
73
|
+
// 创建一个 Vue 插件
|
|
74
|
+
static install(Vue) {
|
|
75
|
+
// 使用 mixin 方式全局注册
|
|
76
|
+
Vue.mixin({
|
|
77
|
+
beforeCreate() {
|
|
78
|
+
this.$lamboJsBridge = new LamboJsBridge({});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
69
82
|
}
|
|
70
83
|
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;
|
package/src/sdk/WechatAdapter.js
CHANGED
|
@@ -24,9 +24,11 @@ class WechatAdapter {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
loadScript('//res.wx.qq.com/open/js/jweixin-1.6.0.js')
|
|
27
|
-
.then(script =>
|
|
27
|
+
.then(script => {
|
|
28
|
+
console.log('Script loaded');
|
|
29
|
+
this.init(_options);
|
|
30
|
+
})
|
|
28
31
|
.catch(err => console.error(err));
|
|
29
|
-
this.init(_options);
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
async init(options) {
|
package/src/sdk/YunTuAdapter.js
CHANGED
|
@@ -4,19 +4,16 @@ class YunTuAdapter {
|
|
|
4
4
|
constructor() {
|
|
5
5
|
// 标志插件是否已初始化
|
|
6
6
|
this.isInitialized = false;
|
|
7
|
+
this.initializePlugin();
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
async initializePlugin(pluginConfig) {
|
|
10
11
|
try {
|
|
11
|
-
// 如果传入的是非空数组,则直接使用;否则使用默认的全部插件配置
|
|
12
12
|
const configToUse = Array.isArray(pluginConfig) && pluginConfig.length > 0
|
|
13
13
|
? JSON.stringify(pluginConfig)
|
|
14
14
|
: '["myPlugin","tabBarPlugin","scanCodePlugin","filePreviewPlugin","imagePickerPlugin"]';
|
|
15
|
-
// 调用插件初始化
|
|
16
15
|
await yuntuConfig(configToUse); // 确保等待 yuntuConfig 执行完成
|
|
17
|
-
|
|
18
16
|
this.isInitialized = true;
|
|
19
|
-
// 将插件信息解析并存储到 this.plugin
|
|
20
17
|
this.plugins = JSON.parse(configToUse);
|
|
21
18
|
console.log("Initialized plugins:", this.plugins);
|
|
22
19
|
return this.plugins;
|