@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.21 → 1.0.0-beta.22

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.
@@ -1,63 +1,63 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- /* eslint-disable no-undef */
3
-
4
- class BrowserAdapter {
5
- constructor(_options) {
6
- // this.appId = _options.appId; // 保存 appId 以便在 getInitInfo 中使用
7
- // 由于是假数据,不需要加载任何实际的脚本
8
- this.init(_options);
9
- }
10
-
11
- async init(options) {
12
- console.log("Initializing with options:", options);
13
- // 模拟初始化操作
14
- return Promise.resolve({
15
- success: true,
16
- message: "Initialized successfully"
17
- });
18
- }
19
-
20
- async getLocation(options) {
21
- console.log(options);
22
- // 返回假位置数据
23
- return Promise.resolve({
24
- latitude: 37.7749, // 假数据
25
- longitude: -122.4194, // 假数据
26
- accuracy: 30 // 假数据
27
- });
28
- }
29
-
30
- async openLocation(options) {
31
- console.log(options);
32
- // 模拟打开位置操作
33
- return Promise.resolve({
34
- success: true,
35
- message: "Location opened successfully"
36
- });
37
- }
38
-
39
- async scanCode(options) {
40
- console.log(options);
41
- // 返回假扫码数据
42
- return Promise.resolve({resultStr:"SCAN_CODE_RESULT"});
43
- }
44
-
45
- async takePhoto(options) {
46
- console.log(options);
47
- // 返回假照片数据
48
- return Promise.resolve({
49
- imageInfo: "FAKE_IMAGE_INFO",
50
- imageData: "FAKE_IMAGE_DATA"
51
- });
52
- }
53
-
54
- async getPlatform(options = {}) {
55
- // 获取初始化信息
56
- return {
57
- appId: 'Example_appId',
58
- platform: 'Browser'
59
- };
60
- }
61
- }
62
-
63
- export default BrowserAdapter;
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ /* eslint-disable no-undef */
3
+
4
+ class BrowserAdapter {
5
+ constructor(_options) {
6
+ // this.appId = _options.appId; // 保存 appId 以便在 getInitInfo 中使用
7
+ // 由于是假数据,不需要加载任何实际的脚本
8
+ this.init(_options);
9
+ }
10
+
11
+ async init(options) {
12
+ console.log("Initializing with options:", options);
13
+ // 模拟初始化操作
14
+ return Promise.resolve({
15
+ success: true,
16
+ message: "Initialized successfully"
17
+ });
18
+ }
19
+
20
+ async getLocation(options) {
21
+ console.log(options);
22
+ // 返回假位置数据
23
+ return Promise.resolve({
24
+ latitude: 37.7749, // 假数据
25
+ longitude: -122.4194, // 假数据
26
+ accuracy: 30 // 假数据
27
+ });
28
+ }
29
+
30
+ async openLocation(options) {
31
+ console.log(options);
32
+ // 模拟打开位置操作
33
+ return Promise.resolve({
34
+ success: true,
35
+ message: "Location opened successfully"
36
+ });
37
+ }
38
+
39
+ async scanCode(options) {
40
+ console.log(options);
41
+ // 返回假扫码数据
42
+ return Promise.resolve({resultStr:"SCAN_CODE_RESULT"});
43
+ }
44
+
45
+ async takePhoto(options) {
46
+ console.log(options);
47
+ // 返回假照片数据
48
+ return Promise.resolve({
49
+ imageInfo: "FAKE_IMAGE_INFO",
50
+ imageData: "FAKE_IMAGE_DATA"
51
+ });
52
+ }
53
+
54
+ async getPlatform(options = {}) {
55
+ // 获取初始化信息
56
+ return {
57
+ appId: 'Example_appId',
58
+ platform: 'Browser'
59
+ };
60
+ }
61
+ }
62
+
63
+ export default BrowserAdapter;
@@ -1,21 +1,21 @@
1
- class CordovaAdapter {
2
- async getLocation(options) {
3
- // 实现Cordova获取位置逻辑,可能涉及到cordova-plugin-geolocation插件的使用
4
- console.log('Cordova: Getting location with options', options);
5
- // 这里应替换为Cordova API的实际调用
6
- }
7
-
8
- async scanCode(options) {
9
- // 实现Cordova扫码逻辑,可能需要集成第三方插件
10
- console.log('Cordova: Scanning code with options', options);
11
- // 这里应替换为Cordova插件调用或自定义实现
12
- }
13
-
14
- async takePhoto(options) {
15
- // 实现Cordova拍照或选择图片逻辑,可能使用cordova-plugin-camera插件
16
- console.log('Cordova: Taking photo with options', options);
17
- // 这里应替换为Cordova插件调用
18
- }
19
- }
20
-
1
+ class CordovaAdapter {
2
+ async getLocation(options) {
3
+ // 实现Cordova获取位置逻辑,可能涉及到cordova-plugin-geolocation插件的使用
4
+ console.log('Cordova: Getting location with options', options);
5
+ // 这里应替换为Cordova API的实际调用
6
+ }
7
+
8
+ async scanCode(options) {
9
+ // 实现Cordova扫码逻辑,可能需要集成第三方插件
10
+ console.log('Cordova: Scanning code with options', options);
11
+ // 这里应替换为Cordova插件调用或自定义实现
12
+ }
13
+
14
+ async takePhoto(options) {
15
+ // 实现Cordova拍照或选择图片逻辑,可能使用cordova-plugin-camera插件
16
+ console.log('Cordova: Taking photo with options', options);
17
+ // 这里应替换为Cordova插件调用
18
+ }
19
+ }
20
+
21
21
  export default CordovaAdapter;
