@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.18 → 1.0.0-beta.19

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,27 @@
1
1
  # Changelog
2
+ ## [1.0.0-beta.19](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.18...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.19) (2025-01-23)
3
+
4
+
5
+ ### ✨ Features | 新功能
6
+
7
+ * **js-bridge:** 为文件预览功能添加 tokenKey 参数 ([de693d9](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/de693d90fa98170d4881b454ddb419f6564de314))
8
+ * **js-bridge:** 支持 Yuntu 云图打开指定地图类型 ([0e3da29](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/0e3da2941b59a2c3bfa5c0a4992754979169ab7f))
9
+ * **js-bridge:** 添加高德地图初始化功能 ([d44535f](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/d44535f27ac257456a4d2864d1ae9e9a9f420c78))
10
+
11
+
12
+ ### ♻️ Code Refactoring | 代码重构
13
+
14
+ * **js-bridge:** 移除初始化插件的冗余代码 ([f6f8460](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/f6f846095c739e440e9eb2fc76a6c9f6bb508af7))
15
+
16
+
17
+ ### 🐛 Bug Fixes | Bug 修复
18
+
19
+ * **js-bridge:** 更新 Android 初始化密钥 ([44e3790](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/44e3790ba10a99443e6e701de8c10184a356dffb))
20
+ * **js-bridge:** 更新文件预览 tokenKey 参数 ([cb5f32a](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/cb5f32afdd23091cf4788360a27a1428c8c95287))
21
+ * **YunTuAdapter:** 优化获取位置信息错误处理 ([9ff4ffc](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/9ff4ffc143056928d825b95219ae88677c8fbb24))
22
+ * **YunTuAdapter:** 修复 initKey 方法的调用错误 ([8487f2d](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/8487f2d6374fe95b6b5e2bddbb08a241a5ea9b52))
23
+ * **YunTuAdapter:** 修复地图跳转失败时的错误处理 ([7335ba7](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/7335ba7e2f4b1596eea250d9f231aac3028fdb6b))
24
+
2
25
  ## [1.0.0-beta.18](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.17...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.18) (2025-01-16)
3
26
 
4
27
 
package/README.md CHANGED
@@ -63,6 +63,8 @@ import LamboJsBridge from '@lambo-design-mobile/lambo-js-bridge';
63
63
  wechatId:this.wechatId,
64
64
  weComId:this.weComId,
65
65
  dingTalkId:this.dingTalkId,
66
+ pluginConfig:["localAuthPlugin","amapPlugin","tabBarPlugin","scanCodePlugin","filePreviewPlugin"],
67
+
66
68
  };
67
69
  this.$lamboJsBridge = new LamboJsBridge(options);
68
70
  await this.getPlatform();
@@ -100,6 +102,40 @@ import LamboJsBridge from '@lambo-design-mobile/lambo-js-bridge';
100
102
  | appId | string | | 是 | 微信、企业微信、钉钉 | 对应平台的id |
101
103
  | platform | string | | 是 | 微信、企业微信、钉钉 | 当前浏览器平台 |
102
104
 
105
+
106
+ ### 高德地图初始化key(initKey)
107
+
108
+ 获取用户当前的地理位置信息。
109
+ ``` javascript
110
+ async initKey() {
111
+ try {
112
+ const options ={
113
+ androidKey:"41c4c1f35d8d14f5bf1907c173924147",
114
+ iosKey:"465abf5da8c8d62e3caa63952a0957a5"
115
+ };
116
+ const reslut = await this.$lamboJsBridge.initKey(options);
117
+ this.initKeyMessage = `initKey result: ${result}`;
118
+ } catch (error) {
119
+ console.error('Error initKey:', error);
120
+ }
121
+ },
122
+ ```
123
+ ### 参数说明
124
+
125
+ `params`: Object
126
+
127
+ | 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
128
+ |------------------|----------|--------|------|-------|-----------------------------------------------------------------------------------------------|
129
+ | androidKey | string | | 否 | yuntu | 前往高德开放平台创建key https://console.amap.com/dev/key/app |
130
+ | iosKey | string | | 否 | yuntu | 前往高德开放平台创建key https://console.amap.com/dev/key/app |
131
+
132
+ ### 返回说明
133
+
134
+ ``
135
+
136
+
137
+
138
+
103
139
  ### 获取地理位置接口(getLocation)
