From 7bf187cc8dd8920a6c87beccf095e4647aae4f66 Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Mon, 14 Aug 2023 11:40:29 +0800 Subject: [PATCH] u --- unitool.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/unitool.js b/unitool.js index 7cff2b5..d58180a 100644 --- a/unitool.js +++ b/unitool.js @@ -1,6 +1,6 @@ // 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 my = { langNow () { @@ -267,7 +267,13 @@ export default { let [errorChoose, { tempFilePath }] = await uni.chooseVideo({ sourceType }) filePath = tempFilePath } else { + // #ifdef H5 + let [errorChoose, { tempFilePaths, tempFiles } = {}] = await uni.chooseFile({ count, type: 'all' }) + filePath = tempFilePaths[0] + // #endif + // #ifndef H5 return { _state: 'UNKNOWN_MEDIATYPE' } + // #endif } if (filePath) { @@ -339,7 +345,7 @@ export default { if (!/\.(mp4|mov)$/i.test(cloudPath)) cloudPath = cloudPath + '.mp4' } else { 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, // extention: [], // onChooseFile: ({ errMsg, tempFilePaths, tempFiles }) => { }, @@ -357,7 +363,7 @@ export default { const { fileID, requestId } = await uniCloud.uploadFile({ filePath: filePath, 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) { 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({ data: text, success: () => { uni.hideToast() - wo.tt.showToast({ - type: wo.c2t.GREEN, - title: `${wo.ll({ zhCN: '已成功拷贝', enUS: 'Successfully copied' })}\n${String(text).substring(0, toastLength)}`, - }) + if (!hidePrompt) + wo.tt.showToast({ + type: wo.c2t.GREEN, + title: `${wo.ll({ zhCN: '已成功拷贝', enUS: 'Successfully copied' })}\n${String(text).substring(0, promptLength)}`, + }) }, }) },