From 58e6c22b584ba40169753ec5038dec7d780c0bd3 Mon Sep 17 00:00:00 2001 From: wupengfei <834520024@qq.com> Date: 星期五, 17 十月 2025 19:47:30 +0800 Subject: [PATCH] Merge branch 'dev-1.2.0.1' of http://120.26.58.240:8888/r/flexJobMiniApp into dev-1.2.0.1 --- packages/utils/file.ts | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/packages/utils/file.ts b/packages/utils/file.ts index bb74f4c..ba20d1a 100644 --- a/packages/utils/file.ts +++ b/packages/utils/file.ts @@ -33,6 +33,17 @@ } const imgReg = /\.(png|jpeg|jpg|webp|gif)$/i; +const videoReg = /\.(mp4|avi|mkv|wmv|flv|webm|m4v|3gp|mpeg|mpg|ts|vob|ogv|f4v)$/i; + +function getFileType(path: string) { + if (imgReg.test(path)) { + return 'image'; + } + if (videoReg.test(path)) { + return 'video'; + } + return ''; +} /** * 鎶奱pi杩斿洖鐨勮矾寰勮浆鎹负upload鐨勮矾寰� @@ -43,7 +54,7 @@ path: urlOmitDomain(path), url: setOSSLink(path), status: 'success', - type: imgReg.test(path) ? 'image' : '', + type: getFileType(path), uid: _.uniqueId(), } as FileItem; } @@ -86,3 +97,15 @@ return fileName; }); } + +export function openDocument(url: string) { + Taro.downloadFile({ + url: url, + success: function (res) { + var filePath = res.tempFilePath; + Taro.openDocument({ + filePath: filePath, + }); + }, + }); +} -- Gitblit v1.9.1