1- import { defineComponent , ref , toRefs , watch } from 'vue'
1+ import { defineComponent , ref , toRefs , watch , computed } from 'vue'
22import { drawerProps , DrawerProps } from './drawer-types'
33
44import DrawerHeader from './components/drawer-header'
@@ -11,9 +11,12 @@ export default defineComponent({
1111 props : drawerProps ,
1212 emits : [ 'close' , 'update:visible' , 'afterOpened' ] ,
1313 setup ( props : DrawerProps , { emit, slots } ) {
14- const { width, visible, zIndex, isCover, escKeyCloseable } = toRefs ( props ) ; // 宽度
14+ const { width, visible, zIndex, isCover, escKeyCloseable, position } = toRefs ( props ) ; // 宽度
1515 const isFullScreen = ref ( false ) ;
1616
17+ const navWidth = computed ( ( ) => isFullScreen . value ? '100vw' : width . value ) ;
18+ const navRight = computed ( ( ) => position . value === 'right' ? { 'right' : 0 } : { 'left' : 0 } ) ;
19+
1720 const fullScreenEvent = ( ) => {
1821 isFullScreen . value = ! isFullScreen . value ;
1922 }
@@ -43,29 +46,29 @@ export default defineComponent({
4346 return {
4447 zIndex,
4548 isFullScreen,
46- width ,
49+ navWidth ,
4750 visible,
4851 slots,
4952 isCover,
53+ navRight,
5054 fullScreenEvent,
5155 closeDrawer,
5256 } ;
5357 } ,
5458 render ( ) {
5559 const zindex : number = this . zIndex ;
56- const width : number = this . isFullScreen ? '100vw' : this . width ;
5760 const fullScreenEvent : any = this . fullScreenEvent ;
5861 const closeDrawer : any = this . closeDrawer ;
5962 const isCover : boolean = this . isCover ;
63+ const navRight : Record < string , unknown > = this . navRight ;
6064
6165 if ( ! this . visible ) return ;
6266
6367 return (
64- < div class = "devui-drawer" style = { { zIndex : zindex } } >
65- { /* TODO : 有遮罩层时才能点击关闭 onClick={ closeDrawer }*/ }
68+ < div class = "devui-drawer" style = { { zIndex : zindex } } onClick = { closeDrawer } >
6669 { isCover ? < div class = "devui-overlay-backdrop" /> : '' }
67- < div class = "devui-overlay-wrapper" >
68- < div class = "devui-drawer-nav" style = { { 'left ' : 0 , 'width' : width } } >
70+ < div class = "devui-overlay-wrapper" >
71+ < div class = "devui-drawer-nav" style = { { 'width ' : this . navWidth , ... navRight } } >
6972 < div class = "devui-drawer-content" >
7073 < DrawerHeader onToggleFullScreen = { fullScreenEvent } onClose = { closeDrawer } />
7174 < div > { this . slots . default ? this . slots . default ( ) : < DrawerContainer /> } </ div >
0 commit comments