From 40ed21141404ea96af41bac752b22c0f9a838168 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期一, 10 十一月 2025 14:55:20 +0800
Subject: [PATCH] fix: bug
---
packages/utils/file.ts | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/packages/utils/file.ts b/packages/utils/file.ts
index a88fe99..76afa6c 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;
}
@@ -89,7 +100,7 @@
export function openDocument(url: string) {
Taro.downloadFile({
- url: url,
+ url: encodeURI(url),
success: function (res) {
var filePath = res.tempFilePath;
Taro.openDocument({
--
Gitblit v1.9.1