fix: 修正控件ID引用,动态加载的UI文件使用'app.main-content'从body开始寻找目标容器

This commit is contained in:
yumoqing 2026-04-22 13:53:35 +08:00
parent 2f312c0554
commit ff3275429d
7 changed files with 10 additions and 10 deletions

View File

@ -69,7 +69,7 @@
"wid": "self", "wid": "self",
"event": "click", "event": "click",
"actiontype": "script", "actiontype": "script",
"script": "const formData = bricks.app.get_widget('add-service-form').get_data(); if (formData.name && formData.url) { fetch('/hermes-web-cli/services', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(formData) }).then(response => response.json()).then(data => { bricks.app.load_widget('{{entire_url(\"services.ui\")}}', 'main-content', 'replace'); }); }" "script": "const formData = bricks.app.get_widget('add-service-form').get_data(); if (formData.name && formData.url) { fetch('/hermes-web-cli/services', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(formData) }).then(response => response.json()).then(data => { bricks.app.load_widget('{{entire_url(\"services.ui\")}}', 'app.main-content', 'replace'); }); }"
} }
] ]
}, },
@ -88,7 +88,7 @@
"wid": "self", "wid": "self",
"event": "click", "event": "click",
"actiontype": "urlwidget", "actiontype": "urlwidget",
"target": "main-content", "target": "app.main-content",
"options": { "options": {
"url": "{{entire_url('services.ui')}}" "url": "{{entire_url('services.ui')}}"
}, },

View File

@ -70,7 +70,7 @@
"wid": "self", "wid": "self",
"event": "click", "event": "click",
"actiontype": "script", "actiontype": "script",
"script": "const formData = bricks.app.get_widget('edit-service-form').get_data(); const serviceId = '{{query.service_id}}'; if (formData.name && formData.url) { fetch(`/hermes-web-cli/hermes_services/?id=${serviceId}`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(formData) }).then(() => { bricks.app.load_widget('{{entire_url(\"services.ui\")}}', 'main-content', 'replace'); }); }" "script": "const formData = bricks.app.get_widget('edit-service-form').get_data(); const serviceId = '{{query.service_id}}'; if (formData.name && formData.url) { fetch(`/hermes-web-cli/hermes_services/?id=${serviceId}`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(formData) }).then(() => { bricks.app.load_widget('{{entire_url(\"services.ui\")}}', 'app.main-content', 'replace'); }); }"
} }
] ]
}, },
@ -89,7 +89,7 @@
"wid": "self", "wid": "self",
"event": "click", "event": "click",
"actiontype": "urlwidget", "actiontype": "urlwidget",
"target": "main-content", "target": "app.main-content",
"options": { "options": {
"url": "{{entire_url('services.ui')}}" "url": "{{entire_url('services.ui')}}"
}, },

View File

@ -44,7 +44,7 @@
"wid": "self", "wid": "self",
"event": "submited", "event": "submited",
"actiontype": "script", "actiontype": "script",
"script": "const data = event.params; if (data && data.session_id) { bricks.app.load_widget('{{entire_url(\"session_detail.ui\")}}?session_id=' + data.session_id, 'main-content', 'replace'); }" "script": "const data = event.params; if (data && data.session_id) { bricks.app.load_widget('{{entire_url(\"session_detail.ui\")}}?session_id=' + data.session_id, 'app.main-content', 'replace'); }"
} }
] ]
} }

View File

@ -33,7 +33,7 @@
"wid": "self", "wid": "self",
"event": "click", "event": "click",
"actiontype": "urlwidget", "actiontype": "urlwidget",
"target": "main-content", "target": "app.main-content",
"options": { "options": {
"url": "{{entire_url('add_service.ui')}}" "url": "{{entire_url('add_service.ui')}}"
}, },
@ -111,7 +111,7 @@
"wid": "self", "wid": "self",
"event": "edit_service", "event": "edit_service",
"actiontype": "script", "actiontype": "script",
"script": "const selectedRow = event.params; if (selectedRow) { const url = `{{entire_url('edit_service.ui')}}?service_id=${selectedRow.id}`; bricks.app.load_widget(url, 'main-content', 'replace'); }" "script": "const selectedRow = event.params; if (selectedRow) { const url = `{{entire_url('edit_service.ui')}}?service_id=${selectedRow.id}`; bricks.app.load_widget(url, 'app.main-content', 'replace'); }"
}, },
{ {
"wid": "self", "wid": "self",

View File

@ -42,7 +42,7 @@
"wid": "self", "wid": "self",
"event": "click", "event": "click",
"actiontype": "urlwidget", "actiontype": "urlwidget",
"target": "main-content", "target": "app.main-content",
"options": { "options": {
"url": "{{entire_url('sessions.ui')}}" "url": "{{entire_url('sessions.ui')}}"
}, },

View File

@ -102,7 +102,7 @@
"wid": "self", "wid": "self",
"event": "click", "event": "click",
"actiontype": "urlwidget", "actiontype": "urlwidget",
"target": "main-content", "target": "app.main-content",
"options": { "options": {
"url": "{{entire_url('sessions.ui')}}" "url": "{{entire_url('sessions.ui')}}"
}, },

View File

@ -75,7 +75,7 @@
"wid": "self", "wid": "self",
"event": "open_session", "event": "open_session",
"actiontype": "script", "actiontype": "script",
"script": "const selectedRow = event.params; if (selectedRow) { const url = `{{entire_url('session_detail.ui')}}?session_id=${selectedRow.session_id}`; bricks.app.load_widget(url, 'main-content', 'replace'); }" "script": "const selectedRow = event.params; if (selectedRow) { const url = `{{entire_url('session_detail.ui')}}?session_id=${selectedRow.session_id}`; bricks.app.load_widget(url, 'app.main-content', 'replace'); }"
}, },
{ {
"wid": "self", "wid": "self",