This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

更新框架组件解析时的事件传递;优化表单组件的按钮事件;优化tree组件的默认配置;优化路由link及路由通知机制

old
宇天 2018-07-24 01:45:35 +08:00
parent b66123278e
commit 0f20fc7c78
7 changed files with 45 additions and 4 deletions

View File

@ -3365,6 +3365,10 @@ const _Anot = (function() {
var camelizeName = camelize(name) var camelizeName = camelize(name)
if (camelizeName.indexOf('@') === 0) { if (camelizeName.indexOf('@') === 0) {
camelizeName = camelizeName.slice(1) camelizeName = camelizeName.slice(1)
attr.value = attr.value.replace(/\(.*\)$/, '')
if (vm.$id.slice(0, 11) === '$proxy$each') {
vm = vm.$up
}
if ( if (
vm.hasOwnProperty(attr.value) && vm.hasOwnProperty(attr.value) &&
typeof vm[attr.value] === 'function' typeof vm[attr.value] === 'function'

View File

@ -3380,6 +3380,10 @@
var camelizeName = camelize(name) var camelizeName = camelize(name)
if (camelizeName.indexOf('@') === 0) { if (camelizeName.indexOf('@') === 0) {
camelizeName = camelizeName.slice(1) camelizeName = camelizeName.slice(1)
attr.value = attr.value.replace(/\(.*\)$/, '')
if (vm.$id.slice(0, 11) === '$proxy$each') {
vm = vm.$up
}
if ( if (
vm.hasOwnProperty(attr.value) && vm.hasOwnProperty(attr.value) &&
typeof vm[attr.value] === 'function' typeof vm[attr.value] === 'function'

View File

@ -3365,6 +3365,10 @@ const _Anot = (function() {
var camelizeName = camelize(name) var camelizeName = camelize(name)
if (camelizeName.indexOf('@') === 0) { if (camelizeName.indexOf('@') === 0) {
camelizeName = camelizeName.slice(1) camelizeName = camelizeName.slice(1)
attr.value = attr.value.replace(/\(.*\)$/, '')
if (vm.$id.slice(0, 11) === '$proxy$each') {
vm = vm.$up
}
if ( if (
vm.hasOwnProperty(attr.value) && vm.hasOwnProperty(attr.value) &&
typeof vm[attr.value] === 'function' typeof vm[attr.value] === 'function'

View File

@ -3380,6 +3380,10 @@
var camelizeName = camelize(name) var camelizeName = camelize(name)
if (camelizeName.indexOf('@') === 0) { if (camelizeName.indexOf('@') === 0) {
camelizeName = camelizeName.slice(1) camelizeName = camelizeName.slice(1)
attr.value = attr.value.replace(/\(.*\)$/, '')
if (vm.$id.slice(0, 11) === '$proxy$each') {
vm = vm.$up
}
if ( if (
vm.hasOwnProperty(attr.value) && vm.hasOwnProperty(attr.value) &&
typeof vm[attr.value] === 'function' typeof vm[attr.value] === 'function'

View File

@ -57,7 +57,7 @@ Anot.component('button', {
return return
} }
if (typeof this.props.click === 'function') { if (typeof this.props.click === 'function') {
this.props.click() this.props.click(this.props.prop)
} }
} }
} }
@ -299,6 +299,9 @@ Anot.component('input', {
this.active = false this.active = false
}, },
onKeyup(ev) { onKeyup(ev) {
if (this.disabled) {
return
}
if (ev.keyCode === 13) { if (ev.keyCode === 13) {
if (typeof this.props.submit === 'function') { if (typeof this.props.submit === 'function') {
this.props.submit() this.props.submit()

View File

@ -28,6 +28,7 @@ const DEFAULT_OPTIONS = {
prefix: /^(#!|#)[\/]?/, //hash前缀正则 prefix: /^(#!|#)[\/]?/, //hash前缀正则
allowReload: true //连续点击同一个链接是否重新加载 allowReload: true //连续点击同一个链接是否重新加载
} }
const LINKS = []
const RULE_REGEXP = /(:id)|(\{id\})|(\{id:([A-z\d\,\[\]\{\}\-\+\*\?\!:\^\$]*)\})/g const RULE_REGEXP = /(:id)|(\{id\})|(\{id:([A-z\d\,\[\]\{\}\-\+\*\?\!:\^\$]*)\})/g
class Router { class Router {
@ -170,7 +171,13 @@ class Router {
this.last = this.path this.last = this.path
this.path = path this.path = path
LINKS.forEach(vm => {
if (vm.rule.test(this.path)) {
vm.active = true
} else {
vm.active = false
}
})
for (let i = 0, route; (route = this.table[i++]); ) { for (let i = 0, route; (route = this.table[i++]); ) {
let args = path.match(route.regexp) let args = path.match(route.regexp)
if (args) { if (args) {
@ -220,11 +227,19 @@ class Router {
Anot.component('link', { Anot.component('link', {
__init__(props, state, next) { __init__(props, state, next) {
if (!Anot.router) {
return Anot.error('使用<anot-link />前,请先初始化路由')
}
let { mode } = Anot.router.options let { mode } = Anot.router.options
if (!props.to) { if (!props.to) {
return return
} }
this.setAttribute(':class', '{active: active}')
state.rule = Anot.router.__parseRule__(
props.to.replace(/^[\/]+|[\/]+$|\s+/g, ''),
{}
).regexp
props.label = props.label || this.textContent
if (mode === 'hash') { if (mode === 'hash') {
state.link = '#!' + props.to state.link = '#!' + props.to
} else { } else {
@ -236,8 +251,14 @@ Anot.component('link', {
render() { render() {
return '<a :attr-href="link" :text="props.label"></a>' return '<a :attr-href="link" :text="props.label"></a>'
}, },
skip: ['rule'],
componentDidMount() {
this.active = this.rule.test(Anot.router.path)
LINKS.push(this)
},
state: { state: {
link: '' link: '',
active: false
}, },
props: { props: {
label: '' label: ''

View File

@ -106,6 +106,7 @@ export default Anot.component('tree', {
} }
}, },
state: { state: {
expand: false,
__LIST_DICT__: {}, __LIST_DICT__: {},
list: [], list: [],
value: null, value: null,