feat: Add duplicate name judgment for notification

- 增加通知渠道的重名判断
This commit is contained in:
Aqr-K
2024-09-27 00:00:11 +08:00
parent 6301cb287e
commit d22f1c97ae
2 changed files with 27 additions and 2 deletions

View File

@@ -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(() => {
<template #item="{ element }">
<NotificationChannelCard
:notification="element"
:notifications="notifications"
@close="removeNotification(element)"
/>
</template>