mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-17 15:09:31 +00:00
feature:
本地编译优化
This commit is contained in:
9
lib/cache/local_file_cache.js
vendored
9
lib/cache/local_file_cache.js
vendored
@@ -10,7 +10,14 @@ export async function getCacheFromFile (key) {
|
||||
const exist = await fs.existsSync(jsonFile)
|
||||
if (!exist) return null
|
||||
const data = await fs.readFileSync(jsonFile)
|
||||
const json = data ? JSON.parse(data) : {}
|
||||
let json = null
|
||||
if (!data) return null
|
||||
try {
|
||||
json = JSON.parse(data)
|
||||
} catch (error) {
|
||||
console.error('读取JSON缓存文件失败', data)
|
||||
return null
|
||||
}
|
||||
// 缓存超过有效期就作废
|
||||
const cacheValidTime = new Date(parseInt(json[key + '_expire_time']) + cacheInvalidSeconds)
|
||||
const currentTime = new Date()
|
||||
|
||||
Reference in New Issue
Block a user