first commit
This commit is contained in:
126
uni_modules/lime-choose-file/readme.md
Normal file
126
uni_modules/lime-choose-file/readme.md
Normal file
@@ -0,0 +1,126 @@
|
||||
# lime-choose-file 文件选择组件
|
||||
一个基于UTS实现的文件选择插件,参考小程序chooseFile API实现,用法保持一致。支持安卓、iOS、鸿蒙和H5平台。提供了选择图片、视频和其他文件类型的功能。组件提供了简单易用的API,使开发者能够方便地在应用中集成文件选择功能。
|
||||
|
||||
## 文档链接
|
||||
📚 组件详细文档请访问以下站点:
|
||||
- [文件选择组件文档 - 站点1](https://limex.qcoon.cn/native/choose-file.html)
|
||||
- [文件选择组件文档 - 站点2](https://limeui.netlify.app/native/choose-file.html)
|
||||
- [文件选择组件文档 - 站点3](https://limeui.familyzone.top/native/choose-file.html)
|
||||
|
||||
## 安装方法
|
||||
1. 在uni-app插件市场中搜索并导入`lime-choose-file`
|
||||
2. 导入后在页面引入相关方法
|
||||
3. 需要自定义基座才能使用
|
||||
4. 试用符合需求后才购买,插件无法退款
|
||||
|
||||
## 代码演示
|
||||
|
||||
### UNIAPPX 使用方式
|
||||
```ts
|
||||
import { chooseFile, type ChooseFileOption } from '@/uni_modules/lime-choose-file'
|
||||
|
||||
const images = ref<string[]>([])
|
||||
const onClick = () => {
|
||||
chooseFile({
|
||||
filename: 'xxxx', // 可选 用于给文件重命名(安卓、iOS)
|
||||
type: 'image',
|
||||
success(res){
|
||||
images.value = res.tempFiles.map((item):string => item.path)
|
||||
console.log('选择结果:', res.tempFiles)
|
||||
},
|
||||
fail(err){
|
||||
console.log('选择失败:', err)
|
||||
}
|
||||
} as ChooseFileOption)
|
||||
}
|
||||
```
|
||||
|
||||
### UNIAPP 使用方式
|
||||
```ts
|
||||
import { chooseFile } from '@/uni_modules/lime-choose-file'
|
||||
|
||||
const images = ref<string[]>([])
|
||||
const onClick = () => {
|
||||
chooseFile({
|
||||
filename: 'xxxx', // 可选 用于给文件重命名(安卓、iOS)
|
||||
type: 'image',
|
||||
success(res){
|
||||
images.value = res.tempFiles.map((item):string => item.path)
|
||||
console.log('选择结果:', res.tempFiles)
|
||||
},
|
||||
fail(err){
|
||||
console.log('选择失败:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
## API文档
|
||||
|
||||
### chooseFile 方法
|
||||
|
||||
| 参数 | 说明 | 类型 | 必填 |
|
||||
| --- | --- | --- | --- |
|
||||
| options | 文件选择选项 | _ChooseFileOption_ | 是 |
|
||||
|
||||
### ChooseFileOption 选项
|
||||
|
||||
| 参数 | 类型 | 必填 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| filename | _string_ | 否 | 指定文件名,用于给文件重命名(安卓、iOS) |
|
||||
| count | _number_ | 否 | 最多可以选择的文件数量,默认为100 |
|
||||
| type | _string_ | 否 | 所选文件类型,默认为'all' |
|
||||
| extension | _string[]_ | 否 | 根据文件拓展名过滤,每一项都不能是空字符串。默认不过滤。仅H5支持 |
|
||||
| success | _(result: ChooseFileSuccessCallbackResult) => void_ | 否 | 接口调用成功的回调函数 |
|
||||
| fail | _(res: GeneralCallbackResult) => void_ | 否 | 接口调用失败的回调函数 |
|
||||
| complete | _(res: GeneralCallbackResult) => void_ | 否 | 接口调用结束的回调函数 |
|
||||
|
||||
### ChooseFileSuccessCallbackResult 返回参数
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| tempFiles | _ChooseFile[]_ | 返回选择的文件的本地临时文件对象数组 |
|
||||
| errMsg | _string_ | 错误信息 |
|
||||
|
||||
### ChooseFile 对象结构
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| name | _string_ | 选择的文件名称 |
|
||||
| path | _string_ | 本地临时文件路径 (本地路径) |
|
||||
| size | _number_ | 本地临时文件大小,单位 B |
|
||||
| time | _number_ | 选择的文件的会话发送时间,Unix时间戳 |
|
||||
| type | _'video' \| 'image' \| 'file' \| 'all'_ | 选择的文件类型 |
|
||||
|
||||
### 文件类型说明
|
||||
|
||||
| 类型值 | 说明 |
|
||||
| --- | --- |
|
||||
| video | 视频文件 |
|
||||
| image | 图片文件 |
|
||||
| file | 除图片和视频外的其他文件 |
|
||||
| all | 所有类型文件 |
|
||||
|
||||
## 功能特点
|
||||
|
||||
- 支持多种文件类型的选择,包括图片、视频和其他文件
|
||||
- 支持文件重命名功能
|
||||
- 兼容安卓、iOS、鸿蒙和H5平台
|
||||
- 提供简单易用的API接口
|
||||
- 支持指定最大选择数量
|
||||
- 支持文件扩展名过滤(H5平台)
|
||||
|
||||
## 常见问题
|
||||
|
||||
- iOS路径是中文时无法上传到服务器,这时候需要设置`filename`给文件重命名
|
||||
- APP端需要自定义基座才能使用
|
||||
- 文件选择后会返回临时文件路径,需要及时使用或保存
|
||||
- H5端可以通过extension参数过滤文件类型
|
||||
|
||||
## 支持与赞赏
|
||||
|
||||
如果你觉得本插件解决了你的问题,可以考虑支持作者:
|
||||
|
||||
| 支付宝赞助 | 微信赞助 |
|
||||
|------------|------------|
|
||||
|  |  |
|
||||
Reference in New Issue
Block a user