@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.36 → 1.0.0-beta.38

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,13 @@
1
1
  # Changelog
2
+ ## [1.0.0-beta.38](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.37...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.38) (2025-09-19)
3
+
4
+ ## [1.0.0-beta.37](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.36...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.37) (2025-09-04)
5
+
6
+
7
+ ### ✨ Features | 新功能
8
+
9
+ * 修复定位问题 ([534fb86](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/534fb867f34c00ceea6d32f0be598a825174ae03))
10
+
2
11
  ## [1.0.0-beta.36](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.35...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.36) (2025-09-04)
3
12
 
4
13
 
package/demo/index.vue CHANGED
@@ -35,6 +35,9 @@
35
35
  <van-button @click="startRecording">开始录音</van-button>
36
36
  <van-button @click="startAutoRecording" style="margin-left: 5px">自动录音</van-button>
37
37
  <van-button @click="stopRecording" style="margin-left: 5px">停止录音</van-button>
38
+ <van-button @click="startWeComRecording" style="margin-left: 5px;">企业微信开始录音</van-button>
39
+ <van-button @click="stopWeComRecording" style="margin-left: 5px;">企业微信停止录音</van-button>
40
+ <van-button @click="startCcworkRecording" style="margin-left: 5px;">云上协同开始录音</van-button>
38
41
  <div v-if="recordingStatus === 'recording'">
39
42
  <p>正在录音中...</p>
40
43
  </div>
@@ -112,6 +115,9 @@ export default {
112
115
  dingTalkId: '',
113
116
  photoPreviews: [],
114
117
  initKeyMessage: '', // 用于存储 initKey 的返回消息
118
+ recordingWeComStatus: '',
119
+ recordingCcWorkStatus: '',
120
+ recordingFileInfo: {},
115
121
  audioUrl: null, // 用于存储录音文件的 URL
116
122
  audioPath: null,
117
123
  audioData: null,
@@ -162,6 +168,63 @@ export default {
162
168
  }
163
169
  },
164
170
 
171
+ async startWeComRecording() {
172
+ this.recordingWeComStatus = 'processing';
173
+ this.recordingFileInfo = null;
174
+ try {
175
+ await this.$lamboJsBridge.startWeComRecording({
176
+ // 当60秒自动停止并成功时:
177
+ onAutoStopSuccess: (fileInfo) => {
178
+ console.log('【自动停止】处理成功:', fileInfo);
179
+ this.recordingFileInfo = fileInfo;
180
+ this.recordingWeComStatus = 'done';
181
+ },
182
+ // 当60秒自动停止但失败时:
183
+ onAutoStopError: (error) => {
184
+ console.error('【自动停止】处理失败:', error);
185
+ this.recordingWeComStatus = 'error';
186
+ }
187
+ });
188
+
189
+ this.recordingWeComStatus = 'recording';
190
+
191
+ } catch (error) {
192
+ console.error("开始录音失败:", error);
193
+ this.recordingWeComStatus = 'error';
194
+ }
195
+ },
196
+
197
+ async stopWeComRecording() {
198
+ this.recordingWeComStatus = 'processing';
199
+ try {
200
+ const fileInfo = await this.$lamboJsBridge.stopWeComRecording();
201
+ console.log('【手动停止】处理成功:', fileInfo);
202
+ this.recordingFileInfo = fileInfo;
203
+ this.recordingWeComStatus = 'done';
204
+
205
+ } catch (error) {
206
+ console.error('【手动停止】处理失败:', error);
207
+ this.recordingWeComStatus = 'error';
208
+ }
209
+ },
210
+
211
+ async startCcworkRecording() {
212
+ this.recordingCcWorkStatus = 'processing';
213
+ this.recordingFileInfo = null;
214
+
215
+ try {
216
+ console.log('正在调用 startCcworkRecording...');
217
+ const fileInfo = await this.$lamboJsBridge.startCcworkRecording();
218
+ console.log('【录音上传】处理成功:', fileInfo);
219
+ this.recordingFileInfo = fileInfo;
220
+ this.recordingCcWorkStatus = 'done';
221
+
222
+ } catch (error) {
223
+ console.error('【录音上传】处理失败:', error);
224
+ this.recordingCcWorkStatus = 'error';
225
+ }
226
+ },
227
+
165
228
  // 开始手动录音
