This commit is contained in:
make
2025-04-23 19:21:11 +08:00
parent 9dca8ceea3
commit f0c9a625c6
4 changed files with 51 additions and 3 deletions

View File

@@ -148,8 +148,38 @@ function throttlingFnV2(fn, delay) {
};
}
// 方法1使用 fetch API
async function reportStats(data) {
try {
const response = await fetch(strPushApi+'/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);
}
}
$(function () {
// checkoutHuiyuanTip()
if ($(".novel-reader").length === 0) {
let _scrollY = 0; // 记录上一次滚动位置
@@ -291,3 +321,18 @@ $(function () {
})();
document.addEventListener("DOMContentLoaded", function () {
if (typeof strNovelId !== "undefined") {
// 使用示例
const statsData = {
n_id: strNovelId,
};
// 调用方法1
reportStats(statsData);
// addHistoryFun()
}
})