|
@@ -44,6 +44,7 @@
|
|
|
<UploadImgs
|
|
<UploadImgs
|
|
|
v-model:file-list="imageFileList"
|
|
v-model:file-list="imageFileList"
|
|
|
:api="handleCustomImageUpload"
|
|
:api="handleCustomImageUpload"
|
|
|
|
|
+ :file-type="PRICE_LIST_IMAGE_FILE_TYPES"
|
|
|
:limit="9"
|
|
:limit="9"
|
|
|
:file-size="20"
|
|
:file-size="20"
|
|
|
:width="'100px'"
|
|
:width="'100px'"
|
|
@@ -241,6 +242,7 @@
|
|
|
<UploadImgs
|
|
<UploadImgs
|
|
|
v-model:file-list="detailImageFileList"
|
|
v-model:file-list="detailImageFileList"
|
|
|
:api="handleCustomImageUpload"
|
|
:api="handleCustomImageUpload"
|
|
|
|
|
+ :file-type="PRICE_LIST_IMAGE_FILE_TYPES"
|
|
|
:limit="9"
|
|
:limit="9"
|
|
|
:file-size="20"
|
|
:file-size="20"
|
|
|
:width="'100px'"
|
|
:width="'100px'"
|
|
@@ -377,6 +379,9 @@ import { localGet } from "@/utils";
|
|
|
import UploadImgs from "@/components/Upload/Imgs.vue";
|
|
import UploadImgs from "@/components/Upload/Imgs.vue";
|
|
|
import { uploadFilesToOss } from "@/api/upload.js";
|
|
import { uploadFilesToOss } from "@/api/upload.js";
|
|
|
|
|
|
|
|
|
|
+/** 价目表仅图片,不含视频(UploadImgs 默认 fileType 含 video/*) */
|
|
|
|
|
+const PRICE_LIST_IMAGE_FILE_TYPES = ["image/jpeg", "image/png", "image/gif", "image/webp", "image/heic", "image/heif"];
|
|
|
|
|
+
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
const route = useRoute();
|
|
const route = useRoute();
|
|
|
const ruleFormRef = ref<FormInstance>();
|
|
const ruleFormRef = ref<FormInstance>();
|
|
@@ -557,8 +562,11 @@ const handleCustomImageUpload = async (formData: FormData, options?: Record<stri
|
|
|
if (!file) {
|
|
if (!file) {
|
|
|
throw new Error("请选择文件");
|
|
throw new Error("请选择文件");
|
|
|
}
|
|
}
|
|
|
- const isVideo = typeof file.type === "string" && file.type.startsWith("video/");
|
|
|
|
|
- const urls = await uploadFilesToOss(file, isVideo ? "video" : "image", options ?? {});
|
|
|
|
|
|
|
+ const mime = typeof file.type === "string" ? file.type : "";
|
|
|
|
|
+ if (mime.startsWith("video/") || /\.(mp4|m4v|webm|ogg|mov|avi)(\?.*)?$/i.test(file.name || "")) {
|
|
|
|
|
+ throw new Error("仅支持上传图片");
|
|
|
|
|
+ }
|
|
|
|
|
+ const urls = await uploadFilesToOss(file, "image", options ?? {});
|
|
|
const fileUrl = urls[0];
|
|
const fileUrl = urls[0];
|
|
|
if (!fileUrl) {
|
|
if (!fileUrl) {
|
|
|
throw new Error("上传失败,未返回地址");
|
|
throw new Error("上传失败,未返回地址");
|