From f2a57ad40311bd5ffc6c316106cb0885e8ead4fe Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 22 Jun 2022 14:49:26 +0800 Subject: [PATCH 01/14] =?UTF-8?q?feature:=20=E9=80=89=E4=B8=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselect/multiselect.loader.js | 45 ++++++++++++------- .../multiselect/multiselect.loader.nobar.js | 41 ++++++++++------- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/src/widget/multiselect/multiselect.loader.js b/src/widget/multiselect/multiselect.loader.js index f01ac18bc..6ab276164 100644 --- a/src/widget/multiselect/multiselect.loader.js +++ b/src/widget/multiselect/multiselect.loader.js @@ -18,7 +18,7 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { valueFormatter: BI.emptyFn, itemsCreator: BI.emptyFn, onLoaded: BI.emptyFn, - itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, + itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT }); }, @@ -64,23 +64,22 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { }, opts.el), itemsCreator: function (op, callback) { var startValue = self._startValue; + var firstItems = []; self.storeValue && (op = BI.extend(op || {}, { selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi ? self.storeValue.value.concat(startValue) : self.storeValue.value })); - opts.itemsCreator(op, function (ob) { - hasNext = ob.hasNext; - var firstItems = []; - if (op.times === 1 && self.storeValue) { - var json = BI.map(self.storeValue.value, function (i, v) { - var txt = opts.valueFormatter(v) || v; - return { - text: txt, - value: v, - title: txt, - selected: self.storeValue.type === BI.Selection.Multi - }; - }); + if (self.storeValue) { + var json = BI.map(self.storeValue.value.slice((op.times - 1) * 10, op.times * 10), function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt, + selected: self.storeValue.type === BI.Selection.Multi + }; + }); + if (op.times === 1) { if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { var txt = opts.valueFormatter(startValue) || startValue; json.unshift({ @@ -90,10 +89,22 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { selected: true }); } - firstItems = self._createItems(json); } + if (op.times < Math.floor((self.storeValue.value.length - 1) / 10)) { + hasNext = true; + callback(self._createItems(json), op.keyword || ""); + (op.times === 1) && self._scrollToTop(); + return; + } + firstItems = self._createItems(json); + } + var times = op.times - Math.max(0, Math.floor((self.storeValue.value.length - 1) / 10)); + opts.itemsCreator(BI.extend({}, op, { + times: times + }), function (ob) { + hasNext = ob.hasNext; callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); - if (op.times === 1 && self.storeValue) { + if (times === 1 && self.storeValue) { BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); self.setValue(self.storeValue); } @@ -190,4 +201,4 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { }); BI.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multi_select_loader", BI.MultiSelectLoader); \ No newline at end of file +BI.shortcut("bi.multi_select_loader", BI.MultiSelectLoader); diff --git a/src/widget/multiselect/multiselect.loader.nobar.js b/src/widget/multiselect/multiselect.loader.nobar.js index d7744d042..5bcb02551 100644 --- a/src/widget/multiselect/multiselect.loader.nobar.js +++ b/src/widget/multiselect/multiselect.loader.nobar.js @@ -55,23 +55,22 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { }, itemsCreator: function (op, callback) { var startValue = self._startValue; + var firstItems = []; self.storeValue && (op = BI.extend(op || {}, { selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi ? self.storeValue.value.concat(startValue) : self.storeValue.value })); - opts.itemsCreator(op, function (ob) { - hasNext = ob.hasNext; - var firstItems = []; - if (op.times === 1 && self.storeValue) { - var json = BI.map(self.storeValue.value, function (i, v) { - var txt = opts.valueFormatter(v) || v; - return { - text: txt, - value: v, - title: txt, - selected: self.storeValue.type === BI.Selection.Multi - }; - }); + if (self.storeValue) { + var json = BI.map(self.storeValue.value.slice((op.times - 1) * 100, op.times * 100), function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt, + selected: self.storeValue.type === BI.Selection.Multi + }; + }); + if (op.times === 1) { if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { var txt = opts.valueFormatter(startValue) || startValue; json.unshift({ @@ -81,10 +80,22 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { selected: true }); } - firstItems = self._createItems(json); } + if (op.times < Math.floor((self.storeValue.value.length - 1) / 100)) { + hasNext = true; + callback(self._createItems(json), op.keyword || ""); + (op.times === 1) && self._scrollToTop(); + return; + } + firstItems = self._createItems(json); + } + var times = op.times - Math.max(0, Math.floor((self.storeValue.value.length - 1) / 100)); + opts.itemsCreator(BI.extend({}, op, { + times: times + }), function (ob) { + hasNext = ob.hasNext; callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); - if (op.times === 1 && self.storeValue) { + if (times === 1 && self.storeValue) { BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); self.setValue(self.storeValue); } From f15b0f1156259e85769008f01cb5d69ae8273dd2 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 22 Jun 2022 14:50:32 +0800 Subject: [PATCH 02/14] =?UTF-8?q?feature:=20=E9=80=89=E4=B8=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselect/multiselect.loader.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widget/multiselect/multiselect.loader.js b/src/widget/multiselect/multiselect.loader.js index 6ab276164..e7e3b2113 100644 --- a/src/widget/multiselect/multiselect.loader.js +++ b/src/widget/multiselect/multiselect.loader.js @@ -70,7 +70,7 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { ? self.storeValue.value.concat(startValue) : self.storeValue.value })); if (self.storeValue) { - var json = BI.map(self.storeValue.value.slice((op.times - 1) * 10, op.times * 10), function (i, v) { + var json = BI.map(self.storeValue.value.slice((op.times - 1) * 100, op.times * 100), function (i, v) { var txt = opts.valueFormatter(v) || v; return { text: txt, @@ -90,7 +90,7 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { }); } } - if (op.times < Math.floor((self.storeValue.value.length - 1) / 10)) { + if (op.times < Math.floor((self.storeValue.value.length - 1) / 100)) { hasNext = true; callback(self._createItems(json), op.keyword || ""); (op.times === 1) && self._scrollToTop(); @@ -98,7 +98,7 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { } firstItems = self._createItems(json); } - var times = op.times - Math.max(0, Math.floor((self.storeValue.value.length - 1) / 10)); + var times = op.times - Math.max(0, Math.floor((self.storeValue.value.length - 1) / 100)); opts.itemsCreator(BI.extend({}, op, { times: times }), function (ob) { From f32bd9861253ee0cae3f6dd58ab9b9dd3dc6ab7f Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 22 Jun 2022 14:54:59 +0800 Subject: [PATCH 03/14] =?UTF-8?q?feature:=20=E9=80=89=E4=B8=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselect/multiselect.loader.js | 2 +- src/widget/multiselect/multiselect.loader.nobar.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widget/multiselect/multiselect.loader.js b/src/widget/multiselect/multiselect.loader.js index e7e3b2113..0b86f44d4 100644 --- a/src/widget/multiselect/multiselect.loader.js +++ b/src/widget/multiselect/multiselect.loader.js @@ -103,7 +103,7 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { times: times }), function (ob) { hasNext = ob.hasNext; - callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); + callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || op.keyword || ""); if (times === 1 && self.storeValue) { BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); self.setValue(self.storeValue); diff --git a/src/widget/multiselect/multiselect.loader.nobar.js b/src/widget/multiselect/multiselect.loader.nobar.js index 5bcb02551..95c8f6fbc 100644 --- a/src/widget/multiselect/multiselect.loader.nobar.js +++ b/src/widget/multiselect/multiselect.loader.nobar.js @@ -94,7 +94,7 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { times: times }), function (ob) { hasNext = ob.hasNext; - callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); + callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || op.keyword || ""); if (times === 1 && self.storeValue) { BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); self.setValue(self.storeValue); From 3ac0b7d2077356a569e08ca51933b15418785805 Mon Sep 17 00:00:00 2001 From: "Zhenfei.Li" Date: Wed, 22 Jun 2022 19:58:05 +0800 Subject: [PATCH 04/14] =?UTF-8?q?KERNEL-11634=20refactor:=20npm=E5=BC=95?= =?UTF-8?q?=E5=85=A5=E7=9A=84fineui=E4=B8=8D=E8=AF=A5=E6=9C=89window.$?= =?UTF-8?q?=E5=92=8Cwindow.=5F=EF=BC=8C=E9=81=BF=E5=85=8D=E5=86=B2?= =?UTF-8?q?=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/fix/fix.compact.js | 4 +- dist/fix/fix.js | 126 +++++++++++------------ dist/fix/fix.proxy.js | 131 ++++++++++++------------ package.json | 2 +- src/core/1.lodash.js | 4 +- src/core/2.base.js | 72 ++++++------- src/core/3.ob.js | 16 +-- src/core/conflict.js | 7 ++ src/core/constant/events.js | 2 +- src/core/constant/var.js | 2 +- src/core/func/alias.js | 4 +- src/core/func/array.js | 2 +- src/core/func/date.js | 2 +- src/core/func/function.js | 4 +- src/core/func/number.js | 2 +- src/core/func/string.js | 4 +- src/core/platform/web/function.js | 2 +- src/core/platform/web/jquery/_jquery.js | 4 - src/core/platform/web/load.js | 2 +- src/core/plugin.js | 4 +- src/core/structure/aes.js | 2 +- src/core/structure/base64.js | 2 +- src/core/utils/chinesePY.js | 2 +- src/core/utils/i18n.js | 2 +- src/core/wrapper/layout.js | 6 +- src/router/0.router.js | 32 +++--- test/utils.js | 2 +- webpack/attachments.js | 25 +++++ webpack/webpack.prod.js | 1 + 29 files changed, 248 insertions(+), 222 deletions(-) create mode 100644 src/core/conflict.js diff --git a/dist/fix/fix.compact.js b/dist/fix/fix.compact.js index b8e49eb28..df02143b6 100644 --- a/dist/fix/fix.compact.js +++ b/dist/fix/fix.compact.js @@ -38,7 +38,7 @@ cb = cb.handler; } options = options || {}; - return Fix.watch(vm.model, keyOrFn, _.bind(cb, vm), BI.extend(options, { + return Fix.watch(vm.model, keyOrFn, BI._.bind(cb, vm), BI.extend(options, { store: vm.store })); } @@ -177,7 +177,7 @@ delete this.__cacheStore; }; - _.each(["_render", "__afterRender", "_mount", "__afterMount"], function (name) { + BI._.each(["_render", "__afterRender", "_mount", "__afterMount"], function (name) { var old = BI.Widget.prototype[name]; old && (BI.Widget.prototype[name] = function () { this.store && pushTarget(this.store); diff --git a/dist/fix/fix.js b/dist/fix/fix.js index 52a6a7907..9a106ae7a 100644 --- a/dist/fix/fix.js +++ b/dist/fix/fix.js @@ -96,8 +96,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons setImmediate(nextTickHandler); }; } else if (typeof MessageChannel !== 'undefined' && (isNative(MessageChannel) || - // PhantomJS - MessageChannel.toString() === '[object MessageChannelConstructor]')) { + // PhantomJS + MessageChannel.toString() === '[object MessageChannelConstructor]')) { var channel = new MessageChannel(); var port = channel.port2; channel.port1.onmessage = nextTickHandler; @@ -106,18 +106,18 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons }; } else /* istanbul ignore next */ - if (typeof Promise !== 'undefined' && isNative(Promise)) { - // use microtask in non-DOM environments, e.g. Weex - var p = Promise.resolve(); - timerFunc = function timerFunc() { - p.then(nextTickHandler); - }; - } else { - // fallback to setTimeout - timerFunc = function timerFunc() { - setTimeout(nextTickHandler, 0); - }; - } + if (typeof Promise !== 'undefined' && isNative(Promise)) { + // use microtask in non-DOM environments, e.g. Weex + var p = Promise.resolve(); + timerFunc = function timerFunc() { + p.then(nextTickHandler); + }; + } else { + // fallback to setTimeout + timerFunc = function timerFunc() { + setTimeout(nextTickHandler, 0); + }; + } return function queueNextTick(cb, ctx) { var _resolve = void 0; @@ -428,10 +428,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons if (this.active) { var value = this.get(); if (value !== this.value || - // Deep watchers and watchers on Object/Arrays should fire even - // when the value is the same, because the value may - // have mutated. - _.isObject(value) && options && options.refresh || this.deep) { + // Deep watchers and watchers on Object/Arrays should fire even + // when the value is the same, because the value may + // have mutated. + BI._.isObject(value) && options && options.refresh || this.deep) { // set new value var oldValue = this.value; this.value = value; @@ -491,8 +491,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons function _traverse(val, seen) { var i = void 0, keys = void 0; - var isA = _.isArray(val); - if (!isA && !_.isObject(val)) { + var isA = BI._.isArray(val); + if (!isA && !BI._.isObject(val)) { return; } if (val.__ob__) { @@ -508,7 +508,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons _traverse(val[i], seen); } } else { - keys = _.keys(val); + keys = BI._.keys(val); i = keys.length; while (i--) { _traverse(val[keys[i]], seen); @@ -518,7 +518,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var arrayProto = Array.prototype; var arrayMethods = []; - _.each(['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse'], function (method) { + BI._.each(['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse'], function (method) { var original = arrayProto[method]; arrayMethods[method] = function mutator() { for (var _len = arguments.length, args = Array(_len), _key2 = 0; _key2 < _len; _key2++) { @@ -554,7 +554,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons }; }); - var arrayKeys = _.keys(arrayMethods); + var arrayKeys = BI._.keys(arrayMethods); var observerState = { shouldConvert: true @@ -583,7 +583,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons this.value = value; this.dep = new Dep(); this.vmCount = 0; - if (_.isArray(value)) { + if (BI._.isArray(value)) { var augment = hasProto ? protoAugment : copyAugment; augment(value, arrayMethods, arrayKeys); this.model = this.observeArray(value); @@ -623,13 +623,13 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons } function observe(value, parentObserver, parentKey) { - if (!_.isObject(value)) { + if (!BI._.isObject(value)) { return; } var ob = void 0; if (value.__ob__ instanceof Observer) { ob = value.__ob__; - } else if (observerState.shouldConvert && isExtensible(value) && (_.isArray(value) || isPlainObject(value))) { + } else if (observerState.shouldConvert && isExtensible(value) && (BI._.isArray(value) || isPlainObject(value))) { ob = new Observer(value); } if (ob) { @@ -643,7 +643,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons dep.notify({ observer: observer, key: key, refresh: refresh }); if (observer) { //触发a.*绑定的依赖 - _.each(observer._deps, function (dep) { + BI._.each(observer._deps, function (dep) { dep.notify({ observer: observer, key: key }); }); //触发a.**绑定的依赖 @@ -651,7 +651,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons root = observer, route = key || ""; while (parent) { - _.each(parent._scopeDeps, function (dep) { + BI._.each(parent._scopeDeps, function (dep) { dep.notify({ observer: observer, key: key }); }); if (parent.parentKey != null) { @@ -674,7 +674,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons function defineReactive(obj, observer, shallow) { var props = {}; var model = void 0; - _.each(obj, function (val, key) { + BI._.each(obj, function (val, key) { if (key in $$skipArray) { return; } @@ -691,7 +691,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons dep.depend(); if (childOb) { childOb.dep.depend(); - if (_.isArray(value)) { + if (BI._.isArray(value)) { dependArray(value); } } @@ -740,7 +740,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons dep.depend(); if (childOb) { childOb.dep.depend(); - if (_.isArray(value)) { + if (BI._.isArray(value)) { dependArray(value); } } @@ -767,12 +767,12 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons * already exist. */ function set(target, key, val) { - if (_.isArray(target)) { + if (BI._.isArray(target)) { target.length = Math.max(target.length, key); target.splice(key, 1, val); return val; } - if (_.has(target, key)) { + if (BI._.has(target, key)) { target[key] = val; return val; } @@ -795,12 +795,12 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons * Delete a property and trigger change if necessary. */ function del(target, key) { - if (_.isArray(target)) { + if (BI._.isArray(target)) { target.splice(key, 1); return; } var ob = target.__ob__; - if (!_.has(target, key)) { + if (!BI._.has(target, key)) { return; } if (!ob) { @@ -821,7 +821,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons for (var e, i = 0, l = value.length; i < l; i++) { e = value[i]; e && e.__ob__ && e.__ob__.dep.depend(); - if (_.isArray(e)) { + if (BI._.isArray(e)) { dependArray(e); } } @@ -838,7 +838,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons function runBinaryFunction(binarys) { var expr = ''; for (var i = 0, len = binarys.length; i < len; i++) { - if (_.isBoolean(binarys[i]) || _.has(operators, binarys[i])) { + if (BI._.isBoolean(binarys[i]) || BI._.has(operators, binarys[i])) { expr += binarys[i]; } else { expr += 'false'; @@ -863,7 +863,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons options = options || {}; options.user = true; var exps = void 0; - if (_.isFunction(expOrFn) || !(exps = expOrFn.match(/[a-zA-Z0-9_.*]+|[|][|]|[&][&]|[(]|[)]/g)) || exps.length === 1 && expOrFn.indexOf("*") < 0) { + if (BI._.isFunction(expOrFn) || !(exps = expOrFn.match(/[a-zA-Z0-9BI._.*]+|[|][|]|[&][&]|[(]|[)]/g)) || exps.length === 1 && expOrFn.indexOf("*") < 0) { var watcher = new Watcher(model, expOrFn, cb, options); if (options.immediate) { cb(watcher.value); @@ -900,8 +900,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons } } }; - _.each(exps, function (exp, i) { - if (_.has(operators, exp)) { + BI._.each(exps, function (exp, i) { + if (BI._.has(operators, exp)) { return; } if (exp.indexOf("*") >= 0) { @@ -929,7 +929,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons _dep.depend(); return NaN; }, function (newValue, oldValue, attrs) { - callback(i, newValue, oldValue, _.extend({ index: i }, attrs)); + callback(i, newValue, oldValue, BI._.extend({ index: i }, attrs)); }, options); watchers.push(function unwatchFn() { _w.teardown(); @@ -955,7 +955,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var _regStr = routeToRegExp(exp); var _dep2 = new Dep(); _root._globalDeps || (_root._globalDeps = {}); - if (_.isArray(_root._globalDeps[_regStr])) { + if (BI._.isArray(_root._globalDeps[_regStr])) { _root._globalDeps[_regStr].push(_dep2); } else { _root._globalDeps[_regStr] = [_dep2]; @@ -965,7 +965,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons _dep2.depend(); return NaN; }, function (newValue, oldValue, attrs) { - callback(i, newValue, oldValue, _.extend({ index: i }, attrs)); + callback(i, newValue, oldValue, BI._.extend({ index: i }, attrs)); }, options); watchers.push(function unwatchFn() { if (_root._globalDeps) { @@ -1005,7 +1005,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var regStr = routeToRegExp(exp); var dep = new Dep(); root._globalDeps || (root._globalDeps = {}); - if (_.isArray(root._globalDeps[regStr])) { + if (BI._.isArray(root._globalDeps[regStr])) { root._globalDeps[regStr].push(dep); } else { root._globalDeps[regStr] = [dep]; @@ -1015,7 +1015,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons dep.depend(); return NaN; }, function (newValue, oldValue, attrs) { - callback(i, newValue, oldValue, _.extend({ index: i }, attrs)); + callback(i, newValue, oldValue, BI._.extend({ index: i }, attrs)); }, options); watchers.push(function unwatchFn() { if (root._globalDeps) { @@ -1029,7 +1029,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons return; } var watcher = new Watcher(model, exp, function (newValue, oldValue, attrs) { - callback(i, newValue, oldValue, _.extend({ index: i }, attrs)); + callback(i, newValue, oldValue, BI._.extend({ index: i }, attrs)); }, options); watchers.push(function unwatchFn() { watcher.teardown(); @@ -1045,7 +1045,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons } function mixin(xtype, cls) { - mixinInjection[xtype] = _.cloneDeep(cls); + mixinInjection[xtype] = BI._.cloneDeep(cls); } var computedWatcherOptions = { lazy: true }; @@ -1119,7 +1119,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons vm._watchers || (vm._watchers = []); for (var key in watch$$1) { var handler = watch$$1[key]; - if (_.isArray(handler)) { + if (BI._.isArray(handler)) { for (var i = 0; i < handler.length; i++) { vm._watchers.push(createWatcher(vm, key, handler[i])); } @@ -1137,27 +1137,27 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons if (typeof cb === 'string') { cb = vm[cb]; } - return watch(vm.model, keyOrFn, _.bind(cb, vm.$$model ? vm.model : vm), options); + return watch(vm.model, keyOrFn, BI._.bind(cb, vm.$$model ? vm.model : vm), options); } function initMethods(vm, methods) { for (var key in methods) { - vm[key] = methods[key] == null ? noop : _.bind(methods[key], vm.$$model ? vm.model : vm); + vm[key] = methods[key] == null ? noop : BI._.bind(methods[key], vm.$$model ? vm.model : vm); } } function initMixins(vm, mixins) { mixins = (mixins || []).slice(0); - _.each(mixins.reverse(), function (mixinType) { + BI._.each(mixins.reverse(), function (mixinType) { var mixin$$1 = getMixins(mixinType); for (var key in mixin$$1) { if (typeof mixin$$1[key] !== "function") continue; - if (_.has(vm, key)) continue; + if (BI._.has(vm, key)) continue; - vm[key] = _.bind(mixin$$1[key], vm.$$model ? vm.model : vm); + vm[key] = BI._.bind(mixin$$1[key], vm.$$model ? vm.model : vm); } }); } @@ -1282,7 +1282,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons function getInjectValues(vm) { var inject = vm.inject || []; var result = {}; - _.each(inject, function (key) { + BI._.each(inject, function (key) { result[key] = getInjectValue(vm, key); }); return result; @@ -1303,7 +1303,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons this.options = model || {}; } this._parent = Model.target; - var state = _.isFunction(this.state) ? this.state() : this.state; + var state = BI._.isFunction(this.state) ? this.state() : this.state; var computed = this.computed; var context = this.context; var inject = this.inject; @@ -1311,7 +1311,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var provide = this.provide; var watch$$1 = this.watch; var actions = this.actions; - var keys = _.keys(this.$$model).concat(_.keys(state)).concat(_.keys(computed)).concat(inject || []).concat(context || []); + var keys = BI._.keys(this.$$model).concat(BI._.keys(state)).concat(BI._.keys(computed)).concat(inject || []).concat(context || []); var mixins = this.mixins; defineProps(this, keys); // deprecated @@ -1320,7 +1320,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons this.$$model && (this.model.__ob__ = this.$$model.__ob__); initMixins(this, mixins); this.init(); - initState(this, _.extend(getInjectValues(this), state)); + initState(this, BI._.extend(getInjectValues(this), state)); initComputed(this, computed); REACTIVE && initWatch(this, watch$$1); initMethods(this, actions); @@ -1341,9 +1341,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons for (var _key3 in this._computedWatchers) { this._computedWatchers[_key3].teardown(); } - _.each(this._watchers, function (unwatches) { - unwatches = _.isArray(unwatches) ? unwatches : [unwatches]; - _.each(unwatches, function (unwatch) { + BI._.each(this._watchers, function (unwatches) { + unwatches = BI._.isArray(unwatches) ? unwatches : [unwatches]; + BI._.each(unwatches, function (unwatch) { unwatch(); }); }); @@ -1373,7 +1373,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons function toJSON(model) { var result = void 0; - if (_.isArray(model)) { + if (BI._.isArray(model)) { result = []; for (var i = 0, len = model.length; i < len; i++) { result[i] = toJSON(model[i]); @@ -1381,7 +1381,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons } else if (model && isPlainObject(model)) { result = {}; for (var _key4 in model) { - if (!_.has($$skipArray, _key4)) { + if (!BI._.has($$skipArray, _key4)) { result[_key4] = toJSON(model[_key4]); } } @@ -1416,4 +1416,4 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons exports.toJSON = toJSON; exports.__esModule = true; -}); +}); \ No newline at end of file diff --git a/dist/fix/fix.proxy.js b/dist/fix/fix.proxy.js index 19eca6178..4a709fb3c 100644 --- a/dist/fix/fix.proxy.js +++ b/dist/fix/fix.proxy.js @@ -2,22 +2,16 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Fix = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; function _typeof(obj) { "@babel/helpers - typeof"; - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof = function (obj) { - return typeof obj; - }; - } else { - _typeof = function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - } - - return _typeof(obj); + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }, _typeof(obj); } function _classCallCheck(instance, Constructor) { @@ -39,6 +33,9 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); + Object.defineProperty(Constructor, "prototype", { + writable: false + }); return Constructor; } @@ -542,10 +539,10 @@ if (type === "clear" /* CLEAR */ ) { - // collection being cleared - // trigger all effects for target - deps = _toConsumableArray(depsMap.values()); - } else if (key === 'length' && isArray(target)) { + // collection being cleared + // trigger all effects for target + deps = _toConsumableArray(depsMap.values()); + } else if (key === 'length' && isArray(target)) { depsMap.forEach(function (dep, key) { if (key === 'length' || key >= newValue) { deps.push(dep); @@ -728,12 +725,12 @@ if (key === "__v_isReactive" /* IS_REACTIVE */ ) { - return !isReadonly; - } else if (key === "__v_isReadonly" + return !isReadonly; + } else if (key === "__v_isReadonly" /* IS_READONLY */ ) { - return isReadonly; - } else if (key === "__v_raw" + return isReadonly; + } else if (key === "__v_raw" /* RAW */ && receiver === (isReadonly ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) { return target; @@ -1217,16 +1214,16 @@ if (key === "__v_isReactive" /* IS_REACTIVE */ ) { - return !isReadonly; - } else if (key === "__v_isReadonly" + return !isReadonly; + } else if (key === "__v_isReadonly" /* IS_READONLY */ ) { - return isReadonly; - } else if (key === "__v_raw" + return isReadonly; + } else if (key === "__v_raw" /* RAW */ ) { - return target; - } + return target; + } return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver); }; @@ -1335,8 +1332,8 @@ if (targetType === 0 /* INVALID */ ) { - return target; - } + return target; + } var proxy = new Proxy(target, targetType === 2 /* COLLECTION */ @@ -1631,7 +1628,7 @@ return mixinInjection[type]; } function mixin(xtype, cls) { - mixinInjection[xtype] = _.cloneDeep(cls); + mixinInjection[xtype] = BI._.cloneDeep(cls); } var queue = []; @@ -1710,7 +1707,7 @@ } function innerWatch(source, cb, options) { - if (!_.isFunction(cb)) { + if (!BI._.isFunction(cb)) { console.warn("`watch(fn, options?)` signature has been moved to a separate API. " + "Use `watchEffect(fn, options?)` instead. `watch` now only " + "supports `watch(source, cb, options?) signature."); } @@ -1775,21 +1772,21 @@ }; deep = true; - } else if (_.isArray(source)) { + } else if (BI._.isArray(source)) { getter = function getter() { return source.map(function (s) { if (isRef(s)) { return s.value; } else if (isReactive(s)) { return traverse(s); - } else if (_.isFunction(s)) { + } else if (BI._.isFunction(s)) { return s.call(instance); } else { warnInvalidSource(s); } }); }; - } else if (_.isFunction(source)) { + } else if (BI._.isFunction(source)) { if (cb) { // getter with cb getter = function getter() { @@ -1831,7 +1828,7 @@ }; }; - var oldValue = _.isArray(source) ? [] : INITIAL_WATCHER_VALUE; + var oldValue = BI._.isArray(source) ? [] : INITIAL_WATCHER_VALUE; var job = function job() { // 这里去掉的原因是,新增属性没有生效也会触发变化监听 @@ -1903,7 +1900,7 @@ function traverse(value) { var seen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set(); - if (!_.isObject(value) || seen.has(value)) { + if (!BI._.isObject(value) || seen.has(value)) { return value; } @@ -1911,7 +1908,7 @@ if (isRef(value)) { traverse(value.value, seen); - } else if (_.isArray(value)) { + } else if (BI._.isArray(value)) { for (var i = 0; i < value.length; i++) { traverse(value[i], seen); } @@ -1940,7 +1937,7 @@ var expr = ""; for (var i = 0, len = binarys.length; i < len; i++) { - if (_.isBoolean(binarys[i]) || _.has(operators, binarys[i])) { + if (BI._.isBoolean(binarys[i]) || BI._.has(operators, binarys[i])) { expr += binarys[i]; } else { expr += "false"; @@ -1953,7 +1950,7 @@ function watchExp(model, getter) { var result = getter.call(model, model); - if (_.isArray(result)) { + if (BI._.isArray(result)) { return result.concat(); } @@ -1974,14 +1971,14 @@ options.user = true; var exps; - if (_.isFunction(expOrFn)) { + if (BI._.isFunction(expOrFn)) { var watcher = innerWatch(expOrFn, cb, options); return function unwatchFn() { watcher(); }; } - if (!(exps = expOrFn.match(/[a-zA-Z0-9_.*]+|[|][|]|[&][&]|[(]|[)]/g)) || exps.length === 1 && !/\*/.test(expOrFn)) { + if (!(exps = expOrFn.match(/[a-zA-Z0-9BI._.*]+|[|][|]|[&][&]|[(]|[)]/g)) || exps.length === 1 && !/\*/.test(expOrFn)) { var paths = expOrFn.split("."); var prePaths = paths.slice(0, paths.length - 1); var preGetter = parsePath(prePaths.join(".")); @@ -2030,8 +2027,8 @@ } }; - _.each(exps, function (exp, i) { - if (_.has(operators, exp)) { + BI._.each(exps, function (exp, i) { + if (BI._.has(operators, exp)) { return; } @@ -2079,14 +2076,14 @@ return watchExp(_v2, _getter); }, function (newValue, oldValue) { // a.** 在a变化的时候不会触发change - if (!_.isArray(newValue) && oldValue !== newValue) { + if (!BI._.isArray(newValue) && oldValue !== newValue) { return; } - callback(i, NaN, NaN, _.extend({ + callback(i, NaN, NaN, BI._.extend({ index: i })); - }, _.extend({ + }, BI._.extend({ deep: true }, options))); return; @@ -2145,11 +2142,11 @@ changes = []; if (newValue === true) { - callback(i, NaN, NaN, _.extend({ + callback(i, NaN, NaN, BI._.extend({ index: i })); } - }, _.extend({}, options, { + }, BI._.extend({}, options, { deep: true, onTrigger: function onTrigger(_ref) { var target = _ref.target, @@ -2167,7 +2164,7 @@ watchers.push(innerWatch(function () { return watchExp(model, getter); }, function (newValue, oldValue) { - callback(i, newValue, oldValue, _.extend({ + callback(i, newValue, oldValue, BI._.extend({ index: i })); }, options)); @@ -2188,7 +2185,7 @@ var $$computed = vm.$$computed = {}; for (var key in c) { - $$computed[key] = computed(_.bind(c[key], vm)); + $$computed[key] = computed(BI._.bind(c[key], vm)); } } @@ -2198,7 +2195,7 @@ for (var key in watch) { var handler = watch[key]; - if (_.isArray(handler)) { + if (BI._.isArray(handler)) { for (var i = 0; i < handler.length; i++) { vm._watchers.push(createWatcher(vm, key, handler[i])); } @@ -2218,25 +2215,25 @@ cb = vm[cb]; } - return watch(vm.model, keyOrFn, _.bind(cb, vm), options); + return watch(vm.model, keyOrFn, BI._.bind(cb, vm), options); } function initMethods(vm, methods) { for (var key in methods) { - vm[key] = methods[key] == null ? noop : _.bind(methods[key], vm); + vm[key] = methods[key] == null ? noop : BI._.bind(methods[key], vm); } } function initMixins(vm, mixins) { mixins = (mixins || []).slice(0); - _.each(mixins.reverse(), function (mixinType) { + BI._.each(mixins.reverse(), function (mixinType) { var mixin = getMixins(mixinType); for (var key in mixin) { if (typeof mixin[key] !== "function") continue; - if (_.has(vm, key)) continue; - vm[key] = _.bind(mixin[key], vm); + if (BI._.has(vm, key)) continue; + vm[key] = BI._.bind(mixin[key], vm); } }); } @@ -2329,7 +2326,7 @@ var inject = vm.inject || []; var result = {}; - _.each(inject, function (key) { + BI._.each(inject, function (key) { result[key] = getInjectValue(vm, key); }); @@ -2346,7 +2343,7 @@ value: function _constructor(options, destroyHandler) { this.options = options || {}; this._parent = Model.target; - var state = _.isFunction(this.state) ? this.state() : this.state; + var state = BI._.isFunction(this.state) ? this.state() : this.state; var computed = this.computed; var context = this.context; var inject = this.inject; @@ -2354,14 +2351,14 @@ var watch = this.watch; var actions = this.actions; - _.keys(state).concat(_.keys(computed)).concat(inject || []).concat(context || []); + BI._.keys(state).concat(BI._.keys(computed)).concat(inject || []).concat(context || []); var mixins = this.mixins; defineProps(this); childContext && defineContext(this, childContext); initMixins(this, mixins); this.init(); - initState(this, _.extend(getInjectValues(this), state)); + initState(this, BI._.extend(getInjectValues(this), state)); initComputed(this, computed); REACTIVE && initWatch(this, watch); initMethods(this, actions); @@ -2379,10 +2376,10 @@ }, { key: "destroy", value: function destroy() { - _.each(this._watchers, function (unwatches) { - unwatches = _.isArray(unwatches) ? unwatches : [unwatches]; + BI._.each(this._watchers, function (unwatches) { + unwatches = BI._.isArray(unwatches) ? unwatches : [unwatches]; - _.each(unwatches, function (unwatch) { + BI._.each(unwatches, function (unwatch) { unwatch(); }); }); @@ -2398,7 +2395,7 @@ return Model; }(); function set(target, key, val) { - if (_.isArray(target)) { + if (BI._.isArray(target)) { target.length = Math.max(target.length, key); target.splice(key, 1, val); return val; @@ -2416,12 +2413,12 @@ return value; } function del(target, key) { - if (_.isArray(target)) { + if (BI._.isArray(target)) { target.splice(key, 1); return; } - if (!_.has(target, key)) { + if (!BI._.has(target, key)) { return; } @@ -2441,7 +2438,7 @@ function toJSON(model) { var result; - if (_.isArray(model)) { + if (BI._.isArray(model)) { result = []; for (var i = 0, len = model.length; i < len; i++) { @@ -2475,4 +2472,4 @@ Object.defineProperty(exports, '__esModule', { value: true }); -}))); +})); diff --git a/package.json b/package.json index 3693c9e1e..e83e9a714 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "fineui", "version": "2.0.20220622110506", "description": "fineui", - "main": "dist/fineui.min.js", + "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts", "devDependencies": { "@babel/core": "^7.17.4", diff --git a/src/core/1.lodash.js b/src/core/1.lodash.js index cab97c0d2..8be57fe24 100644 --- a/src/core/1.lodash.js +++ b/src/core/1.lodash.js @@ -10253,7 +10253,7 @@ // loaded by a script tag in the presence of an AMD loader. // See http://requirejs.org/docs/errors.html#mismatch for more details. // Use `_.noConflict` to remove Lodash from the global object. - root._ = lodash; + BI._ = lodash; // Define as an anonymous module so, through path mapping, it can be // referenced as the "underscore" module. @@ -10270,6 +10270,6 @@ } else { // Export to the global object. - root._ = lodash; + BI._ = lodash; } }.call(this)); diff --git a/src/core/2.base.js b/src/core/2.base.js index ba2d9ec77..4ab530629 100644 --- a/src/core/2.base.js +++ b/src/core/2.base.js @@ -11,19 +11,19 @@ }; var _apply = function (name) { return function () { - return _[name].apply(_, arguments); + return BI._[name].apply(BI._, arguments); }; }; var _applyFunc = function (name) { return function () { var args = Array.prototype.slice.call(arguments, 0); - args[1] = _.isFunction(args[1]) ? traverse(args[1], args[2]) : args[1]; - return _[name].apply(_, args); + args[1] = BI._.isFunction(args[1]) ? traverse(args[1], args[2]) : args[1]; + return BI._[name].apply(BI._, args); }; }; // Utility - _.extend(BI, { + BI._.extend(BI, { assert: function (v, is) { if (this.isFunction(is)) { if (!is(v)) { @@ -146,10 +146,10 @@ }); // 集合相关方法 - _.each(["where", "findWhere", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], function (name) { + BI._.each(["where", "findWhere", "invoke", "pluck", "shuffle", "sample", "toArray", "size"], function (name) { BI[name] = _apply(name); }); - _.each(["get", "set", "each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min", + BI._.each(["get", "set", "each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min", "sortBy", "groupBy", "indexBy", "countBy", "partition", "clamp"], function (name) { if (name === "any") { BI[name] = _applyFunc("some"); @@ -157,7 +157,7 @@ BI[name] = _applyFunc(name); } }); - _.extend(BI, { + BI._.extend(BI, { // 数数 count: function (from, to, predicate) { var t; @@ -217,10 +217,10 @@ }).join(""); } if (BI.isArray(obj1)) { - return _.concat.apply([], arguments); + return BI._.concat.apply([], arguments); } if (BI.isObject(obj1)) { - return _.extend.apply({}, arguments); + return BI._.extend.apply({}, arguments); } }, @@ -254,7 +254,7 @@ backFindKey: function (obj, predicate, context) { predicate = BI.iteratee(predicate, context); - var keys = _.keys(obj), key; + var keys = BI._.keys(obj), key; for (var i = keys.length - 1; i >= 0; i--) { key = keys[i]; if (predicate(obj[key], key, obj)) { @@ -347,14 +347,14 @@ }); // 数组相关的方法 - _.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection", + BI._.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection", "difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight", "uniqBy"], function (name) { BI[name] = _apply(name); }); - _.each(["findIndex", "findLastIndex"], function (name) { + BI._.each(["findIndex", "findLastIndex"], function (name) { BI[name] = _applyFunc(name); }); - _.extend(BI, { + BI._.extend(BI, { // 构建一个长度为length的数组 makeArray: function (length, value) { var res = []; @@ -401,27 +401,27 @@ if (array == null) { return []; } - if (!_.isBoolean(isSorted)) { + if (!BI._.isBoolean(isSorted)) { context = iteratee; iteratee = isSorted; isSorted = false; } iteratee && (iteratee = traverse(iteratee, context)); - return _.uniq.call(_, array, isSorted, iteratee, context); + return BI._.uniq.call(BI._, array, isSorted, iteratee, context); } }); // 对象相关方法 - _.each(["keys", "allKeys", "values", "pairs", "invert", "create", "functions", "extend", "extendOwn", + BI._.each(["keys", "allKeys", "values", "pairs", "invert", "create", "functions", "extend", "extendOwn", "defaults", "clone", "property", "propertyOf", "matcher", "isEqual", "isMatch", "isEmpty", "isElement", "isNumber", "isString", "isArray", "isObject", "isPlainObject", "isArguments", "isFunction", "isFinite", "isBoolean", "isDate", "isRegExp", "isError", "isNaN", "isUndefined", "zipObject", "cloneDeep"], function (name) { BI[name] = _apply(name); }); - _.each(["mapObject", "findKey", "pick", "omit", "tap"], function (name) { + BI._.each(["mapObject", "findKey", "pick", "omit", "tap"], function (name) { BI[name] = _applyFunc(name); }); - _.extend(BI, { + BI._.extend(BI, { inherit: function (sp, overrides) { var sb = function () { @@ -432,7 +432,7 @@ F.prototype = spp; sb.prototype = new F(); sb.superclass = spp; - _.extend(sb.prototype, overrides, { + BI._.extend(sb.prototype, overrides, { superclass: sp }); return sb; @@ -455,10 +455,10 @@ return false; } return BI.every(keys, function (i, key) { - return _.has(obj, key); + return BI._.has(obj, key); }); } - return _.has.apply(_, arguments); + return BI._.has.apply(BI._, arguments); }, freeze: function (value) { @@ -528,9 +528,9 @@ }); // deep方法 - _.extend(BI, { - deepClone: _.cloneDeep, - deepExtend: _.merge, + BI._.extend(BI, { + deepClone: BI._.cloneDeep, + deepExtend: BI._.merge, isDeepMatch: function (object, attrs) { var keys = BI.keys(attrs), length = keys.length; @@ -548,8 +548,8 @@ }, contains: function (obj, target, fromIndex) { - if (!_.isArrayLike(obj)) obj = _.values(obj); - return _.indexOf(obj, target, typeof fromIndex === "number" && fromIndex) >= 0; + if (!BI._.isArrayLike(obj)) obj = BI._.values(obj); + return BI._.indexOf(obj, target, typeof fromIndex === "number" && fromIndex) >= 0; }, deepContains: function (obj, copy) { @@ -647,20 +647,20 @@ }); // 通用方法 - _.each(["uniqueId", "result", "chain", "iteratee", "escape", "unescape", "before", "after"], function (name) { + BI._.each(["uniqueId", "result", "chain", "iteratee", "escape", "unescape", "before", "after"], function (name) { BI[name] = function () { - return _[name].apply(_, arguments); + return BI._[name].apply(BI._, arguments); }; }); // 事件相关方法 - _.each(["bind", "once", "partial", "debounce", "throttle", "delay", "defer", "wrap"], function (name) { + BI._.each(["bind", "once", "partial", "debounce", "throttle", "delay", "defer", "wrap"], function (name) { BI[name] = function () { - return _[name].apply(_, arguments); + return BI._[name].apply(BI._, arguments); }; }); - _.extend(BI, { + BI._.extend(BI, { nextTick: (function () { var callbacks = []; var pending = false; @@ -731,10 +731,10 @@ }); // 数字相关方法 - _.each(["random"], function (name) { + BI._.each(["random"], function (name) { BI[name] = _apply(name); }); - _.extend(BI, { + BI._.extend(BI, { parseInt: function (number) { var radix = 10; @@ -837,9 +837,9 @@ }); // 字符串相关方法 - _.extend(BI, { + BI._.extend(BI, { trim: function () { - return _.trim.apply(_, arguments); + return BI._.trim.apply(BI._, arguments); }, toUpperCase: function (string) { @@ -965,7 +965,7 @@ }); // 日期相关方法 - _.extend(BI, { + BI._.extend(BI, { /** * 是否是闰年 * @param year diff --git a/src/core/3.ob.js b/src/core/3.ob.js index 2c21a11fb..30b6ce536 100644 --- a/src/core/3.ob.js +++ b/src/core/3.ob.js @@ -31,7 +31,7 @@ var OB = function (config) { this._constructor(config); }; - _.extend(OB.prototype, { + BI._.extend(OB.prototype, { props: {}, init: null, destroyed: null, @@ -66,12 +66,12 @@ _initListeners: function () { var self = this; if (this.options.listeners != null) { - _.each(this.options.listeners, function (lis, eventName) { - if (_.isFunction(lis)) { + BI._.each(this.options.listeners, function (lis, eventName) { + if (BI._.isFunction(lis)) { self.on(eventName, lis); return; } - (lis.target ? lis.target : self)[lis.once ? "once" : "on"](lis.eventName, _.bind(lis.action, self)); + (lis.target ? lis.target : self)[lis.once ? "once" : "on"](lis.eventName, BI._.bind(lis.action, self)); }); delete this.options.listeners; } @@ -100,7 +100,7 @@ }, _getEvents: function () { - if (!_.isObject(this.events)) { + if (!BI._.isObject(this.events)) { this.events = {}; } return this.events; @@ -115,7 +115,7 @@ var self = this; eventName = eventName.toLowerCase(); var fns = this._getEvents()[eventName]; - if (!_.isArray(fns)) { + if (!BI._.isArray(fns)) { fns = []; this._getEvents()[eventName] = fns; } @@ -151,9 +151,9 @@ delete this._getEvents()[eventName]; } else { var fns = this._getEvents()[eventName]; - if (_.isArray(fns)) { + if (BI._.isArray(fns)) { var newFns = []; - _.each(fns, function (ifn) { + BI._.each(fns, function (ifn) { if (ifn != fn) { newFns.push(ifn); } diff --git a/src/core/conflict.js b/src/core/conflict.js new file mode 100644 index 000000000..e478c567d --- /dev/null +++ b/src/core/conflict.js @@ -0,0 +1,7 @@ + +if (!window.$ && !window.jQuery) { + window.jQuery = window.$ = BI.jQuery; +} +if (!window._) { + window._ = BI._; +} diff --git a/src/core/constant/events.js b/src/core/constant/events.js index 2faa2593b..41d1d08fd 100644 --- a/src/core/constant/events.js +++ b/src/core/constant/events.js @@ -2,7 +2,7 @@ * 事件集合 * @class BI.Events */ -_.extend(BI, { +BI._.extend(BI, { Events: { /** diff --git a/src/core/constant/var.js b/src/core/constant/var.js index cc767737b..ac5755e45 100644 --- a/src/core/constant/var.js +++ b/src/core/constant/var.js @@ -2,7 +2,7 @@ * 常量 */ -_.extend(BI, { +BI._.extend(BI, { MAX: 0xfffffffffffffff, MIN: -0xfffffffffffffff, EVENT_RESPONSE_TIME: 200, diff --git a/src/core/func/alias.js b/src/core/func/alias.js index 3738a83ea..e30d88c24 100644 --- a/src/core/func/alias.js +++ b/src/core/func/alias.js @@ -450,7 +450,7 @@ BI.cjkEncodeDO = function (o) { if (BI.isPlainObject(o)) { var result = {}; - _.each(o, function (v, k) { + BI._.each(o, function (v, k) { if (!(typeof v === "string")) { v = BI.jsonEncode(v); } @@ -603,7 +603,7 @@ return new Date(o.__time__); } for (var a in o) { - if (o[a] == o || typeof o[a] === "object" || _.isFunction(o[a])) { + if (o[a] == o || typeof o[a] === "object" || BI._.isFunction(o[a])) { break; } o[a] = arguments.callee(o[a]); diff --git a/src/core/func/array.js b/src/core/func/array.js index 7111530f4..a96292352 100644 --- a/src/core/func/array.js +++ b/src/core/func/array.js @@ -2,7 +2,7 @@ * 对数组对象的扩展 * @class Array */ -_.extend(BI, { +BI._.extend(BI, { pushArray: function (sArray, array) { for (var i = 0; i < array.length; i++) { diff --git a/src/core/func/date.js b/src/core/func/date.js index 2b7554079..74bf3bea7 100644 --- a/src/core/func/date.js +++ b/src/core/func/date.js @@ -6,7 +6,7 @@ BI.Date.HOUR = 60 * BI.Date.MINUTE; BI.Date.DAY = 24 * BI.Date.HOUR; BI.Date.WEEK = 7 * BI.Date.DAY; -_.extend(BI, { +BI._.extend(BI, { /** * 获取时区 * @returns {String} diff --git a/src/core/func/function.js b/src/core/func/function.js index 2d3f9a3e8..83d58c5ec 100644 --- a/src/core/func/function.js +++ b/src/core/func/function.js @@ -3,7 +3,7 @@ * Created by GUY on 2015/6/24. */ BI.Func = BI.Func || {}; -_.extend(BI.Func, { +BI._.extend(BI.Func, { /** * 创建唯一的名字 * @param array @@ -143,7 +143,7 @@ _.extend(BI.Func, { } }); -_.extend(BI, { +BI._.extend(BI, { beforeFunc: function (sFunc, func) { var __self = sFunc; return function () { diff --git a/src/core/func/number.js b/src/core/func/number.js index 17083caa3..59021349f 100644 --- a/src/core/func/number.js +++ b/src/core/func/number.js @@ -1,4 +1,4 @@ -_.extend(BI, { +BI._.extend(BI, { // 给Number类型增加一个add方法,调用起来更加方便。 add: function (num, arg) { return accAdd(arg, num); diff --git a/src/core/func/string.js b/src/core/func/string.js index e4b613f6d..55a89e63f 100644 --- a/src/core/func/string.js +++ b/src/core/func/string.js @@ -2,7 +2,7 @@ * 对字符串对象的扩展 * @class String */ -_.extend(BI, { +BI._.extend(BI, { /** * 判断字符串是否已指定的字符串开始 @@ -65,7 +65,7 @@ _.extend(BI, { } else { src += "&"; } - _.each(paras, function (value, name) { + BI._.each(paras, function (value, name) { if (typeof(name) === "string") { src += name + "=" + value + "&"; } diff --git a/src/core/platform/web/function.js b/src/core/platform/web/function.js index faa40307b..230fc6ad5 100644 --- a/src/core/platform/web/function.js +++ b/src/core/platform/web/function.js @@ -1,5 +1,5 @@ // 浏览器相关方法 -_.extend(BI, { +BI._.extend(BI, { isIE: function () { if(!_global.navigator) { return false; diff --git a/src/core/platform/web/jquery/_jquery.js b/src/core/platform/web/jquery/_jquery.js index 48adf702e..8c83f4356 100644 --- a/src/core/platform/web/jquery/_jquery.js +++ b/src/core/platform/web/jquery/_jquery.js @@ -11012,10 +11012,6 @@ // Expose jQuery and $ identifiers, even in // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557) // and CommonJS for browser emulators (#13566) - if (!window.$ && !window.jQuery) { - window.jQuery = window.$ = jQuery; - } - BI.jQuery = BI.$ = jQuery; return jQuery; diff --git a/src/core/platform/web/load.js b/src/core/platform/web/load.js index a3278cd39..f367b8cf6 100644 --- a/src/core/platform/web/load.js +++ b/src/core/platform/web/load.js @@ -1,4 +1,4 @@ -_.extend(BI, { +BI._.extend(BI, { $import: function () { var _LOADED = {}; // alex:保存加载过的 function loadReady (src, must) { diff --git a/src/core/plugin.js b/src/core/plugin.js index 50109a40c..bbfd5e5ac 100644 --- a/src/core/plugin.js +++ b/src/core/plugin.js @@ -36,8 +36,8 @@ BI.Plugin = BI.Plugin || {}; }, config: function (widgetConfigFn, objectConfigFn) { - _GlobalWidgetConfigFns = _GlobalWidgetConfigFns.concat(_.isArray(widgetConfigFn) ? widgetConfigFn : [widgetConfigFn]); - __GlobalObjectConfigFns = __GlobalObjectConfigFns.concat(_.isArray(objectConfigFn) ? objectConfigFn : [objectConfigFn]); + _GlobalWidgetConfigFns = _GlobalWidgetConfigFns.concat(BI._.isArray(widgetConfigFn) ? widgetConfigFn : [widgetConfigFn]); + __GlobalObjectConfigFns = __GlobalObjectConfigFns.concat(BI._.isArray(objectConfigFn) ? objectConfigFn : [objectConfigFn]); }, configWidget: function (type, fn, opt) { diff --git a/src/core/structure/aes.js b/src/core/structure/aes.js index fcb9c54c5..ec5d6b86a 100644 --- a/src/core/structure/aes.js +++ b/src/core/structure/aes.js @@ -2308,7 +2308,7 @@ }()); - _.extend(BI, { + BI._.extend(BI, { /** * aes加密方法 * aes-128-ecb diff --git a/src/core/structure/base64.js b/src/core/structure/base64.js index 4974133ce..976fbab9e 100644 --- a/src/core/structure/base64.js +++ b/src/core/structure/base64.js @@ -57,7 +57,7 @@ return string; }; - _.extend(BI, { + BI._.extend(BI, { encode: function (input) { var output = ""; diff --git a/src/core/utils/chinesePY.js b/src/core/utils/chinesePY.js index d1b5ab17f..b22cd94cb 100644 --- a/src/core/utils/chinesePY.js +++ b/src/core/utils/chinesePY.js @@ -422,7 +422,7 @@ return arrRslt.join(splitChar || "").toLowerCase(); }; - _.extend(BI, { + BI._.extend(BI, { makeFirstPY: function (str, options) { options = options || {}; if (typeof (str) !== "string") {return "" + str;} diff --git a/src/core/utils/i18n.js b/src/core/utils/i18n.js index 0dbf0a1a9..9cec7cc48 100644 --- a/src/core/utils/i18n.js +++ b/src/core/utils/i18n.js @@ -1,6 +1,6 @@ !(function () { var i18nStore = {}; - _.extend(BI, { + BI._.extend(BI, { changeI18n: function (i18n) { if (i18n) { i18nStore = i18n; diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 7a41ee0ae..5b83ff432 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -224,14 +224,14 @@ BI.Layout = BI.inherit(BI.Widget, { } } } else { - var keys = _.keys(a), key; + var keys = BI._.keys(a), key; length = keys.length; - if (_.keys(b).length !== length) { + if (BI._.keys(b).length !== length) { return false; } while (length--) { key = keys[length]; - if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) { + if (!(BI._.has(b, key) && eq(a[key], b[key], aStack, bStack))) { return false; } } diff --git a/src/router/0.router.js b/src/router/0.router.js index 279289fc0..adf48b1bc 100644 --- a/src/router/0.router.js +++ b/src/router/0.router.js @@ -16,7 +16,7 @@ once: function (name, callback, context) { if (!eventsApi(this, "once", name, [callback, context]) || !callback) return this; var self = this; - var once = _.once(function () { + var once = BI._.once(function () { self.off(name, once); callback.apply(this, arguments); }); @@ -37,7 +37,7 @@ return this; } - var names = name ? [name] : _.keys(this._events); + var names = name ? [name] : BI._.keys(this._events); for (var i = 0, length = names.length; i < length; i++) { name = names[i]; @@ -103,7 +103,7 @@ // listening to. listenTo: function (obj, name, callback) { var listeningTo = this._listeningTo || (this._listeningTo = {}); - var id = obj._listenId || (obj._listenId = _.uniqueId("l")); + var id = obj._listenId || (obj._listenId = BI._.uniqueId("l")); listeningTo[id] = obj; if (!callback && typeof name === "object") callback = this; obj.on(name, callback, this); @@ -123,7 +123,7 @@ return this; } if (!callback) return this; - var once = _.once(function () { + var once = BI._.once(function () { this.stopListening(obj, name, once); callback.apply(this, arguments); }); @@ -142,7 +142,7 @@ for (var id in listeningTo) { obj = listeningTo[id]; obj.off(name, callback, this); - if (remove || _.isEmpty(obj._events)) delete this._listeningTo[id]; + if (remove || BI._.isEmpty(obj._events)) delete this._listeningTo[id]; } return this; } @@ -222,7 +222,7 @@ var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g; // Set up all inheritable **BI.Router** properties and methods. - _.extend(Router.prototype, Events, { + BI._.extend(Router.prototype, Events, { // _init is an empty function by default. Override it with your own // initialization logic. @@ -236,8 +236,8 @@ // }); // route: function (route, name, callback) { - if (!_.isRegExp(route)) route = this._routeToRegExp(route); - if (_.isFunction(name)) { + if (!BI._.isRegExp(route)) route = this._routeToRegExp(route); + if (BI._.isFunction(name)) { callback = name; name = ""; } @@ -271,8 +271,8 @@ // routes can be defined at the bottom of the route map. _bindRoutes: function () { if (!this.routes) return; - this.routes = _.result(this, "routes"); - var route, routes = _.keys(this.routes); + this.routes = BI._.result(this, "routes"); + var route, routes = BI._.keys(this.routes); while ((route = routes.pop()) != null) { this.route(route, this.routes[route]); } @@ -295,7 +295,7 @@ // treated as `null` to normalize cross-browser behavior. _extractParameters: function (route, fragment) { var params = route.exec(fragment).slice(1); - return _.map(params, function (param, i) { + return BI._.map(params, function (param, i) { // Don't decode the search params. if (i === params.length - 1) return param || null; var resultParam = null; @@ -322,7 +322,7 @@ // falls back to polling. var History = function () { this.handlers = []; - this.checkUrl = _.bind(this.checkUrl, this); + this.checkUrl = BI._.bind(this.checkUrl, this); // Ensure that `History` can be used outside of the browser. if (typeof window !== "undefined") { @@ -344,7 +344,7 @@ History.started = false; // Set up all inheritable **BI.History** properties and methods. - _.extend(History.prototype, Events, { + BI._.extend(History.prototype, Events, { // The default interval to poll for hash changes, if necessary, is // twenty times a second. @@ -402,7 +402,7 @@ // Figure out the initial configuration. Do we need an iframe? // Is pushState desired ... is it available? - this.options = _.extend({root: "/"}, this.options, options); + this.options = BI._.extend({root: "/"}, this.options, options); this.root = this.options.root; this._wantsHashChange = this.options.hashChange !== false; this._hasHashChange = "onhashchange" in window; @@ -511,7 +511,7 @@ // remove a route match in routes unRoute: function (route) { - var index = _.findIndex(this.handlers, function (handler) { + var index = BI._.findIndex(this.handlers, function (handler) { return handler.route.test(route); }); if (index > -1) { @@ -545,7 +545,7 @@ // returns `false`. loadUrl: function (fragment) { fragment = this.fragment = this.getFragment(fragment); - return _.some(this.handlers, function (handler) { + return BI._.some(this.handlers, function (handler) { if (handler.route.test(fragment)) { handler.callback(fragment); return true; diff --git a/test/utils.js b/test/utils.js index 7e363b9bc..8ecf90a72 100644 --- a/test/utils.js +++ b/test/utils.js @@ -1,6 +1,6 @@ !(function () { BI.Test = {}; - _.extend(BI.Test, { + BI._.extend(BI.Test, { createWidget: function (widgetJson) { var widget = BI.createWidget(BI.extend(widgetJson, { root: true diff --git a/webpack/attachments.js b/webpack/attachments.js index eefbe4b42..cf26e9d09 100644 --- a/webpack/attachments.js +++ b/webpack/attachments.js @@ -5,6 +5,7 @@ const fixProxyJs = './dist/fix/fix.proxy.js'; const fixCompact = "./dist/fix/fix.compact.js"; const workerCompact = './dist/fix/worker.compact.js'; const lodashJs = "src/core/1.lodash.js"; +const jqueryJs = "src/core/platform/web/jquery/_jquery.js"; const basicAttachmentMap = { polyfill: sync(["src/core/0.foundation.js", "src/polyfill/**/*.js"]).concat(["@babel/polyfill", "es6-promise/auto"]), @@ -12,6 +13,7 @@ const basicAttachmentMap = { "src/less/core/**/*.less", "src/less/theme/**/*.less", lodashJs, + jqueryJs, "src/core/**/*.js", "src/data/**/*.js", ]), @@ -46,6 +48,15 @@ const basicAttachmentMap = { core_without_normalize: sync( ["src/less/core/**/*.less", "src/less/theme/**/*.less"], ["src/less/core/normalize.less", "src/less/core/normalize2.less"] ), + core_without_conflict: sync([ + "src/less/core/**/*.less", + "src/less/theme/**/*.less", + lodashJs, + "src/core/**/*.js", + "src/data/**/*.js", + ], [ + "src/core/conflict.js", + ]), resource: sync(["src/less/resource/**/*.less"]), font: sync(["public/less/font.less"]), ts: ['./typescript/bundle.ts'], @@ -156,6 +167,19 @@ const fineui = [].concat( basicAttachmentMap.ts, ); +const fineuiWithoutConflict = [].concat( + basicAttachmentMap.polyfill, + basicAttachmentMap.core_without_conflict, + basicAttachmentMap.fix, + basicAttachmentMap.base, + basicAttachmentMap.case, + basicAttachmentMap.widget, + basicAttachmentMap.router, + [fixCompact, workerCompact], + basicAttachmentMap.ui, + basicAttachmentMap.ts, +); + // const fineuiModern = [].concat( // sync(["src/less/modern.less"]), // sync([ @@ -221,6 +245,7 @@ module.exports = { font: basicAttachmentMap.font, bundle: uniq(bundle), fineuiWithoutNormalize: uniq(fineuiWithoutNormalize), + fineuiWithoutConflict: uniq(fineuiWithoutConflict), bundleWithoutNormalize: uniq(bundleWithoutNormalize), fineui: uniq(fineui), fineuiProxy: uniq(fineuiProxy), diff --git a/webpack/webpack.prod.js b/webpack/webpack.prod.js index 05cb95648..1af08c2af 100644 --- a/webpack/webpack.prod.js +++ b/webpack/webpack.prod.js @@ -18,6 +18,7 @@ module.exports = merge.smart(common, { font: attachments.font, "fineui.min": attachments.fineui, "fineui_without_normalize.min": attachments.fineuiWithoutNormalize, + "fineui_without_conflict.min": attachments.fineuiWithoutConflict, "fineui.proxy.min": attachments.fineuiProxy, "core_without_platform": attachments.coreWithoutPlatform, utils: attachments.utils, From 6c4685cca2f899d29679b01fb486d6d48c8a96f6 Mon Sep 17 00:00:00 2001 From: iapyang Date: Thu, 23 Jun 2022 16:33:48 +0800 Subject: [PATCH 05/14] =?UTF-8?q?refactor:=20=E9=87=8D=E5=A4=8D=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E5=90=8E=E4=B8=8D=E5=86=8D=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/5.inject.js | 58 +++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/src/core/5.inject.js b/src/core/5.inject.js index 2bc662e18..3e606f1a7 100644 --- a/src/core/5.inject.js +++ b/src/core/5.inject.js @@ -10,27 +10,29 @@ BI.module = BI.module || function (xtype, cls) { if (moduleInjection[xtype] != null) { _global.console && console.error("module: [" + xtype + "] 已经注册过了"); - } - if (BI.isFunction(cls)) { - cls = cls(); - } - for (var k in moduleInjectionMap) { - if (cls[k]) { - for (var key in cls[k]) { - if (!moduleInjectionMap[k]) { - continue; - } - if (!moduleInjectionMap[k][key]) { - moduleInjectionMap[k][key] = []; + } else { + if (BI.isFunction(cls)) { + cls = cls(); + } + for (var k in moduleInjectionMap) { + if (cls[k]) { + for (var key in cls[k]) { + if (!moduleInjectionMap[k]) { + continue; + } + if (!moduleInjectionMap[k][key]) { + moduleInjectionMap[k][key] = []; + } + moduleInjectionMap[k][key].push({ + version: cls[k][key], + moduleId: xtype + }); } - moduleInjectionMap[k][key].push({ - version: cls[k][key], - moduleId: xtype - }); } } + moduleInjection[xtype] = cls; } - moduleInjection[xtype] = cls; + return function () { return BI.Modules.getModule(xtype); }; @@ -40,8 +42,10 @@ BI.constant = BI.constant || function (xtype, cls) { if (constantInjection[xtype] != null) { _global.console && console.error("constant: [" + xtype + "]已经注册过了"); + } else { + constantInjection[xtype] = cls; } - constantInjection[xtype] = cls; + return function () { return BI.Constants.getConstant(xtype); }; @@ -51,8 +55,10 @@ BI.model = BI.model || function (xtype, cls) { if (modelInjection[xtype] != null) { _global.console && console.error("model: [" + xtype + "] 已经注册过了"); + } else { + modelInjection[xtype] = cls; } - modelInjection[xtype] = cls; + return function (config) { return BI.Models.getModel(xtype, config); }; @@ -62,8 +68,10 @@ BI.store = BI.store || function (xtype, cls) { if (storeInjection[xtype] != null) { _global.console && console.error("store: [" + xtype + "] 已经注册过了"); + } else { + storeInjection[xtype] = cls; } - storeInjection[xtype] = cls; + return function (config) { return BI.Stores.getStore(xtype, config); }; @@ -73,8 +81,10 @@ BI.service = BI.service || function (xtype, cls) { if (serviceInjection[xtype] != null) { _global.console && console.error("service: [" + xtype + "] 已经注册过了"); + } else { + serviceInjection[xtype] = cls; } - serviceInjection[xtype] = cls; + return function (config) { return BI.Services.getService(xtype, config); }; @@ -84,8 +94,10 @@ BI.provider = BI.provider || function (xtype, cls) { if (providerInjection[xtype] != null) { _global.console && console.error("provider: [" + xtype + "] 已经注册过了"); + } else { + providerInjection[xtype] = cls; } - providerInjection[xtype] = cls; + return function (config) { return BI.Providers.getProvider(xtype, config); }; @@ -390,6 +402,8 @@ BI.shortcut = BI.component = BI.shortcut || function (xtype, cls) { if (kv[xtype] != null) { _global.console && console.error("组件: [" + xtype + "] 已经注册过了"); + + return; } if (cls) { cls["xtype"] = xtype; From 1c05038f7f5bb6b66be724b89febdde5644e5174 Mon Sep 17 00:00:00 2001 From: data Date: Thu, 23 Jun 2022 17:55:15 +0800 Subject: [PATCH 06/14] auto upgrade version to 2.0.20220623175503 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b80b3cd54..efb302c6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220623154535", + "version": "2.0.20220623175503", "description": "fineui", "main": "dist/fineui.min.js", "types": "dist/lib/index.d.ts", From 291554ecb46300820be50fcfc7449c951e24c7f2 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 23 Jun 2022 18:20:31 +0800 Subject: [PATCH 07/14] =?UTF-8?q?feature:=20=E9=80=89=E4=B8=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselect/loader.js | 244 +++++++++++++++++++ src/widget/multiselect/multiselect.loader.js | 63 ++--- 2 files changed, 262 insertions(+), 45 deletions(-) create mode 100644 src/widget/multiselect/loader.js diff --git a/src/widget/multiselect/loader.js b/src/widget/multiselect/loader.js new file mode 100644 index 000000000..7eddae550 --- /dev/null +++ b/src/widget/multiselect/loader.js @@ -0,0 +1,244 @@ +/** + * 加载控件 + * + * Created by GUY on 2015/8/31. + * @class BI.Loader + * @extends BI.Widget + */ +BI.MultiSelectInnerLoader = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiSelectInnerLoader.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-inner-loader", + + direction: "top", + isDefaultInit: true, // 是否默认初始化数据 + logic: { + dynamic: true, + scrolly: true + }, + + // 下面是button_group的属性 + el: { + type: "bi.button_group", + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + behaviors: { + redmark: function () { + return true; + } + }, + layouts: [{ + type: "bi.vertical" + }] + }, + + items: [], + itemsCreator: BI.emptyFn, + onLoaded: BI.emptyFn, + + // 下面是分页信息 + count: false, + prev: false, + next: {}, + hasPrev: BI.emptyFn, + hasNext: BI.emptyFn + }); + }, + + _nextLoad: function () { + var self = this, o = this.options; + this.next.setLoading(); + if (this.cachItems && this.cachItems.length > 0) { + this.next.setLoaded(); + this.addItems(this.cachItems.slice(0, 10)); + this.cachItems = this.cachItems.slice(10); + return; + } + o.itemsCreator.apply(this, [{times: ++this.times}, function () { + self.next.setLoaded(); + self.addItems.apply(self, arguments); + }]); + }, + + render: function () { + var self = this, o = this.options; + if (o.itemsCreator === false) { + o.next = false; + } + this.button_group = BI.createWidget(o.el, { + type: "bi.button_group", + chooseType: 0, + items: o.items, + behaviors: {}, + layouts: [{ + type: "bi.vertical" + }], + value: o.value + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { + if (type === BI.Events.CLICK) { + var node = self.cachGroup.getNodeByValue(value); + if (node) { + node.setSelected(obj.isSelected()); + } + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.Loader.EVENT_CHANGE, obj); + } + }); + + this.cachGroup = BI.createWidget(o.el, { + type: "bi.button_group", + root: true, + chooseType: 0, + items: o.items, + behaviors: {}, + layouts: [{ + type: "bi.vertical" + }], + value: o.value + }); + + if (o.next !== false) { + this.next = BI.createWidget(BI.extend({ + type: "bi.loading_bar" + }, o.next)); + this.next.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + self._nextLoad(); + } + }); + } + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.button_group, this.next] + }); + + o.isDefaultInit && BI.isEmpty(o.items) && BI.nextTick(BI.bind(function () { + o.isDefaultInit && BI.isEmpty(o.items) && this._populate(); + }, this)); + }, + + hasNext: function () { + var o = this.options; + if (BI.isNumber(o.count)) { + return this.count < o.count; + } + if (this.cachItems && this.cachItems.length > 0) { + return true; + } + return !!o.hasNext.apply(this, [{ + times: this.times, + count: this.count + }]); + }, + + addItems: function (items) { + this.count += items.length; + if (BI.isObject(this.next)) { + if (this.hasNext()) { + this.options.items = this.options.items.concat(items); + this.next.setLoaded(); + } else { + this.next.setEnd(); + } + } + this.cachGroup.addItems.apply(this.cachGroup, arguments); + this.button_group.addItems.apply(this.button_group, arguments); + }, + + _populate: function (items) { + var self = this, o = this.options; + if (arguments.length === 0 && (BI.isFunction(o.itemsCreator))) { + o.itemsCreator.apply(this, [{times: 1}, function (items, keyword) { + if (arguments.length === 0) { + throw new Error("参数不能为空"); + } + self.populate.apply(self, arguments); + o.onLoaded(); + }]); + return false; + } + this.options.items = (items || []).slice(0, 10); + this.times = 1; + this.count = 0; + this.count += items.length; + if (BI.isObject(this.next)) { + if (this.hasNext()) { + this.next.setLoaded(); + } else { + this.next.invisible(); + } + } + return true; + }, + + populate: function (items, keyword) { + if (this._populate.apply(this, arguments)) { + this.cachItems = []; + if (items.length > 10) { + this.cachItems = items.slice(10); + } + this.cachGroup.populate.call(this.cachGroup, items, keyword); + this.button_group.populate.call(this.button_group, items.slice(0, 10), keyword); + } + }, + + setNotSelectedValue: function () { + this.button_group.setNotSelectedValue.apply(this.button_group, arguments); + this.cachGroup.setNotSelectedValue.apply(this.cachGroup, arguments); + }, + + getNotSelectedValue: function () { + return this.cachGroup.getNotSelectedValue(); + }, + + setValue: function () { + this.cachGroup.setValue.apply(this.cachGroup, arguments); + this.button_group.setValue.apply(this.button_group, arguments); + }, + + getValue: function () { + return this.cachGroup.getValue.apply(this.cachGroup, arguments); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + getAllLeaves: function () { + return this.button_group.getAllLeaves(); + }, + + getSelectedButtons: function () { + return this.button_group.getSelectedButtons(); + }, + + getNotSelectedButtons: function () { + return this.button_group.getNotSelectedButtons(); + }, + + getIndexByValue: function (value) { + return this.button_group.getIndexByValue(value); + }, + + getNodeById: function (id) { + return this.button_group.getNodeById(id); + }, + + getNodeByValue: function (value) { + return this.button_group.getNodeByValue(value); + }, + + empty: function () { + this.button_group.empty(); + this.cachGroup.empty(); + BI.each([this.prev, this.next], function (i, ob) { + ob && ob.setVisible(false); + }); + } +}); +BI.MultiSelectInnerLoader.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multi_select_inner_loader", BI.MultiSelectInnerLoader); diff --git a/src/widget/multiselect/multiselect.loader.js b/src/widget/multiselect/multiselect.loader.js index 0b86f44d4..d344c09ae 100644 --- a/src/widget/multiselect/multiselect.loader.js +++ b/src/widget/multiselect/multiselect.loader.js @@ -18,7 +18,7 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { valueFormatter: BI.emptyFn, itemsCreator: BI.emptyFn, onLoaded: BI.emptyFn, - itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT + itemHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, }); }, @@ -43,43 +43,28 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { el: BI.extend({ onLoaded: opts.onLoaded, el: { - type: "bi.loader", - isDefaultInit: false, - logic: { - dynamic: true, - scrolly: true - }, - el: { - chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, - behaviors: { - redmark: function () { - return true; - } - }, - layouts: [{ - type: "bi.vertical" - }] - } + type: "bi.multi_select_inner_loader", } }, opts.el), itemsCreator: function (op, callback) { var startValue = self._startValue; - var firstItems = []; self.storeValue && (op = BI.extend(op || {}, { selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi ? self.storeValue.value.concat(startValue) : self.storeValue.value })); - if (self.storeValue) { - var json = BI.map(self.storeValue.value.slice((op.times - 1) * 100, op.times * 100), function (i, v) { - var txt = opts.valueFormatter(v) || v; - return { - text: txt, - value: v, - title: txt, - selected: self.storeValue.type === BI.Selection.Multi - }; - }); - if (op.times === 1) { + opts.itemsCreator(op, function (ob) { + hasNext = ob.hasNext; + var firstItems = []; + if (op.times === 1 && self.storeValue) { + var json = BI.map(self.storeValue.value, function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt, + selected: self.storeValue.type === BI.Selection.Multi + }; + }); if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { var txt = opts.valueFormatter(startValue) || startValue; json.unshift({ @@ -89,22 +74,10 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { selected: true }); } + firstItems = self._createItems(json); } - if (op.times < Math.floor((self.storeValue.value.length - 1) / 100)) { - hasNext = true; - callback(self._createItems(json), op.keyword || ""); - (op.times === 1) && self._scrollToTop(); - return; - } - firstItems = self._createItems(json); - } - var times = op.times - Math.max(0, Math.floor((self.storeValue.value.length - 1) / 100)); - opts.itemsCreator(BI.extend({}, op, { - times: times - }), function (ob) { - hasNext = ob.hasNext; - callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || op.keyword || ""); - if (times === 1 && self.storeValue) { + callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); + if (op.times === 1 && self.storeValue) { BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); self.setValue(self.storeValue); } From b2fc2f50e32a16c0461d9da240b52b6f8b58726c Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 23 Jun 2022 18:21:22 +0800 Subject: [PATCH 08/14] =?UTF-8?q?feature:=20=E9=80=89=E4=B8=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../multiselect/multiselect.loader.nobar.js | 43 +++++++------------ 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/src/widget/multiselect/multiselect.loader.nobar.js b/src/widget/multiselect/multiselect.loader.nobar.js index 95c8f6fbc..d7744d042 100644 --- a/src/widget/multiselect/multiselect.loader.nobar.js +++ b/src/widget/multiselect/multiselect.loader.nobar.js @@ -55,22 +55,23 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { }, itemsCreator: function (op, callback) { var startValue = self._startValue; - var firstItems = []; self.storeValue && (op = BI.extend(op || {}, { selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi ? self.storeValue.value.concat(startValue) : self.storeValue.value })); - if (self.storeValue) { - var json = BI.map(self.storeValue.value.slice((op.times - 1) * 100, op.times * 100), function (i, v) { - var txt = opts.valueFormatter(v) || v; - return { - text: txt, - value: v, - title: txt, - selected: self.storeValue.type === BI.Selection.Multi - }; - }); - if (op.times === 1) { + opts.itemsCreator(op, function (ob) { + hasNext = ob.hasNext; + var firstItems = []; + if (op.times === 1 && self.storeValue) { + var json = BI.map(self.storeValue.value, function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt, + selected: self.storeValue.type === BI.Selection.Multi + }; + }); if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { var txt = opts.valueFormatter(startValue) || startValue; json.unshift({ @@ -80,22 +81,10 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { selected: true }); } + firstItems = self._createItems(json); } - if (op.times < Math.floor((self.storeValue.value.length - 1) / 100)) { - hasNext = true; - callback(self._createItems(json), op.keyword || ""); - (op.times === 1) && self._scrollToTop(); - return; - } - firstItems = self._createItems(json); - } - var times = op.times - Math.max(0, Math.floor((self.storeValue.value.length - 1) / 100)); - opts.itemsCreator(BI.extend({}, op, { - times: times - }), function (ob) { - hasNext = ob.hasNext; - callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || op.keyword || ""); - if (times === 1 && self.storeValue) { + callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); + if (op.times === 1 && self.storeValue) { BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); self.setValue(self.storeValue); } From 03a1a7b2ffa5c0613733b9fd6c0a6b4cc6aa91fb Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 23 Jun 2022 18:24:28 +0800 Subject: [PATCH 09/14] =?UTF-8?q?feature:=20=E9=80=89=E4=B8=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=94=AF=E6=8C=81=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselect/loader.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/widget/multiselect/loader.js b/src/widget/multiselect/loader.js index 7eddae550..f6b6bd3de 100644 --- a/src/widget/multiselect/loader.js +++ b/src/widget/multiselect/loader.js @@ -49,8 +49,8 @@ BI.MultiSelectInnerLoader = BI.inherit(BI.Widget, { this.next.setLoading(); if (this.cachItems && this.cachItems.length > 0) { this.next.setLoaded(); - this.addItems(this.cachItems.slice(0, 10)); - this.cachItems = this.cachItems.slice(10); + this.addItems(this.cachItems.slice(0, 100)); + this.cachItems = this.cachItems.slice(100); return; } o.itemsCreator.apply(this, [{times: ++this.times}, function () { @@ -161,7 +161,7 @@ BI.MultiSelectInnerLoader = BI.inherit(BI.Widget, { }]); return false; } - this.options.items = (items || []).slice(0, 10); + this.options.items = (items || []).slice(0, 100); this.times = 1; this.count = 0; this.count += items.length; @@ -178,11 +178,11 @@ BI.MultiSelectInnerLoader = BI.inherit(BI.Widget, { populate: function (items, keyword) { if (this._populate.apply(this, arguments)) { this.cachItems = []; - if (items.length > 10) { - this.cachItems = items.slice(10); + if (items.length > 100) { + this.cachItems = items.slice(100); } this.cachGroup.populate.call(this.cachGroup, items, keyword); - this.button_group.populate.call(this.button_group, items.slice(0, 10), keyword); + this.button_group.populate.call(this.button_group, items.slice(0, 100), keyword); } }, From b736d209c774ce1ff7e01e2e6451f5c508d27a0e Mon Sep 17 00:00:00 2001 From: data Date: Thu, 23 Jun 2022 21:45:23 +0800 Subject: [PATCH 10/14] auto upgrade version to 2.0.20220623214517 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index efb302c6d..e0802893a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220623175503", + "version": "2.0.20220623214517", "description": "fineui", "main": "dist/fineui.min.js", "types": "dist/lib/index.d.ts", From 52cbf07e7423f42005dddca3513cf8ce7d21a21b Mon Sep 17 00:00:00 2001 From: data Date: Thu, 23 Jun 2022 21:53:14 +0800 Subject: [PATCH 11/14] auto upgrade version to 2.0.20220623215302 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e0802893a..b5b64a274 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220623214517", + "version": "2.0.20220623215302", "description": "fineui", "main": "dist/fineui.min.js", "types": "dist/lib/index.d.ts", From 5311546f547ff8a2575efc03af45af232beae625 Mon Sep 17 00:00:00 2001 From: data Date: Fri, 24 Jun 2022 10:26:12 +0800 Subject: [PATCH 12/14] auto upgrade version to 2.0.20220624102555 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8a4760cc4..3cda0ea2f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220623215302", + "version": "2.0.20220624102555", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts", From 3b6b117930230ffbe645af711309a84ed0c6932b Mon Sep 17 00:00:00 2001 From: Dailer Date: Fri, 24 Jun 2022 10:34:32 +0800 Subject: [PATCH 13/14] Update src/less/lib/constant.less --- src/less/lib/constant.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/less/lib/constant.less b/src/less/lib/constant.less index b3a514511..17421baf0 100644 --- a/src/less/lib/constant.less +++ b/src/less/lib/constant.less @@ -246,4 +246,4 @@ @scroll-thumb-color-theme-dark: @color-black; //box-shadow效果 -@box-shadow-toast: 0 2px 6px 0 rgba(0, 0, 0, 0.2); +@box-shadow-toast: 0 6px 20px -2px rgba(9, 30, 64, 0.16); From e29ae9285cf92dca0dbb41858680b637cc8018e5 Mon Sep 17 00:00:00 2001 From: data Date: Fri, 24 Jun 2022 11:26:04 +0800 Subject: [PATCH 14/14] auto upgrade version to 2.0.20220624112553 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3cda0ea2f..e8439daa8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220624102555", + "version": "2.0.20220624112553", "description": "fineui", "main": "dist/fineui_without_conflict.min.js", "types": "dist/lib/index.d.ts",