From ab46d1de7e20a221cedd846af6882178192bc2e0 Mon Sep 17 00:00:00 2001 From: Jacky Date: Tue, 25 Feb 2025 19:06:39 +0800 Subject: [PATCH] refactor: notification module --- api/certificate/certificate.go | 4 +- api/certificate/notifications.ts | 8 + .../components/Notification/Notification.vue | 3 +- app/src/components/Notification/cert.ts | 15 - app/src/components/Notification/config.ts | 96 ---- .../components/Notification/detailRender.ts | 65 --- .../components/Notification/detailRender.tsx | 26 + .../components/Notification/notifications.ts | 126 +++++ app/src/language/ar/app.po | 484 ++++++++++------ app/src/language/de_DE/app.po | 461 ++++++++++------ app/src/language/en/app.po | 459 ++++++++++------ app/src/language/es/app.po | 490 ++++++++++------- app/src/language/fr_FR/app.po | 459 ++++++++++------ app/src/language/ko_KR/app.po | 453 +++++++++------ app/src/language/messages.pot | 323 ++++++----- app/src/language/ru_RU/app.po | 488 ++++++++++------- app/src/language/tr_TR/app.po | 516 +++++++++++------- app/src/language/vi_VN/app.po | 458 ++++++++++------ app/src/language/zh_CN/app.po | 444 +++++++++------ app/src/language/zh_TW/app.po | 468 ++++++++++------ cmd/notification/generate.go | 245 +++++++++ gen.sh | 3 + internal/cert/auto_cert.go | 12 +- internal/cert/sync.go | 22 +- internal/config/sync.go | 37 +- internal/notification/notification.go | 63 +-- internal/notification/subscribe.go | 54 ++ internal/site/delete.go | 13 +- internal/site/disable.go | 6 +- internal/site/enable.go | 15 +- internal/site/rename.go | 10 +- internal/site/save.go | 19 +- internal/site/sync.go | 8 - internal/stream/delete.go | 6 +- internal/stream/disable.go | 6 +- internal/stream/enable.go | 6 +- internal/stream/rename.go | 10 +- internal/stream/save.go | 6 +- internal/stream/sync.go | 8 - internal/user/otp.go | 2 +- model/notification.go | 3 +- 41 files changed, 3989 insertions(+), 2411 deletions(-) create mode 100644 api/certificate/notifications.ts delete mode 100644 app/src/components/Notification/cert.ts delete mode 100644 app/src/components/Notification/config.ts delete mode 100644 app/src/components/Notification/detailRender.ts create mode 100644 app/src/components/Notification/detailRender.tsx create mode 100644 app/src/components/Notification/notifications.ts create mode 100644 cmd/notification/generate.go create mode 100644 internal/notification/subscribe.go diff --git a/api/certificate/certificate.go b/api/certificate/certificate.go index 3a10cf2f..094ada4e 100644 --- a/api/certificate/certificate.go +++ b/api/certificate/certificate.go @@ -133,7 +133,7 @@ func AddCert(c *gin.Context) { err = cert.SyncToRemoteServer(certModel) if err != nil { - notification.Error("Sync Certificate Error", err.Error()) + notification.Error("Sync Certificate Error", err.Error(), nil) return } @@ -188,7 +188,7 @@ func ModifyCert(c *gin.Context) { err = cert.SyncToRemoteServer(certModel) if err != nil { - notification.Error("Sync Certificate Error", err.Error()) + notification.Error("Sync Certificate Error", err.Error(), nil) return } diff --git a/api/certificate/notifications.ts b/api/certificate/notifications.ts new file mode 100644 index 00000000..2121916b --- /dev/null +++ b/api/certificate/notifications.ts @@ -0,0 +1,8 @@ +// Auto-generated notification messages +// Do not edit manually + +const notifications: Record = { + "Sync_Certificate_Error_Error": "err.Error()", +}; + +export default notifications; diff --git a/app/src/components/Notification/Notification.vue b/app/src/components/Notification/Notification.vue index b95be9c8..20a9c18c 100644 --- a/app/src/components/Notification/Notification.vue +++ b/app/src/components/Notification/Notification.vue @@ -12,6 +12,7 @@ import { message, notification } from 'ant-design-vue' import dayjs from 'dayjs' import relativeTime from 'dayjs/plugin/relativeTime' import { SSE } from 'sse.js' +import notifications from './notifications' defineProps<{ headerRef: HTMLElement @@ -181,7 +182,7 @@ function viewAll() {