From 2642a885f097660ba171abb8d5e0935077e3552d Mon Sep 17 00:00:00 2001 From: wangyifeng <812766448@qq.com> Date: Tue, 18 Mar 2025 20:00:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E6=9C=AC=E5=9C=B0=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E6=B2=A1=E6=9C=89=E6=97=B6=EF=BC=8C=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=9A=84=E8=B7=B3=E8=BD=AC=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E5=A4=84=E7=90=86=E7=9B=B4=E6=8E=A5=E8=B0=83=E8=B5=B7=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E3=80=81=E6=96=87=E4=BB=B6=E6=9F=A5=E7=9C=8B=E7=AD=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/talk/message/FileMessage.vue | 104 +++- .../components/selectMemberByAlphabet.vue | 6 + src/pages/chatSettings/index.vue | 36 +- src/pages/dialog/components/filePanel.vue | 493 ++++++++++-------- src/pages/dialog/index.vue | 234 ++++++--- src/pages/index/components/chatItem.vue | 2 +- src/pages/index/index.vue | 2 +- src/pages/search/components/searchList.vue | 16 +- src/pages/search/searchByCondition/index.vue | 96 +++- 9 files changed, 672 insertions(+), 317 deletions(-) diff --git a/src/components/talk/message/FileMessage.vue b/src/components/talk/message/FileMessage.vue index 7677ac8..6735c14 100644 --- a/src/components/talk/message/FileMessage.vue +++ b/src/components/talk/message/FileMessage.vue @@ -25,33 +25,33 @@ const getFileTypeIMG = computed(() => { let objT = { finishedImg: '', blankImg: '', - progressColor: '' - }; + progressColor: '', + } switch (suffix) { case 'pdf': objT.finishedImg = filePaperPDF objT.blankImg = filePaperPDFBlank objT.progressColor = '#DE4E4E' - break; + break case 'doc': case 'docx': objT.finishedImg = filePaperWord objT.blankImg = filePaperWordBlank objT.progressColor = '#2750B2' - break; + break case 'xls': case 'xlsx': objT.finishedImg = filePaperExcel objT.blankImg = filePaperExcelBlank objT.progressColor = '#3C7F4B' - break; + break case 'ppt': case 'pptx': objT.finishedImg = filePaperPPT objT.blankImg = filePaperPPTBlank objT.progressColor = '#B74B2B' - break; + break default: objT.finishedImg = filePaperOther objT.blankImg = filePaperOtherBlank @@ -60,34 +60,92 @@ const getFileTypeIMG = computed(() => { return objT }) +const previewPDF = () => { + if (typeof plus !== 'undefined') { + downloadAndOpenFile() + } else { + document.addEventListener('plusready', () => { + downloadAndOpenFile() + }) + } +} + +const downloadAndOpenFile = () => { + uni.showLoading({ title: '加载中...', mask: true }) + const downloadUrl = props?.extra?.path + if (!downloadUrl) { + uni.hideLoading() + uni.showToast({ title: '文件路径无效', icon: 'none' }) + return + } + const options = { + filename: '_doc/downloads/', // 保存路径 + } + const dtask = plus.downloader.createDownload(downloadUrl, options, function ( + d, + status, + ) { + if (status === 200) { + uni.hideLoading() + const filePath = d.filename + if (filePath) { + plus.runtime.openFile(filePath, {}, function () {}) + } else { + uni.showToast({ title: '文件路径无效', icon: 'none' }) + } + } else { + uni.hideLoading() + } + }) + dtask.start() +}