From 46aed51811f302dec226911d8dd26e812ca01c1e Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 31 Jan 2024 14:36:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A0=E7=89=A9=E4=B8=BB=E9=A2=98=E5=88=87?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/global.js | 5 +++-- lib/notion/getNotionData.js | 2 +- themes/theme.js | 14 +++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/global.js b/lib/global.js index f6ffc1e8..3346b4da 100644 --- a/lib/global.js +++ b/lib/global.js @@ -25,10 +25,11 @@ export function GlobalContextProvider(props) { // 切换主题 function switchTheme() { - const currentIndex = THEMES.indexOf(theme) + const query = router.query + const currentTheme = query.theme || theme + const currentIndex = THEMES.indexOf(currentTheme) const newIndex = currentIndex < THEMES.length - 1 ? currentIndex + 1 : 0 const newTheme = THEMES[newIndex] - const query = router.query query.theme = newTheme router.push({ pathname: router.pathname, query }) return newTheme diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js index e06553eb..4902f5e4 100755 --- a/lib/notion/getNotionData.js +++ b/lib/notion/getNotionData.js @@ -278,7 +278,7 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) { if (pageIds?.length === 0) { console.error('获取到的文章列表为空,请检查notion模板', collectionQuery, collection, collectionView, viewIds, pageRecordMap) } else { - console.log('有效Page数量', pageIds?.length) + // console.log('有效Page数量', pageIds?.length) } // 获取每篇文章基础数据 diff --git a/themes/theme.js b/themes/theme.js index 9261749e..da9e1b66 100644 --- a/themes/theme.js +++ b/themes/theme.js @@ -14,13 +14,13 @@ export const { THEMES = [] } = getConfig().publicRuntimeConfig * @returns */ export const getGlobalLayoutByTheme = (themeQuery) => { - const layout = getLayoutNameByPath(-1) - if (themeQuery !== BLOG.THEME) { - return dynamic(() => import(`@/themes/${themeQuery}`).then(m => m[layout]), { ssr: true }) - } else { - return ThemeComponents[layout] - } + const layout = getLayoutNameByPath(-1) + if (themeQuery !== BLOG.THEME) { + return dynamic(() => import(`@/themes/${themeQuery}`).then(m => m[layout]), { ssr: true }) + } else { + return ThemeComponents[layout] } +} /** * 加载主题文件 @@ -71,7 +71,7 @@ const checkThemeDOM = () => { export const getLayoutNameByPath = (path) => { switch (path) { case -1: - return 'LayoutBase' + return 'LayoutBase' case '/': return 'LayoutIndex' case '/archive':