Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 46768952
authored
Jan 11, 2025
by
Netfan
Committed by
GitHub
Jan 11, 2025
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
perf: add nested modal demo (#5353)
1 parent
1a04a05b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
21 deletions
playground/src/views/examples/modal/index.vue
playground/src/views/examples/modal/nested-demo.vue
playground/src/views/examples/modal/index.vue
View file @
4676895
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
Page
,
useVbenModal
}
from
'@vben/common-ui'
;
import
{
Page
,
useVbenModal
}
from
'@vben/common-ui'
;
import
{
Button
,
Card
}
from
'ant-design-vue'
;
import
{
Button
,
Card
,
Flex
}
from
'ant-design-vue'
;
import
DocButton
from
'../doc-button.vue'
;
import
DocButton
from
'../doc-button.vue'
;
import
AutoHeightDemo
from
'./auto-height-demo.vue'
;
import
AutoHeightDemo
from
'./auto-height-demo.vue'
;
...
@@ -10,6 +10,7 @@ import DragDemo from './drag-demo.vue';
...
@@ -10,6 +10,7 @@ import DragDemo from './drag-demo.vue';
import
DynamicDemo
from
'./dynamic-demo.vue'
;
import
DynamicDemo
from
'./dynamic-demo.vue'
;
import
FormModalDemo
from
'./form-modal-demo.vue'
;
import
FormModalDemo
from
'./form-modal-demo.vue'
;
import
InContentModalDemo
from
'./in-content-demo.vue'
;
import
InContentModalDemo
from
'./in-content-demo.vue'
;
import
NestedDemo
from
'./nested-demo.vue'
;
import
SharedDataDemo
from
'./shared-data-demo.vue'
;
import
SharedDataDemo
from
'./shared-data-demo.vue'
;
const
[
BaseModal
,
baseModalApi
]
=
useVbenModal
({
const
[
BaseModal
,
baseModalApi
]
=
useVbenModal
({
...
@@ -42,6 +43,10 @@ const [FormModal, formModalApi] = useVbenModal({
...
@@ -42,6 +43,10 @@ const [FormModal, formModalApi] = useVbenModal({
connectedComponent
:
FormModalDemo
,
connectedComponent
:
FormModalDemo
,
});
});
const
[
NestedModal
,
nestedModalApi
]
=
useVbenModal
({
connectedComponent
:
NestedDemo
,
});
function
openBaseModal
()
{
function
openBaseModal
()
{
baseModalApi
.
open
();
baseModalApi
.
open
();
}
}
...
@@ -71,6 +76,10 @@ function openSharedModal() {
...
@@ -71,6 +76,10 @@ function openSharedModal() {
.
open
();
.
open
();
}
}
function
openNestedModal
()
{
nestedModalApi
.
open
();
}
function
handleUpdateTitle
()
{
function
handleUpdateTitle
()
{
dynamicModalApi
.
setState
({
title
:
'外部动态标题'
}).
open
();
dynamicModalApi
.
setState
({
title
:
'外部动态标题'
}).
open
();
}
}
...
@@ -101,44 +110,72 @@ function openFormModal() {
...
@@ -101,44 +110,72 @@ function openFormModal() {
<DynamicModal
/>
<DynamicModal
/>
<SharedDataModal
/>
<SharedDataModal
/>
<FormModal
/>
<FormModal
/>
<Card
class=
"mb-4"
title=
"基本使用"
>
<NestedModal
/>
<p
class=
"mb-3"
>
一个基础的弹窗示例
</p>
<Flex
wrap=
"wrap"
class=
"w-full"
gap=
"10"
>
<Card
class=
"w-[300px]"
title=
"基本使用"
>
<p>
一个基础的弹窗示例
</p>
<
template
#
actions
>
<Button
type=
"primary"
@
click=
"openBaseModal"
>
打开弹窗
</Button>
<Button
type=
"primary"
@
click=
"openBaseModal"
>
打开弹窗
</Button>
</
template
>
</Card>
</Card>
<Card
class=
"mb-4"
title=
"指定容器"
>
<Card
class=
"w-[300px]"
title=
"指定容器"
>
<p
class=
"mb-3"
>
在内容区域打开弹窗的示例
</p>
<p>
在内容区域打开弹窗的示例
</p>
<
template
#
actions
>
<Button
type=
"primary"
@
click=
"openInContentModal"
>
打开弹窗
</Button>
<Button
type=
"primary"
@
click=
"openInContentModal"
>
打开弹窗
</Button>
</
template
>
</Card>
</Card>
<Card
class=
"mb-4"
title=
"内容高度自适应"
>
<Card
class=
"w-[300px]"
title=
"内容高度自适应"
>
<p
class=
"mb-3"
>
可根据内容并自动调整高度
</p>
<p>
可根据内容并自动调整高度
</p>
<Button
type=
"primary"
@
click=
"openAutoHeightModal"
>
打开弹窗
</Button>
<
template
#
actions
>
<Button
type=
"primary"
@
click=
"openAutoHeightModal"
>
打开弹窗
</Button>
</
template
>
</Card>
</Card>
<Card
class=
"mb-4"
title=
"可拖拽示例"
>
<Card
class=
"w-[300px]"
title=
"可拖拽示例"
>
<p
class=
"mb-3"
>
配置 draggable 可开启拖拽功能
</p>
<p>
配置 draggable 可开启拖拽功能
</p>
<Button
type=
"primary"
@
click=
"openDragModal"
>
打开弹窗
</Button>
<
template
#
actions
>
<Button
type=
"primary"
@
click=
"openDragModal"
>
打开弹窗
</Button>
</
template
>
</Card>
</Card>
<Card
class=
"mb-4"
title=
"动态配置示例"
>
<Card
class=
"w-[300px]"
title=
"动态配置示例"
>
<p
class=
"mb-3"
>
通过 setState 动态调整弹窗数据
</p>
<p>
通过 setState 动态调整弹窗数据
</p>
<Button
type=
"primary"
@
click=
"openDynamicModal"
>
打开弹窗
</Button>
<
template
#
extra
>
<Button
class=
"ml-2"
type=
"primary"
@
click=
"handleUpdateTitle"
>
<Button
type=
"link"
@
click=
"openDynamicModal"
>
打开弹窗
</Button>
从外部修改标题并打开
</
template
>
<
template
#
actions
>
<Button
type=
"primary"
@
click=
"handleUpdateTitle"
>
外部修改标题并打开
</Button>
</Button>
</
template
>
</Card>
</Card>
<Card
class=
"mb-4"
title=
"内外数据共享示例"
>
<Card
class=
"w-[300px]"
title=
"内外数据共享示例"
>
<p
class=
"mb-3"
>
通过共享 sharedData 来进行数据交互
</p>
<p>
通过共享 sharedData 来进行数据交互
</p>
<
template
#
actions
>
<Button
type=
"primary"
@
click=
"openSharedModal"
>
<Button
type=
"primary"
@
click=
"openSharedModal"
>
打开弹窗并传递数据
打开弹窗并传递数据
</Button>
</Button>
</
template
>
</Card>
</Card>
<Card
class=
"mb-4"
title=
"表单弹窗示例"
>
<Card
class=
"w-[300px]"
title=
"表单弹窗示例"
>
<p
class=
"mb-3"
>
弹窗与表单结合
</p>
<p>
弹窗与表单结合
</p>
<Button
type=
"primary"
@
click=
"openFormModal"
>
打开弹窗
</Button>
<
template
#
actions
>
<Button
type=
"primary"
@
click=
"openFormModal"
>
打开表单弹窗
</Button>
</
template
>
</Card>
<Card
class=
"w-[300px]"
title=
"嵌套弹窗示例"
>
<p>
在已经打开的弹窗中再次打开弹窗
</p>
<
template
#
actions
>
<Button
type=
"primary"
@
click=
"openNestedModal"
>
打开嵌套弹窗
</Button>
</
template
>
</Card>
</Card>
</Flex>
</Page>
</Page>
</template>
</template>
playground/src/views/examples/modal/nested-demo.vue
0 → 100644
View file @
4676895
<
script
lang=
"ts"
setup
>
import
{
useVbenModal
}
from
'@vben/common-ui'
;
import
{
Button
}
from
'ant-design-vue'
;
import
DragDemo
from
'./drag-demo.vue'
;
const
[
Modal
]
=
useVbenModal
({
destroyOnClose
:
true
,
});
const
[
BaseModal
,
baseModalApi
]
=
useVbenModal
({
connectedComponent
:
DragDemo
,
});
function
openNestedModal
()
{
baseModalApi
.
open
();
}
</
script
>
<
template
>
<Modal
title=
"嵌套弹窗示例"
>
<Button
@
click=
"openNestedModal"
type=
"primary"
>
打开子弹窗
</Button>
<BaseModal
/>
</Modal>
</
template
>
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment