|
|
@ -1,11 +1,12 @@
|
|
|
|
import classNames from 'classnames';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
|
|
|
|
import { inject, provide } from 'vue';
|
|
|
|
import PropTypes from '../_util/vue-types';
|
|
|
|
import PropTypes from '../_util/vue-types';
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
initDefaultProps,
|
|
|
|
initDefaultProps,
|
|
|
|
getOptionProps,
|
|
|
|
getOptionProps,
|
|
|
|
hasProp,
|
|
|
|
hasProp,
|
|
|
|
getComponentFromProp,
|
|
|
|
getComponent,
|
|
|
|
getListeners,
|
|
|
|
getSlot,
|
|
|
|
} from '../_util/props-util';
|
|
|
|
} from '../_util/props-util';
|
|
|
|
import BaseMixin from '../_util/BaseMixin';
|
|
|
|
import BaseMixin from '../_util/BaseMixin';
|
|
|
|
import isNumeric from '../_util/isNumeric';
|
|
|
|
import isNumeric from '../_util/isNumeric';
|
|
|
@ -76,10 +77,6 @@ export default {
|
|
|
|
name: 'ALayoutSider',
|
|
|
|
name: 'ALayoutSider',
|
|
|
|
__ANT_LAYOUT_SIDER: true,
|
|
|
|
__ANT_LAYOUT_SIDER: true,
|
|
|
|
mixins: [BaseMixin],
|
|
|
|
mixins: [BaseMixin],
|
|
|
|
model: {
|
|
|
|
|
|
|
|
prop: 'collapsed',
|
|
|
|
|
|
|
|
event: 'collapse',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
props: initDefaultProps(SiderProps, {
|
|
|
|
props: initDefaultProps(SiderProps, {
|
|
|
|
collapsible: false,
|
|
|
|
collapsible: false,
|
|
|
|
defaultCollapsed: false,
|
|
|
|
defaultCollapsed: false,
|
|
|
@ -109,21 +106,6 @@ export default {
|
|
|
|
belowShow: false,
|
|
|
|
belowShow: false,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
provide() {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
layoutSiderContext: this, // menu组件中使用
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
inject: {
|
|
|
|
|
|
|
|
siderHook: { default: () => ({}) },
|
|
|
|
|
|
|
|
configProvider: { default: () => ConfigConsumerProps },
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// getChildContext() {
|
|
|
|
|
|
|
|
// return {
|
|
|
|
|
|
|
|
// siderCollapsed: this.state.collapsed,
|
|
|
|
|
|
|
|
// collapsedWidth: this.props.collapsedWidth,
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
watch: {
|
|
|
|
collapsed(val) {
|
|
|
|
collapsed(val) {
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
@ -131,6 +113,15 @@ export default {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
|
|
|
|
provide('layoutSiderContext', this); // menu组件中使用
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
siderHook: inject('siderHook', {}),
|
|
|
|
|
|
|
|
configProvider: inject('configProvider', ConfigConsumerProps),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
mounted() {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.$nextTick(() => {
|
|
|
@ -169,6 +160,7 @@ export default {
|
|
|
|
sCollapsed: collapsed,
|
|
|
|
sCollapsed: collapsed,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$emit('update:collapsed', collapsed);
|
|
|
|
this.$emit('collapse', collapsed, type);
|
|
|
|
this.$emit('collapse', collapsed, type);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -195,7 +187,7 @@ export default {
|
|
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
|
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
|
|
|
const prefixCls = getPrefixCls('layout-sider', customizePrefixCls);
|
|
|
|
const prefixCls = getPrefixCls('layout-sider', customizePrefixCls);
|
|
|
|
|
|
|
|
|
|
|
|
const trigger = getComponentFromProp(this, 'trigger');
|
|
|
|
const trigger = getComponent(this, 'trigger');
|
|
|
|
const rawWidth = this.sCollapsed ? collapsedWidth : width;
|
|
|
|
const rawWidth = this.sCollapsed ? collapsedWidth : width;
|
|
|
|
// use "px" as fallback unit for width
|
|
|
|
// use "px" as fallback unit for width
|
|
|
|
const siderWidth = isNumeric(rawWidth) ? `${rawWidth}px` : String(rawWidth);
|
|
|
|
const siderWidth = isNumeric(rawWidth) ? `${rawWidth}px` : String(rawWidth);
|
|
|
@ -240,13 +232,12 @@ export default {
|
|
|
|
[`${prefixCls}-zero-width`]: parseFloat(siderWidth) === 0,
|
|
|
|
[`${prefixCls}-zero-width`]: parseFloat(siderWidth) === 0,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const divProps = {
|
|
|
|
const divProps = {
|
|
|
|
on: getListeners(this),
|
|
|
|
|
|
|
|
class: siderCls,
|
|
|
|
class: siderCls,
|
|
|
|
style: divStyle,
|
|
|
|
style: divStyle,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<aside {...divProps}>
|
|
|
|
<aside {...divProps}>
|
|
|
|
<div class={`${prefixCls}-children`}>{this.$slots.default}</div>
|
|
|
|
<div class={`${prefixCls}-children`}>{getSlot(this)}</div>
|
|
|
|
{collapsible || (this.below && zeroWidthTrigger) ? triggerDom : null}
|
|
|
|
{collapsible || (this.below && zeroWidthTrigger) ? triggerDom : null}
|
|
|
|
</aside>
|
|
|
|
</aside>
|
|
|
|
);
|
|
|
|
);
|
|
|
|