@@ -1,21 +1,21 @@
1
- class DingTalkAdapter {
2
- async getLocation(options) {
3
- // 实现钉钉获取位置逻辑
4
- console.log('DingTalk: Getting location with options', options);
5
- // 这里应替换为钉钉API的实际调用
6
- }
7
-
8
- async scanCode(options) {
9
- // 实现钉钉扫码逻辑
10
- console.log('DingTalk: Scanning code with options', options);
11
- // 这里应替换为钉钉API的实际调用
12
- }
13
-
14
- async takePhoto(options) {
15
- // 实现钉钉拍照或选择图片逻辑
16
- console.log('DingTalk: Taking photo with options', options);
17
- // 这里应替换为钉钉API的实际调用
18
- }
19
- }
20
-
1
+ class DingTalkAdapter {
2
+ async getLocation(options) {
3
+ // 实现钉钉获取位置逻辑
4
+ console.log('DingTalk: Getting location with options', options);
5
+ // 这里应替换为钉钉API的实际调用
6
+ }
7
+
8
+ async scanCode(options) {
9
+ // 实现钉钉扫码逻辑
10
+ console.log('DingTalk: Scanning code with options', options);
11
+ // 这里应替换为钉钉API的实际调用
12
+ }
13
+
14
+ async takePhoto(options) {
15
+ // 实现钉钉拍照或选择图片逻辑
16
+ console.log('DingTalk: Taking photo with options', options);
17
+ // 这里应替换为钉钉API的实际调用
18
+ }
19
+ }
20
+
21
21
  export default DingTalkAdapter;
@@ -1,90 +1,98 @@
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
- // 创建一个 Vue 插件
84
- static install(Vue) {
85
- // 将 LamboJsBridge 实例挂载到 Vue 原型上,全局可用
86
- Vue.prototype.$lamboJsBridge = new LamboJsBridge({});
87
- }
88
- }
89
-
90
- 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
+ // 创建一个 Vue 插件
92
+ static install(Vue) {
93
+ // 将 LamboJsBridge 实例挂载到 Vue 原型上,全局可用
94
+ Vue.prototype.$lamboJsBridge = new LamboJsBridge({});
95
+ }
96
+ }
97
+
98
+ export default LamboJsBridge;