@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.7 → 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,16 @@
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
+
2
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)
3
15
 
4
16
 
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 {
@@ -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.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.7",
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) {