Skip to content

Commit 499a4e8

Browse files
committed
chore: 添加多个组件在 FaModal 中使用的示例
1 parent 268ce5c commit 499a4e8

6 files changed

Lines changed: 133 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<script setup lang="ts">
2+
const modal = shallowRef(false)
3+
4+
function handleClick(text: string) {
5+
faToast(text)
6+
}
7+
8+
const items = [
9+
[
10+
{ label: 'Preview', icon: 'i-lucide:eye', handle: () => handleClick('Preview') },
11+
{ label: 'Duplicate', icon: 'i-lucide:copy', handle: () => handleClick('Duplicate') },
12+
],
13+
[
14+
{
15+
label: 'More',
16+
items: [
17+
[
18+
{ label: 'Share', handle: () => handleClick('Share') },
19+
],
20+
[
21+
{ label: 'Delete', variant: 'destructive' as const, handle: () => handleClick('Delete') },
22+
],
23+
],
24+
},
25+
],
26+
]
27+
</script>
28+
29+
<template>
30+
<div>
31+
<FaButton @click="modal = true">
32+
打开
33+
</FaButton>
34+
<FaModal
35+
v-model="modal"
36+
title="FaModal 中的下拉菜单"
37+
description="在模态框内容区内触发 FaDropdown"
38+
:footer="false"
39+
class="sm:max-w-2xl"
40+
content-class="min-h-auto"
41+
>
42+
<div class="py-6 flex-center">
43+
<FaDropdown :items="items">
44+
<FaButton>
45+
Actions
46+
<FaIcon name="i-ep:caret-bottom" />
47+
</FaButton>
48+
</FaDropdown>
49+
</div>
50+
</FaModal>
51+
</div>
52+
</template>

apps/example/src/views/component_example/dropdown/index.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import Demo1 from './_demo1.vue'
33
import Demo2 from './_demo2.vue'
4+
import Demo3 from './_demo3.vue'
45
</script>
56

67
<template>
@@ -16,5 +17,10 @@ import Demo2 from './_demo2.vue'
1617
<Demo2 />
1718
</div>
1819
</FaPageMain>
20+
<FaPageMain title="在 FaModal 里展示" main-class="p-0">
21+
<div class="p-4">
22+
<Demo3 />
23+
</div>
24+
</FaPageMain>
1925
</div>
2026
</template>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<script setup lang="ts">
2+
const modal = ref(false)
3+
</script>
4+
5+
<template>
6+
<div>
7+
<FaButton @click="modal = true">
8+
打开
9+
</FaButton>
10+
<FaModal
11+
v-model="modal"
12+
title="FaModal 中的图片预览"
13+
description="点击图片后仍可继续进入全屏预览"
14+
:footer="false"
15+
class="sm:max-w-3xl"
16+
content-class="min-h-auto"
17+
>
18+
<div class="py-4 flex-center">
19+
<FaImagePreview src="https://fantastic-admin.hurui.me/logo.svg" />
20+
</div>
21+
</FaModal>
22+
</div>
23+
</template>

apps/example/src/views/component_example/image_preview/index.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import Demo1 from './_demo1.vue'
33
import Demo2 from './_demo2.vue'
4+
import Demo3 from './_demo3.vue'
45
</script>
56

67
<template>
@@ -16,5 +17,10 @@ import Demo2 from './_demo2.vue'
1617
<Demo2 />
1718
</div>
1819
</FaPageMain>
20+
<FaPageMain title="在 FaModal 里展示" main-class="p-0">
21+
<div class="p-4">
22+
<Demo3 />
23+
</div>
24+
</FaPageMain>
1925
</div>
2026
</template>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<script setup lang="ts">
2+
const modal = shallowRef(false)
3+
const cityInFaModal = shallowRef('shanghai')
4+
5+
const options = [
6+
{ label: 'Beijing', value: 'beijing' },
7+
{ label: 'Shanghai', value: 'shanghai' },
8+
{ label: 'Shenzhen', value: 'shenzhen' },
9+
]
10+
</script>
11+
12+
<template>
13+
<div>
14+
<div class="flex gap-2">
15+
<FaButton @click="modal = true">
16+
打开 FaModal
17+
</FaButton>
18+
</div>
19+
<FaModal
20+
v-model="modal"
21+
title="FaModal 中的选择器"
22+
description="在模态框内容区内使用 FaSelect"
23+
:footer="false"
24+
class="sm:max-w-lg"
25+
content-class="min-h-auto"
26+
>
27+
<div class="py-4 flex flex-col gap-4">
28+
<FaSelect
29+
v-model="cityInFaModal"
30+
:options="options"
31+
placeholder="请选择城市"
32+
class="w-full"
33+
/>
34+
<div class="text-sm text-muted-foreground">
35+
当前值:{{ cityInFaModal }}
36+
</div>
37+
</div>
38+
</FaModal>
39+
</div>
40+
</template>

apps/example/src/views/component_example/select/index.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import Demo1 from './_demo1.vue'
33
import Demo2 from './_demo2.vue'
44
import Demo3 from './_demo3.vue'
5+
import Demo4 from './_demo4.vue'
56
</script>
67

78
<template>
@@ -22,5 +23,10 @@ import Demo3 from './_demo3.vue'
2223
<Demo3 />
2324
</div>
2425
</FaPageMain>
26+
<FaPageMain title="在 FaModal 里展示" main-class="p-0">
27+
<div class="p-4">
28+
<Demo4 />
29+
</div>
30+
</FaPageMain>
2531
</div>
2632
</template>

0 commit comments

Comments
 (0)