更新dns查询

This commit is contained in:
Alex Yang
2025-11-24 23:28:49 +08:00
parent 1debd1b1d8
commit 87143a77b9
5 changed files with 65 additions and 28 deletions

View File

@@ -48,7 +48,7 @@ if (typeof window.showNotification === 'undefined') {
window.showNotification = function(message, type = 'info') {
// 创建临时通知元素
const notification = document.createElement('div');
notification.className = `notification notification-${type}`;
notification.className = `notification notification-${type} show`;
notification.innerHTML = `
<div class="notification-content">${message}</div>
`;
@@ -127,14 +127,27 @@ function apiRequest(endpoint, method = 'GET', data = null, maxRetries = 3) {
timeout: 10000, // 设置超时时间为10秒
};
if (data && (method === 'POST' || method === 'PUT' || method === 'DELETE')) {
config.body = JSON.stringify(data);
// 处理请求URL和参数
let url = `${API_BASE_URL}${endpoint}`;
if (data) {
if (method === 'GET') {
// 为GET请求拼接查询参数
const params = new URLSearchParams();
Object.keys(data).forEach(key => {
params.append(key, data[key]);
});
url += `?${params.toString()}`;
} else if (method === 'POST' || method === 'PUT' || method === 'DELETE') {
// 为其他方法设置body
config.body = JSON.stringify(data);
}
}
let retries = 0;
function makeRequest() {
return fetch(`${API_BASE_URL}${endpoint}`, config)
return fetch(url, config)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);