From 8affe5beedfcd9f6fbf4826ec1a7f9ce0718a9d3 Mon Sep 17 00:00:00 2001
From: jhzh <1628036192@qq.com>
Date: Fri, 29 Nov 2024 16:10:38 +0800
Subject: [PATCH] 1
---
src/page/authentication/index.vue | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/src/page/authentication/index.vue b/src/page/authentication/index.vue
index 4b322cd..a8512c2 100644
--- a/src/page/authentication/index.vue
+++ b/src/page/authentication/index.vue
@@ -206,11 +206,26 @@
}
},
methods: {
+ checkImageFormat(url) {
+ const img = new Image();
+ img.onload = function() {
+ console.log('图片加载成功,格式正确');
+ };
+ img.onerror = function() {
+ console.log('图片加载失败,格式不支持');
+ };
+ img.src = url;
+ },
handleAvatarSuccess(res, file) {
this.imgStatus = false;
this.form.img1key = res.data.url;
},
beforeAvatarUpload(file) {
+ const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
+ if (!isJpgOrPng) {
+ this.$message.error('只能上传 JPG 或 PNG 格式的图片!');
+ }
+ return isJpgOrPng;
this.imgStatus = true;
},
handleError() {
@@ -221,6 +236,11 @@
this.form.img2key = res.data.url; // URL.createObjectURL(file.raw);
},
beforeAvatarUpload2(file) {
+ const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
+ if (!isJpgOrPng) {
+ this.$message.error('Only images in JPG or PNG format can be uploaded!');
+ }
+ return isJpgOrPng;
this.imgStatus2 = true;
const isLt10M = file.size / 1024 / 1024 < 10;
if (!isLt10M) {
--
Gitblit v1.9.3