feat update placeholder syntax in notify templates

This commit is contained in:
Fu Diwei 2024-12-23 22:33:12 +08:00
parent 0556d68a4e
commit 16bc12c15b
4 changed files with 12 additions and 12 deletions

View File

@ -13,8 +13,8 @@ import (
) )
const ( const (
defaultExpireSubject = "您有 {COUNT} 张证书即将过期" defaultExpireSubject = "您有 ${COUNT} 张证书即将过期"
defaultExpireMessage = "有 {COUNT} 张证书即将过期,域名分别为 {DOMAINS},请保持关注!" defaultExpireMessage = "有 ${COUNT} 张证书即将过期,域名分别为 ${DOMAINS},请保持关注!"
) )
type CertificateRepository interface { type CertificateRepository interface {
@ -88,11 +88,11 @@ func buildMsg(records []domain.Certificate) *domain.NotifyMessage {
countStr := strconv.Itoa(count) countStr := strconv.Itoa(count)
domainStr := strings.Join(domains, ";") domainStr := strings.Join(domains, ";")
subject = strings.ReplaceAll(subject, "{COUNT}", countStr) subject = strings.ReplaceAll(subject, "${COUNT}", countStr)
subject = strings.ReplaceAll(subject, "{DOMAINS}", domainStr) subject = strings.ReplaceAll(subject, "${DOMAINS}", domainStr)
message = strings.ReplaceAll(message, "{COUNT}", countStr) message = strings.ReplaceAll(message, "${COUNT}", countStr)
message = strings.ReplaceAll(message, "{DOMAINS}", domainStr) message = strings.ReplaceAll(message, "${DOMAINS}", domainStr)
// 返回消息 // 返回消息
return &domain.NotifyMessage{ return &domain.NotifyMessage{

View File

@ -33,8 +33,8 @@ export type NotifyTemplate = {
}; };
export const defaultNotifyTemplate: NotifyTemplate = { export const defaultNotifyTemplate: NotifyTemplate = {
subject: "您有 {COUNT} 张证书即将过期", subject: "您有 ${COUNT} 张证书即将过期",
message: "有 {COUNT} 张证书即将过期,域名分别为 {DOMAINS},请保持关注!", message: "有 ${COUNT} 张证书即将过期,域名分别为 ${DOMAINS},请保持关注!",
}; };
// #endregion // #endregion

View File

@ -19,10 +19,10 @@
"settings.notification.template.card.title": "Template", "settings.notification.template.card.title": "Template",
"settings.notification.template.form.subject.label": "Subject", "settings.notification.template.form.subject.label": "Subject",
"settings.notification.template.form.subject.placeholder": "Please enter notification subject", "settings.notification.template.form.subject.placeholder": "Please enter notification subject",
"settings.notification.template.form.subject.tooltip": "Optional variables ({COUNT}: number of expiring soon)", "settings.notification.template.form.subject.tooltip": "Optional variables (${COUNT}: number of expiring soon)",
"settings.notification.template.form.message.label": "Message", "settings.notification.template.form.message.label": "Message",
"settings.notification.template.form.message.placeholder": "Please enter notification message", "settings.notification.template.form.message.placeholder": "Please enter notification message",
"settings.notification.template.form.message.tooltip": "Optional variables ({COUNT}: number of expiring soon. {DOMAINS}: Domain list)", "settings.notification.template.form.message.tooltip": "Optional variables (${COUNT}: number of expiring soon. ${DOMAINS}: Domain list)",
"settings.notification.channels.card.title": "Channels", "settings.notification.channels.card.title": "Channels",
"settings.notification.channel.enabled.on": "On", "settings.notification.channel.enabled.on": "On",
"settings.notification.channel.enabled.off": "Off", "settings.notification.channel.enabled.off": "Off",

View File

@ -19,10 +19,10 @@
"settings.notification.template.card.title": "通知模板", "settings.notification.template.card.title": "通知模板",
"settings.notification.template.form.subject.label": "通知主题", "settings.notification.template.form.subject.label": "通知主题",
"settings.notification.template.form.subject.placeholder": "请输入通知主题", "settings.notification.template.form.subject.placeholder": "请输入通知主题",
"settings.notification.template.form.subject.tooltip": "可选的变量({COUNT}: 即将过期张数)", "settings.notification.template.form.subject.tooltip": "可选的变量(${COUNT}: 即将过期张数)",
"settings.notification.template.form.message.label": "通知内容", "settings.notification.template.form.message.label": "通知内容",
"settings.notification.template.form.message.placeholder": "请输入通知内容", "settings.notification.template.form.message.placeholder": "请输入通知内容",
"settings.notification.template.form.message.tooltip": "可选的变量({COUNT}: 即将过期张数;{DOMAINS}: 域名列表)", "settings.notification.template.form.message.tooltip": "可选的变量(${COUNT}: 即将过期张数;${DOMAINS}: 域名列表)",
"settings.notification.channels.card.title": "通知渠道", "settings.notification.channels.card.title": "通知渠道",
"settings.notification.channel.enabled.on": "启用", "settings.notification.channel.enabled.on": "启用",
"settings.notification.channel.enabled.off": "未启用", "settings.notification.channel.enabled.off": "未启用",