@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.23 → 1.0.0-beta.24
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 +7 -0
- package/README.md +39 -3
- package/demo/index.vue +28 -6
- package/package.json +1 -1
- package/src/sdk/YunTuAdapter.js +28 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
## [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)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ✨ Features | 新功能
|
|
6
|
+
|
|
7
|
+
* **@lambo-design-mobile/js-bridge:** 录音新增base64出参;新增下载接口 ([131e4a6](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/commit/131e4a68228d528badea094d057a3d81c41f359b))
|
|
8
|
+
|
|
2
9
|
## [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
10
|
|
|
4
11
|
|
package/README.md
CHANGED
|
@@ -399,9 +399,11 @@ mounted() {
|
|
|
399
399
|
|
|
400
400
|
`Promise<Object>`
|
|
401
401
|
|
|
402
|
-
| 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明
|
|
403
|
-
|
|
404
|
-
|
|
|
402
|
+
| 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
|
|
403
|
+
|-----------|--|----------|-----|----------|---------------|
|
|
404
|
+
| fileUrl | string | | 是 | Yuntu | 录音文件的URL |
|
|
405
|
+
| filePath | string | | 是 | Yuntu | 录音文件的路径 |
|
|
406
|
+
| fileData | string | | 是 | Yuntu | 录音文件的base64文件 |
|
|
405
407
|
<br>
|
|
406
408
|
|
|
407
409
|
**录音状态** <br>
|
|
@@ -409,3 +411,37 @@ mounted() {
|
|
|
409
411
|
**not started**:录音未开始。<br>
|
|
410
412
|
**stopped**:录音已停止。<br>
|
|
411
413
|
**failed**:录音失败。<br>
|
|
414
|
+
|
|
415
|
+
### 下载文件(downloadFile)
|
|
416
|
+
|
|
417
|
+
调用文件下载功能,通过指定文件 URL 下载文件,并自动触发下载行为。
|
|
418
|
+
``` javascript
|
|
419
|
+
async downloadFile() {
|
|
420
|
+
try {
|
|
421
|
+
const fileUrl = 'http://10.110.34.27/yc_scrm.apk'; // 需要下载的文件 URL
|
|
422
|
+
const fileName = '下载文件'; // 文件保存名称
|
|
423
|
+
await this.$lamboJsBridge.downloadFile({ fileUrl, fileName });
|
|
424
|
+
console.log('Download initiated');
|
|
425
|
+
} catch (error) {
|
|
426
|
+
console.error('Download failed:', error);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
### 参数说明
|
|
432
|
+
|
|
433
|
+
`params`: Object
|
|
434
|
+
|
|
435
|
+
| 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
|
|
436
|
+
|-----------|--|----------|-----|----------|-------------------------------------------------------------|
|
|
437
|
+
| fileUrl | string | 无 | 是 | Yuntu | 要下载文件的 URL 地址 |
|
|
438
|
+
| fileName | string | 'downloadedFile' | 否 | Yuntu | 下载后保存的文件名称,建议不包含文件扩展名(可由调用者自行添加扩展名) |
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
### 返回说明
|
|
442
|
+
|
|
443
|
+
`Promise<Object>`
|
|
444
|
+
|
|
445
|
+
| 属性 | 类型 | 默认值 | 必填 | 支持平台 | 说明 |
|
|
446
|
+
|-----------|--|----------|-----|----------|---------|
|
|
447
|
+
| 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();
|
|
@@ -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
|
|