|
1 | 1 | <template>
|
2 |
| - <div> |
3 |
| - Nuxt module playground! |
4 |
| - </div> |
| 2 | + <a-config-provider :theme="theme"> |
| 3 | + <div class="container"> |
| 4 | + <div> |
| 5 | + <a-space> |
| 6 | + <a-button @click="changeTheme('dark')"> |
| 7 | + dark |
| 8 | + </a-button> |
| 9 | + <a-button @click="changeTheme('light')"> |
| 10 | + light |
| 11 | + </a-button> |
| 12 | + </a-space> |
| 13 | + </div> |
| 14 | + <a-alert |
| 15 | + message="Success Text" |
| 16 | + type="success" |
| 17 | + /> |
| 18 | + <div> |
| 19 | + icon: |
| 20 | + <AlertFilled /> |
| 21 | + <LoadingOutlined /> |
| 22 | + </div> |
| 23 | + <a-table v-bind="tableProps" /> |
| 24 | + <a-space> |
| 25 | + <a-button |
| 26 | + type="primary" |
| 27 | + @click="handleMessage('success')" |
| 28 | + > |
| 29 | + message success |
| 30 | + </a-button> |
| 31 | + <a-button @click="handleMessage('info')"> |
| 32 | + message info |
| 33 | + </a-button> |
| 34 | + </a-space> |
| 35 | + <a-space> |
| 36 | + <a-button |
| 37 | + type="primary" |
| 38 | + @click="handleModal('success')" |
| 39 | + > |
| 40 | + modal success |
| 41 | + </a-button> |
| 42 | + <a-button @click="handleModal('info')"> |
| 43 | + modal info |
| 44 | + </a-button> |
| 45 | + </a-space> |
| 46 | + <a-space> |
| 47 | + <a-button |
| 48 | + type="primary" |
| 49 | + @click="handleNotification('success')" |
| 50 | + > |
| 51 | + notification success |
| 52 | + </a-button> |
| 53 | + <a-button @click="handleNotification('info')"> |
| 54 | + notification info |
| 55 | + </a-button> |
| 56 | + </a-space> |
| 57 | + </div> |
| 58 | + </a-config-provider> |
5 | 59 | </template>
|
6 | 60 |
|
7 |
| -<script setup> |
| 61 | +<script setup lang="ts"> |
| 62 | +import { theme as antdTheme } from "ant-design-vue" |
| 63 | +import { reactive } from "#imports"; |
| 64 | +const theme = reactive({ |
| 65 | + algorithm: antdTheme.defaultAlgorithm |
| 66 | +}) |
| 67 | +
|
| 68 | +const color = reactive({ |
| 69 | + bg:"#fff", |
| 70 | + color:"#000" |
| 71 | +}) |
| 72 | +const changeTheme = (type:'dark' | 'light') => { |
| 73 | + if(type === 'dark'){ |
| 74 | + theme.algorithm = antdTheme.darkAlgorithm |
| 75 | + color.bg = "#000" |
| 76 | + color.color = "#fff" |
| 77 | + }else{ |
| 78 | + theme.algorithm = antdTheme.defaultAlgorithm |
| 79 | + color.bg = "#fff" |
| 80 | + color.color = "#000" |
| 81 | + } |
| 82 | +} |
| 83 | +
|
| 84 | +
|
| 85 | +const tableProps = reactive({ |
| 86 | + dataSource:[ |
| 87 | + { |
| 88 | + key: '1', |
| 89 | + name: 'Mike', |
| 90 | + age: 32, |
| 91 | + address: '10 Downing Street', |
| 92 | + }, |
| 93 | + { |
| 94 | + key: '2', |
| 95 | + name: 'John', |
| 96 | + age: 42, |
| 97 | + address: '10 Downing Street', |
| 98 | + }, |
| 99 | + ], |
| 100 | + columns:[ |
| 101 | + { |
| 102 | + title: 'Name', |
| 103 | + dataIndex: 'name', |
| 104 | + key: 'name', |
| 105 | + }, |
| 106 | + { |
| 107 | + title: 'Age', |
| 108 | + dataIndex: 'age', |
| 109 | + key: 'age', |
| 110 | + }, |
| 111 | + { |
| 112 | + title: 'Address', |
| 113 | + dataIndex: 'address', |
| 114 | + key: 'address', |
| 115 | + }, |
| 116 | + ] |
| 117 | +}) |
| 118 | +
|
| 119 | +type StatusType = 'success' | 'info' |
| 120 | +
|
| 121 | +const handleMessage = (type:StatusType) => { |
| 122 | + if(type === 'success') |
| 123 | + message.success('This is a prompt message for success, and it will disappear in 10 seconds', 10); |
| 124 | + else if(type === 'info'){ |
| 125 | + message.info('This is a prompt message for info, and it will disappear in 10 seconds', 10); |
| 126 | + } |
| 127 | +} |
| 128 | +
|
| 129 | +const handleModal = (type:StatusType) =>{ |
| 130 | + if(type === 'success') |
| 131 | + Modal.success({ |
| 132 | + title: 'This is a success message', |
| 133 | + content: 'some messages...some messages...', |
| 134 | + }); |
| 135 | + else if(type === 'info'){ |
| 136 | + Modal.info({ |
| 137 | + title: 'This is a info message', |
| 138 | + content: 'some messages...some messages...', |
| 139 | + }); |
| 140 | + } |
| 141 | +} |
| 142 | +
|
| 143 | +const handleNotification = (type:StatusType) =>{ |
| 144 | + if(type === 'success') |
| 145 | + notification.success({ |
| 146 | + message: 'Notification Title', |
| 147 | + description: |
| 148 | + 'This is the content of the notification. This is the content of the notification. This is the content of the notification.', |
| 149 | + }); |
| 150 | + else if(type === 'info'){ |
| 151 | + notification.info({ |
| 152 | + message: 'Notification Title', |
| 153 | + description: |
| 154 | + 'This is the content of the notification. This is the content of the notification. This is the content of the notification.', |
| 155 | + }); |
| 156 | + } |
| 157 | +} |
8 | 158 | </script>
|
| 159 | + |
| 160 | +<style> |
| 161 | +*{ |
| 162 | + margin: 0; |
| 163 | + padding: 0; |
| 164 | +} |
| 165 | +.container{ |
| 166 | + padding: 10px; |
| 167 | + display: flex; |
| 168 | + overflow-x: hidden; |
| 169 | + overflow-y: auto; |
| 170 | + flex-direction: column; |
| 171 | + gap: 10px; |
| 172 | + height: 100vh; |
| 173 | + width: 100vw; |
| 174 | + background-color: v-bind("color.bg"); |
| 175 | + color: v-bind("color.color"); |
| 176 | +} |
| 177 | +
|
| 178 | +</style> |
0 commit comments