debuhg
This commit is contained in:
@@ -107,6 +107,9 @@
|
|||||||
|
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const strPushApi = `{site:cfg code="PUSH_API_DOMAIN" encode="false"/}`;
|
||||||
|
</script>
|
||||||
{include file="public/footer" /}
|
{include file="public/footer" /}
|
||||||
|
|
||||||
{block name="customize"}
|
{block name="customize"}
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ function displayHistory() {
|
|||||||
|
|
||||||
// 方法1:使用 fetch API
|
// 方法1:使用 fetch API
|
||||||
async function reportStats(data) {
|
async function reportStats(data) {
|
||||||
console.log(strPushApi)
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(strPushApi+'/publish', {
|
const response = await fetch(strPushApi+'/publish', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -349,7 +349,7 @@ async function reportStats(data) {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
// 如果需要认证可以添加
|
// 如果需要认证可以添加
|
||||||
// 'Authorization': 'Bearer your-token'
|
'Authorization': 'Bearer your-token'
|
||||||
},
|
},
|
||||||
body: JSON.stringify(data)
|
body: JSON.stringify(data)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ async function reportStats(data) {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
// 如果需要认证可以添加
|
// 如果需要认证可以添加
|
||||||
// 'Authorization': 'Bearer your-token'
|
'Authorization': 'Bearer your-token'
|
||||||
},
|
},
|
||||||
body: JSON.stringify(data)
|
body: JSON.stringify(data)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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 () {
|
$(function () {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// checkoutHuiyuanTip()
|
// checkoutHuiyuanTip()
|
||||||
if ($(".novel-reader").length === 0) {
|
if ($(".novel-reader").length === 0) {
|
||||||
let _scrollY = 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()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user