@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.29 → 1.0.0-beta.30
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/.versionrc +23 -23
- package/CHANGELOG.md +342 -335
- package/README.md +523 -523
- package/demo/index.vue +454 -454
- package/index.js +3 -3
- package/package.json +1 -1
- package/src/sdk/BrowserAdapter.js +63 -63
- package/src/sdk/CordovaAdapter.js +20 -20
- package/src/sdk/DingTalkAdapter.js +20 -20
- package/src/sdk/LPAPI.js +1117 -1117
- package/src/sdk/LamboJsBridge.js +102 -102
- package/src/sdk/MobileIMAdaoter.js +44 -25
- package/src/sdk/WeComAdapter.js +367 -367
- package/src/sdk/YunTuAdapter.js +316 -316
- package/src/sdk/yuntu.js +55 -55
package/src/sdk/LamboJsBridge.js
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
/* eslint-disable prefer-destructuring */
|
|
2
|
-
import WechatAdapter from './WechatAdapter';
|
|
3
|
-
import DingTalkAdapter from './DingTalkAdapter';
|
|
4
|
-
import CordovaAdapter from './CordovaAdapter';
|
|
5
|
-
import YunTuAdapter from './YunTuAdapter';
|
|
6
|
-
import WeComAdapter from './WeComAdapter';
|
|
7
|
-
import BrowserAdapter from './BrowserAdapter';
|
|
8
|
-
import MobileIMAdaoter from './MobileIMAdaoter';
|
|
9
|
-
|
|
10
|
-
class LamboJsBridge {
|
|
11
|
-
constructor(param) {
|
|
12
|
-
this._detectPlatform(param);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
_detectPlatform(param) {
|
|
16
|
-
let userAgent;
|
|
17
|
-
if (param.userAgent) {
|
|
18
|
-
userAgent = param.userAgent;
|
|
19
|
-
} else {
|
|
20
|
-
userAgent = navigator.userAgent.toLowerCase();
|
|
21
|
-
}
|
|
22
|
-
if (/wxwork/.test(userAgent)) {
|
|
23
|
-
this.platform = new WeComAdapter(param);
|
|
24
|
-
} else if (/micromessenger/.test(userAgent)) {
|
|
25
|
-
this.platform = new WechatAdapter(param);
|
|
26
|
-
} else if (/dingtalk/.test(userAgent)) {
|
|
27
|
-
this.platform = new DingTalkAdapter(param);
|
|
28
|
-
} else if (/cordova/.test(userAgent)) {
|
|
29
|
-
this.platform = new CordovaAdapter(param);
|
|
30
|
-
} else if (/yuntu/.test(userAgent)) {
|
|
31
|
-
this.platform = new YunTuAdapter(param);
|
|
32
|
-
} else if (/mobileim/.test(userAgent)) {
|
|
33
|
-
this.platform = new MobileIMAdaoter(param);
|
|
34
|
-
} else {
|
|
35
|
-
this.platform = new BrowserAdapter();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async initializePlugin(pluginConfig = []) {
|
|
40
|
-
if (this.platform instanceof YunTuAdapter) {
|
|
41
|
-
return this.platform.initializePlugin(pluginConfig);
|
|
42
|
-
}
|
|
43
|
-
return Promise.resolve();
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async getPlatform(options = {}) {
|
|
48
|
-
return this.platform.getPlatform(options);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async getLocation(options = {}) {
|
|
52
|
-
return this.platform.getLocation(options);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async scanCode(options = {}) {
|
|
56
|
-
return this.platform.scanCode(options);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async localAuthPlugin(options = {}) {
|
|
60
|
-
return this.platform.localAuthPlugin(options);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async getAvailableBiometrics(options = {}) {
|
|
64
|
-
return this.platform.getAvailableBiometrics(options);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async takePhoto(options = {}) {
|
|
68
|
-
return this.platform.takePhoto(options);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async openLocation(options = {}) {
|
|
72
|
-
return this.platform.openLocation(options);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async filePreview(options = {}) {
|
|
76
|
-
return this.platform.filePreview(options);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async initKey(options = {}) {
|
|
80
|
-
return this.platform.initKey(options);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async startRecording(options = {}) {
|
|
84
|
-
return this.platform.startRecording(options);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async stopRecording(options = {}) {
|
|
88
|
-
return this.platform.stopRecording(options);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async downloadFile(options={}){
|
|
92
|
-
return this.platform.downloadFile(options);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// 创建一个 Vue 插件
|
|
96
|
-
static install(Vue) {
|
|
97
|
-
// 将 LamboJsBridge 实例挂载到 Vue 原型上,全局可用
|
|
98
|
-
Vue.prototype.$lamboJsBridge = new LamboJsBridge({});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export default LamboJsBridge;
|
|
1
|
+
/* eslint-disable prefer-destructuring */
|
|
2
|
+
import WechatAdapter from './WechatAdapter';
|
|
3
|
+
import DingTalkAdapter from './DingTalkAdapter';
|
|
4
|
+
import CordovaAdapter from './CordovaAdapter';
|
|
5
|
+
import YunTuAdapter from './YunTuAdapter';
|
|
6
|
+
import WeComAdapter from './WeComAdapter';
|
|
7
|
+
import BrowserAdapter from './BrowserAdapter';
|
|
8
|
+
import MobileIMAdaoter from './MobileIMAdaoter';
|
|
9
|
+
|
|
10
|
+
class LamboJsBridge {
|
|
11
|
+
constructor(param) {
|
|
12
|
+
this._detectPlatform(param);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_detectPlatform(param) {
|
|
16
|
+
let userAgent;
|
|
17
|
+
if (param.userAgent) {
|
|
18
|
+
userAgent = param.userAgent;
|
|
19
|
+
} else {
|
|
20
|
+
userAgent = navigator.userAgent.toLowerCase();
|
|
21
|
+
}
|
|
22
|
+
if (/wxwork/.test(userAgent)) {
|
|
23
|
+
this.platform = new WeComAdapter(param);
|
|
24
|
+
} else if (/micromessenger/.test(userAgent)) {
|
|
25
|
+
this.platform = new WechatAdapter(param);
|
|
26
|
+
} else if (/dingtalk/.test(userAgent)) {
|
|
27
|
+
this.platform = new DingTalkAdapter(param);
|
|
28
|
+
} else if (/cordova/.test(userAgent)) {
|
|
29
|
+
this.platform = new CordovaAdapter(param);
|
|
30
|
+
} else if (/yuntu/.test(userAgent)) {
|
|
31
|
+
this.platform = new YunTuAdapter(param);
|
|
32
|
+
} else if (/mobileim/.test(userAgent)) {
|
|
33
|
+
this.platform = new MobileIMAdaoter(param);
|
|
34
|
+
} else {
|
|
35
|
+
this.platform = new BrowserAdapter();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async initializePlugin(pluginConfig = []) {
|
|
40
|
+
if (this.platform instanceof YunTuAdapter) {
|
|
41
|
+
return this.platform.initializePlugin(pluginConfig);
|
|
42
|
+
}
|
|
43
|
+
return Promise.resolve();
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async getPlatform(options = {}) {
|
|
48
|
+
return this.platform.getPlatform(options);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async getLocation(options = {}) {
|
|
52
|
+
return this.platform.getLocation(options);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async scanCode(options = {}) {
|
|
56
|
+
return this.platform.scanCode(options);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async localAuthPlugin(options = {}) {
|
|
60
|
+
return this.platform.localAuthPlugin(options);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async getAvailableBiometrics(options = {}) {
|
|
64
|
+
return this.platform.getAvailableBiometrics(options);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async takePhoto(options = {}) {
|
|
68
|
+
return this.platform.takePhoto(options);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async openLocation(options = {}) {
|
|
72
|
+
return this.platform.openLocation(options);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async filePreview(options = {}) {
|
|
76
|
+
return this.platform.filePreview(options);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async initKey(options = {}) {
|
|
80
|
+
return this.platform.initKey(options);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async startRecording(options = {}) {
|
|
84
|
+
return this.platform.startRecording(options);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async stopRecording(options = {}) {
|
|
88
|
+
return this.platform.stopRecording(options);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async downloadFile(options={}){
|
|
92
|
+
return this.platform.downloadFile(options);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 创建一个 Vue 插件
|
|
96
|
+
static install(Vue) {
|
|
97
|
+
// 将 LamboJsBridge 实例挂载到 Vue 原型上,全局可用
|
|
98
|
+
Vue.prototype.$lamboJsBridge = new LamboJsBridge({});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default LamboJsBridge;
|
|
@@ -1,40 +1,59 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { getAddress } from './BdMapUtils';
|
|
2
2
|
|
|
3
3
|
class MobileIMAdaoter {
|
|
4
4
|
constructor(_options) {
|
|
5
|
-
function loadScript(src) {
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
const script = document.createElement('script');
|
|
8
|
-
script.src = src;
|
|
9
|
-
script.onload = () => resolve(script);
|
|
10
|
-
script.onerror = () => reject(new Error('Failed to load script'));
|
|
11
|
-
document.head.appendChild(script);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
loadScript('/ind-uc-ext/native.js')
|
|
15
|
-
.then((script) => console.log('Script loaded'))
|
|
16
|
-
.catch((err) => console.error(err));
|
|
17
5
|
}
|
|
18
6
|
|
|
7
|
+
// 新门户系统: 我们移动端只能提供坐标数据,没法提供街道地市这些信息。。
|
|
19
8
|
async getLocation(options) {
|
|
20
9
|
return new Promise((resolve, reject) => {
|
|
21
10
|
try {
|
|
22
11
|
let args = {
|
|
23
12
|
// 是否获取地址信息
|
|
24
13
|
// isNeedAddress: true,
|
|
25
|
-
...config.imGeoOptions
|
|
26
14
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
15
|
+
|
|
16
|
+
const fetchLocation = () => {
|
|
17
|
+
return new Promise((resolve2) => {
|
|
18
|
+
window.native.getLocation(args, (res) => {
|
|
19
|
+
resolve2({
|
|
20
|
+
latitude: res.point.latitude,
|
|
21
|
+
longitude: res.point.longitude,
|
|
22
|
+
accuracy: res.point.horizontalAccuracy,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
36
25
|
});
|
|
37
|
-
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// 先判断是否需要地理位置 如不需要 直接返回坐标
|
|
29
|
+
if (options.needAddress) {
|
|
30
|
+
fetchLocation()
|
|
31
|
+
.then(async (bd09Location) => {
|
|
32
|
+
console.log(
|
|
33
|
+
'with options.needAddress bd09Location',
|
|
34
|
+
bd09Location
|
|
35
|
+
);
|
|
36
|
+
// const result = getAddress(bd09Location.longitude, bd09Location.latitude)
|
|
37
|
+
//平台返回的经纬度是反的 解决了再换回来
|
|
38
|
+
const result = await getAddress(
|
|
39
|
+
bd09Location.latitude,
|
|
40
|
+
bd09Location.longitude
|
|
41
|
+
);
|
|
42
|
+
console.log('with options.needAddress getAddress result', result);
|
|
43
|
+
if (!result) {
|
|
44
|
+
return reject(new Error('Invalid location data'));
|
|
45
|
+
}
|
|
46
|
+
resolve({
|
|
47
|
+
...bd09Location,
|
|
48
|
+
...result,
|
|
49
|
+
});
|
|
50
|
+
})
|
|
51
|
+
.catch((err) => {
|
|
52
|
+
reject(err);
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
resolve(fetchLocation());
|
|
56
|
+
}
|
|
38
57
|
} catch (err) {
|
|
39
58
|
console.error('getLocation failed:', err);
|
|
40
59
|
reject(err);
|
|
@@ -56,7 +75,7 @@ class MobileIMAdaoter {
|
|
|
56
75
|
});
|
|
57
76
|
}
|
|
58
77
|
|
|
59
|
-
async
|
|
78
|
+
async getPlatform(options = {}) {
|
|
60
79
|
// 获取初始化信息
|
|
61
80
|
return {
|
|
62
81
|
platform: 'MobileIM',
|