From 0adaa66b8eef4dac0bccc03398f2ccc80496e896 Mon Sep 17 00:00:00 2001 From: zyxkad Date: Thu, 21 Mar 2024 12:14:48 -0600 Subject: [PATCH] add login first notice --- dashboard/src/assets/lang/en-US.json | 3 +++ dashboard/src/assets/lang/zh-CN.json | 3 +++ dashboard/src/views/SettingsView.vue | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/dashboard/src/assets/lang/en-US.json b/dashboard/src/assets/lang/en-US.json index 31c3a780..263ee61c 100644 --- a/dashboard/src/assets/lang/en-US.json +++ b/dashboard/src/assets/lang/en-US.json @@ -54,6 +54,9 @@ "login-to-view": " to view logs" }, "settings": { + "login": { + "first": "Please login first before enable this feature" + }, "notify": { "cant.enable": "Cannot enable notification", "denied": "Notification is denied by the browser" diff --git a/dashboard/src/assets/lang/zh-CN.json b/dashboard/src/assets/lang/zh-CN.json index d3556c7f..760415a9 100644 --- a/dashboard/src/assets/lang/zh-CN.json +++ b/dashboard/src/assets/lang/zh-CN.json @@ -54,6 +54,9 @@ "login-to-view": "后查看日志" }, "settings": { + "login": { + "first": "启用此功能前请先登录" + }, "notify": { "cant.enable": "无法启用通知", "denied": "通知已被浏览器拒绝" diff --git a/dashboard/src/views/SettingsView.vue b/dashboard/src/views/SettingsView.vue index 80dad1a7..56b3ce0d 100644 --- a/dashboard/src/views/SettingsView.vue +++ b/dashboard/src/views/SettingsView.vue @@ -96,6 +96,14 @@ async function onEnableNotify(): Promise { enableNotify.value = false return } + if (!token.value) { + toast.add({ + severity: 'error', + summary: tr('message.settings.login.first'), + life: 5000, + }) + return + } requestingPermission.value = true try { if ((await Notification.requestPermission()) !== 'granted') {