-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(frontend): too many notifications when 401
- Loading branch information
1 parent
f029237
commit 95f5456
Showing
7 changed files
with
75 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package Cloudsdale |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,140 +1,146 @@ | ||
import { notifications, showNotification } from "@mantine/notifications"; | ||
import { | ||
NotificationData, | ||
showNotification, | ||
updateNotification, | ||
} from "@mantine/notifications"; | ||
import MDIcon from "@/components/ui/MDIcon"; | ||
|
||
export function showErrNotification({ | ||
id, | ||
title, | ||
message, | ||
update, | ||
}: { | ||
id?: string; | ||
title?: string; | ||
message?: string; | ||
update?: boolean; | ||
}) { | ||
if (id) { | ||
notifications.update({ | ||
id: id, | ||
title: title || "发生了错误", | ||
message: message, | ||
color: "red", | ||
icon: <MDIcon c={"white"}>close</MDIcon>, | ||
const notificationData: NotificationData = { | ||
id: id, | ||
title: title || "错误", | ||
message: message, | ||
color: "red", | ||
icon: <MDIcon c={"white"}>exclamation</MDIcon>, | ||
}; | ||
if (update) { | ||
updateNotification({ | ||
...notificationData, | ||
autoClose: 2000, | ||
withCloseButton: true, | ||
loading: false, | ||
}); | ||
return; | ||
} else { | ||
showNotification(notificationData); | ||
} | ||
showNotification({ | ||
title: title || "发生了错误", | ||
message: message, | ||
color: "red", | ||
icon: <MDIcon c={"white"}>close</MDIcon>, | ||
}); | ||
} | ||
|
||
export function showSuccessNotification({ | ||
id, | ||
title, | ||
message, | ||
update, | ||
}: { | ||
id?: string; | ||
title?: string; | ||
message?: string; | ||
update?: boolean; | ||
}) { | ||
if (id) { | ||
notifications.update({ | ||
id: id, | ||
title: title || "成功", | ||
message: message, | ||
color: "green", | ||
icon: <MDIcon c={"white"}>check</MDIcon>, | ||
const notificationData: NotificationData = { | ||
id: id, | ||
title: title || "成功", | ||
message: message, | ||
color: "green", | ||
icon: <MDIcon c={"white"}>check</MDIcon>, | ||
}; | ||
if (update) { | ||
updateNotification({ | ||
...notificationData, | ||
autoClose: 2000, | ||
withCloseButton: true, | ||
loading: false, | ||
}); | ||
return; | ||
} else { | ||
showNotification(notificationData); | ||
} | ||
showNotification({ | ||
title: title || "成功", | ||
message: message, | ||
color: "green", | ||
icon: <MDIcon c={"white"}>check</MDIcon>, | ||
}); | ||
} | ||
|
||
export function showInfoNotification({ | ||
id, | ||
title, | ||
message, | ||
update, | ||
}: { | ||
id?: string; | ||
title?: string; | ||
message?: string; | ||
update?: boolean; | ||
}) { | ||
if (id) { | ||
notifications.update({ | ||
id: id, | ||
title: title || "信息", | ||
message: message, | ||
color: "blue", | ||
icon: <MDIcon c={"white"}>info_i</MDIcon>, | ||
const notificationData: NotificationData = { | ||
id: id, | ||
title: title || "信息", | ||
message: message, | ||
color: "blue", | ||
icon: <MDIcon c={"white"}>info_i</MDIcon>, | ||
}; | ||
if (update) { | ||
updateNotification({ | ||
...notificationData, | ||
autoClose: 2000, | ||
withCloseButton: true, | ||
loading: false, | ||
}); | ||
return; | ||
} else { | ||
showNotification(notificationData); | ||
} | ||
showNotification({ | ||
title: title || "信息", | ||
message: message, | ||
color: "blue", | ||
icon: <MDIcon c={"white"}>info_i</MDIcon>, | ||
}); | ||
} | ||
|
||
export function showWarnNotification({ | ||
id, | ||
title, | ||
message, | ||
update, | ||
}: { | ||
id?: string; | ||
title?: string; | ||
message?: string; | ||
update?: boolean; | ||
}) { | ||
if (id) { | ||
notifications.update({ | ||
id: id, | ||
title: title || "警告", | ||
message: message, | ||
color: "orange", | ||
icon: <MDIcon c={"white"}>exclamation</MDIcon>, | ||
const notificationData: NotificationData = { | ||
id: id, | ||
title: title || "警告", | ||
message: message, | ||
color: "orange", | ||
icon: <MDIcon c={"white"}>exclamation</MDIcon>, | ||
}; | ||
if (update) { | ||
updateNotification({ | ||
...notificationData, | ||
autoClose: 2000, | ||
withCloseButton: true, | ||
loading: false, | ||
}); | ||
return; | ||
} else { | ||
showNotification(notificationData); | ||
} | ||
showNotification({ | ||
title: title || "警告", | ||
message: message, | ||
color: "orange", | ||
icon: <MDIcon c={"white"}>exclamation</MDIcon>, | ||
}); | ||
} | ||
|
||
export function showLoadingNotification({ | ||
id, | ||
title, | ||
message, | ||
}: { | ||
id?: string; | ||
title?: string; | ||
message?: string; | ||
}): string { | ||
const id = notifications.show({ | ||
}) { | ||
showNotification({ | ||
id: id, | ||
title: title || "请稍后", | ||
loading: true, | ||
message: message, | ||
color: "blue", | ||
autoClose: false, | ||
withCloseButton: false, | ||
}); | ||
return id; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters