u
This commit is contained in:
parent
32d2bcbf5f
commit
7bf187cc8d
23
unitool.js
23
unitool.js
@ -1,6 +1,6 @@
|
|||||||
// uniapp people side tools
|
// uniapp people side tools
|
||||||
|
|
||||||
import './ican-H5Api.js' // 对齐H5Api: https://ext.dcloud.net.cn/plugin?id=415 // 注意要取消默认自带的 showToast https://uniapp.dcloud.io/api/system/clipboard?id=%e6%b3%a8%e6%84%8f
|
//import './ican-H5Api.js' // 对齐H5Api: https://ext.dcloud.net.cn/plugin?id=415 // 注意要取消默认自带的 showToast https://uniapp.dcloud.io/api/system/clipboard?id=%e6%b3%a8%e6%84%8f
|
||||||
const BASE_TYPE_DEFAULT = 'SERVER' // one of { SERVER: 服务器, UNICLOUD_FUNC: 云函数, UNICLOUD_OBJECT: 云对象 }
|
const BASE_TYPE_DEFAULT = 'SERVER' // one of { SERVER: 服务器, UNICLOUD_FUNC: 云函数, UNICLOUD_OBJECT: 云对象 }
|
||||||
const my = {
|
const my = {
|
||||||
langNow () {
|
langNow () {
|
||||||
@ -267,7 +267,13 @@ export default {
|
|||||||
let [errorChoose, { tempFilePath }] = await uni.chooseVideo({ sourceType })
|
let [errorChoose, { tempFilePath }] = await uni.chooseVideo({ sourceType })
|
||||||
filePath = tempFilePath
|
filePath = tempFilePath
|
||||||
} else {
|
} else {
|
||||||
|
// #ifdef H5
|
||||||
|
let [errorChoose, { tempFilePaths, tempFiles } = {}] = await uni.chooseFile({ count, type: 'all' })
|
||||||
|
filePath = tempFilePaths[0]
|
||||||
|
// #endif
|
||||||
|
// #ifndef H5
|
||||||
return { _state: 'UNKNOWN_MEDIATYPE' }
|
return { _state: 'UNKNOWN_MEDIATYPE' }
|
||||||
|
// #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
@ -339,7 +345,7 @@ export default {
|
|||||||
if (!/\.(mp4|mov)$/i.test(cloudPath)) cloudPath = cloudPath + '.mp4'
|
if (!/\.(mp4|mov)$/i.test(cloudPath)) cloudPath = cloudPath + '.mp4'
|
||||||
} else {
|
} else {
|
||||||
let { errMsg, tempFilePaths, tempFiles } = await uniCloud.chooseAndUploadFile({
|
let { errMsg, tempFilePaths, tempFiles } = await uniCloud.chooseAndUploadFile({
|
||||||
type: 'all',
|
type: 'all', // valid for H5 only: https://uniapp.dcloud.net.cn/uniCloud/storage.html#uploadfile
|
||||||
count: 1,
|
count: 1,
|
||||||
// extention: [],
|
// extention: [],
|
||||||
// onChooseFile: ({ errMsg, tempFilePaths, tempFiles }) => { },
|
// onChooseFile: ({ errMsg, tempFilePaths, tempFiles }) => { },
|
||||||
@ -357,7 +363,7 @@ export default {
|
|||||||
const { fileID, requestId } = await uniCloud.uploadFile({
|
const { fileID, requestId } = await uniCloud.uploadFile({
|
||||||
filePath: filePath,
|
filePath: filePath,
|
||||||
cloudPath: process.env.NODE_ENV !== 'production' ? 'dev_' + cloudPath : cloudPath, // 关键是要具有文件格式后缀名,这样可以保持阿里云下载链接也用这个后缀名。
|
cloudPath: process.env.NODE_ENV !== 'production' ? 'dev_' + cloudPath : cloudPath, // 关键是要具有文件格式后缀名,这样可以保持阿里云下载链接也用这个后缀名。
|
||||||
fileType: mediaType, // = image, video, audio
|
//fileType: mediaType, // = image, video, audio. Looks like only necessary for for 支付宝小程序: https://uniapp.dcloud.net.cn/uniCloud/storage.html#uploadfile
|
||||||
onUploadProgress: function (progressEvent) {
|
onUploadProgress: function (progressEvent) {
|
||||||
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
|
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
|
||||||
},
|
},
|
||||||
@ -614,15 +620,16 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
copy_to_clipboard (text, toastLength = 50) {
|
copy_to_clipboard (text, { promptLength = 50, hidePrompt = false } = {}) {
|
||||||
uni.setClipboardData({
|
uni.setClipboardData({
|
||||||
data: text,
|
data: text,
|
||||||
success: () => {
|
success: () => {
|
||||||
uni.hideToast()
|
uni.hideToast()
|
||||||
wo.tt.showToast({
|
if (!hidePrompt)
|
||||||
type: wo.c2t.GREEN,
|
wo.tt.showToast({
|
||||||
title: `${wo.ll({ zhCN: '已成功拷贝', enUS: 'Successfully copied' })}\n${String(text).substring(0, toastLength)}`,
|
type: wo.c2t.GREEN,
|
||||||
})
|
title: `${wo.ll({ zhCN: '已成功拷贝', enUS: 'Successfully copied' })}\n${String(text).substring(0, promptLength)}`,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user