Skip to content

Commit d31ff7f

Browse files
authored
Merge pull request #13 from viiccwen/feature/sonner
Integrate `vue-sonner` for Toast Notifications
2 parents fbf1e90 + c617611 commit d31ff7f

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"@vuepic/vue-datepicker": "^8.1.1",
1616
"ics": "^3.7.2",
1717
"primevue": "^4.2.4",
18-
"vue": "^3.2.45"
18+
"vue": "^3.2.45",
19+
"vue-sonner": "^1.3.0"
1920
},
2021
"devDependencies": {
2122
"@eslint/js": "^9.22.0",

pnpm-lock.yaml

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<script setup>
2-
import DatePicker from "primevue/datepicker";
3-
import "@vuepic/vue-datepicker/dist/main.css";
4-
import { ref } from "vue";
5-
import * as ics from "ics";
2+
import DatePicker from 'primevue/datepicker';
3+
import '@vuepic/vue-datepicker/dist/main.css'
4+
import { ref } from 'vue';
5+
import * as ics from 'ics';
6+
import { Toaster, toast } from 'vue-sonner';
7+
68
79
const startDate = ref();
810
const endDate = ref();
@@ -220,15 +222,15 @@ function createEvents(courses, curriculum, classRooms) {
220222
221223
function downloadFile() {
222224
if (!startDate.value || !endDate.value) {
223-
alert("請選擇起始日期和結束日期!");
225+
toast.error('請選擇起始日期和結束日期!');
224226
return;
225227
}
226-
if (new Date(startDate.value) > new Date(endDate.value)) {
227-
alert("結束日期需大於起始日期!");
228+
if(new Date(startDate.value) > new Date(endDate.value)) {
229+
toast('結束日期需大於起始日期!');
228230
return;
229231
}
230232
if (!curriculumFile.value || !curriculumFile.value.files[0]) {
231-
alert("請上傳課表網頁檔案!");
233+
toast('請上傳課表網頁檔案!');
232234
return;
233235
}
234236
@@ -300,6 +302,7 @@ function downloadFile() {
300302
</script>
301303

302304
<template>
305+
<Toaster richColors />
303306
<img alt="Logo" src="./assets/ntust_so_hard.png" class="logo" />
304307
<h1 class="title">NTUST Calendar Maker</h1>
305308
<p>製作 .ics 檔案以匯入通用日曆軟體!</p>

0 commit comments

Comments
 (0)