mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-17 23:16:50 +00:00
scheduler log
This commit is contained in:
@@ -356,12 +356,33 @@ function handleDataBeforeReturn(db) {
|
||||
// 新特性,判断文章的发布和下架时间,如果不在有效期内则进行下架处理
|
||||
const publish = isInRange(p.title, p.date)
|
||||
if (!publish) {
|
||||
const currentTimestamp = Date.now()
|
||||
const startTimestamp = getTimestamp(
|
||||
p.date.start_date,
|
||||
p.date.start_time,
|
||||
p.date.time_zone
|
||||
)
|
||||
const endTimestamp = getTimestamp(
|
||||
p.date.end_date,
|
||||
p.date.end_time,
|
||||
p.date.time_zone
|
||||
)
|
||||
console.log(
|
||||
'[定时任务] 隐藏--> 文章:',
|
||||
p.title,
|
||||
'当前时间戳:',
|
||||
currentTimestamp,
|
||||
'目标时间戳:',
|
||||
startTimestamp,
|
||||
'-',
|
||||
endTimestamp
|
||||
)
|
||||
console.log(
|
||||
'[定时发布] 隐藏--> 文章:',
|
||||
p.title,
|
||||
'当前时间:',
|
||||
Date.now(),
|
||||
'目标',
|
||||
new Date(),
|
||||
'目标时间:',
|
||||
p.date
|
||||
)
|
||||
// 隐藏
|
||||
@@ -651,47 +672,31 @@ function isInRange(title, date = {}) {
|
||||
// 获取当前时间的时间戳(基于目标时区)
|
||||
const currentTimestamp = Date.now()
|
||||
|
||||
// 辅助函数:生成指定日期时间的时间戳(基于目标时区)
|
||||
function getTimestamp(date, time) {
|
||||
if (!date) return null
|
||||
const dateTimeString = `${date}T${time}:00` // 拼接日期时间
|
||||
return new Date(
|
||||
new Date(dateTimeString).toLocaleString('en-US', { timeZone: time_zone })
|
||||
).getTime()
|
||||
}
|
||||
|
||||
// 获取开始和结束时间的时间戳
|
||||
const startTimestamp = getTimestamp(start_date, start_time)
|
||||
const endTimestamp = getTimestamp(end_date, end_time)
|
||||
const startTimestamp = getTimestamp(start_date, start_time, time_zone)
|
||||
const endTimestamp = getTimestamp(end_date, end_time, time_zone)
|
||||
|
||||
// 判断是否在范围内
|
||||
if (startTimestamp && currentTimestamp < startTimestamp) {
|
||||
console.log(
|
||||
'[定时发布] 未到发布时间:',
|
||||
title,
|
||||
'指定时间:',
|
||||
new Date(startTimestamp),
|
||||
'当前时间:',
|
||||
new Date(currentTimestamp)
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
if (endTimestamp && currentTimestamp > endTimestamp) {
|
||||
console.log(
|
||||
'[定时发布] 超过下架时间:',
|
||||
title,
|
||||
'指定时间:',
|
||||
new Date(endTimestamp),
|
||||
'当前时间:',
|
||||
new Date(currentTimestamp)
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// 辅助函数:生成指定日期时间的时间戳(基于目标时区)
|
||||
function getTimestamp(date, time, time_zone) {
|
||||
if (!date) return null
|
||||
const dateTimeString = `${date}T${time}:00` // 拼接日期时间
|
||||
return new Date(
|
||||
new Date(dateTimeString).toLocaleString('en-US', { timeZone: time_zone })
|
||||
).getTime()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导航用的精减文章列表
|
||||
* gitbook主题用到,只保留文章的标题分类标签分类信息,精减掉摘要密码日期等数据
|
||||
|
||||
Reference in New Issue
Block a user