@coffic/cosy-ui 0.6.18 → 0.6.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.css +1 -1
- package/dist/assets/iconData.ts +5 -0
- package/dist/env.d.ts +12 -0
- package/dist/icons/AstroIcon.astro +1 -1
- package/dist/icons/InboxArchive.astro +23 -0
- package/dist/index_icons.ts +1 -0
- package/dist/index_vue.ts +10 -4
- package/dist/vue/BlogList/Basic.vue +30 -0
- package/dist/vue/BlogList/BlogList.vue +100 -0
- package/dist/vue/BlogList/Empty.vue +8 -0
- package/dist/vue/BlogList/EmptyEnglish.vue +8 -0
- package/dist/vue/BlogList/English.vue +24 -0
- package/dist/vue/BlogList/index.ts +51 -0
- package/dist/vue/Buttons/FeatureBasic.vue +8 -0
- package/dist/vue/{FeatureButton.vue → Buttons/FeatureButton.vue} +7 -10
- package/dist/vue/Buttons/FeatureWithTips.vue +8 -0
- package/dist/vue/Buttons/LinkBasic.vue +8 -0
- package/dist/vue/Buttons/LinkButton.vue +65 -0
- package/dist/vue/Buttons/Multiple.vue +11 -0
- package/dist/vue/Buttons/index.ts +59 -0
- package/dist/vue/ConfirmDialog/Basic.vue +57 -0
- package/dist/vue/ConfirmDialog/ConfirmDialog.vue +134 -0
- package/dist/vue/ConfirmDialog/CustomButtons.vue +69 -0
- package/dist/vue/ConfirmDialog/index.ts +58 -0
- package/dist/vue/Icons/InboxArchiveIcon.vue +30 -0
- package/dist/vue/SmartHero/Basic.vue +14 -0
- package/dist/vue/SmartHero/SmartHero.vue +132 -0
- package/dist/vue/SmartHero/WithCustomContent.vue +36 -0
- package/dist/vue/SmartHero/WithImage.vue +19 -0
- package/dist/vue/SmartHero/index.ts +46 -0
- package/dist/vue/SmartLink.vue +7 -11
- package/package.json +1 -1
- package/dist/vue/ConfirmDialog.vue +0 -76
- package/dist/vue/SmartHero.vue +0 -88
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
import AstroIcon from './AstroIcon.astro';
|
3
|
+
interface Props {
|
4
|
+
/**
|
5
|
+
* 图标的大小
|
6
|
+
* @default "24px"
|
7
|
+
*/
|
8
|
+
size?: string;
|
9
|
+
/**
|
10
|
+
* 图标的颜色
|
11
|
+
* @default "currentColor"
|
12
|
+
*/
|
13
|
+
color?: string;
|
14
|
+
/**
|
15
|
+
* 自定义类名
|
16
|
+
*/
|
17
|
+
class?: string;
|
18
|
+
}
|
19
|
+
|
20
|
+
const { size = '24px', color = 'currentColor', class: className = '' } = Astro.props;
|
21
|
+
---
|
22
|
+
|
23
|
+
<AstroIcon name="inboxArchive" size={size} color={color} class={className} />
|
package/dist/index_icons.ts
CHANGED
@@ -19,5 +19,6 @@ export { default as CloseIcon } from './icons/CloseIcon.astro';
|
|
19
19
|
export { default as ErrorIcon } from './icons/ErrorIcon.astro';
|
20
20
|
export { default as GithubIcon } from './icons/GithubIcon.astro';
|
21
21
|
export { default as InfoCircle } from './icons/InfoCircle.astro';
|
22
|
+
export { default as InboxArchive } from './icons/InboxArchive.astro';
|
22
23
|
export { default as SettingsIcon } from './icons/SettingsIcon.astro';
|
23
24
|
export { default as ChevronDownIcon } from './icons/ChevronDownIcon.astro';
|
package/dist/index_vue.ts
CHANGED
@@ -4,17 +4,22 @@ export { AlertDialogExamples, AlertDialogExampleCodes, AlertDialog } from './vue
|
|
4
4
|
// Banner
|
5
5
|
export { BannerBoxExamples, BannerBoxExampleCodes, BannerBox } from './vue/BannerBox';
|
6
6
|
|
7
|
+
// BlogList
|
8
|
+
export * from './vue/BlogList';
|
9
|
+
|
7
10
|
// Counter
|
8
11
|
export { default as VueCounter } from './vue/VueCounter.vue';
|
9
12
|
|
10
13
|
// SmartHero
|
11
|
-
export {
|
14
|
+
export { SmartHero, SmartHeroExamples, SmartHeroExampleCodes } from './vue/SmartHero';
|
12
15
|
|
13
16
|
// ConfirmDialog
|
14
|
-
export { default as ConfirmDialog } from './vue/ConfirmDialog.vue';
|
17
|
+
export { default as ConfirmDialog } from './vue/ConfirmDialog/ConfirmDialog.vue';
|
18
|
+
export { ConfirmDialogExamples, ConfirmDialogExampleCodes } from './vue/ConfirmDialog';
|
19
|
+
|
20
|
+
// Buttons
|
21
|
+
export * from './vue/Buttons';
|
15
22
|
|
16
|
-
// FeatureButton
|
17
|
-
export { default as FeatureButton } from './vue/FeatureButton.vue';
|
18
23
|
export { default as FeatureCard } from './vue/BannerBox/FeatureCard.vue';
|
19
24
|
|
20
25
|
// Icons
|
@@ -26,6 +31,7 @@ export { default as LinkIcon } from './vue/Icons/LinkIcon.vue';
|
|
26
31
|
export { default as MenuIcon } from './vue/Icons/MenuIcon.vue';
|
27
32
|
export { default as UserIcon } from './vue/Icons/UserIcon.vue';
|
28
33
|
export { default as XCircleIcon } from './vue/Icons/XCircleIcon.vue';
|
34
|
+
export { default as InboxArchiveIcon } from './vue/Icons/InboxArchiveIcon.vue';
|
29
35
|
|
30
36
|
// List
|
31
37
|
export { default as ListItem } from './vue/ListItem.vue';
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<template>
|
2
|
+
<BlogList :blogs="blogs" lang="zh" />
|
3
|
+
</template>
|
4
|
+
|
5
|
+
<script setup lang="ts">
|
6
|
+
import '../../style';
|
7
|
+
import { ref } from 'vue';
|
8
|
+
import BlogList from './BlogList.vue';
|
9
|
+
|
10
|
+
const blogs = ref([
|
11
|
+
{
|
12
|
+
id: '1',
|
13
|
+
title: '如何在Vue 3中使用组合式API',
|
14
|
+
link: '/blog/vue3-composition-api',
|
15
|
+
tags: ['Vue', '前端']
|
16
|
+
},
|
17
|
+
{
|
18
|
+
id: '2',
|
19
|
+
title: 'TypeScript高级类型技巧',
|
20
|
+
link: '/blog/typescript-advanced-types',
|
21
|
+
tags: ['TypeScript', '编程']
|
22
|
+
},
|
23
|
+
{
|
24
|
+
id: '3',
|
25
|
+
title: '响应式设计最佳实践',
|
26
|
+
link: '/blog/responsive-design-best-practices',
|
27
|
+
tags: ['CSS', '设计']
|
28
|
+
}
|
29
|
+
]);
|
30
|
+
</script>
|
@@ -0,0 +1,100 @@
|
|
1
|
+
<!--
|
2
|
+
@component BlogList
|
3
|
+
|
4
|
+
@description
|
5
|
+
BlogList 组件用于展示博客文章列表,支持国际化,提供空状态显示。
|
6
|
+
|
7
|
+
@usage
|
8
|
+
基本用法:
|
9
|
+
```vue
|
10
|
+
<BlogList :blogs="blogPosts" lang="zh" />
|
11
|
+
```
|
12
|
+
|
13
|
+
多语言支持:
|
14
|
+
```vue
|
15
|
+
<BlogList :blogs="blogPosts" lang="en" />
|
16
|
+
```
|
17
|
+
|
18
|
+
组合使用:
|
19
|
+
```vue
|
20
|
+
<template>
|
21
|
+
<BlogList :blogs="blogPosts" :lang="currentLang" />
|
22
|
+
</template>
|
23
|
+
|
24
|
+
<script setup lang="ts">
|
25
|
+
import { ref } from 'vue';
|
26
|
+
import { BlogList } from 'cosy-ui';
|
27
|
+
|
28
|
+
const blogPosts = ref([
|
29
|
+
{ id: '1', title: '文章标题', link: '/blog/post-1', tags: ['技术', 'Vue'] }
|
30
|
+
]);
|
31
|
+
const currentLang = ref('zh');
|
32
|
+
</script>
|
33
|
+
```
|
34
|
+
|
35
|
+
@props
|
36
|
+
@prop {IBlog[]} blogs - 博客文章数组
|
37
|
+
@prop {('zh'|'en')} [lang='zh'] - 语言设置,影响空状态显示文本
|
38
|
+
-->
|
39
|
+
|
40
|
+
<script setup lang="ts">
|
41
|
+
import '../../style';
|
42
|
+
import InboxArchiveIcon from '../Icons/InboxArchiveIcon.vue';
|
43
|
+
import Link from '../SmartLink.vue';
|
44
|
+
import ListItem from '../ListItem.vue';
|
45
|
+
|
46
|
+
export interface IBlog {
|
47
|
+
id: string;
|
48
|
+
title: string;
|
49
|
+
link: string;
|
50
|
+
tags: string[];
|
51
|
+
}
|
52
|
+
|
53
|
+
interface Props {
|
54
|
+
blogs: IBlog[];
|
55
|
+
lang?: 'zh' | 'en';
|
56
|
+
}
|
57
|
+
|
58
|
+
const props = withDefaults(defineProps<Props>(), {
|
59
|
+
lang: 'zh'
|
60
|
+
});
|
61
|
+
|
62
|
+
// 多语言文本
|
63
|
+
const messages = {
|
64
|
+
'zh': {
|
65
|
+
empty: '暂无博客文章',
|
66
|
+
checkLater: '稍后再来看看吧'
|
67
|
+
},
|
68
|
+
'en': {
|
69
|
+
empty: 'No blog posts yet',
|
70
|
+
checkLater: 'Check back later'
|
71
|
+
}
|
72
|
+
};
|
73
|
+
|
74
|
+
const t = (key: keyof typeof messages['zh']) => {
|
75
|
+
return messages[props.lang][key];
|
76
|
+
};
|
77
|
+
</script>
|
78
|
+
|
79
|
+
<template>
|
80
|
+
<div class="cosy:py-4">
|
81
|
+
<ul v-if="blogs.length > 0" class="cosy:list-none">
|
82
|
+
<ListItem v-for="blog in blogs" :key="blog.id">
|
83
|
+
<Link :href="blog.link">
|
84
|
+
{{ blog.title }}
|
85
|
+
</Link>
|
86
|
+
</ListItem>
|
87
|
+
</ul>
|
88
|
+
<div v-else class="cosy:text-center cosy:py-8">
|
89
|
+
<div class="cosy:flex cosy:flex-col cosy:items-center cosy:text-base-content/50">
|
90
|
+
<InboxArchiveIcon class="cosy:text-5xl cosy:mb-4 cosy:h-36 cosy:w-36" />
|
91
|
+
<p class="cosy:text-lg">
|
92
|
+
{{ t('empty') }}
|
93
|
+
</p>
|
94
|
+
<p class="cosy:text-sm">
|
95
|
+
{{ t('checkLater') }}
|
96
|
+
</p>
|
97
|
+
</div>
|
98
|
+
</div>
|
99
|
+
</div>
|
100
|
+
</template>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<template>
|
2
|
+
<BlogList :blogs="blogs" lang="en" />
|
3
|
+
</template>
|
4
|
+
|
5
|
+
<script setup lang="ts">
|
6
|
+
import '../../style';
|
7
|
+
import { ref } from 'vue';
|
8
|
+
import BlogList from './BlogList.vue';
|
9
|
+
|
10
|
+
const blogs = ref([
|
11
|
+
{
|
12
|
+
id: '1',
|
13
|
+
title: 'Getting Started with Vue 3 Composition API',
|
14
|
+
link: '/blog/vue3-composition-api',
|
15
|
+
tags: ['Vue', 'Frontend']
|
16
|
+
},
|
17
|
+
{
|
18
|
+
id: '2',
|
19
|
+
title: 'Advanced TypeScript Type Techniques',
|
20
|
+
link: '/blog/typescript-advanced-types',
|
21
|
+
tags: ['TypeScript', 'Programming']
|
22
|
+
}
|
23
|
+
]);
|
24
|
+
</script>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import Basic from './Basic.vue';
|
2
|
+
import Empty from './Empty.vue';
|
3
|
+
import English from './English.vue';
|
4
|
+
import EmptyEnglish from './EmptyEnglish.vue';
|
5
|
+
import BasicSource from './Basic.vue?raw';
|
6
|
+
import EmptySource from './Empty.vue?raw';
|
7
|
+
import EnglishSource from './English.vue?raw';
|
8
|
+
import EmptyEnglishSource from './EmptyEnglish.vue?raw';
|
9
|
+
|
10
|
+
// 转换Vue SFC组件为简化的示例代码(只保留template和setup script)
|
11
|
+
function extractSimpleExample(source: string): string {
|
12
|
+
// 提取模板部分
|
13
|
+
const templateMatch = source.match(/<template>([\s\S]*?)<\/template>/);
|
14
|
+
const template = templateMatch ? templateMatch[1].trim() : '';
|
15
|
+
|
16
|
+
// 提取script setup部分(去除import部分)
|
17
|
+
const scriptMatch = source.match(/<script setup lang="ts">([\s\S]*?)<\/script>/);
|
18
|
+
let script = '';
|
19
|
+
if (scriptMatch) {
|
20
|
+
// 只保留相关变量定义,去除导入语句
|
21
|
+
script = scriptMatch[1]
|
22
|
+
.replace(/import [^;]+;/g, '')
|
23
|
+
.replace(/import BlogList from '[^']+';/g, "import { BlogList } from 'cosy-ui';")
|
24
|
+
.trim();
|
25
|
+
}
|
26
|
+
|
27
|
+
// 创建简化版本的代码
|
28
|
+
return `<template>${template}</template>
|
29
|
+
|
30
|
+
<script setup lang="ts">${script}</script>`;
|
31
|
+
}
|
32
|
+
|
33
|
+
// 导出主组件
|
34
|
+
export { default as BlogList } from './BlogList.vue';
|
35
|
+
export type { IBlog } from './BlogList.vue';
|
36
|
+
|
37
|
+
// 将示例组件整合为一个对象导出
|
38
|
+
export const BlogListExamples = {
|
39
|
+
Basic,
|
40
|
+
Empty,
|
41
|
+
English,
|
42
|
+
EmptyEnglish,
|
43
|
+
};
|
44
|
+
|
45
|
+
// 导出示例组件的源代码(简化版本)
|
46
|
+
export const BlogListExampleCodes = {
|
47
|
+
Basic: extractSimpleExample(BasicSource),
|
48
|
+
Empty: extractSimpleExample(EmptySource),
|
49
|
+
English: extractSimpleExample(EnglishSource),
|
50
|
+
EmptyEnglish: extractSimpleExample(EmptyEnglishSource),
|
51
|
+
};
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<div>
|
3
3
|
<!-- Button with hover effects -->
|
4
4
|
<button :class="[
|
5
|
-
'bg-cyan-500/20
|
5
|
+
'cosy:bg-cyan-500/20 cosy:text-cyan-500 cosy:border-cyan-500 cosy:border-2 cosy:hover:bg-cyan-500/30 cosy:hover:text-white cosy:hover:border-cyan-500/30 cosy:hover:scale-105 cosy:transition-all cosy:duration-300 cosy:rounded-2xl cosy:text-center cosy:backdrop-blur-lg cosy:text-2xl',
|
6
6
|
props.size
|
7
7
|
]" @click="showPopup">
|
8
8
|
<slot />
|
@@ -11,8 +11,11 @@
|
|
11
11
|
|
12
12
|
<!-- Popup message -->
|
13
13
|
<Transition name="fade">
|
14
|
-
<div v-if="isPopupVisible"
|
15
|
-
|
14
|
+
<div v-if="isPopupVisible"
|
15
|
+
class="cosy:fixed cosy:inset-0 cosy:flex cosy:items-center cosy:justify-center cosy:z-50"
|
16
|
+
@click="hidePopup">
|
17
|
+
<div
|
18
|
+
class="cosy:bg-black/80 cosy:backdrop-blur-sm cosy:p-6 cosy:rounded-xl cosy:text-white cosy:animate-popup">
|
16
19
|
{{ lang === 'zh' ? '这是展示图,不支持操作' : 'This is a preview image, no operation is supported' }}
|
17
20
|
</div>
|
18
21
|
</div>
|
@@ -85,10 +88,4 @@ const hidePopup = () => {
|
|
85
88
|
opacity: 1;
|
86
89
|
}
|
87
90
|
}
|
88
|
-
</style>
|
89
|
-
|
90
|
-
<script lang="ts">
|
91
|
-
export default {
|
92
|
-
name: 'FeatureButton'
|
93
|
-
}
|
94
|
-
</script>
|
91
|
+
</style>
|
@@ -0,0 +1,65 @@
|
|
1
|
+
<!--
|
2
|
+
@component LinkButton
|
3
|
+
|
4
|
+
@description
|
5
|
+
LinkButton 组件是一个现代化的链接按钮,支持外部链接和路由跳转,带有动画效果。
|
6
|
+
|
7
|
+
@usage
|
8
|
+
基本用法:
|
9
|
+
```vue
|
10
|
+
<LinkButton text="了解更多" href="#" />
|
11
|
+
```
|
12
|
+
|
13
|
+
多个按钮:
|
14
|
+
```vue
|
15
|
+
<div class="cosy:flex cosy:gap-4">
|
16
|
+
<LinkButton text="了解更多" href="#" />
|
17
|
+
<LinkButton text="立即开始" href="#get-started" />
|
18
|
+
</div>
|
19
|
+
```
|
20
|
+
|
21
|
+
@props
|
22
|
+
@prop {string} text - 按钮文本
|
23
|
+
@prop {string} href - 链接地址
|
24
|
+
@prop {boolean} [openInNewTab=true] - 是否在新标签页打开链接
|
25
|
+
-->
|
26
|
+
|
27
|
+
<script setup lang="ts">
|
28
|
+
import '../../style';
|
29
|
+
|
30
|
+
defineProps({
|
31
|
+
/**
|
32
|
+
* 按钮文本
|
33
|
+
*/
|
34
|
+
text: {
|
35
|
+
type: String,
|
36
|
+
required: true
|
37
|
+
},
|
38
|
+
/**
|
39
|
+
* 链接地址
|
40
|
+
*/
|
41
|
+
href: {
|
42
|
+
type: String,
|
43
|
+
required: true
|
44
|
+
},
|
45
|
+
/**
|
46
|
+
* 是否在新标签页打开链接
|
47
|
+
* @default true
|
48
|
+
*/
|
49
|
+
openInNewTab: {
|
50
|
+
type: Boolean,
|
51
|
+
default: true
|
52
|
+
}
|
53
|
+
});
|
54
|
+
</script>
|
55
|
+
|
56
|
+
<template>
|
57
|
+
<a :href="href" :target="openInNewTab ? '_blank' : ''" class="cosy:px-6 cosy:py-3 cosy:rounded-lg cosy:bg-blue-600 cosy:text-white cosy:font-medium
|
58
|
+
cosy:transition-all cosy:duration-300 cosy:ease-in-out
|
59
|
+
cosy:no-underline
|
60
|
+
cosy:hover:bg-blue-700 cosy:hover:shadow-lg cosy:hover:-translate-y-0.5
|
61
|
+
cosy:focus:outline-none cosy:focus:ring-2 cosy:focus:ring-blue-500 cosy:focus:ring-offset-2
|
62
|
+
cosy:active:bg-blue-800 cosy:active:translate-y-0">
|
63
|
+
{{ text }}
|
64
|
+
</a>
|
65
|
+
</template>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="cosy:flex cosy:gap-4">
|
3
|
+
<LinkButton text="了解更多" href="#" />
|
4
|
+
<LinkButton text="立即开始" href="#get-started" />
|
5
|
+
</div>
|
6
|
+
</template>
|
7
|
+
|
8
|
+
<script setup lang="ts">
|
9
|
+
import '../../style';
|
10
|
+
import LinkButton from './LinkButton.vue';
|
11
|
+
</script>
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import FeatureBasic from './FeatureBasic.vue';
|
2
|
+
import FeatureWithTips from './FeatureWithTips.vue';
|
3
|
+
import Multiple from './Multiple.vue';
|
4
|
+
import LinkBasic from './LinkBasic.vue';
|
5
|
+
import FeatureBasicSource from './FeatureBasic.vue?raw';
|
6
|
+
import FeatureWithTipsSource from './FeatureWithTips.vue?raw';
|
7
|
+
import MultipleSource from './Multiple.vue?raw';
|
8
|
+
import LinkBasicSource from './LinkBasic.vue?raw';
|
9
|
+
|
10
|
+
// 转换Vue SFC组件为简化的示例代码(只保留template和setup script)
|
11
|
+
function extractSimpleExample(source: string): string {
|
12
|
+
// 提取模板部分
|
13
|
+
const templateMatch = source.match(/<template>([\s\S]*?)<\/template>/);
|
14
|
+
const template = templateMatch ? templateMatch[1].trim() : '';
|
15
|
+
|
16
|
+
// 提取script setup部分(去除import部分)
|
17
|
+
const scriptMatch = source.match(/<script setup lang="ts">([\s\S]*?)<\/script>/);
|
18
|
+
let script = '';
|
19
|
+
if (scriptMatch) {
|
20
|
+
// 只保留相关变量定义,去除导入语句
|
21
|
+
script = scriptMatch[1]
|
22
|
+
.replace(/import [^;]+;/g, '')
|
23
|
+
.replace(/import (FeatureButton|LinkButton) from '[^']+';/g, "import { $1 } from 'cosy-ui';")
|
24
|
+
.trim();
|
25
|
+
}
|
26
|
+
|
27
|
+
// 创建简化版本的代码
|
28
|
+
return `<template>${template}</template>
|
29
|
+
|
30
|
+
<script setup lang="ts">${script}</script>`;
|
31
|
+
}
|
32
|
+
|
33
|
+
// 导出组件
|
34
|
+
export { default as FeatureButton } from './FeatureButton.vue';
|
35
|
+
export { default as LinkButton } from './LinkButton.vue';
|
36
|
+
|
37
|
+
// 将示例组件整合为一个对象导出
|
38
|
+
export const ButtonsExamples = {
|
39
|
+
FeatureButton: {
|
40
|
+
Basic: FeatureBasic,
|
41
|
+
WithTips: FeatureWithTips,
|
42
|
+
},
|
43
|
+
LinkButton: {
|
44
|
+
Basic: LinkBasic,
|
45
|
+
Multiple: Multiple,
|
46
|
+
},
|
47
|
+
};
|
48
|
+
|
49
|
+
// 导出示例组件的源代码(简化版本)
|
50
|
+
export const ButtonsExampleCodes = {
|
51
|
+
FeatureButton: {
|
52
|
+
Basic: extractSimpleExample(FeatureBasicSource),
|
53
|
+
WithTips: extractSimpleExample(FeatureWithTipsSource),
|
54
|
+
},
|
55
|
+
LinkButton: {
|
56
|
+
Basic: extractSimpleExample(LinkBasicSource),
|
57
|
+
Multiple: extractSimpleExample(MultipleSource),
|
58
|
+
},
|
59
|
+
};
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<!--
|
2
|
+
@component ConfirmDialog.Basic
|
3
|
+
|
4
|
+
@description
|
5
|
+
ConfirmDialog 组件的基础示例,展示最基本的确认对话框用法。
|
6
|
+
|
7
|
+
@usage
|
8
|
+
```vue
|
9
|
+
<ConfirmDialogExamples.Basic />
|
10
|
+
```
|
11
|
+
-->
|
12
|
+
|
13
|
+
<script lang="ts">
|
14
|
+
import '../../app.css'
|
15
|
+
import { ref, defineComponent } from 'vue'
|
16
|
+
import ConfirmDialog from './ConfirmDialog.vue'
|
17
|
+
|
18
|
+
export default defineComponent({
|
19
|
+
name: 'ConfirmDialogBasicExample',
|
20
|
+
components: {
|
21
|
+
ConfirmDialog
|
22
|
+
},
|
23
|
+
setup() {
|
24
|
+
const isShow = ref(false)
|
25
|
+
const result = ref('')
|
26
|
+
|
27
|
+
const handleConfirm = () => {
|
28
|
+
result.value = '用户已确认操作'
|
29
|
+
|
30
|
+
// 3秒后清除结果
|
31
|
+
setTimeout(() => {
|
32
|
+
result.value = ''
|
33
|
+
}, 3000)
|
34
|
+
}
|
35
|
+
|
36
|
+
return {
|
37
|
+
isShow,
|
38
|
+
result,
|
39
|
+
handleConfirm
|
40
|
+
}
|
41
|
+
}
|
42
|
+
})
|
43
|
+
</script>
|
44
|
+
|
45
|
+
<template>
|
46
|
+
<div class="cosy:flex cosy:flex-col cosy:gap-4">
|
47
|
+
<button @click="isShow = true" class="cosy:btn cosy:btn-primary">
|
48
|
+
显示确认对话框
|
49
|
+
</button>
|
50
|
+
|
51
|
+
<div v-if="result" class="cosy:alert cosy:alert-success cosy:shadow-lg">
|
52
|
+
<span>{{ result }}</span>
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
|
56
|
+
<ConfirmDialog v-model="isShow" title="确认操作" message="您确定要执行此操作吗?此操作无法撤销。" @confirm="handleConfirm" />
|
57
|
+
</template>
|