debug
This commit is contained in:
@@ -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);
|
||||
})
|
||||
Reference in New Issue
Block a user