Files
dns-server/static/js/shield.js
2025-11-25 15:17:45 +08:00

96 lines
2.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 屏蔽管理页面功能实现
// 初始化屏蔽管理页面 - 已禁用加载屏蔽规则功能
function initShieldPage() {
// 不再加载屏蔽规则避免DOM元素不存在导致的错误
setupShieldEventListeners();
}
// 加载屏蔽规则 - 已禁用此功能
async function loadShieldRules() {
console.log('屏蔽规则加载功能已禁用');
}
// 更新屏蔽规则表格 - 已禁用此功能
function updateShieldRulesTable(rules) {
// 不再更新表格避免DOM元素不存在导致的错误
console.log('屏蔽规则表格更新功能已禁用');
}
// 处理删除规则 - 已禁用此功能
async function handleDeleteRule(e) {
showErrorMessage('删除规则功能已禁用');
}
// 添加新规则 - 已禁用此功能
async function handleAddRule() {
showErrorMessage('添加规则功能已禁用');
}
// 更新远程规则 - 已禁用此功能
async function handleUpdateRemoteRules() {
showErrorMessage('更新远程规则功能已禁用');
}
// 设置事件监听器 - 已禁用规则相关功能
function setupShieldEventListeners() {
// 移除所有事件监听器,避免触发已禁用的功能
console.log('屏蔽规则相关事件监听器已设置,但功能已禁用');
}
// 显示成功消息
function showSuccessMessage(message) {
showNotification(message, 'success');
}
// 显示错误消息
function showErrorMessage(message) {
showNotification(message, 'error');
}
// 显示通知
function showNotification(message, type = 'info') {
// 移除现有通知
const existingNotification = document.querySelector('.notification');
if (existingNotification) {
existingNotification.remove();
}
// 创建新通知
const notification = document.createElement('div');
notification.className = `notification fixed bottom-4 right-4 px-6 py-3 rounded-lg shadow-lg z-50 transform transition-transform duration-300 ease-in-out translate-y-0 opacity-0`;
// 设置通知样式
if (type === 'success') {
notification.classList.add('bg-green-500', 'text-white');
} else if (type === 'error') {
notification.classList.add('bg-red-500', 'text-white');
} else {
notification.classList.add('bg-blue-500', 'text-white');
}
notification.textContent = message;
document.body.appendChild(notification);
// 显示通知
setTimeout(() => {
notification.classList.remove('opacity-0');
notification.classList.add('opacity-100');
}, 10);
// 3秒后隐藏通知
setTimeout(() => {
notification.classList.remove('opacity-100');
notification.classList.add('opacity-0');
setTimeout(() => {
notification.remove();
}, 300);
}, 3000);
}
// 页面加载完成后初始化
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initShieldPage);
} else {
initShieldPage();
}