From d22f1c97ae031f590559dbf06eb891c746945eea Mon Sep 17 00:00:00 2001 From: Aqr-K <95741669+Aqr-K@users.noreply.github.com> Date: Fri, 27 Sep 2024 00:00:11 +0800 Subject: [PATCH 1/2] feat: Add duplicate name judgment for notification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 增加通知渠道的重名判断 --- .../cards/NotificationChannelCard.vue | 22 ++++++++++++++++++- .../setting/AccountSettingNotification.vue | 7 +++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/components/cards/NotificationChannelCard.vue b/src/components/cards/NotificationChannelCard.vue index 2fff899c..77512b31 100644 --- a/src/components/cards/NotificationChannelCard.vue +++ b/src/components/cards/NotificationChannelCard.vue @@ -6,18 +6,28 @@ import vocechat_image from '@images/logos/vocechat.png' import synologychat_image from '@images/logos/synologychat.png' import slack_image from '@images/logos/slack.webp' import chrome_image from '@images/logos/chrome.png' +import { useToast } from 'vue-toast-notification' // 定义输入 const props = defineProps({ + // 单个通知 notification: { type: Object as PropType, required: true, }, + // 所有通知 + notifications: { + type: Array as PropType, + required: true, + }, }) // 定义触发的自定义事件 const emit = defineEmits(['close', 'change', 'done']) +// 提示框 +const $toast = useToast() + // 通知详情弹窗 const notificationInfoDialog = ref(false) @@ -63,6 +73,16 @@ function openNotificationInfoDialog() { // 保存详情数据 function saveNotificationInfo() { + // 为空不保存,跳出警告框 + if (!notificationName.value) { + $toast.error('名称不能为空,请输入后再确定') + return + } + // 重名判断 + if (props.notifications.some(item => item.name === notificationName.value && item!== props.notification)) { + $toast.error(`【${notificationName.value}】已存在,请替换为其他名称`) + return + } notificationInfoDialog.value = false notificationInfo.value.name = notificationName.value emit('change', notificationInfo.value) @@ -109,7 +129,7 @@ function onClose() { - + diff --git a/src/views/setting/AccountSettingNotification.vue b/src/views/setting/AccountSettingNotification.vue index 3122f601..07904af6 100644 --- a/src/views/setting/AccountSettingNotification.vue +++ b/src/views/setting/AccountSettingNotification.vue @@ -60,8 +60,12 @@ async function reloadSystem() { // 添加媒体服务器 function addNotification(notification: string) { + let name = `通知${notifications.value.length + 1}`; + while (notifications.value.some(item => item.name === name)) { + name = `通知${parseInt(name.split('通知')[1]) + 1}`; + } notifications.value.push({ - name: `通知${notifications.value.length + 1}`, + name: name, type: notification, enabled: false, config: {}, @@ -147,6 +151,7 @@ onMounted(() => { From 4126692c5a4bb369591b30ac7785086692238010 Mon Sep 17 00:00:00 2001 From: Aqr-K <95741669+Aqr-K@users.noreply.github.com> Date: Fri, 27 Sep 2024 00:03:05 +0800 Subject: [PATCH 2/2] style: Unified card style. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 统一禁止全部弹窗式设置的点击功能区以外区域的close功能。 --- src/components/cards/CustomRuleCard.vue | 2 +- src/components/cards/DownloaderCard.vue | 2 +- src/components/cards/FilterRuleGroupCard.vue | 2 +- src/components/cards/MediaServerCard.vue | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/cards/CustomRuleCard.vue b/src/components/cards/CustomRuleCard.vue index c585d30c..39fe5f71 100644 --- a/src/components/cards/CustomRuleCard.vue +++ b/src/components/cards/CustomRuleCard.vue @@ -102,7 +102,7 @@ function onClose() { - + diff --git a/src/components/cards/DownloaderCard.vue b/src/components/cards/DownloaderCard.vue index 93b080a8..d109b90c 100644 --- a/src/components/cards/DownloaderCard.vue +++ b/src/components/cards/DownloaderCard.vue @@ -175,7 +175,7 @@ onUnmounted(() => { - + diff --git a/src/components/cards/FilterRuleGroupCard.vue b/src/components/cards/FilterRuleGroupCard.vue index cc775929..c84b4e19 100644 --- a/src/components/cards/FilterRuleGroupCard.vue +++ b/src/components/cards/FilterRuleGroupCard.vue @@ -221,7 +221,7 @@ function onClose() { - + diff --git a/src/components/cards/MediaServerCard.vue b/src/components/cards/MediaServerCard.vue index 9d427d13..44815bdb 100644 --- a/src/components/cards/MediaServerCard.vue +++ b/src/components/cards/MediaServerCard.vue @@ -174,7 +174,7 @@ onMounted(() => { - +