From 85ca8b1da7e7c785a8b3cdf52eef391f1299cb45 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Sat, 12 Apr 2025 08:58:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=BE=A9=E6=97=A0=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/cache/cache_manager.js | 2 +- lib/notion/getAllTags.js | 2 +- lib/notion/getPostBlocks.js | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/cache/cache_manager.js b/lib/cache/cache_manager.js index ba643b51..c9f7b95f 100644 --- a/lib/cache/cache_manager.js +++ b/lib/cache/cache_manager.js @@ -40,7 +40,7 @@ export async function getOrSetDataWithCustomCache( ) { const dataFromCache = await getDataFromCache(key) if (dataFromCache) { - console.log('[缓存-->>API]:', key) + // console.log('[缓存-->>API]:', key) // 避免过多的缓存日志输出 return dataFromCache } const data = await getDataFunction(...getDataArgs) diff --git a/lib/notion/getAllTags.js b/lib/notion/getAllTags.js index d8430ff7..db5ea55b 100644 --- a/lib/notion/getAllTags.js +++ b/lib/notion/getAllTags.js @@ -28,7 +28,7 @@ export function getAllTags({ const AllTagInfos = {} // 遍历所有文章 allPosts.forEach(post => { - post.tags.forEach(tag => { + post?.tags?.forEach(tag => { // 如果标签已经存在 if (AllTagInfos[tag]) { if ( diff --git a/lib/notion/getPostBlocks.js b/lib/notion/getPostBlocks.js index 19ca3b51..fb486d61 100644 --- a/lib/notion/getPostBlocks.js +++ b/lib/notion/getPostBlocks.js @@ -8,17 +8,17 @@ import { deepClone, delay } from '../utils' import notionAPI from '@/lib/notion/getNotionAPI' /** - * 获取文章内容 + * 获取文章内容块 * @param {*} id * @param {*} from * @param {*} slice * @returns */ export async function getPage(id, from = null, slice) { + const cacheKey = `page_content_${id}` return await getOrSetDataWithCache( - `page_content_${id}_${slice}`, + cacheKey, async (id, slice) => { - const cacheKey = `page_block_${id}` let pageBlock = await getDataFromCache(cacheKey) if (pageBlock) { // console.debug('[API<<--缓存]', `from:${from}`, cacheKey)