Skip to content

Commit

Permalink
add login first notice
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxkad committed Mar 21, 2024
1 parent 6877264 commit 0adaa66
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dashboard/src/assets/lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions dashboard/src/assets/lang/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
"login-to-view": "后查看日志"
},
"settings": {
"login": {
"first": "启用此功能前请先登录"
},
"notify": {
"cant.enable": "无法启用通知",
"denied": "通知已被浏览器拒绝"
Expand Down
8 changes: 8 additions & 0 deletions dashboard/src/views/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ async function onEnableNotify(): Promise<void> {
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') {
Expand Down

0 comments on commit 0adaa66

Please sign in to comment.