166
229
  async startRecording() {
167
230
  // 清空之前的录音数据
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.36",
3
+ "version": "1.0.0-beta.38",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -0,0 +1,81 @@
1
+ import config from '@lambo-design-mobile/shared/config/config';
2
+
3
+ class CcworkAdapter {
4
+ constructor(_options) {
5
+ this.uploadUrl = config.upmsServerContext + '/oss/file/put';
6
+ this.isInitialized = false;
7
+
8
+ this._initPromise = this._initialize();
9
+ }
10
+
11
+ _initialize() {
12
+ return new Promise((resolve, reject) => {
13
+ if (window.ccworkBridge) {
14
+ console.log('ccworkBridge 已存在,直接初始化...');
15
+ this._initBridge(resolve, reject);
16
+ return;
17
+ }
18
+
19
+ console.log('正在加载 ccworkJsbridge.js...');
20
+ const script = document.createElement('script');
21
+ script.src = "https://cc.ccwork.com/file/download/h5/ccworkJsbridge.js";
22
+ script.onload = () => {
23
+ console.log('ccworkJsbridge.js 加载成功,开始初始化...');
24
+ if (window.ccworkBridge) {
25
+ this._initBridge(resolve, reject);
26
+ } else {
27
+ console.error('脚本加载后,window.ccworkBridge 仍然不存在。');
28
+ reject(new Error('ccworkJsbridge 脚本加载失败。'));
29
+ }
30
+ };
31
+ script.onerror = () => {
32
+ console.error('ccworkJsbridge.js 脚本网络加载失败。');
33
+ reject(new Error('ccworkJsbridge 脚本网络加载失败。'));
34
+ };
35
+ document.head.appendChild(script);
36
+ });
37
+ }
38
+
39
+ _initBridge(resolve, reject) {
40
+ try {
41
+ ccworkBridge.init((hasLogin) => {
42
+ console.log(`ccworkBridge 初始化完成,登录状态: ${hasLogin}`);
43
+ this.isInitialized = true;
44
+ resolve(hasLogin);
45
+ });
46
+ } catch (err) {
47
+ console.error('调用 ccworkBridge.init 时出错:', err);
48
+ reject(err);
49
+ }
50
+ }
51
+
52
+ async startCcworkRecording(options = {}) {
53
+ await this._initPromise;
54
+
55
+ return new Promise((resolve, reject) => {
56
+ console.log('正在调用 ccworkRecordingAudio...');
57
+ const params = {
58
+ local: false,
59
+ id: this.uploadUrl
60
+ };
61
+
62
+ ccworkBridge.ccworkRecordingAudio(params, (res) => {
63
+ console.log('录音上传完成,收到回调:', res);
64
+ if (res && res.data && res.data.code === 1) {
65
+ resolve(res.data.data[0]);
66
+ } else {
67
+ reject(new Error(res ? res.message : '录音或上传失败,未知错误。'));
68
+ }
69
+ });
70
+ });
71
+ }
72
+
73
+
74
+ async getPlatform(options = {}) {
75
+ return Promise.resolve({
76
+ platform: 'Ccwork'
77
+ });
78
+ }
79
+ }
80
+
81
+ export default CcworkAdapter;
@@ -6,6 +6,7 @@ import YunTuAdapter from './YunTuAdapter';
6
6
  import WeComAdapter from './WeComAdapter';
7
7
  import BrowserAdapter from './BrowserAdapter';
8
8
  import MobileIMAdapter from './MobileIMAdapter';
9
+ import CcworkAdapter from './CcworkAdapter';
9
10
 
10
11
  class LamboJsBridge {
11
12
  constructor(param) {
@@ -31,6 +32,8 @@ class LamboJsBridge {
31
32
  this.platform = new YunTuAdapter(param);
32
33
  } else if (/mobileim/.test(userAgent)) {
33
34
  this.platform = new MobileIMAdapter(param);
35
+ } else if (/ccwork/.test(userAgent)) {
36
+ this.platform = new CcworkAdapter(param);
34
37
  } else {
35
38
  this.platform = new BrowserAdapter();
36
39
  }
@@ -88,6 +91,18 @@ class LamboJsBridge {
88
91
  return this.platform.stopRecording(options);
89
92
  }
90
93
 
94
+ async startWeComRecording(options = {}) {
95
+ return this.platform.startWeComRecording(options);
96
+ }
97
+
98
+ async stopWeComRecording(options = {}) {
99
+ return this.platform.stopWeComRecording(options);
100
+ }
101
+
102
+ async startCcworkRecording(options = {}) {
103
+ return this.platform.startCcworkRecording(options);
104
+ }
105
+
91
106
  async downloadFile(options={}){
92
107
  return this.platform.downloadFile(options);
93
108
  }
@@ -7,6 +7,8 @@ import config from '@lambo-design-mobile/shared/config/config';
7
7
  class WeComAdapter {
8
8
  constructor(_options) {
9
9
  this.corpId = _options.weComId; // 保存 appId 以便在 getInitInfo 中使用
10
+ this.agentId = _options.agentId;
11
+ this.isRecording = false;
10
12
  // if(!window.wx){
11
13
  // // const script = document.createElement('script')
12
14
  // // script.src = "//wwcdn.weixin.qq.com/node/open/js/wecom-jssdk-1.3.1.js"
@@ -29,11 +31,12 @@ class WeComAdapter {
29
31
  });
30
32
  }
31
33
 
34
+ let self = this
32
35
  function initJsSdk() {
33
36
  loadScript('//res.wx.qq.com/open/js/jweixin-1.2.0.js')
34
37
  .then((script) => {
35
38
  console.log('Script loaded');
36
- this.init(_options);
39
+ self.init(_options);
37
40
  })
38
41
  .catch((err) => console.error(err));
39
42
  }
@@ -86,6 +89,10 @@ class WeComAdapter {
86
89
  'chooseImage',
87
90
  'openLocation',
88
91
  'getLocalImgData',
92
+ 'startRecord',
93
+ 'stopRecord',
94
+ 'onVoiceRecordEnd',
95
+ 'uploadVoice'
89
96
  ], // 必填,传入需要使用的接口名称
90
97
  success(res) {
91
98
  console.log('ready...');
@@ -111,6 +118,10 @@ class WeComAdapter {
111
118
  'chooseImage',
112
119
  'openLocation',
113
120
  'getLocalImgData',
121
+ 'startRecord',
122
+ 'stopRecord',
123
+ 'onVoiceRecordEnd',
124
+ 'uploadVoice',
114
125
  ], // 需要检测的JS接口列表
115
126
  success(res) {
116
127
  // 以键值对的形式返回,可用的api值true,不可用为false
@@ -124,6 +135,111 @@ class WeComAdapter {
124
135
  });
125
136
  }
126
137
 
138
+ async startWeComRecording(options = {}) {
139
+ if (this.isRecording) {
140
+ throw new Error('录音已在进行中');
141
+ }
142
+
143
+ return new Promise((resolve, reject) => {
144
+ wx.ready(() => {
145
+ wx.onVoiceRecordEnd({
146
+ complete: (res) => {
147
+ if (!this.isRecording) return;
148
+ this.isRecording = false;
149
+ console.log('录音满1分钟自动停止,开始处理...');
150
+ this._uploadAndSave(res.localId)
151
+ .then(fileInfo => {
152
+ if (options.onAutoStopSuccess && typeof options.onAutoStopSuccess === 'function') {
153
+ options.onAutoStopSuccess(fileInfo);
154
+ }
155
+ })
156
+ .catch(error => {
157
+ if (options.onAutoStopError && typeof options.onAutoStopError === 'function') {
158
+ options.onAutoStopError(error);
159
+ }
160
+ });
161
+ }
162
+ });
163
+ wx.startRecord({
164
+ success: () => {
165
+ this.isRecording = true;
166
+ console.log('录音已开始...');
167
+ resolve();
168
+ },
169
+ fail: (err) => {
170
+ console.error('startRecord failed:', err);
171
+ reject(new Error('开始录音失败'));
172
+ }
173
+ });
174
+ });
175
+ });
176
+ }
177
+
178
+ async stopWeComRecording() {
179
+ if (!this.isRecording) {
180
+ return Promise.reject(new Error('当前没有正在进行的录音'));
181
+ }
182
+ return new Promise((resolve, reject) => {
183
+ wx.ready(() => {
184
+ wx.stopRecord({
185
+ success: (res) => {
186
+ this.isRecording = false;
187
+ console.log('用户手动停止录音,开始处理...');
188
+ this._uploadAndSave(res.localId).then(resolve).catch(reject);
189
+ },
190
+ fail: (err) => {
191
+ this.isRecording = false;
192
+ console.error('stopRecord failed:', err);
193
+ reject(new Error('停止录音失败'));
194
+ }
195
+ });
196
+ });
197
+ });
198
+ }
199
+ async _uploadAndSave(localId) {
200
+ return new Promise((resolve, reject) => {
201
+ wx.uploadVoice({
202
+ localId: localId,
203
+ isShowProgressTips: 1,
204
+ success: (uploadRes) => {
205
+ this._saveVoiceToServer(uploadRes.serverId).then(resolve).catch(reject);
206
+ },
207
+ fail: (err) => {
208
+ console.error('wx.uploadVoice failed:', err);
209
+ reject(new Error('上传语音至微信服务器失败'));
210
+ }
211
+ });
212
+ });
213
+ }
214
+ async _saveVoiceToServer(serverId) {
215
+ if (!this.corpId || !this.agentId) {
216
+ return Promise.reject(new Error('corpId 或 agentId 未初始化'));
217
+ }
218
+
219
+ // 后端接口使用 @RequestParam,对应 'application/x-www-form-urlencoded'
220
+ const params = new URLSearchParams();
221
+ params.append('corpId', this.corpId);
222
+ params.append('agentId', this.agentId);
223
+ params.append('mediaId', serverId);
224
+
225
+ try {
226
+ const response = await ajax({
227
+ method: 'post',
228
+ url: config.upmsServerContext + '/manage/ibpWxCpBaseinfo/handleVoice',
229
+ data: params,
230
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
231
+ });
232
+ if (response.data && response.data.code === 1) {
233
+ console.log('后端处理成功,返回 FileInfoVO:', response.data.data);
234
+ return response.data.data; // 返回 FileInfoVO 对象
235
+ } else {
236
+ throw new Error(response.data.msg || '服务器处理录音文件失败');
237
+ }
238
+ } catch (err) {
239
+ console.error('调用后端 /handleVoice 接口失败:', err);
240
+ throw err;
241
+ }
242
+ }
127
243
  async getLocation(options) {
128
244
  return new Promise((resolve, reject) => {
129
245
  wx.ready(async () => {