From 7fffba896323ee509183d0596fc6560be95a6f85 Mon Sep 17 00:00:00 2001 From: Karson Date: Wed, 30 Aug 2023 16:27:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A1=A8=E6=A0=BC=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=9B=BE=E7=89=87=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/js/require-table.js | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/public/assets/js/require-table.js b/public/assets/js/require-table.js index 7ee994d1..879d5b80 100644 --- a/public/assets/js/require-table.js +++ b/public/assets/js/require-table.js @@ -726,40 +726,30 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table return ' ' + value; }, image: function (value, row, index) { - value = value == null || value.length === 0 ? '' : value.toString(); - value = value ? value : '/assets/img/blank.gif'; - var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center'; - var url = Fast.api.cdnurl(value, true); - url = url.match(/^(\/|data:image\\)/) ? url : url + Config.upload.thumbstyle; - return ''; + return Table.api.formatter.images.call(this, value, row, index); }, images: function (value, row, index) { value = value == null || value.length === 0 ? '' : value.toString(); var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center'; - var arr = value != '' ? value.split(',') : []; + var arr = value !== '' ? (value.indexOf('data:image/') === -1 ? value.split(',') : [value]) : []; var html = []; var url; $.each(arr, function (i, value) { value = value ? value : '/assets/img/blank.gif'; url = Fast.api.cdnurl(value, true); - url = url.match(/^(\/|data:image\\)/) ? url : url + Config.upload.thumbstyle; + //匹配本地、data:image、或已包含标识符首字符 + url = !Config.upload.thumbstyle || url.match(/^(\/|data:image\/)/) || url.indexOf(Config.upload.thumbstyle.substring(0, 1)) > -1 ? url : url + Config.upload.thumbstyle; html.push(''); }); return html.join(' '); }, file: function (value, row, index) { - value = value == null || value.length === 0 ? '' : value.toString(); - value = Fast.api.cdnurl(value, true); - var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center'; - var suffix = /[\.]?([a-zA-Z0-9]+)$/.exec(value); - suffix = suffix ? suffix[1] : 'file'; - var url = Fast.api.fixurl("ajax/icon?suffix=" + suffix); - return ''; + Table.api.formatter.files.call(this, value, row, index); }, files: function (value, row, index) { value = value == null || value.length === 0 ? '' : value.toString(); var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center'; - var arr = value != '' ? value.split(',') : []; + var arr = value !== '' ? (value.indexOf('data:image/') === -1 ? value.split(',') : [value]) : []; var html = []; var suffix, url; $.each(arr, function (i, value) {