mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-07-28 01:08:34 +08:00
feat: 新增智能体(Agent)消息类型,优化通知开关加载逻辑自动合并新增类型
This commit is contained in:
@@ -91,6 +91,10 @@ const notificationSwitchs = ref<NotificationSwitchConf[]>([
|
||||
type: '插件',
|
||||
action: 'admin',
|
||||
},
|
||||
{
|
||||
type: '智能体',
|
||||
action: 'admin',
|
||||
},
|
||||
{
|
||||
type: '其它',
|
||||
action: 'admin',
|
||||
@@ -214,7 +218,17 @@ function changNotificationSetting(notification: NotificationConf, name: string)
|
||||
async function loadNotificationSwitchs() {
|
||||
try {
|
||||
const result: { [key: string]: any } = await api.get('system/setting/NotificationSwitchs')
|
||||
if (result.data?.value && result.data?.value.length > 0) notificationSwitchs.value = result.data?.value
|
||||
if (result.data?.value && result.data?.value.length > 0) {
|
||||
const savedSwitchs: NotificationSwitchConf[] = result.data.value
|
||||
// 合并默认值中存在但后端数据中缺失的类型(如新增的类型)
|
||||
const defaults = notificationSwitchs.value
|
||||
for (const def of defaults) {
|
||||
if (!savedSwitchs.find(item => item.type === def.type)) {
|
||||
savedSwitchs.push(def)
|
||||
}
|
||||
}
|
||||
notificationSwitchs.value = savedSwitchs
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user