This commit is contained in:
make
2025-04-03 16:47:32 +08:00
parent f286309918
commit 6f76ba8476
9 changed files with 99 additions and 41 deletions

View File

@@ -290,4 +290,36 @@ function displayHistory() {
}
// 方法1使用 fetch API
async function reportStats(data) {
try {
const response = await fetch('http://api.novel2.com/publish', {
method: 'POST',
// mode: 'no-cors', // 添加这行
headers: {
'Content-Type': 'application/json',
// 如果需要认证可以添加
// 'Authorization': 'Bearer your-token'
},
body: JSON.stringify(data)
});
if (!response.ok) {
throw new Error('上报失败');
}
// const result = await response.json();
// console.log('上报成功:', result);
// return result;
} catch (error) {
console.error('上报错误:', error);
}
}
document.addEventListener("DOMContentLoaded", function () {
// 使用示例
const statsData = {
n_id: strNovelId,
};
// 调用方法1
reportStats(statsData);
})