104
140
 
105
141
  获取用户当前的地理位置信息。
@@ -246,7 +282,8 @@ async openLocation() {
246
282
  longitude: this.longitude,
247
283
  name: this.name,
248
284
  address: this.address,
249
- scale: this.scale
285
+ scale: this.scale,
286
+ type:"amap"
250
287
  };
251
288
  await this.$lamboJsBridge.openLocation(options);
252
289
  this.openLocationResult = '位置已成功打开'; // 成功打开位置时存储信息
@@ -269,11 +306,12 @@ async openLocation() {
269
306
 
270
307
  | 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
271
308
  |-----------|--|-----|-----|----------|------------------------------------------------------------------|
272
- | latitude | number | | 是 | 微信、企业微信、钉钉 | 纬度,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 |
273
- | longitude | number | | 是 | 微信、企业微信、钉钉 | 经度,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 |
309
+ | latitude | number | | 是 | 微信、企业微信、钉钉、Yuntu | 纬度,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 |
310
+ | longitude | number | | 是 | 微信、企业微信、钉钉、Yuntu | 经度,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 |
274
311
  | name | string | | 钉钉 | 微信、企业微信、钉钉 | 位置名称 |
275
312
  | address | string | | 钉钉 | 微信、企业微信、钉钉 | 详细位置 |
276
313
  | scale | number | | 否 | 微信、企业微信 | 缩放比例,范围5~18 |
314
+ | type | string | amap | 否 | Yuntu | 'baidu':百度地图,'amap':高德地图,'URLSchema':自定义协议 |
277
315
 
278
316
  ### 返回说明
279
317
 
package/demo/index.vue CHANGED
@@ -1,20 +1,24 @@
1
1
  <template>
2
2
  <demo-section>
3
3
  <demo-block title="初始化信息">
4
- <pre v-if="initInfo"><code>{{ initInfo }}</code></pre>
4
+ <pre v-show="initInfo"><code>{{ initInfo }}</code></pre>
5
+ </demo-block>
6
+ <demo-block title="初始化地图Key">
7
+ <van-button @click="initKey">初始化地图Key</van-button>
8
+ <pre v-show="initKeyMessage"><code>{{ initKeyMessage }}</code></pre>
5
9
  </demo-block>
6
10
  <demo-block title="获取定位">
7
11
  <van-button @click="getLocation">获取定位</van-button>
8
- <pre v-if="location"><code>{{ location }}</code></pre>
9
- </demo-block>
12
+ <pre v-show="location"><code>{{ location }}</code></pre>
13
+ </demo-block>
10
14
  <demo-block title="扫码">
11
15
  <van-button @click="scanCode">扫码</van-button>
12
- <pre v-if="scanResult"><code>{{ scanResult }}</code></pre>
16
+ <pre v-show="scanResult"><code>{{ scanResult }}</code></pre>
13
17
  </demo-block>
14
18
  <demo-block title="拍照">
15
19
  <van-button @click="takePhoto">拍照</van-button>
16
- <pre v-if="photoResult"><code>{{ photoResult }}</code></pre>
17
- <div v-if="photoPreviews.length" :class="gridClass">
20
+ <pre v-show="photoResult"><code>{{ photoResult }}</code></pre>
21
+ <div v-show="photoPreviews.length" :class="gridClass">
18
22
  <div v-for="(preview, index) in photoPreviews" :key="index" class="photo-container">
19
23
  <img :src="preview" alt="Photo Preview" class="photo">
20
24
  </div>
@@ -22,22 +26,20 @@
22
26
  </demo-block>
23
27
  <demo-block title="打开位置">
24
28
  <van-button @click="openLocation">打开位置</van-button>
25
- <pre v-if="openLocationResult"><code>{{ openLocationResult }}</code></pre>
29
+ <pre v-show="openLocationResult"><code>{{ openLocationResult }}</code></pre>
26
30
  </demo-block>
27
31
  <demo-block title="文件预览">
28
32
  <a href="javascript:void(0);" @click="previewFile">点击这里预览文件</a>
29
33
  </demo-block>
30
- </demo-section>
31
- </template>
32
-
33
-
34
34
 
35
+ </demo-section>
36
+ </template>
35
37
 
36
38
  <script>
37
39
  import LamboJsBridge from "../src/sdk/LamboJsBridge";
38
40
 
39
41
  export default {
40
- name: 'MyComponent',
42
+ name: 'js-bridge-demo',
41
43
  data() {
42
44
  return {
43
45
  lamboBridge: null,
@@ -58,17 +60,18 @@ export default {
58
60
  weComId: 'wx0eb3ba9d89eca3cb',
59
61
  agentId:'1000065',
60
62
  dingTalkId: '',
61
- photoPreviews: []
63
+ photoPreviews: [],
64
+ initKeyMessage: '' // 用于存储 initKey 的返回消息
62
65
  };
63
66
  },
64
67
  computed: {
65
68
  gridClass() {
66
- const length = this.photoPreviews.length;
69
+ const {length} = this.photoPreviews;
67
70
  if (length === 1) {
68
71
  return 'grid-single';
69
- } else if (length > 1 && length <= 4) {
72
+ } if (length > 1 && length <= 4) {
70
73
  return 'grid-two';
71
- } else if (length > 4) {
74
+ } if (length > 4) {
72
75
  return 'grid-three';
73
76
  }
74
77
  return '';
@@ -85,7 +88,7 @@ export default {
85
88
  weComId:this.weComId,
86
89
  agentId:this.agentId,
87
90
  dingTalkId:this.dingTalkId,
88
- pluginConfig:["localAuthPlugin","myPlugin","tabBarPlugin","scanCodePlugin","filePreviewPlugin"],
91
+ pluginConfig:["localAuthPlugin","amapPlugin","tabBarPlugin","scanCodePlugin","filePreviewPlugin"],
89
92
  };
90
93
  this.$lamboJsBridge = new LamboJsBridge(options);
91
94
  await this.getPlatform();
@@ -162,12 +165,13 @@ export default {
162
165
  try {
163
166
  if (this.latitude !== null && this.longitude !== null) {
164
167
  const options = {
165
- //初始化参数,根据需要修改
168
+ // 初始化参数,根据需要修改
166
169
  latitude: this.latitude,
167
170
  longitude: this.longitude,
168
171
  name: this.name,
169
172
  address: this.address,
170
- scale: this.scale
173
+ scale: this.scale,
174
+ type:"amap"
171
175
  };
172
176
  await this.$lamboJsBridge.openLocation(options);
173
177
  this.openLocationResult = '位置已成功打开'; // 成功打开位置时存储信息
@@ -185,13 +189,24 @@ export default {
185
189
  try {
186
190
  const options = {
187
191
  title: '预览文件.txt', // 文件的标题
188
- path: 'http://160.mall.eap.lambo.top/ecm-runtime-server/api/file/get/123456' // 文件的URL路径
192
+ path: 'http://160.mall.eap.lambo.top/ecm-runtime-server/api/file/get/123456' ,// 文件的URL路径
193
+ tokenKey:"lambo-token-ibp"
189
194
  };
190
195
  const result = await this.$lamboJsBridge.filePreview(options);
191
196
  console.log('File preview result:', result);
192
197
  } catch (error) {
193
198
  console.error('Error previewing file:', error);
194
199
  }
200
+ },
201
+ async initKey() {
202
+ try {
203
+ const result = await this.$lamboJsBridge.initKey( {"androidKey":"41c4c1f35d8d14f5bf1907c173924147","iosKey":"465abf5da8c8d62e3caa63952a0957a5"});
204
+ console.log('initKey result:', result);
205
+ this.initKeyMessage = `initKey result: ${JSON.stringify(result)}`;
206
+ } catch (error) {
207
+ this.initKeyMessage = `初始化 Key 时出错: ${error.message}`;
208
+ console.error('Error initializing key:', error);
209
+ }
195
210
  }
196
211
  },
197
212
  beforeRouteEnter (to, from, next) {
@@ -206,8 +221,6 @@ export default {
206
221
  };
207
222
  </script>
208
223
 
209
-
210
-
211
224
  <style scoped>
212
225
  pre {
213
226
  background-color: #f5f5f5;
@@ -245,4 +258,4 @@ code {
245
258
  max-width: 100%;
246
259
  border-radius: 4px;
247
260
  }
248
- </style>
261
+ </style>
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.18",
3
+ "version": "1.0.0-beta.19",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -39,9 +39,9 @@ class LamboJsBridge {
39
39
  async initializePlugin(pluginConfig = []) {
40
40
  if (this.platform instanceof YunTuAdapter) {
41
41
  return this.platform.initializePlugin(pluginConfig);
42
- } else {
42
+ }
43
43
  return Promise.resolve();
44
- }
44
+
45
45
  }
46
46
 
47
47
  async getPlatform(options = {}) {
@@ -76,6 +76,10 @@ class LamboJsBridge {
76
76
  return this.platform.filePreview(options);
77
77
  }
78
78
 
79
+ async initKey(options = {}) {
80
+ return this.platform.initKey(options);
81
+ }
82
+
79
83
  // 创建一个 Vue 插件
80
84
  static install(Vue) {
81
85
  // 将 LamboJsBridge 实例挂载到 Vue 原型上,全局可用
@@ -11,7 +11,8 @@ class YunTuAdapter {
11
11
  try {
12
12
  const configToUse = Array.isArray(pluginConfig) && pluginConfig.length > 0
13
13
  ? JSON.stringify(pluginConfig)
14
- : '["localAuthPlugin","myPlugin","tabBarPlugin","scanCodePlugin","filePreviewPlugin","imagePickerPlugin"]';
14
+ : '["localAuthPlugin","amapPlugin","tabBarPlugin","scanCodePlugin","filePreviewPlugin","imagePickerPlugin"]';
15
+ // eslint-disable-next-line no-undef
15
16
  await yuntuConfig(configToUse); // 确保等待 yuntuConfig 执行完成
16
17
  this.isInitialized = true;
17
18
  this.plugins = JSON.parse(configToUse);
@@ -59,19 +60,16 @@ class YunTuAdapter {
59
60
  if (window.top.geolocation && typeof window.top.geolocation.openLocation === 'function') {
60
61
  console.log("1")
61
62
  window.top.geolocation.openLocation(
62
- (res) => {
63
- console.log('YunTu: Open location success', res);
64
- resolve(res); // 成功打开地图
65
- },
66
63
  (err) => {
67
64
  console.error('YunTu: Failed to open location', err);
68
- reject(err); // 打开地图失败
65
+ err.message=err.msg
66
+ reject(err); // 打开地图失败
69
67
  },
70
- {
68
+ JSON.stringify( {
71
69
  latitude: options.latitude,
72
70
  longitude: options.longitude,
73
71
  type: options.type || 'amap' // 默认为高德地图
74
- }
72
+ })
75
73
  );
76
74
  } else {
77
75
  const errorMessage = 'Geolocation is not initialized or not available';
@@ -81,6 +79,21 @@ class YunTuAdapter {
81
79
  });
82
80
  }
83
81
 
82
+ async initKey(options) {
83
+ return new Promise((resolve, reject) => {
84
+ if (window.top.geolocation && typeof window.top.geolocation.initKey === 'function') {
85
+ window.top.geolocation.initKey(function (msg) {
86
+ console.log('YunTu: initKey success', msg);
87
+ resolve(msg); //
88
+ }, JSON.stringify(options) );
89
+ } else {
90
+ const errorMessage = 'Geolocation is not initialized or not available';
91
+ console.error('YunTu:', errorMessage);
92
+ reject(new Error(errorMessage)); // Geolocation 未初始化或不可用
93
+ }
94
+ });
95
+ }
96
+
84
97
  async scanCode(options) {
85
98
  return new Promise((resolve, reject) => {
86
99
  if (window.top.scanCode && typeof window.top.scanCode.startScan === 'function') {
@@ -160,11 +173,11 @@ class YunTuAdapter {
160
173
  pickerFunction(
161
174
  (res) => {
162
175
  console.log('YunTu: Photo selection success', res);
163
- resolve(JSON.parse(res)); // 成功获取照片
176
+ resolve(res); // 成功获取照片
164
177
  },
165
178
  (err) => {
166
179
  console.error('YunTu: Failed to select photo', err);
167
- reject(JSON.parse(err)); // 选择照片失败
180
+ reject(err); // 选择照片失败
168
181
  },
169
182
  options // 传递给选取照片方法的选项(如果有需要的话)
170
183
  );