This commit is contained in:
2025-03-26 01:46:27 +08:00
parent 858d0f0bb5
commit 00035a5cb1

View File

@ -0,0 +1,35 @@
// 修改原有的数据获取方式
async function fetchSites() {
try {
const response = await fetch('/api/sites');
if (!response.ok) throw new Error('Network response was not ok');
return await response.json();
} catch (error) {
console.error('Error fetching sites:', error);
return {};
}
}
// 修改添加网站的函数
async function addSite(site) {
const response = await fetch('/api/add', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(site)
});
return await response.json();
}
// 修改删除网站的函数
async function deleteSite(id) {
const response = await fetch('/api/delete', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ id })
});
return await response.json();
}