@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.23 → 1.0.0-beta.25
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 +14 -0
- package/README.md +48 -7
- package/demo/index.vue +29 -7
- package/package.json +1 -1
- package/src/sdk/YunTuAdapter.js +28 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
## [1.0.0-beta.25](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.24...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.25) (2025-03-10)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ✨ Features | 新功能
|
|
6
|
+
|
|
7
|
+
* **@lambo-design-mobile/js-bridge:** 录音接口新增silenceDelay、silenceStopSeconds、volumeThreshold入参 ([e501510](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/e5015100c715b07a677ca90dffd4228ae13bd659))
|
|
8
|
+
|
|
9
|
+
## [1.0.0-beta.24](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.23...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.24) (2025-03-04)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### ✨ Features | 新功能
|
|
13
|
+
|
|
14
|
+
* **@lambo-design-mobile/js-bridge:** 录音新增base64出参;新增下载接口 ([131e4a6](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/131e4a68228d528badea094d057a3d81c41f359b))
|
|
15
|
+
|
|
2
16
|
## [1.0.0-beta.23](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.22...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.23) (2025-02-28)
|
|
3
17
|
|
|
4
18
|
|
package/README.md
CHANGED
|
@@ -350,7 +350,7 @@ method:{
|
|
|
350
350
|
this.recordingStatus = 'recording';
|
|
351
351
|
try {
|
|
352
352
|
// 传入 { auto: true } 表示启用自动录音
|
|
353
|
-
const result = await this.$lamboJsBridge.startRecording({ auto: true });
|
|
353
|
+
const result = await this.$lamboJsBridge.startRecording({ auto: true , silenceDelay: 1, silenceStopSeconds: 2, volumeThreshold: 60});
|
|
354
354
|
console.log("自动录音开始成功:", result);
|
|
355
355
|
} catch (error) {
|
|
356
356
|
console.error("自动录音开始失败:", error);
|
|
@@ -379,6 +379,8 @@ method:{
|
|
|
379
379
|
// 更新组件中的数据,页面会自动响应
|
|
380
380
|
this.recordingStatus = 'stopped';
|
|
381
381
|
this.audioUrl = data.fileUrl;
|
|
382
|
+
this.audioPath = data.filePath;
|
|
383
|
+
this.audioData = data.fileData;
|
|
382
384
|
},
|
|
383
385
|
},
|
|
384
386
|
mounted() {
|
|
@@ -390,18 +392,23 @@ mounted() {
|
|
|
390
392
|
|
|
391
393
|
`recordingOptions`: Object
|
|
392
394
|
|
|
393
|
-
| 属性 | 类型
|
|
394
|
-
|
|
395
|
-
| isAuto | boolean | false
|
|
395
|
+
| 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
|
|
396
|
+
|-----------|---------|-------|-----|----------|---------------------------|
|
|
397
|
+
| isAuto | boolean | false | 否 | Yuntu | 是否开启自动录音。若为 true,则自动开始录音。 |
|
|
398
|
+
| silenceDelay | int | 3 | 否 | Yuntu | 延迟 n 秒后开始静音检测 |
|
|
399
|
+
| silenceStopSeconds | int | 4 | 否 | Yuntu | 连续 n 秒静音停止录音 |
|
|
400
|
+
| volumeThreshold | double | 40 | 否 | Yuntu | 音量阈值,单位为分贝 |
|
|
396
401
|
|
|
397
402
|
|
|
398
403
|
### 返回说明
|
|
399
404
|
|
|
400
405
|
`Promise<Object>`
|
|
401
406
|
|
|
402
|
-
| 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明
|
|
403
|
-
|
|
404
|
-
|
|
|
407
|
+
| 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
|
|
408
|
+
|-----------|--|----------|-----|----------|---------------|
|
|
409
|
+
| fileUrl | string | | 是 | Yuntu | 录音文件的URL |
|
|
410
|
+
| filePath | string | | 是 | Yuntu | 录音文件的路径 |
|
|
411
|
+
| fileData | string | | 是 | Yuntu | 录音文件的base64文件 |
|
|
405
412
|
<br>
|
|
406
413
|
|
|
407
414
|
**录音状态** <br>
|
|
@@ -409,3 +416,37 @@ mounted() {
|
|
|
409
416
|
**not started**:录音未开始。<br>
|
|
410
417
|
**stopped**:录音已停止。<br>
|
|
411
418
|
**failed**:录音失败。<br>
|
|
419
|
+
|
|
420
|
+
### 下载文件(downloadFile)
|
|
421
|
+
|
|
422
|
+
调用文件下载功能,通过指定文件 URL 下载文件,并自动触发下载行为。
|
|
423
|
+
``` javascript
|
|
424
|
+
async downloadFile() {
|
|
425
|
+
try {
|
|
426
|
+
const fileUrl = 'http://10.110.34.27/yc_scrm.apk'; // 需要下载的文件 URL
|
|
427
|
+
const fileName = '下载文件'; // 文件保存名称
|
|
428
|
+
await this.$lamboJsBridge.downloadFile({ fileUrl, fileName });
|
|
429
|
+
console.log('Download initiated');
|
|
430
|
+
} catch (error) {
|
|
431
|
+
console.error('Download failed:', error);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### 参数说明
|
|
437
|
+
|
|
438
|
+
`params`: Object
|
|
439
|
+
|
|
440
|
+
| 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
|
|
441
|
+
|-----------|--|----------|-----|----------|-------------------------------------------------------------|
|
|
442
|
+
| fileUrl | string | 无 | 是 | Yuntu | 要下载文件的 URL 地址 |
|
|
443
|
+
| fileName | string | 'downloadedFile' | 否 | Yuntu | 下载后保存的文件名称,建议不包含文件扩展名(可由调用者自行添加扩展名) |
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
### 返回说明
|
|
447
|
+
|
|
448
|
+
`Promise<Object>`
|
|
449
|
+
|
|
450
|
+
| 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
|
|
451
|
+
|-----------|--|----------|-----|----------|---------|
|
|
452
|
+
| filePath | string | | 是 | Yuntu | 录音文件的路径 |
|
package/demo/index.vue
CHANGED
|
@@ -50,11 +50,14 @@
|
|
|
50
50
|
<div v-if="audioUrl">
|
|
51
51
|
<h3>录音已完成</h3>
|
|
52
52
|
<audio :src="audioUrl" controls></audio>
|
|
53
|
-
<p
|
|
53
|
+
<p>FileUrl:{{ audioUrl }}</p>
|
|
54
|
+
<p>FilePath:{{ audioPath }}</p>
|
|
55
|
+
<p>FileData:{{ audioData }}</p>
|
|
54
56
|
</div>
|
|
55
57
|
</demo-block>
|
|
56
58
|
<demo-block title="下载">
|
|
57
59
|
<van-button @click="downloadFile">下载文件</van-button>
|
|
60
|
+
<p v-if="downloadLink">文件已下载,路径:{{ downloadLink }}</p>
|
|
58
61
|
</demo-block>
|
|
59
62
|
|
|
60
63
|
|
|
@@ -90,6 +93,8 @@ export default {
|
|
|
90
93
|
photoPreviews: [],
|
|
91
94
|
initKeyMessage: '', // 用于存储 initKey 的返回消息
|
|
92
95
|
audioUrl: null, // 用于存储录音文件的 URL
|
|
96
|
+
audioPath: null,
|
|
97
|
+
audioData: null,
|
|
93
98
|
recordingStatus: "not started", // 用于记录当前录音状态
|
|
94
99
|
downloadLink : null,
|
|
95
100
|
};
|
|
@@ -118,7 +123,7 @@ export default {
|
|
|
118
123
|
weComId:this.weComId,
|
|
119
124
|
agentId:this.agentId,
|
|
120
125
|
dingTalkId:this.dingTalkId,
|
|
121
|
-
pluginConfig:["localAuthPlugin","amapPlugin","tabBarPlugin","scanCodePlugin","filePreviewPlugin","autoRecordPlugin"],
|
|
126
|
+
pluginConfig:["localAuthPlugin","amapPlugin","tabBarPlugin","scanCodePlugin","filePreviewPlugin","autoRecordPlugin","downloadFilePlugin"],
|
|
122
127
|
};
|
|
123
128
|
this.$lamboJsBridge = new LamboJsBridge(options);
|
|
124
129
|
await this.getPlatform();
|
|
@@ -157,7 +162,7 @@ export default {
|
|
|
157
162
|
this.recordingStatus = 'recording';
|
|
158
163
|
try {
|
|
159
164
|
// 传入 { auto: true } 表示启用自动录音
|
|
160
|
-
const result = await this.$lamboJsBridge.startRecording({ auto: true });
|
|
165
|
+
const result = await this.$lamboJsBridge.startRecording({ auto: true , silenceDelay: 1, silenceStopSeconds: 2, volumeThreshold: 60});
|
|
161
166
|
console.log("自动录音开始成功:", result);
|
|
162
167
|
} catch (error) {
|
|
163
168
|
console.error("自动录音开始失败:", error);
|
|
@@ -186,15 +191,32 @@ export default {
|
|
|
186
191
|
// 更新组件中的数据,页面会自动响应
|
|
187
192
|
this.recordingStatus = 'stopped';
|
|
188
193
|
this.audioUrl = data.fileUrl;
|
|
194
|
+
this.audioPath = data.filePath;
|
|
195
|
+
this.audioData = data.fileData;
|
|
189
196
|
},
|
|
190
197
|
|
|
191
198
|
|
|
192
199
|
async downloadFile(){
|
|
193
200
|
try {
|
|
194
|
-
const fileUrl = 'http://10.110.34.27/
|
|
195
|
-
const fileName = '
|
|
196
|
-
|
|
197
|
-
|
|
201
|
+
const fileUrl = 'http://10.110.34.27/sampleFile.txt'; // 要下载的文件 URL
|
|
202
|
+
const fileName = '下载文件.txt'; // 文件名称(建议带上扩展名)
|
|
203
|
+
// 注意传递的参数键需与插件内部代码一致:title 和 path
|
|
204
|
+
let result = await this.$lamboJsBridge.downloadFile({ title: fileName, path: fileUrl });
|
|
205
|
+
console.log('Download initiated, result:', result);
|
|
206
|
+
|
|
207
|
+
// 如果返回的数据为字符串,则尝试解析为对象
|
|
208
|
+
if (typeof result === 'string') {
|
|
209
|
+
try {
|
|
210
|
+
result = JSON.parse(result);
|
|
211
|
+
} catch (e) {
|
|
212
|
+
console.error('解析下载结果失败:', e);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// 假设返回的对象中包含 path 属性(如果没有则直接使用 result)
|
|
217
|
+
const filePath = result.path || result;
|
|
218
|
+
// 更新组件数据,显示文件下载路径
|
|
219
|
+
this.downloadLink = filePath;
|
|
198
220
|
} catch (error){
|
|
199
221
|
console.error('Download failed:', error);
|
|
200
222
|
}
|
package/package.json
CHANGED
package/src/sdk/YunTuAdapter.js
CHANGED
|
@@ -85,29 +85,35 @@ class YunTuAdapter {
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
//
|
|
89
|
-
async downloadFile(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
// 新增下载文件接口,options 作为参数传入
|
|
89
|
+
async downloadFile(options) {
|
|
90
|
+
return new Promise((resolve, reject) => {
|
|
91
|
+
if (window.fileDownload && typeof window.fileDownload.downloadFile === 'function') {
|
|
92
|
+
window.fileDownload.downloadFile(
|
|
93
|
+
// 成功回调
|
|
94
|
+
(result) => {
|
|
95
|
+
console.log("文件下载成功:", result);
|
|
96
|
+
try {
|
|
97
|
+
if (typeof result === "string") {
|
|
98
|
+
result = JSON.parse(result);
|
|
99
|
+
}
|
|
100
|
+
} catch (e) {
|
|
101
|
+
console.error("JSON.parse error:", e);
|
|
102
|
+
}
|
|
103
|
+
resolve(result);
|
|
104
|
+
},
|
|
105
|
+
// 失败回调
|
|
106
|
+
(error) => {
|
|
107
|
+
console.error("文件下载失败:", error);
|
|
108
|
+
reject(error);
|
|
109
|
+
},
|
|
110
|
+
// 直接将传入的 options 对象转为字符串
|
|
111
|
+
JSON.stringify(options)
|
|
112
|
+
);
|
|
113
|
+
} else {
|
|
114
|
+
reject(new Error("downloadFile 接口不可用"));
|
|
94
115
|
}
|
|
95
|
-
|
|
96
|
-
const fileBlob = await response.blob();
|
|
97
|
-
|
|
98
|
-
// 创建一个下载的 Blob URL
|
|
99
|
-
const downloadUrl = URL.createObjectURL(fileBlob);
|
|
100
|
-
|
|
101
|
-
// 通过 window.open 来触发文件下载(无 <a> 标签)
|
|
102
|
-
window.open(downloadUrl, '_blank');
|
|
103
|
-
|
|
104
|
-
// 清理临时 URL
|
|
105
|
-
URL.revokeObjectURL(downloadUrl);
|
|
106
|
-
|
|
107
|
-
console.log(`File "${fileName}" downloaded successfully.`);
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.error('Download failed:', error);
|
|
110
|
-
}
|
|
116
|
+
});
|
|
111
117
|
}
|
|
112
118
|
|
|
113
119
|
|