From 5ad66a644b4450df27ab62cb3fbc4a881575a36e Mon Sep 17 00:00:00 2001 From: CanisMinor Date: Thu, 26 Dec 2024 15:23:50 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20Fix=20changelog=20fetch?= =?UTF-8?q?=20fail=20(fix=20#5187)=20(#5189)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(main)/changelog/page.tsx | 4 +++- src/app/@modal/(.)changelog/modal/page.tsx | 4 +++- src/features/ChangelogModal/index.tsx | 10 ++++++++-- src/features/User/UserPanel/useMenu.tsx | 2 +- src/server/services/changelog/index.ts | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/app/(main)/changelog/page.tsx b/src/app/(main)/changelog/page.tsx index 861735fe65c6..fe8ae4edeb97 100644 --- a/src/app/(main)/changelog/page.tsx +++ b/src/app/(main)/changelog/page.tsx @@ -38,6 +38,8 @@ const Page = async () => { const changelogService = new ChangelogService(); const data = await changelogService.getChangelogIndex(); + if (!data) return notFound(); + const ld = ldModule.generate({ description: t('changelog.description', { appName: BRANDING_NAME }), title: t('changelog.title', { appName: BRANDING_NAME }), @@ -48,7 +50,7 @@ const Page = async () => { <> - {data.map((item) => ( + {data?.map((item) => ( { const changelogService = new ChangelogService(); const data = await changelogService.getChangelogIndex(); + if (!data) return notFound(); + return ( <> - {data.map((item) => ( + {data?.map((item) => ( } key={item.id}> diff --git a/src/features/ChangelogModal/index.tsx b/src/features/ChangelogModal/index.tsx index fac8bf59d85a..cc527bdafaa0 100644 --- a/src/features/ChangelogModal/index.tsx +++ b/src/features/ChangelogModal/index.tsx @@ -7,11 +7,17 @@ import { memo } from 'react'; import { useGlobalStore } from '@/store/global'; const ChangelogModal = memo<{ currentId?: string }>(({ currentId }) => { - const latestChangelogId = useGlobalStore((s) => s.status.latestChangelogId); + const [latestChangelogId, updateSystemStatus] = useGlobalStore((s) => [ + s.status.latestChangelogId, + s.updateSystemStatus, + ]); const router = useRouter(); useTimeout(() => { - if (latestChangelogId !== currentId) { + if (!currentId) return; + if (!latestChangelogId) { + updateSystemStatus({ latestChangelogId: currentId }); + } else if (latestChangelogId !== currentId) { router.push('/changelog/modal'); } }, 1000); diff --git a/src/features/User/UserPanel/useMenu.tsx b/src/features/User/UserPanel/useMenu.tsx index d3e0f651c1e7..62a9cfffc1e0 100644 --- a/src/features/User/UserPanel/useMenu.tsx +++ b/src/features/User/UserPanel/useMenu.tsx @@ -188,7 +188,7 @@ export const useMenu = () => { { icon: , key: 'changelog', - label: {t('changelog')}, + label: {t('changelog')}, }, { children: [ diff --git a/src/server/services/changelog/index.ts b/src/server/services/changelog/index.ts index 45e1e2014cad..dd5a464afc37 100644 --- a/src/server/services/changelog/index.ts +++ b/src/server/services/changelog/index.ts @@ -54,7 +54,7 @@ export class ChangelogService { return this.mergeChangelogs(data.cloud, data.community).slice(0, 5); } catch (e) { console.error('Error getting changelog lists:', e); - return false as any; + return []; } }