From f6f0e9d41a9d1606fd85fada1a4f152fd8b3377c Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Fri, 17 Dec 2021 21:21:44 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E5=B9=BF=E5=91=8A=E3=80=81=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/SideArea.js | 22 +++++++++++----------- lib/cache/cache_manager.js | 1 - lib/cache/memory_cache.js | 5 ++++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/components/SideArea.js b/components/SideArea.js index 9d9e4473..d39b160a 100644 --- a/components/SideArea.js +++ b/components/SideArea.js @@ -52,17 +52,6 @@ const SideArea = ({ title, tags, currentTag, post, posts, categories, currentCat )} -
- {/* 展示广告 */} - -
- {/* 分类 */} {categories && (
@@ -94,6 +83,17 @@ const SideArea = ({ title, tags, currentTag, post, posts, categories, currentCat
)} + +
+ {/* 展示广告 */} + +
{post && post.toc && post.toc.length > 1 && ( diff --git a/lib/cache/cache_manager.js b/lib/cache/cache_manager.js index 24bf33ae..045b5abd 100644 --- a/lib/cache/cache_manager.js +++ b/lib/cache/cache_manager.js @@ -1,4 +1,3 @@ -import BLOG from '@/blog.config' import { getCacheFromMemory, setCacheToMemory } from '@/lib/cache/memory_cache' const enableCache = true // 生产环境禁用 diff --git a/lib/cache/memory_cache.js b/lib/cache/memory_cache.js index ce107e0c..973225a0 100644 --- a/lib/cache/memory_cache.js +++ b/lib/cache/memory_cache.js @@ -1,9 +1,12 @@ import cache from 'memory-cache' +import BLOG from 'blog.config' + +const cacheTime = BLOG.isProd ? 60 : 60 * 60 export async function getCacheFromMemory (key, options) { return cache.get(key) } export async function setCacheToMemory (key, data) { - await cache.put(key, data, 60 * 1000) // 1 minutes + await cache.put(key, data, cacheTime * 1000) }