-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'x-extends:master' into master
- Loading branch information
Showing
61 changed files
with
1,736 additions
and
475 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<template> | ||
<div> | ||
<p> | ||
<vxe-button content="左侧打开" @click="demo1.value1 = true"></vxe-button> | ||
<vxe-drawer v-model="demo1.value1" position="left"> | ||
<template #default> | ||
<div>默认尺寸</div> | ||
<div>xxxxxxxxx</div> | ||
<div>xxxxxxxxxx</div> | ||
</template> | ||
</vxe-drawer> | ||
|
||
<vxe-button content="右侧打开" @click="demo1.value2 = true"></vxe-button> | ||
<vxe-drawer v-model="demo1.value2" position="right"> | ||
<template #default> | ||
<div>默认尺寸</div> | ||
<div>xxxxxxxxx</div> | ||
<div>xxxxxxxxxx</div> | ||
</template> | ||
</vxe-drawer> | ||
|
||
<vxe-button content="顶部打开" @click="demo1.value3 = true"></vxe-button> | ||
<vxe-drawer v-model="demo1.value3" position="top"> | ||
<template #default> | ||
<div>默认尺寸</div> | ||
<div>xxxxxxxxx</div> | ||
<div>xxxxxxxxxx</div> | ||
</template> | ||
</vxe-drawer> | ||
|
||
<vxe-button content="底部打开" @click="demo1.value4 = true"></vxe-button> | ||
<vxe-drawer v-model="demo1.value4" position="bottom"> | ||
<template #default> | ||
<div>默认尺寸</div> | ||
<div>xxxxxxxxx</div> | ||
<div>xxxxxxxxxx</div> | ||
</template> | ||
</vxe-drawer> | ||
</p> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { reactive } from 'vue' | ||
const demo1 = reactive({ | ||
value1: false, | ||
value2: false, | ||
value3: false, | ||
value4: false | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { VxeDrawer } from '../../types/drawer' | ||
|
||
export * from '../../types/drawer' | ||
export default VxeDrawer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { App } from 'vue' | ||
import XEUtils from 'xe-utils' | ||
import VxeDrawerComponent, { allActiveDrawers } from './src/modal' | ||
import { VXETable } from '../v-x-e-table' | ||
import { dynamicApp, dynamicStore, checkDynamic } from '../dynamics' | ||
|
||
import { VxeDrawerPropTypes, DrawerEventTypes, VxeDrawerDefines } from '../../types' | ||
|
||
function openDrawer (options: VxeDrawerDefines.DrawerOptions): Promise<DrawerEventTypes> { | ||
// 使用动态组件渲染动态弹框 | ||
checkDynamic() | ||
return new Promise(resolve => { | ||
if (options && options.id && allActiveDrawers.some(comp => comp.props.id === options.id)) { | ||
resolve('exist') | ||
} else { | ||
const _onHide = options.onHide | ||
const drawerOpts = Object.assign(options, { | ||
key: XEUtils.uniqueId(), | ||
modelValue: true, | ||
onHide (params) { | ||
const drawerList = dynamicStore.drawers | ||
if (_onHide) { | ||
_onHide(params) | ||
} | ||
dynamicStore.drawers = drawerList.filter(item => item.key !== drawerOpts.key) | ||
resolve(params.type) | ||
} | ||
} as VxeDrawerDefines.DrawerOptions) | ||
dynamicStore.drawers.push(drawerOpts) | ||
} | ||
}) | ||
} | ||
|
||
function getDrawer (id: VxeDrawerPropTypes.ID) { | ||
return XEUtils.find(allActiveDrawers, $drawer => $drawer.props.id === id) | ||
} | ||
|
||
/** | ||
* 全局关闭动态的活动窗口(只能用于关闭动态的创建的活动窗口) | ||
* 如果传 id 则关闭指定的窗口 | ||
* 如果不传则关闭所有窗口 | ||
*/ | ||
function closeDrawer (id?: VxeDrawerPropTypes.ID) { | ||
const drawers = id ? [getDrawer(id)] : allActiveDrawers | ||
const restPromises: any[] = [] | ||
drawers.forEach($drawer => { | ||
if ($drawer) { | ||
restPromises.push($drawer.close()) | ||
} | ||
}) | ||
return Promise.all(restPromises) | ||
} | ||
|
||
const DrawerController = { | ||
get: getDrawer, | ||
close: closeDrawer, | ||
open: openDrawer | ||
} | ||
|
||
export const drawer = DrawerController | ||
|
||
export const VxeDrawer = Object.assign(VxeDrawerComponent, { | ||
install: function (app: App) { | ||
app.component(VxeDrawerComponent.name as string, VxeDrawerComponent) | ||
VXETable.drawer = DrawerController | ||
} | ||
}) | ||
|
||
dynamicApp.component(VxeDrawerComponent.name as string, VxeDrawerComponent) | ||
|
||
export const Drawer = VxeDrawer | ||
|
||
export default VxeDrawer |
Oops, something went wrong.