@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.6 → 1.0.0-beta.8

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 CHANGED
@@ -1,4 +1,24 @@
1
1
  # Changelog
2
+ ## [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)
3
+
4
+
5
+ ### ✨ Features | 新功能
6
+
7
+ * **@lambo-design-mobile/js-bridge:** 新增mixin全局声明 ([b7abf59](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/b7abf5976e3ee850a49e2ea2386fe2dec110a89c))
8
+
9
+
10
+ ### 🐛 Bug Fixes | Bug 修复
11
+
12
+ * **@lambo-design-mobile/js-bridge:** 修改脚本加载方式 ([c54550d](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/c54550d5698fe8f35f055fa6ab0bcf85429d138c))
13
+
14
+ ## [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)
15
+
16
+
17
+ ### 🐛 Bug Fixes | Bug 修复
18
+
19
+ * **@lambo-design-mobile/js-bridge:** 完善文档 ([5d3b7b9](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/5d3b7b928e05b65ec21008b23f9e07ddd0deff1f))
20
+ * **@lambo-dsign-mobile/js-bridge:** 修复filePreview报错 ([5d19e45](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/5d19e45f14f558323aee06dedbe6462068469e66))
21
+
2
22
  ## [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)
3
23
 
4
24
 
package/README.md CHANGED
@@ -31,10 +31,13 @@ Vue.prototype.$lamboJsBridge = lamboJsBridge;
31
31
 
32
32
  ``` javascript
33
33
  // 直接调用扫码功能
34
- Vue.prototype.$lamboJsBridge.scanCode();
34
+ // Vue方法中
35
+ this.$lamboJsBridge.scanCode()
35
36
 
37
+ //其他Js界面
38
+ Vue.prototype.$lamboJsBridge.scanCode();
36
39
  /**
37
- * 也可以自己封装一层工具类
40
+ * 也可以自己封装一层工具类
38
41
  * 扫描二维码并返回结果。(需要在APP环境下测试)
39
42
  * 此函数通过调用 Flutter scanCode.startScan 方法来启动二维码扫描。
40
43
  * 扫描成功后返回扫描结果,若扫描失败则返回错误信息。
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.lamboBridge = new LamboJsBridge(options);
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.lamboBridge.getPlatform(); // 获取初始化信息
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.lamboBridge.getLocation(options);
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.lamboBridge.scanCode(options);
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.lamboBridge.takePhoto(options);
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.lamboBridge.openLocation(options);
165
+ await this.$lamboJsBridge.openLocation(options);
166
166
  this.openLocationResult = '位置已成功打开'; // 成功打开位置时存储信息
167
167
  console.log('Location opened successfully');
168
168
  } else {
@@ -177,10 +177,10 @@ 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
- const result = await this.lamboBridge.filePreview(options);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design-mobile/lambo-js-bridge",
3
- "version": "1.0.0-beta.6",
3
+ "version": "1.0.0-beta.8",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -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;
@@ -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 => console.log('Script loaded'))
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) {
@@ -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","amapPlugin","tabBarPlugin","scanCodePlugin","filePreviewPlugin","imagePickerPlugin"]';
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