mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-04 07:26:47 +00:00
Merge branch 'main' into feat-data-cache
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import BLOG from '@/blog.config'
|
||||
import { getDataFromCache, getOrSetDataWithCache, setDataToCache } from '@/lib/cache/cache_manager'
|
||||
import { deepClone, delay } from '../utils'
|
||||
import getNotionAPI from '@/lib/notion/getNotionAPI'
|
||||
import notionAPI from '@/lib/notion/getNotionAPI'
|
||||
|
||||
/**
|
||||
* 获取文章内容
|
||||
@@ -49,9 +49,8 @@ export async function getPageWithRetry(id, from, retryAttempts = 3) {
|
||||
retryAttempts < 3 ? `剩余重试次数:${retryAttempts}` : ''
|
||||
)
|
||||
try {
|
||||
const api = getNotionAPI()
|
||||
const start = new Date().getTime()
|
||||
const pageData = await api.getPage(id)
|
||||
const pageData = await notionAPI.getPage(id)
|
||||
const end = new Date().getTime()
|
||||
console.log('[API<<--响应]', `耗时:${end - start}ms - from:${from}`)
|
||||
return pageData
|
||||
@@ -169,14 +168,12 @@ export const fetchInBatches = async (ids, batchSize = 100) => {
|
||||
ids = [ids]
|
||||
}
|
||||
|
||||
const api = getNotionAPI()
|
||||
|
||||
let fetchedBlocks = {}
|
||||
for (let i = 0; i < ids.length; i += batchSize) {
|
||||
const batch = ids.slice(i, i + batchSize)
|
||||
console.log('[API-->>请求] Fetching missing blocks', batch, ids.length)
|
||||
const start = new Date().getTime()
|
||||
const pageChunk = await api.getBlocks(batch)
|
||||
const pageChunk = await notionAPI.getBlocks(batch)
|
||||
const end = new Date().getTime()
|
||||
console.log(
|
||||
`[API<<--响应] 耗时:${end - start}ms Fetching missing blocks count:${ids.length} `
|
||||
|
||||
Reference in New Issue
Block a user