-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathapp.vue
210 lines (200 loc) · 4.88 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<template>
<a-extract-style>
<a-config-provider :theme="theme">
<div class="container">
<a-date-picker />
<a-date-picker picker="week"/>
<a-range-picker />
<a-range-picker picker="week"/>
<div>
<a-space>
<a-button @click="changeTheme('dark')">
dark
</a-button>
<a-button @click="changeTheme('light')">
light
</a-button>
</a-space>
</div>
<a-alert
message="Success Text"
type="success"
/>
<div>
icon:
<AlertFilled />
<LoadingOutlined />
</div>
<a-table v-bind="tableProps" />
<a-space>
<a-button
type="primary"
@click="handleMessage('success')"
>
message success
</a-button>
<a-button @click="handleMessage('info')">
message info
</a-button>
</a-space>
<a-space>
<a-button
type="primary"
@click="handleModal('success')"
>
modal success
</a-button>
<a-button @click="handleModal('info')">
modal info
</a-button>
</a-space>
<a-space>
<a-button
type="primary"
@click="handleNotification('success')"
>
notification success
</a-button>
<a-button @click="handleNotification('info')">
notification info
</a-button>
</a-space>
<a-flex
gap="middle"
vertical
>
<a-radio-group v-model:value="value">
<a-radio value="horizontal">
horizontal
</a-radio>
<a-radio value="vertical">
vertical
</a-radio>
</a-radio-group>
<a-flex :vertical="value === 'vertical'">
<div
v-for="(item, index) in new Array(4)"
:key="item"
:style="{ ...baseStyle, background: `${index % 2 ? '#1677ff' : '#1677ffbf'}` }"
/>
</a-flex>
</a-flex>
</div>
</a-config-provider>
</a-extract-style>
</template>
<script setup lang="ts">
import { theme as antdTheme } from "ant-design-vue"
import { reactive, ref} from "#imports";
import type { CSSProperties } from 'vue';
const theme = reactive({
algorithm: antdTheme.defaultAlgorithm
})
const value = ref('horizontal');
const baseStyle: CSSProperties = {
width: '25%',
height: '54px',
};
const color = reactive({
bg:"#fff",
color:"#000"
})
const changeTheme = (type:'dark' | 'light') => {
if(type === 'dark'){
theme.algorithm = antdTheme.darkAlgorithm
color.bg = "#000"
color.color = "#fff"
}else{
theme.algorithm = antdTheme.defaultAlgorithm
color.bg = "#fff"
color.color = "#000"
}
}
const tableProps = reactive({
dataSource:[
{
key: '1',
name: 'Mike',
age: 32,
address: '10 Downing Street',
},
{
key: '2',
name: 'John',
age: 42,
address: '10 Downing Street',
},
],
columns:[
{
title: 'Name',
dataIndex: 'name',
key: 'name',
},
{
title: 'Age',
dataIndex: 'age',
key: 'age',
},
{
title: 'Address',
dataIndex: 'address',
key: 'address',
},
]
})
type StatusType = 'success' | 'info'
const handleMessage = (type:StatusType) => {
if(type === 'success')
message.success('This is a prompt message for success, and it will disappear in 10 seconds', 10);
else if(type === 'info'){
message.info('This is a prompt message for info, and it will disappear in 10 seconds', 10);
}
}
const handleModal = (type:StatusType) =>{
if(type === 'success')
Modal.success({
title: 'This is a success message',
content: 'some messages...some messages...',
});
else if(type === 'info'){
Modal.info({
title: 'This is a info message',
content: 'some messages...some messages...',
});
}
}
const handleNotification = (type:StatusType) =>{
if(type === 'success')
notification.success({
message: 'Notification Title',
description:
'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
});
else if(type === 'info'){
notification.info({
message: 'Notification Title',
description:
'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
});
}
}
</script>
<style>
*{
margin: 0;
padding: 0;
}
.container{
padding: 10px;
display: flex;
overflow-x: hidden;
overflow-y: auto;
flex-direction: column;
gap: 10px;
height: 100vh;
width: 100vw;
background-color: v-bind("color.bg");
color: v-bind("color.color");
}
</style>