From dfbd364f60825e82b9524264b96ba4778b527444 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=98=AD?= <81747598+lan-yonghui@users.noreply.github.com>
Date: Fri, 29 Aug 2025 13:56:15 +0800
Subject: [PATCH] fix: Fix the initialization issue of alert tasks (#10191)
---
agent/init/hook/hook.go | 6 ++++++
frontend/src/lang/modules/en.ts | 3 ++-
frontend/src/lang/modules/ja.ts | 3 ++-
frontend/src/lang/modules/ko.ts | 3 ++-
frontend/src/lang/modules/ms.ts | 3 ++-
frontend/src/lang/modules/pt-br.ts | 3 ++-
frontend/src/lang/modules/ru.ts | 3 ++-
frontend/src/lang/modules/tr.ts | 3 ++-
frontend/src/lang/modules/zh-Hant.ts | 2 +-
frontend/src/lang/modules/zh.ts | 2 +-
frontend/src/views/setting/alert/dash/index.vue | 14 +++++++++++---
.../src/views/setting/alert/dash/task/index.vue | 6 +++---
12 files changed, 36 insertions(+), 15 deletions(-)
diff --git a/agent/init/hook/hook.go b/agent/init/hook/hook.go
index cf2194874..e8488ec11 100644
--- a/agent/init/hook/hook.go
+++ b/agent/init/hook/hook.go
@@ -1,6 +1,7 @@
package hook
import (
+ "github.com/1Panel-dev/1Panel/agent/app/service"
"github.com/1Panel-dev/1Panel/agent/utils/alert_push"
"os"
"strings"
@@ -23,6 +24,7 @@ func Init() {
loadLocalDir()
initDockerConf()
+ initAlertTask()
}
func initGlobalData() {
@@ -125,3 +127,7 @@ func initDockerConf() {
constant.DaemonJsonPath = "/var/snap/docker/current/config/daemon.json"
}
}
+
+func initAlertTask() {
+ service.NewIAlertTaskHelper().ResetTask()
+}
diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts
index 3184d158f..12df91777 100644
--- a/frontend/src/lang/modules/en.ts
+++ b/frontend/src/lang/modules/en.ts
@@ -3759,7 +3759,8 @@ const message = {
sshLogin: 'SSH Login Exception Alert',
panelIpLogin: 'Panel Login IP Exception Alert',
sshIpLogin: 'SSH Login IP Exception Alert',
- ipWhiteListHelper: 'IPs in the whitelist are not restricted by any rules',
+ ipWhiteListHelper:
+ 'IPs in the whitelist are not restricted by rules, and there will be no alert upon successful login',
nodeExceptionRule: 'Node exception alert, sent {0} times per day',
licenseExceptionRule: 'License exception alert, sent {0} times per day',
panelLoginRule: 'Panel login alert, sent {0} times per day',
diff --git a/frontend/src/lang/modules/ja.ts b/frontend/src/lang/modules/ja.ts
index 59c46ed38..b75b5ace8 100644
--- a/frontend/src/lang/modules/ja.ts
+++ b/frontend/src/lang/modules/ja.ts
@@ -3637,7 +3637,8 @@ const message = {
sshLogin: 'SSHログイン異常アラート',
panelIpLogin: 'パネルログインIP異常アラート',
sshIpLogin: 'SSHログインIP異常アラート',
- ipWhiteListHelper: 'ホワイトリスト内のIPは、いかなるルールの制限も受けません',
+ ipWhiteListHelper:
+ 'ホワイトリストに登録されたIPはルールの制限を受けず、ログインが成功してもアラートは発生しません',
nodeExceptionRule: 'ノード異常アラートは、1日あたり{0}回送信',
licenseExceptionRule: 'ライセンス異常アラートは、1日あたり{0}回送信',
panelLoginRule: 'パネルログインアラートは、1日あたり{0}回送信',
diff --git a/frontend/src/lang/modules/ko.ts b/frontend/src/lang/modules/ko.ts
index 063b09a95..cd05aa052 100644
--- a/frontend/src/lang/modules/ko.ts
+++ b/frontend/src/lang/modules/ko.ts
@@ -3573,7 +3573,8 @@ const message = {
sshLogin: 'SSH 로그인 이상 알림',
panelIpLogin: '패널 로그인 IP 이상 알림',
sshIpLogin: 'SSH 로그인 IP 이상 알림',
- ipWhiteListHelper: '화이트리스트에 있는 IP는 어떠한 규칙의 제한도 받지 않습니다',
+ ipWhiteListHelper:
+ '화이트리스트에 있는 IP는 규칙의 제한을 받지 않으며, 로그인에 성공해도 알림이 발생하지 않습니다',
nodeExceptionRule: '노드 이상 알림은 하루 {0}회 전송',
licenseExceptionRule: '라이선스 이상 알림은 하루 {0}회 전송',
panelLoginRule: '패널 로그인 알림은 하루 {0}회 전송',
diff --git a/frontend/src/lang/modules/ms.ts b/frontend/src/lang/modules/ms.ts
index fcf178d4b..41c4d56b1 100644
--- a/frontend/src/lang/modules/ms.ts
+++ b/frontend/src/lang/modules/ms.ts
@@ -3723,7 +3723,8 @@ const message = {
sshLogin: 'Amaran Log Masuk SSH Tidak Normal',
panelIpLogin: 'Amaran IP Log Masuk Panel Tidak Normal',
sshIpLogin: 'Amaran IP Log Masuk SSH Tidak Normal',
- ipWhiteListHelper: 'IP dalam senarai putih tidak tertakluk kepada sebarang peraturan',
+ ipWhiteListHelper:
+ 'IP dalam senarai putih tidak tertakluk kepada peraturan, dan tiada amaran akan dikeluarkan apabila log masuk berjaya',
nodeExceptionRule: 'Amaran kerosakan nod, dihantar {0} kali sehari',
licenseExceptionRule: 'Amaran kerosakan lesen, dihantar {0} kali sehari',
panelLoginRule: 'Amaran log masuk panel, dihantar {0} kali sehari',
diff --git a/frontend/src/lang/modules/pt-br.ts b/frontend/src/lang/modules/pt-br.ts
index 157c4e793..d538b0c43 100644
--- a/frontend/src/lang/modules/pt-br.ts
+++ b/frontend/src/lang/modules/pt-br.ts
@@ -3731,7 +3731,8 @@ const message = {
sshLogin: 'Alerta de Exceção de Login SSH',
panelIpLogin: 'Alerta de Exceção de IP de Login no Painel',
sshIpLogin: 'Alerta de Exceção de IP de Login SSH',
- ipWhiteListHelper: 'IPs na lista branca não estão sujeitos a nenhuma regra',
+ ipWhiteListHelper:
+ 'Os IPs na lista de permissões não são restringidos pelas regras e não haverá alerta em caso de login bem-sucedido',
nodeExceptionRule: 'Alerta de exceção de nó, enviado {0} vezes por dia',
licenseExceptionRule: 'Alerta de exceção de licença, enviado {0} vezes por dia',
panelLoginRule: 'Alerta de login no painel, enviado {0} vezes por dia',
diff --git a/frontend/src/lang/modules/ru.ts b/frontend/src/lang/modules/ru.ts
index 6e8f3225b..6d284e8db 100644
--- a/frontend/src/lang/modules/ru.ts
+++ b/frontend/src/lang/modules/ru.ts
@@ -3722,7 +3722,8 @@ const message = {
sshLogin: 'Оповещение о сбое входа по SSH',
panelIpLogin: 'Оповещение о сбое IP входа в панель',
sshIpLogin: 'Оповещение о сбое IP входа по SSH',
- ipWhiteListHelper: 'IP-адреса в белом списке не подпадают под действие каких-либо правил',
+ ipWhiteListHelper:
+ 'IP-адреса в белом списке не ограничиваются правилами, и при успешном входе оповещение не создается',
nodeExceptionRule: 'Оповещение о сбое узла, отправляется {0} раз в день',
licenseExceptionRule: 'Оповещение о сбое лицензии, отправляется {0} раз в день',
panelLoginRule: 'Оповещение о входе в панель, отправляется {0} раз в день',
diff --git a/frontend/src/lang/modules/tr.ts b/frontend/src/lang/modules/tr.ts
index ecc1649dd..fdfdb0846 100644
--- a/frontend/src/lang/modules/tr.ts
+++ b/frontend/src/lang/modules/tr.ts
@@ -3801,7 +3801,8 @@ const message = {
sshLogin: 'SSH Girişi Hatası Uyarısı',
panelIpLogin: 'Panel Girişi IP Hatası Uyarısı',
sshIpLogin: 'SSH Girişi IP Hatası Uyarısı',
- ipWhiteListHelper: 'Beyaz listedeki IP’ler herhangi bir kuralla kısıtlanmaz',
+ ipWhiteListHelper:
+ 'Beyaz listedeki IP’ler kurallara tabi değildir ve başarılı girişlerde uyarı oluşturulmaz',
nodeExceptionRule: 'Düğüm hatası uyarısı, günde {0} kez gönderilir',
licenseExceptionRule: 'Lisans hatası uyarısı, günde {0} kez gönderilir',
panelLoginRule: 'Panel girişi uyarısı, günde {0} kez gönderilir',
diff --git a/frontend/src/lang/modules/zh-Hant.ts b/frontend/src/lang/modules/zh-Hant.ts
index 57a93d5af..dd51a96e2 100644
--- a/frontend/src/lang/modules/zh-Hant.ts
+++ b/frontend/src/lang/modules/zh-Hant.ts
@@ -3499,7 +3499,7 @@ const message = {
sshLogin: 'SSH 登入異常告警',
panelIpLogin: '面板登入 IP 異常告警',
sshIpLogin: 'SSH 登入 IP 異常告警',
- ipWhiteListHelper: '白名單中的 IP 不受任何規則限制',
+ ipWhiteListHelper: '在白名單中的 IP 不受規則限制,成功登入時也不會產生警報',
nodeExceptionRule: '節點異常告警,每天發送 {0} 次',
licenseExceptionRule: '許可證異常告警,每天發送 {0} 次',
panelLoginRule: '面板登入告警,每天發送 {0} 次',
diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts
index 19af10847..07c652e19 100644
--- a/frontend/src/lang/modules/zh.ts
+++ b/frontend/src/lang/modules/zh.ts
@@ -3469,7 +3469,7 @@ const message = {
sshLogin: 'SSH 登录异常告警',
panelIpLogin: '面板登录 IP 异常告警',
sshIpLogin: 'SSH 登录 IP 异常告警',
- ipWhiteListHelper: '白名单中的 IP 不受任何规则限制',
+ ipWhiteListHelper: '白名单中的 IP 不受规则限制,登录成功不进行告警',
nodeExceptionRule: '节点异常告警,每天发送 {0} 次',
licenseExceptionRule: '许可证异常告警,每天发送 {0} 次',
panelLoginRule: '面板登录告警,每天发送 {0} 次',
diff --git a/frontend/src/views/setting/alert/dash/index.vue b/frontend/src/views/setting/alert/dash/index.vue
index 0c1873cc1..37d96d71a 100644
--- a/frontend/src/views/setting/alert/dash/index.vue
+++ b/frontend/src/views/setting/alert/dash/index.vue
@@ -18,8 +18,16 @@
-
-
+
+
@@ -142,7 +150,7 @@ import { UpdateAlertStatus, SearchAlerts, DeleteAlert } from '@/api/modules/aler
import { storeToRefs } from 'pinia';
const globalStore = GlobalStore();
-const { isMaster } = storeToRefs(globalStore);
+const { isMaster, isProductPro } = storeToRefs(globalStore);
const { t } = i18n.global;
const loading = ref(false);
diff --git a/frontend/src/views/setting/alert/dash/task/index.vue b/frontend/src/views/setting/alert/dash/task/index.vue
index 0c70a0545..7ad5193e4 100644
--- a/frontend/src/views/setting/alert/dash/task/index.vue
+++ b/frontend/src/views/setting/alert/dash/task/index.vue
@@ -371,7 +371,7 @@ import { routerToName } from '@/utils/router';
import { checkCidr, checkCidrV6, checkIpV4V6 } from '@/utils/util';
const globalStore = GlobalStore();
-const { isMaster } = storeToRefs(globalStore);
+const { isMaster, isProductPro } = storeToRefs(globalStore);
interface DialogProps {
title: string;
@@ -441,10 +441,10 @@ const allTaskOptions = [
{ value: 'panelPwdEndTime', label: 'xpack.alert.panelPwdEndTime', show: isMaster.value },
{ value: 'panelLogin', label: 'xpack.alert.panelLogin', show: isMaster.value },
{ value: 'sshLogin', label: 'xpack.alert.sshLogin', show: true },
- { value: 'licenseException', label: 'xpack.alert.licenseException', show: isMaster.value },
+ { value: 'licenseException', label: 'xpack.alert.licenseException', show: isMaster.value && isProductPro.value },
{ value: 'ssl', label: 'xpack.alert.ssl', show: true },
{ value: 'siteEndTime', label: 'xpack.alert.siteEndTime', show: true },
- { value: 'nodeException', label: 'xpack.alert.nodeException', show: isMaster.value },
+ { value: 'nodeException', label: 'xpack.alert.nodeException', show: isMaster.value && isProductPro.value },
{ value: 'cpu', label: 'xpack.alert.cpu', show: true },
{ value: 'memory', label: 'xpack.alert.memory', show: true },
{ value: 'disk', label: 'xpack.alert.disk', show: true },