Browse Source

Pull request #2708: 无JIRA history.current 变成响应式

Merge in VISUAL/fineui from ~DAILER/fineui:master to master

* commit 'f00ecee1067ca07fc7a4f025e4bdfb67787a8f3e':
  JSY-17840 fix: clearButton 占满高度
  无JIRA history.current 变成响应式
es6
Dailer 3 years ago
parent
commit
5507a0d3c6
  1. 146
      dist/fix/fix.js
  2. 2
      src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js
  3. 1
      src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js
  4. 2
      src/case/combo/textvaluecombo/combo.textvalue.js
  5. 1
      src/case/trigger/trigger.text.js
  6. 28
      src/less/base/combo/combo.searchtextvalue.less
  7. 1
      src/router/router.js

146
dist/fix/fix.js vendored

@ -135,8 +135,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
setImmediate(nextTickHandler); setImmediate(nextTickHandler);
}; };
} else if (typeof MessageChannel !== 'undefined' && (isNative(MessageChannel) || } else if (typeof MessageChannel !== 'undefined' && (isNative(MessageChannel) ||
// PhantomJS // PhantomJS
MessageChannel.toString() === '[object MessageChannelConstructor]')) { MessageChannel.toString() === '[object MessageChannelConstructor]')) {
var channel = new MessageChannel(); var channel = new MessageChannel();
var port = channel.port2; var port = channel.port2;
channel.port1.onmessage = nextTickHandler; channel.port1.onmessage = nextTickHandler;
@ -145,18 +145,18 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
}; };
} else } else
/* istanbul ignore next */ /* istanbul ignore next */
if (typeof Promise !== 'undefined' && isNative(Promise)) { if (typeof Promise !== 'undefined' && isNative(Promise)) {
// use microtask in non-DOM environments, e.g. Weex // use microtask in non-DOM environments, e.g. Weex
var p = Promise.resolve(); var p = Promise.resolve();
timerFunc = function timerFunc() { timerFunc = function timerFunc() {
p.then(nextTickHandler); p.then(nextTickHandler);
}; };
} else { } else {
// fallback to setTimeout // fallback to setTimeout
timerFunc = function timerFunc() { timerFunc = function timerFunc() {
setTimeout(nextTickHandler, 0); setTimeout(nextTickHandler, 0);
}; };
} }
return function queueNextTick(cb, ctx) { return function queueNextTick(cb, ctx) {
var _resolve = void 0; var _resolve = void 0;
@ -295,7 +295,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
if (isIE9Below) { if (isIE9Below) {
var VBClassPool = {}; var VBClassPool = {};
window.execScript([// jshint ignore:line window.execScript([// jshint ignore:line
'Function parseVB(code)', '\tExecuteGlobal(code)', 'End Function' //转换一段文本为VB代码 'Function parseVB(code)', '\tExecuteGlobal(code)', 'End Function' //转换一段文本为VB代码
].join('\n'), 'VBScript'); ].join('\n'), 'VBScript');
var VBMediator = function VBMediator(instance, accessors, name, value) { var VBMediator = function VBMediator(instance, accessors, name, value) {
@ -311,7 +311,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
// jshint ignore:line // jshint ignore:line
var buffer = []; var buffer = [];
buffer.push('\tPrivate [$vbsetter]', '\tPublic [$accessors]', '\tPublic Default Function [$vbthis](ac' + timeBucket + ', s' + timeBucket + ')', '\t\tSet [$accessors] = ac' + timeBucket + ': set [$vbsetter] = s' + timeBucket, '\t\tSet [$vbthis] = Me', //链式调用 buffer.push('\tPrivate [$vbsetter]', '\tPublic [$accessors]', '\tPublic Default Function [$vbthis](ac' + timeBucket + ', s' + timeBucket + ')', '\t\tSet [$accessors] = ac' + timeBucket + ': set [$vbsetter] = s' + timeBucket, '\t\tSet [$vbthis] = Me', //链式调用
'\tEnd Function'); '\tEnd Function');
//添加普通属性,因为VBScript对象不能像JS那样随意增删属性,必须在这里预先定义好 //添加普通属性,因为VBScript对象不能像JS那样随意增删属性,必须在这里预先定义好
var uniq = { var uniq = {
$vbthis: true, $vbthis: true,
@ -331,12 +331,12 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
} }
uniq[name] = true; uniq[name] = true;
buffer.push( buffer.push(
//由于不知对方会传入什么,因此set, let都用上 //由于不知对方会传入什么,因此set, let都用上
'\tPublic Property Let [' + name + '](val' + timeBucket + ')', //setter '\tPublic Property Let [' + name + '](val' + timeBucket + ')', //setter
'\t\tCall [$vbsetter](Me, [$accessors], "' + name + '", val' + timeBucket + ')', '\tEnd Property', '\tPublic Property Set [' + name + '](val' + timeBucket + ')', //setter '\t\tCall [$vbsetter](Me, [$accessors], "' + name + '", val' + timeBucket + ')', '\tEnd Property', '\tPublic Property Set [' + name + '](val' + timeBucket + ')', //setter
'\t\tCall [$vbsetter](Me, [$accessors], "' + name + '", val' + timeBucket + ')', '\tEnd Property', '\tPublic Property Get [' + name + ']', //getter '\t\tCall [$vbsetter](Me, [$accessors], "' + name + '", val' + timeBucket + ')', '\tEnd Property', '\tPublic Property Get [' + name + ']', //getter
'\tOn Error Resume Next', //必须优先使用set语句,否则它会误将数组当字符串返回 '\tOn Error Resume Next', //必须优先使用set语句,否则它会误将数组当字符串返回
'\t\tSet[' + name + '] = [$vbsetter](Me, [$accessors],"' + name + '")', '\tIf Err.Number <> 0 Then', '\t\t[' + name + '] = [$vbsetter](Me, [$accessors],"' + name + '")', '\tEnd If', '\tOn Error Goto 0', '\tEnd Property'); '\t\tSet[' + name + '] = [$vbsetter](Me, [$accessors],"' + name + '")', '\tIf Err.Number <> 0 Then', '\t\t[' + name + '] = [$vbsetter](Me, [$accessors],"' + name + '")', '\tEnd If', '\tOn Error Goto 0', '\tEnd Property');
} }
for (name in properties) { for (name in properties) {
@ -354,7 +354,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
className = makeHashCode('VBClass'); className = makeHashCode('VBClass');
window.parseVB('Class ' + className + body); window.parseVB('Class ' + className + body);
window.parseVB(['Function ' + className + 'Factory(acc, vbm)', //创建实例并传入两个关键的参数 window.parseVB(['Function ' + className + 'Factory(acc, vbm)', //创建实例并传入两个关键的参数
'\tDim o', '\tSet o = (New ' + className + ')(acc, vbm)', '\tSet ' + className + 'Factory = o', 'End Function'].join('\r\n')); '\tDim o', '\tSet o = (New ' + className + ')(acc, vbm)', '\tSet ' + className + 'Factory = o', 'End Function'].join('\r\n'));
VBClassPool[body] = className; VBClassPool[body] = className;
} }
var ret = window[className + 'Factory'](accessors, VBMediator); //得到其产品 var ret = window[className + 'Factory'](accessors, VBMediator); //得到其产品
@ -538,10 +538,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
if (this.active) { if (this.active) {
var value = this.get(); var value = this.get();
if (value !== this.value || if (value !== this.value ||
// Deep watchers and watchers on Object/Arrays should fire even // Deep watchers and watchers on Object/Arrays should fire even
// when the value is the same, because the value may // when the value is the same, because the value may
// have mutated. // have mutated.
_.isObject(value) && options && options.refresh || this.deep) { _.isObject(value) && options && options.refresh || this.deep) {
// set new value // set new value
var oldValue = this.value; var oldValue = this.value;
this.value = value; this.value = value;
@ -788,53 +788,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
function defineReactive(obj, observer, shallow) { function defineReactive(obj, observer, shallow) {
var props = {}; var props = {};
var model = void 0; var model = void 0;
// if (typeof Proxy === 'function') {
// const deps = {}, childObs = {}, cache = {}
// _.each(obj, function (val, key) {
// if (key in $$skipArray) {
// return
// }
// cache[key] = val
// const dep = deps[key] = (observer && observer['__dep' + key]) || new Dep()
// observer && (observer['__dep' + key] = dep)
// childObs[key] = !shallow && observe(val, observer, key)
// })
// return model = new Proxy(props, {
// has: function (target, key) {
// return key in obj;
// },
// get: function (target, key) {
// if (key in $$skipArray) {
// return target[key]
// }
// const value = cache[key]
// if (Dep.target) {
// deps[key].depend()
// if (childObs[key]) {
// childObs[key].dep.depend()
// if (_.isArray(value)) {
// dependArray(value)
// }
// }
// }
// return value
// },
// set: function (target, key, newVal) {
// if (key in $$skipArray) {
// return target[key] = newVal
// }
// const value = cache[key], dep = deps[key]
// if (newVal === value || (newVal !== newVal && value !== value)) {
// return newVal
// }
// cache[key] = newVal
// childObs[key] = !shallow && observe(newVal, observer, key)
// obj[key] = childObs[key] ? childObs[key].model : newVal
// notify(model, key, dep)
// return obj[key]
// }
// })
// }
_.each(obj, function (val, key) { _.each(obj, function (val, key) {
if (key in $$skipArray) { if (key in $$skipArray) {
return; return;
@ -878,6 +831,50 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
return model = createViewModel$1(obj, props); return model = createViewModel$1(obj, props);
} }
function defineReactiveProperty(obj, key, val, shallow) {
var dep = new Dep();
var configurable = isConfigurable(obj, key);
if (!configurable) {
return;
}
if (arguments.length === 2) {
val = obj[key];
}
var childOb = !shallow && observe(val);
Object.defineProperty(obj, key, {
enumerable: true,
configurable: true,
get: function reactiveGetter() {
var value = childOb ? childOb.model : val;
if (Dep.target) {
dep.depend();
if (childOb) {
childOb.dep.depend();
if (_.isArray(value)) {
dependArray(value);
}
}
}
return value;
},
set: function reactiveSetter(newVal) {
var value = childOb ? childOb.model : val;
if (newVal === value || newVal !== newVal && value !== value) {
return;
}
childOb = configurable && !shallow && observe(newVal);
val = newVal;
obj[key] = childOb ? childOb.model : newVal;
dep.notify();
}
});
}
/** /**
* Set a property on an object. Adds the new property and * Set a property on an object. Adds the new property and
* triggers change notification if the property doesn't * triggers change notification if the property doesn't
@ -1522,6 +1519,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
exports.observe = observe; exports.observe = observe;
exports.notify = notify; exports.notify = notify;
exports.defineReactive = defineReactive; exports.defineReactive = defineReactive;
exports.defineReactiveProperty = defineReactiveProperty;
exports.set = set; exports.set = set;
exports.freeze = freeze; exports.freeze = freeze;
exports.del = del; exports.del = del;

2
src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js

@ -28,7 +28,7 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
return { return {
type: "bi.combo", type: "bi.combo",
cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-focus-shadow", cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius bi-focus-shadow",
container: o.container, container: o.container,
adjustLength: 2, adjustLength: 2,
height: height, height: height,

1
src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js

@ -86,6 +86,7 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, {
stopPropagation: true, stopPropagation: true,
invisible: !BI.isNotEmptyString(stateText), invisible: !BI.isNotEmptyString(stateText),
width: o.height, width: o.height,
height: o.height,
handler: function () { handler: function () {
self.fireEvent(BI.SearchTextValueTrigger.EVENT_CLEAR); self.fireEvent(BI.SearchTextValueTrigger.EVENT_CLEAR);
}, },

2
src/case/combo/textvaluecombo/combo.textvalue.js

@ -7,7 +7,7 @@
BI.TextValueCombo = BI.inherit(BI.Widget, { BI.TextValueCombo = BI.inherit(BI.Widget, {
_defaultConfig: function (config) { _defaultConfig: function (config) {
return BI.extend(BI.TextValueCombo.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.TextValueCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-text-value-combo " + (config.simple ? "bi-border-bottom" : "bi-border"), baseCls: "bi-text-value-combo bi-border-radius " + (config.simple ? "bi-border-bottom" : "bi-border"),
height: 24, height: 24,
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
text: "", text: "",

1
src/case/trigger/trigger.text.js

@ -73,6 +73,7 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
cls: "close-h-font " + (o.allowClear ? "clear-button" : ""), cls: "close-h-font " + (o.allowClear ? "clear-button" : ""),
stopPropagation: true, stopPropagation: true,
width: o.triggerWidth || o.height, width: o.triggerWidth || o.height,
height: o.height,
invisible: !BI.isNotEmptyString(o.text), invisible: !BI.isNotEmptyString(o.text),
handler: function () { handler: function () {
self.fireEvent(BI.TextTrigger.EVENT_CLEAR); self.fireEvent(BI.TextTrigger.EVENT_CLEAR);

28
src/less/base/combo/combo.searchtextvalue.less

@ -1,33 +1,19 @@
@import "../../index.less"; @import "../../index.less";
@val: transform .3s ease;
.bi-search-text-value-combo{ .bi-search-text-value-combo {
& .trigger-icon-button{ & .trigger-icon-button {
font-size: 16px; font-size: 16px;
} }
& .search-text-value-trigger{
.border-radius(2px);
}
&.combo-error { &.combo-error {
& .bi-search-text-value-trigger{ & .bi-search-text-value-trigger {
& .bi-text-button { & .bi-text-button {
color: @color-bi-text-error-hover-search-text-value-combo; color: @color-bi-text-error-hover-search-text-value-combo;
} }
} }
&>.bi-border, &>.bi-border-bottom {
&.bi-border, &.bi-border-bottom {
border-color: @border-color-negative; border-color: @border-color-negative;
} }
} }
// 此combo的trigger_button是absolute上去的,与bi-combo在同一层级,独立写一下
& .bi-combo.bi-combo-popup + .bi-trigger-icon-button {
& .x-icon {
.rotate(180deg);
.transition(@val);
}
}
& .bi-combo + .bi-trigger-icon-button {
& .x-icon {
.rotate(0deg);
.transition(@val);
}
}
} }

1
src/router/router.js

@ -3130,6 +3130,7 @@
routes: this.options.routes, routes: this.options.routes,
base: this.options.base, base: this.options.base,
}); });
Fix.defineReactiveProperty(BI.Router.$router.history, "current");
this.$router.beforeEach(function (to, from, next) { this.$router.beforeEach(function (to, from, next) {
if (to.matched.length === 0) { if (to.matched.length === 0) {
//如果上级也未匹配到路由则跳转主页面,如果上级能匹配到则转上级路由 //如果上级也未匹配到路由则跳转主页面,如果上级能匹配到则转上级路由

Loading…
Cancel
Save