|
1
|
<template>
|
vben
authored
|
2
|
<PageWrapper title="消息示例">
|
vben
authored
|
3
|
<CollapseContainer class="w-full h-32 bg-white rounded-md" title="Message">
|
vben
authored
|
4
|
<a-button @click="infoMsg('Info message')" class="mr-2"> Info </a-button>
|
|
5
6
7
8
9
10
11
12
13
14
|
<a-button @click="successMsg('Success message')" class="mr-2" color="success">
Success
</a-button>
<a-button @click="warningMsg('Warning message')" class="mr-2" color="warning">
Warning
</a-button>
<a-button @click="errorMsg('Error message')" class="mr-2" color="error"> Error </a-button>
<a-button @click="handleLoading" class="mr-2" type="primary"> Loading </a-button>
</CollapseContainer>
|
vben
authored
|
15
|
<CollapseContainer class="w-full h-32 mt-5 bg-white rounded-md" title="Comfirm">
|
vben
authored
|
16
17
18
19
|
<a-button @click="handleConfirm('info')" class="mr-2"> Info </a-button>
<a-button @click="handleConfirm('warning')" color="warning" class="mr-2"> Warning </a-button>
<a-button @click="handleConfirm('success')" color="success" class="mr-2"> Success </a-button>
<a-button @click="handleConfirm('error')" color="error" class="mr-2"> Error </a-button>
|
|
20
21
|
</CollapseContainer>
|
vben
authored
|
22
|
<CollapseContainer class="w-full h-32 mt-5 bg-white rounded-md" title="Modal">
|
vben
authored
|
23
24
25
26
|
<a-button @click="handleInfoModal" class="mr-2"> Info </a-button>
<a-button @click="handleSuccessModal" color="success" class="mr-2"> Success </a-button>
<a-button @click="handleErrorModal" color="error" class="mr-2"> Error </a-button>
<a-button @click="handleWarningModal" color="warning" class="mr-2"> Warning </a-button>
|
|
27
28
29
|
</CollapseContainer>
<CollapseContainer
|
vben
authored
|
30
|
class="w-full h-32 mt-5 bg-white rounded-md"
|
|
31
32
|
title="Notification 用法与上面一致"
>
|
vben
authored
|
33
|
<a-button @click="handleNotify" color="success" class="mr-2"> Success </a-button>
|
|
34
|
</CollapseContainer>
|
vben
authored
|
35
|
</PageWrapper>
|
|
36
37
38
39
40
|
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { CollapseContainer } from '/@/components/Container/index';
import { useMessage } from '/@/hooks/web/useMessage';
|
vben
authored
|
41
42
|
import { PageWrapper } from '/@/components/Page';
|
|
43
|
export default defineComponent({
|
vben
authored
|
44
|
components: { CollapseContainer, PageWrapper },
|
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
setup() {
const {
createMessage,
createConfirm,
createSuccessModal,
createInfoModal,
createErrorModal,
createWarningModal,
notification,
} = useMessage();
const { info, success, warning, error } = createMessage;
function handleLoading() {
createMessage.loading('Loading...');
}
|
vben
authored
|
60
|
function handleConfirm(type: 'warning' | 'error' | 'success' | 'info') {
|
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
createConfirm({
iconType: type,
title: 'Tip',
content: 'content message...',
});
}
function handleSuccessModal() {
createSuccessModal({ title: 'Tip', content: 'content message...' });
}
function handleErrorModal() {
createErrorModal({ title: 'Tip', content: 'content message...' });
}
function handleWarningModal() {
createWarningModal({ title: 'Tip', content: 'content message...' });
}
function handleInfoModal() {
createInfoModal({ title: 'Tip', content: 'content message...' });
}
function handleNotify() {
notification.success({
message: 'Tip',
description: 'content message...',
});
}
return {
infoMsg: info,
successMsg: success,
warningMsg: warning,
errorMsg: error,
handleLoading,
handleConfirm,
handleSuccessModal,
handleErrorModal,
handleWarningModal,
handleInfoModal,
handleNotify,
};
},
});
</script>
|