From ab5005dc459c1de78b5527a7a584ed7c8a9206c3 Mon Sep 17 00:00:00 2001 From: pzy Date: Tue, 1 Mar 2022 09:16:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E9=99=90=E5=88=B6500k?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 2 +- src/utils/get-img-width.js | 15 +++++++++--- src/views/ad/index.vue | 2 +- src/views/article/index.vue | 2 +- src/views/article/subject/index.vue | 36 +++++++++++++++++++++++++---- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/.env.production b/.env.production index 1eb24be..07d391e 100644 --- a/.env.production +++ b/.env.production @@ -2,5 +2,5 @@ ENV = 'production' # base api -VUE_APP_BASE_API = 'http://lsytest.rocpool.top/api.php' +VUE_APP_BASE_API = '/api' diff --git a/src/utils/get-img-width.js b/src/utils/get-img-width.js index 4bcf056..9f30f90 100644 --- a/src/utils/get-img-width.js +++ b/src/utils/get-img-width.js @@ -48,9 +48,18 @@ export default function (file, id) { let img = document.createElement("img"); img.src = txt; img.onload = function () { - // console.log(id, width, height); + // 限制图片上传大小 + if (parseInt(file.size / 1024) > 500) { + resolve({ validation: false, msg: `图片限制500kb以内` }); + Message({ + type: 'warning', + message: '图片限制500kb以内' + }); + return; + } + // 限制图片宽高 if (width && height) { - if (img.width === width && img.height === height) { + if ((img.width === width && img.height === height) || (img.width === width * 2 && img.height === height * 2) || (img.width === width * 3 && img.height === height * 3)) { resolve({ validation: true }) } else { Message({ @@ -58,7 +67,7 @@ export default function (file, id) { type: "warning", duration: 5000 }); - let res = { width, height, validation: false } + let res = { msg: `提示:基础宽高${width}x${height}`, validation: false } resolve(res); } } else { diff --git a/src/views/ad/index.vue b/src/views/ad/index.vue index 15e3b74..65cd14f 100644 --- a/src/views/ad/index.vue +++ b/src/views/ad/index.vue @@ -155,7 +155,7 @@ v-if="validation === false" style="padding-left: 10px; color: red" > - 提示:宽高{{ dislabelSize.width }}x{{ dislabelSize.height }} + {{ dislabelSize.msg }} diff --git a/src/views/article/index.vue b/src/views/article/index.vue index d9f0f16..f31de77 100644 --- a/src/views/article/index.vue +++ b/src/views/article/index.vue @@ -293,7 +293,7 @@ v-if="validation === false" style="padding-left: 10px; color: red" > - 提示:宽高{{ dislabelSize.width }}x{{ dislabelSize.height }} + {{ dislabelSize.msg }} diff --git a/src/views/article/subject/index.vue b/src/views/article/subject/index.vue index 87f1a29..650b6ef 100644 --- a/src/views/article/subject/index.vue +++ b/src/views/article/subject/index.vue @@ -142,6 +142,12 @@ > +
+ {{ dislabel_cover.msg }} +
@@ -163,6 +169,12 @@ > +
+ {{ dislabel_banner.msg }} +