新增自定义通知类型支持,更新相关提示信息和样式

This commit is contained in:
jxxghp
2025-05-18 13:39:44 +08:00
parent 59e12c5e96
commit c4a02f7497
6 changed files with 48 additions and 9 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

@@ -6,6 +6,7 @@ import vocechat_image from '@images/logos/vocechat.png'
import synologychat_image from '@images/logos/synologychat.png' import synologychat_image from '@images/logos/synologychat.png'
import slack_image from '@images/logos/slack.webp' import slack_image from '@images/logos/slack.webp'
import chrome_image from '@images/logos/chrome.png' import chrome_image from '@images/logos/chrome.png'
import custom_image from '@images/logos/notification.png'
import { useToast } from 'vue-toast-notification' import { useToast } from 'vue-toast-notification'
import { cloneDeep } from 'lodash-es' import { cloneDeep } from 'lodash-es'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
@@ -51,6 +52,7 @@ const notificationTypeNames: { [key: string]: string } = {
synologychat: t('notification.synologychat.name'), synologychat: t('notification.synologychat.name'),
slack: t('notification.slack.name'), slack: t('notification.slack.name'),
webpush: t('notification.webpush.name'), webpush: t('notification.webpush.name'),
custom: t('setting.notification.custom'),
} }
// 消息类型下拉字典 // 消息类型下拉字典
@@ -104,8 +106,10 @@ const getIcon = computed(() => {
return slack_image return slack_image
case 'webpush': case 'webpush':
return chrome_image return chrome_image
default: case 'wechat':
return wechat_image return wechat_image
default:
return custom_image
} }
}) })
@@ -131,7 +135,7 @@ function onClose() {
</div> </div>
<div class="text-body-1 mb-3">{{ notificationTypeNames[notification.type] }}</div> <div class="text-body-1 mb-3">{{ notificationTypeNames[notification.type] }}</div>
</div> </div>
<VImg :src="getIcon" cover class="mt-7 me-3" max-width="3rem" /> <VImg :src="getIcon" cover class="mt-7 me-1" max-width="3rem" />
</VCardText> </VCardText>
</VCard> </VCard>
<VDialog v-if="notificationInfoDialog" v-model="notificationInfoDialog" scrollable max-width="40rem"> <VDialog v-if="notificationInfoDialog" v-model="notificationInfoDialog" scrollable max-width="40rem">
@@ -225,7 +229,7 @@ function onClose() {
/> />
</VCol> </VCol>
</VRow> </VRow>
<VRow v-if="notificationInfo.type == 'telegram'"> <VRow v-else-if="notificationInfo.type == 'telegram'">
<VCol cols="12" md="6"> <VCol cols="12" md="6">
<VTextField <VTextField
v-model="notificationInfo.name" v-model="notificationInfo.name"
@@ -270,7 +274,7 @@ function onClose() {
/> />
</VCol> </VCol>
</VRow> </VRow>
<VRow v-if="notificationInfo.type == 'slack'"> <VRow v-else-if="notificationInfo.type == 'slack'">
<VCol cols="12" md="6"> <VCol cols="12" md="6">
<VTextField <VTextField
v-model="notificationInfo.name" v-model="notificationInfo.name"
@@ -308,7 +312,7 @@ function onClose() {
/> />
</VCol> </VCol>
</VRow> </VRow>
<VRow v-if="notificationInfo.type == 'synologychat'"> <VRow v-else-if="notificationInfo.type == 'synologychat'">
<VCol cols="12" md="6"> <VCol cols="12" md="6">
<VTextField <VTextField
v-model="notificationInfo.name" v-model="notificationInfo.name"
@@ -335,7 +339,7 @@ function onClose() {
/> />
</VCol> </VCol>
</VRow> </VRow>
<VRow v-if="notificationInfo.type == 'vocechat'"> <VRow v-else-if="notificationInfo.type == 'vocechat'">
<VCol cols="12" md="6"> <VCol cols="12" md="6">
<VTextField <VTextField
v-model="notificationInfo.name" v-model="notificationInfo.name"
@@ -371,7 +375,7 @@ function onClose() {
/> />
</VCol> </VCol>
</VRow> </VRow>
<VRow v-if="notificationInfo.type == 'webpush'"> <VRow v-else-if="notificationInfo.type == 'webpush'">
<VCol cols="12" md="6"> <VCol cols="12" md="6">
<VTextField <VTextField
v-model="notificationInfo.name" v-model="notificationInfo.name"
@@ -390,6 +394,26 @@ function onClose() {
/> />
</VCol> </VCol>
</VRow> </VRow>
<VRow v-else>
<VCol cols="12" md="6">
<VTextField
v-model="notificationInfo.type"
:label="t('notification.type')"
:hint="t('notification.customTypeHint')"
persistent-hint
active
/>
</VCol>
<VCol cols="12" md="6">
<VTextField
v-model="notificationInfo.name"
:label="t('notification.name')"
:hint="t('notification.nameRequired')"
persistent-hint
active
/>
</VCol>
</VRow>
</VForm> </VForm>
</VCardText> </VCardText>
<VCardActions class="pt-3"> <VCardActions class="pt-3">
+4
View File
@@ -279,6 +279,9 @@ export default {
nameHint: 'Name of notification channel', nameHint: 'Name of notification channel',
type: 'Type', type: 'Type',
typeHint: 'Type of notification channel', typeHint: 'Type of notification channel',
customTypeHint: 'Custom notification type, used for plugin implementation scenarios',
customTypePlaceholder: 'custom',
nameRequired: 'Please enter name',
enabled: 'Enabled', enabled: 'Enabled',
config: 'Configuration', config: 'Configuration',
wechat: { wechat: {
@@ -1184,6 +1187,7 @@ export default {
synologyChat: 'SynologyChat', synologyChat: 'SynologyChat',
voceChat: 'VoceChat', voceChat: 'VoceChat',
webPush: 'WebPush', webPush: 'WebPush',
custom: 'Custom Notification',
}, },
words: { words: {
customIdentifiers: 'Custom Identifiers', customIdentifiers: 'Custom Identifiers',
+4
View File
@@ -278,6 +278,9 @@ export default {
nameHint: '通知渠道名称', nameHint: '通知渠道名称',
type: '类型', type: '类型',
typeHint: '通知渠道类型', typeHint: '通知渠道类型',
customTypeHint: '自定义通知类型,用于插件实现场景',
customTypePlaceholder: 'custom',
nameRequired: '请输入名称',
enabled: '启用', enabled: '启用',
config: '配置', config: '配置',
wechat: { wechat: {
@@ -1171,6 +1174,7 @@ export default {
synologyChat: 'SynologyChat', synologyChat: 'SynologyChat',
voceChat: 'VoceChat', voceChat: 'VoceChat',
webPush: 'WebPush', webPush: 'WebPush',
custom: '自定义通知',
}, },
words: { words: {
customIdentifiers: '自定义识别词', customIdentifiers: '自定义识别词',
+4
View File
@@ -279,6 +279,9 @@ export default {
nameHint: '通知渠道名稱', nameHint: '通知渠道名稱',
type: '類型', type: '類型',
typeHint: '通知渠道類型', typeHint: '通知渠道類型',
customTypeHint: '自定義通知類型,用於插件實現場景',
customTypePlaceholder: 'custom',
nameRequired: '請輸入名稱',
enabled: '啟用', enabled: '啟用',
config: '配置', config: '配置',
wechat: { wechat: {
@@ -1173,6 +1176,7 @@ export default {
synologyChat: 'SynologyChat', synologyChat: 'SynologyChat',
voceChat: 'VoceChat', voceChat: 'VoceChat',
webPush: 'WebPush', webPush: 'WebPush',
custom: '自定義通知',
}, },
words: { words: {
customIdentifiers: '自定義識別詞', customIdentifiers: '自定義識別詞',
@@ -313,6 +313,9 @@ onMounted(() => {
<VListItem @click="addNotification('webpush')"> <VListItem @click="addNotification('webpush')">
<VListItemTitle>{{ t('setting.notification.webPush') }}</VListItemTitle> <VListItemTitle>{{ t('setting.notification.webPush') }}</VListItemTitle>
</VListItem> </VListItem>
<VListItem @click="addNotification('custom')">
<VListItemTitle>{{ t('setting.system.custom') }}</VListItemTitle>
</VListItem>
</VList> </VList>
</VMenu> </VMenu>
</VBtn> </VBtn>
@@ -466,10 +469,10 @@ onMounted(() => {
<style scoped> <style scoped>
/* Monaco编辑器容器样式 */ /* Monaco编辑器容器样式 */
.monaco-editor-container { .monaco-editor-container {
overflow: hidden;
border: 1px solid rgba(var(--v-border-color), var(--v-border-opacity)); border: 1px solid rgba(var(--v-border-color), var(--v-border-opacity));
border-radius: 8px; border-radius: 8px;
overflow: hidden; margin-block-start: 1rem;
margin-top: 1rem;
} }
.template-card { .template-card {