From b107f1d4a445adebd8905251971d8bb93a67d640 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Wed, 30 Jun 2021 16:51:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BE=9Bprovider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/system.js | 51 +++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/src/core/system.js b/src/core/system.js index e4c079c71..38123233b 100644 --- a/src/core/system.js +++ b/src/core/system.js @@ -3,23 +3,42 @@ * @version 2.0 * Created by windy on 2021/6/30 */ -_.extend(BI, { - switchSystemParam: function(opt) { - BI.config('bi.constant.system', function (ob) { - return BI.deepExtend(ob, opt); - }); - }, -}); - // 系统参数常量 -BI.constant('bi.constant.system', { - size: { // 尺寸 - TOOL_BAR_HEIGHT: 24, - LIST_ITEM_HEIGHT: 24, - TRIGGER_HEIGHT: 24, - }, -}); +!(function () { + var system = { + SIZE: { // 尺寸 + TOOL_BAR_HEIGHT: 24, + LIST_ITEM_HEIGHT: 24, + TRIGGER_HEIGHT: 24, + }, + }; + + var provider = function () { + this.inject = function (type, config) { + BI.deepExtend(system[type], config); + }; + + this.$get = function () { + return BI.inherit(BI.OB, { + + getConfig: function (type) { + return system[type]; + }, + }); + }; + }; + + BI.provider("bi.provider.system", provider); +})(); BI.prepares.push(function () { - BI.SIZE_CONSANTS = BI.Constants.getConstant('bi.constant.system').size; + BI.SIZE_CONSANTS = BI.Providers.getProvider('bi.provider.system').getConfig('SIZE'); +}); + +BI.config('bi.provider.system', function (provider) { + provider.inject('SIZE', { + TOOL_BAR_HEIGHT: 30, + LIST_ITEM_HEIGHT: 30, + TRIGGER_HEIGHT: 30, + }) });