feat: update vc-menu
parent
2cce6a5f55
commit
4d86a61e4d
|
@ -26,6 +26,7 @@ export default function connect (mapStateToProps) {
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
this.store = this.storeContext.store
|
this.store = this.storeContext.store
|
||||||
|
this.preProps = { ...omit(getOptionProps(this), ['__propsSymbol__']) }
|
||||||
return {
|
return {
|
||||||
subscribed: finnalMapStateToProps(this.store.getState(), this.$props),
|
subscribed: finnalMapStateToProps(this.store.getState(), this.$props),
|
||||||
}
|
}
|
||||||
|
@ -49,10 +50,10 @@ export default function connect (mapStateToProps) {
|
||||||
if (!this.unsubscribe) {
|
if (!this.unsubscribe) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const props = getOptionProps(this)
|
||||||
const nextState = finnalMapStateToProps(this.store.getState(), this.$props)
|
const nextSubscribed = finnalMapStateToProps(this.store.getState(), props)
|
||||||
if (!shallowEqual(this.subscribed, nextState)) {
|
if (!shallowEqual(this.preProps, props) || !shallowEqual(this.subscribed, nextSubscribed)) {
|
||||||
this.subscribed = nextState
|
this.subscribed = nextSubscribed
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -74,8 +75,10 @@ export default function connect (mapStateToProps) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
render () {
|
render () {
|
||||||
|
this.preProps = { ...this.$props }
|
||||||
const { $listeners, $slots = {}, $attrs, $scopedSlots, subscribed, store } = this
|
const { $listeners, $slots = {}, $attrs, $scopedSlots, subscribed, store } = this
|
||||||
const props = getOptionProps(this)
|
const props = getOptionProps(this)
|
||||||
|
this.preProps = { ...omit(props, ['__propsSymbol__']) }
|
||||||
const wrapProps = {
|
const wrapProps = {
|
||||||
props: {
|
props: {
|
||||||
...props,
|
...props,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import Horizontal from './horizontal'
|
import Horizontal from './horizontal'
|
||||||
import InlineCollapsed from './inline-collapsed'
|
import InlineCollapsed from './inline-collapsed'
|
||||||
|
import Inline from './inline'
|
||||||
import SiderCurrent from './sider-current'
|
import SiderCurrent from './sider-current'
|
||||||
import SwitchMode from './switch-mode'
|
import SwitchMode from './switch-mode'
|
||||||
import Theme from './theme'
|
import Theme from './theme'
|
||||||
|
@ -32,6 +33,7 @@ export default {
|
||||||
<md cn={md.cn} us={md.us}/>
|
<md cn={md.cn} us={md.us}/>
|
||||||
<Horizontal />
|
<Horizontal />
|
||||||
<InlineCollapsed />
|
<InlineCollapsed />
|
||||||
|
<Inline />
|
||||||
<SiderCurrent />
|
<SiderCurrent />
|
||||||
<SwitchMode />
|
<SwitchMode />
|
||||||
<Theme />
|
<Theme />
|
||||||
|
|
|
@ -162,7 +162,6 @@ const Menu = {
|
||||||
openTransitionName: this.getOpenTransitionName(),
|
openTransitionName: this.getOpenTransitionName(),
|
||||||
parentMenu: this,
|
parentMenu: this,
|
||||||
children: this.$slots.default || [],
|
children: this.$slots.default || [],
|
||||||
__propsSymbol__: Symbol(),
|
|
||||||
},
|
},
|
||||||
class: `${props.prefixCls}-root`,
|
class: `${props.prefixCls}-root`,
|
||||||
on: {
|
on: {
|
||||||
|
|
|
@ -362,7 +362,6 @@ const SubMenu = {
|
||||||
itemIcon: getComponentFromProp(this, 'itemIcon'),
|
itemIcon: getComponentFromProp(this, 'itemIcon'),
|
||||||
expandIcon: getComponentFromProp(this, 'expandIcon'),
|
expandIcon: getComponentFromProp(this, 'expandIcon'),
|
||||||
children,
|
children,
|
||||||
__propsSymbol__: Symbol(),
|
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
click: this.onSubMenuClick,
|
click: this.onSubMenuClick,
|
||||||
|
|
|
@ -37,14 +37,6 @@ export function saveRef (key, c) {
|
||||||
if (c) {
|
if (c) {
|
||||||
const index = this.instanceArrayKeyIndexMap[key]
|
const index = this.instanceArrayKeyIndexMap[key]
|
||||||
this.instanceArray[index] = c
|
this.instanceArray[index] = c
|
||||||
// const index = this.instanceArray.indexOf(c)
|
|
||||||
// if (index !== -1) {
|
|
||||||
// // update component if it's already inside instanceArray
|
|
||||||
// this.instanceArray[index] = c
|
|
||||||
// } else {
|
|
||||||
// // add component if it's not in instanceArray yet;
|
|
||||||
// this.instanceArray.push(c)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export function getActiveKey (props, originalActiveKey) {
|
export function getActiveKey (props, originalActiveKey) {
|
||||||
|
@ -145,18 +137,6 @@ const SubPopupMenu = {
|
||||||
updateActiveKey(props.store, getEventKey(props), activeKey)
|
updateActiveKey(props.store, getEventKey(props), activeKey)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// watch: {
|
|
||||||
// __propsSymbol__ () {
|
|
||||||
// const props = getOptionProps(this)
|
|
||||||
// const storeActiveKey = this.getStore().getState().activeKey[this.getEventKey()]
|
|
||||||
// const originalActiveKey = 'activeKey' in props ? props.activeKey
|
|
||||||
// : storeActiveKey
|
|
||||||
// const activeKey = getActiveKey(props, originalActiveKey)
|
|
||||||
// if (activeKey !== originalActiveKey || storeActiveKey !== activeKey) {
|
|
||||||
// updateActiveKey(this.getStore(), this.getEventKey(), activeKey)
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
methods: {
|
methods: {
|
||||||
// all keyboard events callbacks run from here at first
|
// all keyboard events callbacks run from here at first
|
||||||
onKeyDown (e, callback) {
|
onKeyDown (e, callback) {
|
||||||
|
@ -221,7 +201,7 @@ const SubPopupMenu = {
|
||||||
|
|
||||||
step (direction) {
|
step (direction) {
|
||||||
let children = this.getFlatInstanceArray()
|
let children = this.getFlatInstanceArray()
|
||||||
const activeKey = this.$props.store.getState().activeKey[this.getEventKey(this.$props)]
|
const activeKey = this.$props.store.getState().activeKey[getEventKey(this.$props)]
|
||||||
const len = children.length
|
const len = children.length
|
||||||
if (!len) {
|
if (!len) {
|
||||||
return null
|
return null
|
||||||
|
@ -290,7 +270,8 @@ const SubPopupMenu = {
|
||||||
const props = this.$props
|
const props = this.$props
|
||||||
const key = getKeyFromChildrenIndex(child, props.eventKey, i)
|
const key = getKeyFromChildrenIndex(child, props.eventKey, i)
|
||||||
const childProps = child.componentOptions.propsData || {}
|
const childProps = child.componentOptions.propsData || {}
|
||||||
const isActive = key === state.activeKey
|
|
||||||
|
const isActive = key === state.activeKey[getEventKey(this.$props)]
|
||||||
if (!childProps.disabled) {
|
if (!childProps.disabled) {
|
||||||
// manualRef的执行顺序不能保证,使用key映射ref在this.instanceArray中的位置
|
// manualRef的执行顺序不能保证,使用key映射ref在this.instanceArray中的位置
|
||||||
this.instanceArrayKeyIndexMap[key] = Object.keys(this.instanceArrayKeyIndexMap).length
|
this.instanceArrayKeyIndexMap[key] = Object.keys(this.instanceArrayKeyIndexMap).length
|
||||||
|
|
Loading…
Reference in New Issue