feat:设备使用记录

This commit is contained in:
houjunxiang
2026-03-05 16:54:47 +08:00
parent 749ac7f507
commit 9c88c45d66
357 changed files with 21486 additions and 5845 deletions

View File

@@ -56,7 +56,7 @@ export const props = defineMixin({
type: Function,
default: null
},
// 是否显示组件自带的图片预览功能
// 是否显示组件自带的图片&视频预览功能
previewFullImage: {
type: Boolean,
default: () => defProps.upload.previewFullImage
@@ -125,6 +125,52 @@ export const props = defineMixin({
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
},
}
})

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,11 @@
/*
* @Author : LQ
* @Description :
* @version : 1.0
* @version : 3.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
* @LastAuthor : jry
* @lastTime : 2025-12-19 08:55:21
* @FilePath : /uview-plus/libs/config/props/upload.js
*/
export default {
// upload组件
@@ -32,6 +32,15 @@ export default {
uploadText: '',
width: 80,
height: 80,
previewImage: true
previewImage: true,
autoDelete: false,
autoUpload: false,
autoUploadApi: '',
autoUploadAuthUrl: '',
autoUploadDriver: '',
autoUploadHeader: {},
getVideoThumb: false,
customAfterAutoUpload: false,
videoPreviewObjectFit: 'cover'
}
}

View File

@@ -1,3 +1,4 @@
import test from '../../libs/function/test'
function pickExclude(obj, keys) {
// 某些情况下type可能会为
if (!['[object Object]', '[object File]'].includes(Object.prototype.toString.call(obj))) {
@@ -22,10 +23,14 @@ 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']),
@@ -33,10 +38,15 @@ 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
}
]
}
@@ -51,6 +61,9 @@ function formatMedia(res) {
// #ifdef H5
file: item
// #endif
// #ifndef H5
name: item.tempFilePath.split('/').pop() + (res.type === 'video' ? '.mp4': '.png'),
// #endif
}))
}
@@ -77,6 +90,11 @@ 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':
@@ -112,32 +130,28 @@ 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