这一版本优化了很多
This commit is contained in:
49
unpackage/dist/dev/mp-weixin/app.js
vendored
49
unpackage/dist/dev/mp-weixin/app.js
vendored
@@ -49,6 +49,55 @@ const _sfc_main = {
|
||||
common_vendor.index.__f__("log", "at App.vue:10", "App Hide");
|
||||
}
|
||||
};
|
||||
common_vendor.index.addInterceptor("chooseImage", {
|
||||
success(res) {
|
||||
const allowedExtensions = ["bmp", "gif", "jpg", "jpeg", "png"];
|
||||
const validTempFilePaths = [];
|
||||
const validTempFiles = [];
|
||||
let hasInvalid = false;
|
||||
let invalidExt = "";
|
||||
res.tempFiles.forEach((file, index) => {
|
||||
const path = file.path || res.tempFilePaths[index];
|
||||
const cleanPath = path.split("?")[0];
|
||||
const ext = cleanPath.split(".").pop().toLowerCase();
|
||||
if (allowedExtensions.includes(ext)) {
|
||||
validTempFiles.push(file);
|
||||
validTempFilePaths.push(res.tempFilePaths[index]);
|
||||
} else {
|
||||
hasInvalid = true;
|
||||
invalidExt = ext;
|
||||
}
|
||||
});
|
||||
if (hasInvalid) {
|
||||
common_vendor.index.showToast({
|
||||
title: `已过滤不支持的 .${invalidExt} 格式图片,请上传 png/jpg/jpeg/gif/bmp`,
|
||||
icon: "none",
|
||||
duration: 3500
|
||||
});
|
||||
}
|
||||
res.tempFilePaths = validTempFilePaths;
|
||||
res.tempFiles = validTempFiles;
|
||||
}
|
||||
});
|
||||
common_vendor.index.addInterceptor("uploadFile", {
|
||||
invoke(args) {
|
||||
const filePath = args.filePath;
|
||||
if (filePath) {
|
||||
const cleanPath = filePath.split("?")[0];
|
||||
const ext = cleanPath.split(".").pop().toLowerCase();
|
||||
const allowedExtensions = ["bmp", "gif", "jpg", "jpeg", "png", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt", "rar", "zip", "gz", "bz2", "mp4", "avi", "rmvb", "pdf"];
|
||||
if (!allowedExtensions.includes(ext)) {
|
||||
common_vendor.index.showToast({
|
||||
title: `不支持 .${ext} 格式,请上传合规的文件或图片`,
|
||||
icon: "none",
|
||||
duration: 3e3
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return args;
|
||||
}
|
||||
});
|
||||
function createApp() {
|
||||
const app = common_vendor.createSSRApp(_sfc_main);
|
||||
app.use(uni_modules_uviewPlus_index.uviewPlus);
|
||||
|
||||
Reference in New Issue
Block a user