更新
This commit is contained in:
@@ -30,6 +30,7 @@ function loadBlacklists() {
|
|||||||
|
|
||||||
apiRequest('/api/shield/blacklists')
|
apiRequest('/api/shield/blacklists')
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
// 直接渲染返回的blacklists数组
|
||||||
renderBlacklists(data);
|
renderBlacklists(data);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@@ -125,6 +126,12 @@ function addBlacklist() {
|
|||||||
|
|
||||||
apiRequest('/api/shield/blacklists', 'POST', { name: name, url: url })
|
apiRequest('/api/shield/blacklists', 'POST', { name: name, url: url })
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
// 检查响应中是否有status字段
|
||||||
|
if (!data || typeof data === 'undefined') {
|
||||||
|
window.showNotification('远程黑名单添加失败: 无效的响应', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (data.status === 'success') {
|
if (data.status === 'success') {
|
||||||
window.showNotification('远程黑名单添加成功', 'success');
|
window.showNotification('远程黑名单添加成功', 'success');
|
||||||
nameInput.value = '';
|
nameInput.value = '';
|
||||||
@@ -144,6 +151,12 @@ function addBlacklist() {
|
|||||||
function updateBlacklist(id) {
|
function updateBlacklist(id) {
|
||||||
apiRequest(`/api/shield/blacklists/${id}/update`, 'POST')
|
apiRequest(`/api/shield/blacklists/${id}/update`, 'POST')
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
// 检查响应中是否有status字段
|
||||||
|
if (!data || typeof data === 'undefined') {
|
||||||
|
window.showNotification('远程黑名单更新失败: 无效的响应', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (data.status === 'success') {
|
if (data.status === 'success') {
|
||||||
window.showNotification('远程黑名单更新成功', 'success');
|
window.showNotification('远程黑名单更新成功', 'success');
|
||||||
loadBlacklists();
|
loadBlacklists();
|
||||||
@@ -164,6 +177,12 @@ function updateAllBlacklists() {
|
|||||||
() => {
|
() => {
|
||||||
apiRequest('/api/shield/blacklists', 'PUT')
|
apiRequest('/api/shield/blacklists', 'PUT')
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
// 检查响应中是否有status字段
|
||||||
|
if (!data || typeof data === 'undefined') {
|
||||||
|
window.showNotification('所有远程黑名单更新失败: 无效的响应', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (data.status === 'success') {
|
if (data.status === 'success') {
|
||||||
window.showNotification('所有远程黑名单更新成功', 'success');
|
window.showNotification('所有远程黑名单更新成功', 'success');
|
||||||
loadBlacklists();
|
loadBlacklists();
|
||||||
@@ -183,6 +202,12 @@ function updateAllBlacklists() {
|
|||||||
function deleteBlacklist(id) {
|
function deleteBlacklist(id) {
|
||||||
apiRequest(`/api/shield/blacklists/${id}`, 'DELETE')
|
apiRequest(`/api/shield/blacklists/${id}`, 'DELETE')
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
// 检查响应中是否有status字段
|
||||||
|
if (!data || typeof data === 'undefined') {
|
||||||
|
window.showNotification('远程黑名单删除失败: 无效的响应', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (data.status === 'success') {
|
if (data.status === 'success') {
|
||||||
window.showNotification('远程黑名单删除成功', 'success');
|
window.showNotification('远程黑名单删除成功', 'success');
|
||||||
loadBlacklists();
|
loadBlacklists();
|
||||||
|
|||||||
Reference in New Issue
Block a user