From b2abf387d524fa5cd84669b1d7cb6928d116fe70 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 13 May 2022 12:56:13 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E5=B8=83=E5=B1=80=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=86=99=E6=B3=95=EF=BC=8C=E6=8F=90=E4=BE=9B=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/system.js | 11 ++++++++++- src/core/wrapper/layout.js | 20 +++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/core/system.js b/src/core/system.js index 123bd88be..652a9c256 100644 --- a/src/core/system.js +++ b/src/core/system.js @@ -7,6 +7,7 @@ !(function () { var system = { dependencies: {}, + layoutOptimize: false, responsiveMode: false, workerMode: false, size: { @@ -24,7 +25,7 @@ // 具体尺寸还没定,先写着 var sizeMap = { "S": 10, - "M" : 20, + "M": 20, "L": 24 }; @@ -44,6 +45,10 @@ system.workerMode = !!mode; }; + this.setLayoutOptimize = function (layoutOptimize) { + system.layoutOptimize = layoutOptimize; + }; + this.addDependency = function (moduleId, minVersion, maxVersion) { system.dependencies[moduleId] = { min: minVersion, @@ -77,6 +82,10 @@ return system.workerMode; }, + getLayoutOptimize: function () { + return system.layoutOptimize; + }, + getDependencies: function () { return system.dependencies; } diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index a79b3775b..28dadbd08 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -16,7 +16,7 @@ BI.Layout = BI.inherit(BI.Widget, { scrolly: false, // true, false items: [], innerHgap: 0, - innerVgap: 0, + innerVgap: 0 }; }, @@ -293,21 +293,39 @@ BI.Layout = BI.inherit(BI.Widget, { }, _optimiseItemLgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? item.lgap : item._lgap) || 0; + } return item.lgap || 0; }, _optimiseItemRgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? item.rgap : item._rgap) || 0; + } return item.rgap || 0; }, _optimiseItemTgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? item.tgap : item._tgap) || 0; + } return item.tgap || 0; }, _optimiseItemBgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? item.bgap : item._bgap) || 0; + } return item.bgap || 0; }, _optimiseItemHgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? item.hgap : item._hgap) || 0; + } return item.hgap || 0; }, _optimiseItemVgap: function (item) { + if (BI.Providers.getProvider("bi.provider.system").getLayoutOptimize()) { + return ((!item.type && item.el) ? item.vgap : item._vgap) || 0; + } return item.vgap || 0; },