feat:还原更新框架
This commit is contained in:
@@ -1,179 +1,130 @@
|
||||
import { defineMixin } from '../../libs/vue'
|
||||
import UploadDefaultProps from './upload'
|
||||
import { registerComponentProps } from '../../libs/config/props.js'
|
||||
|
||||
const defProps = registerComponentProps(UploadDefaultProps)
|
||||
export const props = defineMixin({
|
||||
props: {
|
||||
// 接受的文件类型, 可选值为all media image file video
|
||||
accept: {
|
||||
type: String,
|
||||
default: () => defProps.upload.accept
|
||||
},
|
||||
extension: {
|
||||
type: Array,
|
||||
default: () => defProps.upload.extension
|
||||
},
|
||||
// 图片或视频拾取模式,当accept为image类型时设置capture可选额外camera可以直接调起摄像头
|
||||
capture: {
|
||||
type: [String, Array],
|
||||
default: () => defProps.upload.capture
|
||||
},
|
||||
// 当accept为video时生效,是否压缩视频,默认为true
|
||||
compressed: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.compressed
|
||||
},
|
||||
// 当accept为video时生效,可选值为back或front
|
||||
camera: {
|
||||
type: String,
|
||||
default: () => defProps.upload.camera
|
||||
},
|
||||
// 当accept为video时生效,拍摄视频最长拍摄时间,单位秒
|
||||
maxDuration: {
|
||||
type: Number,
|
||||
default: () => defProps.upload.maxDuration
|
||||
},
|
||||
// 上传区域的图标,只能内置图标
|
||||
uploadIcon: {
|
||||
type: String,
|
||||
default: () => defProps.upload.uploadIcon
|
||||
},
|
||||
// 上传区域的图标的颜色,默认
|
||||
uploadIconColor: {
|
||||
type: String,
|
||||
default: () => defProps.upload.uploadIconColor
|
||||
},
|
||||
// 是否开启文件读取前事件
|
||||
useBeforeRead: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.useBeforeRead
|
||||
},
|
||||
// 读取后的处理函数
|
||||
afterRead: {
|
||||
type: Function,
|
||||
default: null
|
||||
},
|
||||
// 读取前的处理函数
|
||||
beforeRead: {
|
||||
type: Function,
|
||||
default: null
|
||||
},
|
||||
// 是否显示组件自带的图片&视频预览功能
|
||||
previewFullImage: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.previewFullImage
|
||||
},
|
||||
// 最大上传数量
|
||||
maxCount: {
|
||||
type: [String, Number],
|
||||
default: () => defProps.upload.maxCount
|
||||
},
|
||||
// 是否启用
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.disabled
|
||||
},
|
||||
// 预览上传的图片时的裁剪模式,和image组件mode属性一致
|
||||
imageMode: {
|
||||
type: String,
|
||||
default: () => defProps.upload.imageMode
|
||||
},
|
||||
// 标识符,可以在回调函数的第二项参数中获取
|
||||
name: {
|
||||
type: String,
|
||||
default: () => defProps.upload.name
|
||||
},
|
||||
// 所选的图片的尺寸, 可选值为original compressed
|
||||
sizeType: {
|
||||
type: Array,
|
||||
default: () => defProps.upload.sizeType
|
||||
},
|
||||
// 是否开启图片多选,部分安卓机型不支持
|
||||
multiple: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.multiple
|
||||
},
|
||||
// 是否展示删除按钮
|
||||
deletable: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.deletable
|
||||
},
|
||||
// 文件大小限制,单位为byte
|
||||
maxSize: {
|
||||
type: [String, Number],
|
||||
default: () => defProps.upload.maxSize
|
||||
},
|
||||
// 显示已上传的文件列表
|
||||
fileList: {
|
||||
type: Array,
|
||||
default: () => defProps.upload.fileList
|
||||
},
|
||||
// 上传区域的提示文字
|
||||
uploadText: {
|
||||
type: String,
|
||||
default: () => defProps.upload.uploadText
|
||||
},
|
||||
// 内部预览图片区域和选择图片按钮的区域宽度
|
||||
width: {
|
||||
type: [String, Number],
|
||||
default: () => defProps.upload.width
|
||||
},
|
||||
// 内部预览图片区域和选择图片按钮的区域高度
|
||||
height: {
|
||||
type: [String, Number],
|
||||
default: () => defProps.upload.height
|
||||
},
|
||||
// 是否在上传完成后展示预览图
|
||||
previewImage: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.previewImage
|
||||
},
|
||||
// 是否自动删除
|
||||
autoDelete: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.autoDelete
|
||||
},
|
||||
// 是否自动上传需要传递action指定地址
|
||||
autoUpload: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.autoUpload
|
||||
},
|
||||
// 自动上传接口地址
|
||||
autoUploadApi: {
|
||||
type: String,
|
||||
default: () => defProps.upload.autoUploadApi
|
||||
},
|
||||
// 自动上传驱动,local/oss/cos/kodo
|
||||
autoUploadDriver: {
|
||||
type: String,
|
||||
default: () => defProps.upload.autoUploadDriver
|
||||
},
|
||||
// 自动上传授权接口,比如oss的签名接口。
|
||||
autoUploadAuthUrl: {
|
||||
type: String,
|
||||
default: () => defProps.upload.autoUploadAuthUrl
|
||||
},
|
||||
// 自动上传携带的header
|
||||
autoUploadHeader: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return defProps.upload.autoUploadHeader
|
||||
}
|
||||
},
|
||||
// 本地计算视频封面
|
||||
getVideoThumb: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.getVideoThumb
|
||||
},
|
||||
// 自定义自动上传后处理
|
||||
customAfterAutoUpload: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.customAfterAutoUpload
|
||||
},
|
||||
videoPreviewObjectFit: {
|
||||
type: String,
|
||||
default: () => defProps.upload.videoPreviewObjectFit
|
||||
},
|
||||
}
|
||||
})
|
||||
import { defineMixin } from '../../libs/vue'
|
||||
import defProps from '../../libs/config/props.js'
|
||||
export const props = defineMixin({
|
||||
props: {
|
||||
// 接受的文件类型, 可选值为all media image file video
|
||||
accept: {
|
||||
type: String,
|
||||
default: () => defProps.upload.accept
|
||||
},
|
||||
extension: {
|
||||
type: Array,
|
||||
default: () => defProps.upload.extension
|
||||
},
|
||||
// 图片或视频拾取模式,当accept为image类型时设置capture可选额外camera可以直接调起摄像头
|
||||
capture: {
|
||||
type: [String, Array],
|
||||
default: () => defProps.upload.capture
|
||||
},
|
||||
// 当accept为video时生效,是否压缩视频,默认为true
|
||||
compressed: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.compressed
|
||||
},
|
||||
// 当accept为video时生效,可选值为back或front
|
||||
camera: {
|
||||
type: String,
|
||||
default: () => defProps.upload.camera
|
||||
},
|
||||
// 当accept为video时生效,拍摄视频最长拍摄时间,单位秒
|
||||
maxDuration: {
|
||||
type: Number,
|
||||
default: () => defProps.upload.maxDuration
|
||||
},
|
||||
// 上传区域的图标,只能内置图标
|
||||
uploadIcon: {
|
||||
type: String,
|
||||
default: () => defProps.upload.uploadIcon
|
||||
},
|
||||
// 上传区域的图标的颜色,默认
|
||||
uploadIconColor: {
|
||||
type: String,
|
||||
default: () => defProps.upload.uploadIconColor
|
||||
},
|
||||
// 是否开启文件读取前事件
|
||||
useBeforeRead: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.useBeforeRead
|
||||
},
|
||||
// 读取后的处理函数
|
||||
afterRead: {
|
||||
type: Function,
|
||||
default: null
|
||||
},
|
||||
// 读取前的处理函数
|
||||
beforeRead: {
|
||||
type: Function,
|
||||
default: null
|
||||
},
|
||||
// 是否显示组件自带的图片预览功能
|
||||
previewFullImage: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.previewFullImage
|
||||
},
|
||||
// 最大上传数量
|
||||
maxCount: {
|
||||
type: [String, Number],
|
||||
default: () => defProps.upload.maxCount
|
||||
},
|
||||
// 是否启用
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.disabled
|
||||
},
|
||||
// 预览上传的图片时的裁剪模式,和image组件mode属性一致
|
||||
imageMode: {
|
||||
type: String,
|
||||
default: () => defProps.upload.imageMode
|
||||
},
|
||||
// 标识符,可以在回调函数的第二项参数中获取
|
||||
name: {
|
||||
type: String,
|
||||
default: () => defProps.upload.name
|
||||
},
|
||||
// 所选的图片的尺寸, 可选值为original compressed
|
||||
sizeType: {
|
||||
type: Array,
|
||||
default: () => defProps.upload.sizeType
|
||||
},
|
||||
// 是否开启图片多选,部分安卓机型不支持
|
||||
multiple: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.multiple
|
||||
},
|
||||
// 是否展示删除按钮
|
||||
deletable: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.deletable
|
||||
},
|
||||
// 文件大小限制,单位为byte
|
||||
maxSize: {
|
||||
type: [String, Number],
|
||||
default: () => defProps.upload.maxSize
|
||||
},
|
||||
// 显示已上传的文件列表
|
||||
fileList: {
|
||||
type: Array,
|
||||
default: () => defProps.upload.fileList
|
||||
},
|
||||
// 上传区域的提示文字
|
||||
uploadText: {
|
||||
type: String,
|
||||
default: () => defProps.upload.uploadText
|
||||
},
|
||||
// 内部预览图片区域和选择图片按钮的区域宽度
|
||||
width: {
|
||||
type: [String, Number],
|
||||
default: () => defProps.upload.width
|
||||
},
|
||||
// 内部预览图片区域和选择图片按钮的区域高度
|
||||
height: {
|
||||
type: [String, Number],
|
||||
default: () => defProps.upload.height
|
||||
},
|
||||
// 是否在上传完成后展示预览图
|
||||
previewImage: {
|
||||
type: Boolean,
|
||||
default: () => defProps.upload.previewImage
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,46 +1,37 @@
|
||||
/*
|
||||
* @Author : LQ
|
||||
* @Description :
|
||||
* @version : 3.0
|
||||
* @Date : 2021-08-20 16:44:21
|
||||
* @LastAuthor : jry
|
||||
* @lastTime : 2025-12-19 08:55:21
|
||||
* @FilePath : /uview-plus/libs/config/props/upload.js
|
||||
*/
|
||||
export default {
|
||||
// upload组件
|
||||
upload: {
|
||||
accept: 'image',
|
||||
extension: [],
|
||||
capture: ['album', 'camera'],
|
||||
compressed: true,
|
||||
camera: 'back',
|
||||
maxDuration: 60,
|
||||
uploadIcon: 'camera-fill',
|
||||
uploadIconColor: '#D3D4D6',
|
||||
useBeforeRead: false,
|
||||
previewFullImage: true,
|
||||
maxCount: 52,
|
||||
disabled: false,
|
||||
imageMode: 'aspectFill',
|
||||
name: '',
|
||||
sizeType: ['original', 'compressed'],
|
||||
multiple: false,
|
||||
deletable: true,
|
||||
maxSize: Number.MAX_VALUE,
|
||||
fileList: [],
|
||||
uploadText: '',
|
||||
width: 80,
|
||||
height: 80,
|
||||
previewImage: true,
|
||||
autoDelete: false,
|
||||
autoUpload: false,
|
||||
autoUploadApi: '',
|
||||
autoUploadAuthUrl: '',
|
||||
autoUploadDriver: '',
|
||||
autoUploadHeader: {},
|
||||
getVideoThumb: false,
|
||||
customAfterAutoUpload: false,
|
||||
videoPreviewObjectFit: 'cover'
|
||||
}
|
||||
}
|
||||
/*
|
||||
* @Author : LQ
|
||||
* @Description :
|
||||
* @version : 1.0
|
||||
* @Date : 2021-08-20 16:44:21
|
||||
* @LastAuthor : LQ
|
||||
* @lastTime : 2021-08-20 17:09:50
|
||||
* @FilePath : /u-view2.0/uview-ui/libs/config/props/upload.js
|
||||
*/
|
||||
export default {
|
||||
// upload组件
|
||||
upload: {
|
||||
accept: 'image',
|
||||
extension: [],
|
||||
capture: ['album', 'camera'],
|
||||
compressed: true,
|
||||
camera: 'back',
|
||||
maxDuration: 60,
|
||||
uploadIcon: 'camera-fill',
|
||||
uploadIconColor: '#D3D4D6',
|
||||
useBeforeRead: false,
|
||||
previewFullImage: true,
|
||||
maxCount: 52,
|
||||
disabled: false,
|
||||
imageMode: 'aspectFill',
|
||||
name: '',
|
||||
sizeType: ['original', 'compressed'],
|
||||
multiple: false,
|
||||
deletable: true,
|
||||
maxSize: Number.MAX_VALUE,
|
||||
fileList: [],
|
||||
uploadText: '',
|
||||
width: 80,
|
||||
height: 80,
|
||||
previewImage: true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import test from '../../libs/function/test'
|
||||
function pickExclude(obj, keys) {
|
||||
// 某些情况下,type可能会为
|
||||
if (!['[object Object]', '[object File]'].includes(Object.prototype.toString.call(obj))) {
|
||||
@@ -23,14 +22,10 @@ function formatImage(res) {
|
||||
name: item.name,
|
||||
file: item
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
name: item.path.split('/').pop() + '.png',
|
||||
// #endif
|
||||
}))
|
||||
}
|
||||
|
||||
function formatVideo(res) {
|
||||
// console.log(res)
|
||||
return [
|
||||
{
|
||||
...pickExclude(res, ['tempFilePath', 'thumbTempFilePath', 'errMsg']),
|
||||
@@ -38,15 +33,10 @@ function formatVideo(res) {
|
||||
url: res.tempFilePath,
|
||||
thumb: res.thumbTempFilePath,
|
||||
size: res.size,
|
||||
width: res.width || 0, // APP 2.1.0+、H5、微信小程序、京东小程序
|
||||
height: res.height || 0, // APP 2.1.0+、H5、微信小程序、京东小程序
|
||||
// #ifdef H5
|
||||
name: res.name,
|
||||
file: res
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
name: res.tempFilePath.split('/').pop() + '.mp4',
|
||||
// #endif
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -61,9 +51,6 @@ function formatMedia(res) {
|
||||
// #ifdef H5
|
||||
file: item
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
name: item.tempFilePath.split('/').pop() + (res.type === 'video' ? '.mp4': '.png'),
|
||||
// #endif
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -90,11 +77,6 @@ export function chooseFile({
|
||||
maxCount,
|
||||
extension
|
||||
}) {
|
||||
try {
|
||||
capture = test.array(capture) ? capture : capture.split(',');
|
||||
} catch(e) {
|
||||
capture = [];
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
switch (accept) {
|
||||
case 'image':
|
||||
@@ -130,28 +112,32 @@ export function chooseFile({
|
||||
fail: reject
|
||||
})
|
||||
break
|
||||
// #ifdef MP-WEIXIN || H5
|
||||
// 只有微信小程序才支持chooseMessageFile接口
|
||||
// #ifdef MP-WEIXIN || H5
|
||||
// 只有微信小程序才支持chooseMessageFile接口
|
||||
case 'file':
|
||||
// #ifdef MP-WEIXIN
|
||||
wx.chooseMessageFile({
|
||||
count: multiple ? maxCount : 1,
|
||||
type: accept,
|
||||
success: (res) => resolve(formatFile(res)),
|
||||
fail: reject
|
||||
})
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
// 需要hx2.9.9以上才支持uni.chooseFile
|
||||
let params = {
|
||||
count: multiple ? maxCount : 1,
|
||||
type: accept,
|
||||
success: (res) => resolve(formatFile(res)),
|
||||
fail: reject
|
||||
}
|
||||
// Array<string>根据文件拓展名过滤,仅 type==file 时有效。每一项都不能是空字符串。默认不过滤。
|
||||
if (extension.length && extension.length > 0) {
|
||||
params.extension = extension
|
||||
}
|
||||
// #ifdef MP-WEIXIN
|
||||
wx.chooseMessageFile(params)
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
// 需要hx2.9.9以上才支持uni.chooseFile
|
||||
uni.chooseFile(params)
|
||||
// #endif
|
||||
break
|
||||
// #endif
|
||||
// #endif
|
||||
default:
|
||||
// 此为保底选项,在accept不为上面任意一项的时候选取全部文件
|
||||
// #ifdef MP-WEIXIN
|
||||
|
||||
Reference in New Issue
Block a user