From 8f0bd55e82d4fe143e8cb53a11c96c94a3a277da Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 9 Dec 2021 10:47:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?widget=E4=B9=9F=E6=94=AF=E6=8C=81=E5=9F=8B?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/{6.inject.js => 5.inject.js} | 99 ++++++++++++++++++++++++++- src/core/5.shortcut.js | 98 -------------------------- src/core/{7.plugin.js => plugin.js} | 0 src/core/{8.popper.js => popper.js} | 0 src/core/{9.worker.js => worker.js} | 0 webpack/attachments.js | 2 +- 6 files changed, 99 insertions(+), 100 deletions(-) rename src/core/{6.inject.js => 5.inject.js} (81%) delete mode 100644 src/core/5.shortcut.js rename src/core/{7.plugin.js => plugin.js} (100%) rename src/core/{8.popper.js => popper.js} (100%) rename src/core/{9.worker.js => worker.js} (100%) diff --git a/src/core/6.inject.js b/src/core/5.inject.js similarity index 81% rename from src/core/6.inject.js rename to src/core/5.inject.js index e86c925d8..78417079c 100644 --- a/src/core/6.inject.js +++ b/src/core/5.inject.js @@ -92,7 +92,7 @@ }; var configFunctions = {}; - var runConfigFunction = BI.runConfigFunction = function (type) { + var runConfigFunction = function (type) { if (!type || !configFunctions[type]) { return false; } @@ -371,6 +371,103 @@ } }; + var kv = {}; + BI.shortcut = BI.component = BI.shortcut || function (xtype, cls) { + if (kv[xtype] != null) { + _global.console && console.error("组件: [" + xtype + "] 已经注册过了"); + } + if (cls) { + cls["xtype"] = xtype; + } + kv[xtype] = cls; + }; + + // 根据配置属性生成widget + var createWidget = function (config, context, lazy) { + var cls = kv[config.type]; + + if (!cls) { + throw new Error("组件: [" + config.type + "] 未定义"); + } + var pushed = false; + var widget = new cls(); + widget._context = BI.Widget.context || context; + if (!BI.Widget.context && context) { + pushed = true; + BI.Widget.pushContext(context); + } + callPoint(widget, config.type); + widget._initProps(config); + widget._initRoot(); + widget._constructed(); + // if (!lazy || config.element || config.root) { + widget._lazyConstructor(); + // } + pushed && BI.Widget.popContext(); + return widget; + }; + + BI.createWidget = BI.createWidget || function (item, options, context, lazy) { + item || (item = {}); + if (BI.isWidget(options)) { + context = options; + options = {}; + } else { + options || (options = {}); + } + + var el, w; + if (item.type || options.type) { + el = BI.extend({}, options, item); + } else if (item.el && (item.el.type || options.type)) { + el = BI.extend({}, options, item.el); + } + + if (el) { + runConfigFunction(el.type); + } + + // 先把准备环境准备好 + BI.init(); + + if (BI.isEmpty(item) && BI.isEmpty(options)) { + return BI.createWidget({ + type: "bi.layout" + }); + } + if (BI.isWidget(item)) { + return item; + } + if (el) { + w = BI.Plugin.getWidget(el.type, el); + if (w.type === el.type) { + if (BI.Plugin.hasObject(el.type)) { + w.listeners = (w.listeners || []).concat([{ + eventName: BI.Events.MOUNT, + action: function () { + BI.Plugin.getObject(el.type, this); + } + }]); + } + return createWidget(w, context, lazy); + } + return BI.createWidget(w, options, context, lazy); + } + if (BI.isWidget(item.el)) { + return item.el; + } + throw new Error("组件:无法根据item创建组件", item); + }; + + BI._lazyCreateWidget = BI._lazyCreateWidget || function (item, options, context) { + return BI.createWidget(item, options, context, true); + }; + + BI.createElement = BI.createElement || function () { + var widget = BI.createWidget.apply(this, arguments); + return widget.element; + }; + BI.getResource = BI.getResource || function (type, config) { if (BI.isNotNull(constantInjection[type])) { return BI.Constants.getConstant(type); diff --git a/src/core/5.shortcut.js b/src/core/5.shortcut.js deleted file mode 100644 index 95e488214..000000000 --- a/src/core/5.shortcut.js +++ /dev/null @@ -1,98 +0,0 @@ -(function () { - var kv = {}; - BI.shortcut = BI.component = BI.shortcut || function (xtype, cls) { - if (kv[xtype] != null) { - _global.console && console.error("组件: [" + xtype + "] 已经注册过了"); - } - if (cls) { - cls["xtype"] = xtype; - } - kv[xtype] = cls; - }; - - // 根据配置属性生成widget - var createWidget = function (config, context, lazy) { - var cls = kv[config.type]; - - if (!cls) { - throw new Error("组件: [" + config.type + "] 未定义"); - } - var pushed = false; - var widget = new cls(); - widget._context = BI.Widget.context || context; - if (!BI.Widget.context && context) { - pushed = true; - BI.Widget.pushContext(context); - } - widget._initProps(config); - widget._initRoot(); - widget._constructed(); - // if (!lazy || config.element || config.root) { - widget._lazyConstructor(); - // } - pushed && BI.Widget.popContext(); - return widget; - }; - - BI.createWidget = BI.createWidget || function (item, options, context, lazy) { - item || (item = {}); - if (BI.isWidget(options)) { - context = options; - options = {}; - } else { - options || (options = {}); - } - - var el, w; - if (item.type || options.type) { - el = BI.extend({}, options, item); - } else if (item.el && (item.el.type || options.type)) { - el = BI.extend({}, options, item.el); - } - - if (el) { - BI.runConfigFunction(el.type); - } - - // 先把准备环境准备好 - BI.init(); - - if (BI.isEmpty(item) && BI.isEmpty(options)) { - return BI.createWidget({ - type: "bi.layout" - }); - } - if (BI.isWidget(item)) { - return item; - } - if (el) { - w = BI.Plugin.getWidget(el.type, el); - if (w.type === el.type) { - if (BI.Plugin.hasObject(el.type)) { - w.listeners = (w.listeners || []).concat([{ - eventName: BI.Events.MOUNT, - action: function () { - BI.Plugin.getObject(el.type, this); - } - }]); - } - return createWidget(w, context, lazy); - } - return BI.createWidget(w, options, context, lazy); - } - if (BI.isWidget(item.el)) { - return item.el; - } - throw new Error("组件:无法根据item创建组件", item); - }; - - BI._lazyCreateWidget = BI._lazyCreateWidget || function (item, options, context) { - return BI.createWidget(item, options, context, true); - }; - - BI.createElement = BI.createElement || function () { - var widget = BI.createWidget.apply(this, arguments); - return widget.element; - }; - -})(); diff --git a/src/core/7.plugin.js b/src/core/plugin.js similarity index 100% rename from src/core/7.plugin.js rename to src/core/plugin.js diff --git a/src/core/8.popper.js b/src/core/popper.js similarity index 100% rename from src/core/8.popper.js rename to src/core/popper.js diff --git a/src/core/9.worker.js b/src/core/worker.js similarity index 100% rename from src/core/9.worker.js rename to src/core/worker.js diff --git a/webpack/attachments.js b/webpack/attachments.js index b463f5ee9..a4328bd29 100644 --- a/webpack/attachments.js +++ b/webpack/attachments.js @@ -60,7 +60,7 @@ const basicAttachmentMap = { "src/core/func/**/*.js", "src/core/2.base.js", "src/core/3.ob.js", - "src/core/6.inject.js", + "src/core/5.inject.js", "src/core/utils/*.js", "i18n/i18n.cn.js", "_mobile/date.i18n.cn.js", From a790d17b84e250025463ae26d7b71e62896a9a52 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 9 Dec 2021 10:49:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?widget=E4=B9=9F=E6=94=AF=E6=8C=81=E5=9F=8B?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 78c07f643..043dae7b7 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2021-12) +- BI.point支持widget添加埋点 - childContext废弃,替换成provide - 支持BI.useContext获取上下文环境 - BI.Msg.alert支持message传json格式 From 49c0953a7420dd58e83e646d85b6a7e66e78a9cd Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 9 Dec 2021 11:48:54 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=AF=B9=E4=BA=8E?= =?UTF-8?q?=E9=9D=9Ediv=E3=80=81input=E3=80=81a=E7=AD=89=E5=85=83=E7=B4=A0?= =?UTF-8?q?=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/less/core/normalize2.less | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/less/core/normalize2.less b/src/less/core/normalize2.less index cb936708d..11c876b5c 100644 --- a/src/less/core/normalize2.less +++ b/src/less/core/normalize2.less @@ -1,20 +1,5 @@ @import "../index"; -html, -body, -div, -ul, -ol, -li, -img, -a, -span, -p, -* { - margin: 0; - padding: 0; -} - a { outline: none; text-decoration: none; @@ -48,14 +33,6 @@ textarea { outline: none; } -ul { - list-style: disc; -} - -li { - list-style-type: none; -} - i { //font-style: normal; -webkit-font-smoothing: antialiased;