mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-03 07:26:45 +00:00
v4.2.4
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
# 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables
|
# 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables
|
||||||
NEXT_PUBLIC_VERSION=4.2.3
|
NEXT_PUBLIC_VERSION=4.2.4
|
||||||
|
|
||||||
|
|
||||||
# 可在此添加环境变量,去掉最左边的(# )注释即可
|
# 可在此添加环境变量,去掉最左边的(# )注释即可
|
||||||
|
|||||||
@@ -18,10 +18,7 @@ export async function getPostBlocks(id, from, slice) {
|
|||||||
return filterPostBlocks(id, pageBlock, slice)
|
return filterPostBlocks(id, pageBlock, slice)
|
||||||
}
|
}
|
||||||
|
|
||||||
const start = new Date().getTime()
|
|
||||||
pageBlock = await getPageWithRetry(id, from)
|
pageBlock = await getPageWithRetry(id, from)
|
||||||
const end = new Date().getTime()
|
|
||||||
console.log('[API耗时]', `${end - start}ms`)
|
|
||||||
|
|
||||||
if (pageBlock) {
|
if (pageBlock) {
|
||||||
await setDataToCache(cacheKey, pageBlock)
|
await setDataToCache(cacheKey, pageBlock)
|
||||||
@@ -38,10 +35,7 @@ export async function getSingleBlock(id, from) {
|
|||||||
return pageBlock
|
return pageBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
const start = new Date().getTime()
|
|
||||||
pageBlock = await getPageWithRetry(id, from)
|
pageBlock = await getPageWithRetry(id, from)
|
||||||
const end = new Date().getTime()
|
|
||||||
console.log('[API耗时]', `${end - start}ms`)
|
|
||||||
|
|
||||||
if (pageBlock) {
|
if (pageBlock) {
|
||||||
await setDataToCache(cacheKey, pageBlock)
|
await setDataToCache(cacheKey, pageBlock)
|
||||||
@@ -56,16 +50,17 @@ export async function getSingleBlock(id, from) {
|
|||||||
*/
|
*/
|
||||||
export async function getPageWithRetry(id, from, retryAttempts = 3) {
|
export async function getPageWithRetry(id, from, retryAttempts = 3) {
|
||||||
if (retryAttempts && retryAttempts > 0) {
|
if (retryAttempts && retryAttempts > 0) {
|
||||||
console.log('[请求API]', `from:${from}`, `id:${id}`, retryAttempts < 3 ? `剩余重试次数:${retryAttempts}` : '')
|
console.log('[API-->>请求]', `from:${from}`, `id:${id}`, retryAttempts < 3 ? `剩余重试次数:${retryAttempts}` : '')
|
||||||
try {
|
try {
|
||||||
const authToken = BLOG.NOTION_ACCESS_TOKEN || null
|
const authToken = BLOG.NOTION_ACCESS_TOKEN || null
|
||||||
const api = new NotionAPI({ authToken, userTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone })
|
const api = new NotionAPI({ authToken, userTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone })
|
||||||
|
const start = new Date().getTime()
|
||||||
const pageData = await api.getPage(id)
|
const pageData = await api.getPage(id)
|
||||||
// console.log('stringfy', JSON.stringify(pageData))
|
const end = new Date().getTime()
|
||||||
console.info('[响应成功]:', `from:${from}`)
|
console.log('[API<<--响应]', `耗时:${end - start}ms - from:${from}`)
|
||||||
return pageData
|
return pageData
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('[响应异常]:', e)
|
console.warn('[API<<--异常]:', e)
|
||||||
await delay(1000)
|
await delay(1000)
|
||||||
const cacheKey = 'page_block_' + id
|
const cacheKey = 'page_block_' + id
|
||||||
const pageBlock = await getDataFromCache(cacheKey)
|
const pageBlock = await getDataFromCache(cacheKey)
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ module.exports = withBundleAnalyzer({
|
|||||||
// }
|
// }
|
||||||
// 动态主题:添加 resolve.alias 配置,将动态路径映射到实际路径
|
// 动态主题:添加 resolve.alias 配置,将动态路径映射到实际路径
|
||||||
if (!isServer) {
|
if (!isServer) {
|
||||||
console.log('加载默认主题', path.resolve(__dirname, 'themes', THEME))
|
console.log('[加载主题]', path.resolve(__dirname, 'themes', THEME))
|
||||||
}
|
}
|
||||||
config.resolve.alias['@theme-components'] = path.resolve(__dirname, 'themes', THEME)
|
config.resolve.alias['@theme-components'] = path.resolve(__dirname, 'themes', THEME)
|
||||||
return config
|
return config
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "notion-next",
|
"name": "notion-next",
|
||||||
"version": "4.2.3",
|
"version": "4.2.4",
|
||||||
"homepage": "https://github.com/tangly1024/NotionNext.git",
|
"homepage": "https://github.com/tangly1024/NotionNext.git",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
Reference in New Issue
Block a user