mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-13 19:20:04 +00:00
🐛 fix: try to fix discover error (#5794)
This commit is contained in:
@@ -176,11 +176,6 @@ const nextConfig: NextConfig = {
|
||||
permanent: false,
|
||||
source: '/repos',
|
||||
},
|
||||
{
|
||||
destination: '/files',
|
||||
permanent: false,
|
||||
source: '/repos',
|
||||
},
|
||||
],
|
||||
// when external packages in dev mode with turbopack, this config will lead to bundle error
|
||||
serverExternalPackages: isProd ? ['@electric-sql/pglite'] : undefined,
|
||||
|
||||
@@ -9,6 +9,7 @@ import { DiscoverService } from '@/server/services/discover';
|
||||
import { translation } from '@/server/translation';
|
||||
import { DiscoverProviderItem } from '@/types/discover';
|
||||
import { PageProps } from '@/types/next';
|
||||
import { parsePageLocale } from '@/utils/locale';
|
||||
import { RouteVariants } from '@/utils/server/routeVariants';
|
||||
|
||||
import DetailLayout from '../../features/DetailLayout';
|
||||
@@ -26,9 +27,10 @@ export const generateMetadata = async (props: Props) => {
|
||||
|
||||
const { slugs } = params;
|
||||
const identifier = decodeURIComponent(slugs.join('/'));
|
||||
const { t, locale } = await translation('metadata', searchParams?.hl);
|
||||
const { t } = await translation('metadata', searchParams?.hl);
|
||||
const { t: td } = await translation('models', searchParams?.hl);
|
||||
|
||||
const locale = await parsePageLocale(props);
|
||||
const discoverService = new DiscoverService();
|
||||
const data = await discoverService.getModelById(locale, identifier);
|
||||
if (!data) return;
|
||||
@@ -70,9 +72,11 @@ const Page = async (props: Props) => {
|
||||
const { slugs } = params;
|
||||
|
||||
const identifier = decodeURIComponent(slugs.join('/'));
|
||||
const { t, locale } = await translation('metadata', searchParams?.hl);
|
||||
const { t } = await translation('metadata', searchParams?.hl);
|
||||
const { t: td } = await translation('models', searchParams?.hl);
|
||||
|
||||
const mobile = await RouteVariants.getIsMobile(props);
|
||||
const locale = await parsePageLocale(props);
|
||||
|
||||
const discoverService = new DiscoverService();
|
||||
const data = await discoverService.getModelById(locale, identifier);
|
||||
|
||||
@@ -7,6 +7,7 @@ import { metadataModule } from '@/server/metadata';
|
||||
import { DiscoverService } from '@/server/services/discover';
|
||||
import { translation } from '@/server/translation';
|
||||
import { DiscoverPageProps } from '@/types/discover';
|
||||
import { parsePageLocale } from '@/utils/locale';
|
||||
import { RouteVariants } from '@/utils/server/routeVariants';
|
||||
|
||||
import List from '../features/List';
|
||||
@@ -15,7 +16,8 @@ export const generateMetadata = async (props: DiscoverPageProps) => {
|
||||
const params = await props.params;
|
||||
const searchParams = await props.searchParams;
|
||||
|
||||
const { t, locale } = await translation('metadata', searchParams?.hl);
|
||||
const { t } = await translation('metadata', searchParams?.hl);
|
||||
const locale = await parsePageLocale(props);
|
||||
|
||||
const discoverService = new DiscoverService();
|
||||
const list = await discoverService.getProviderList(locale);
|
||||
@@ -34,8 +36,9 @@ const Page = async (props: DiscoverPageProps) => {
|
||||
const params = await props.params;
|
||||
const searchParams = await props.searchParams;
|
||||
|
||||
const { t, locale } = await translation('metadata', searchParams?.hl);
|
||||
const { t } = await translation('metadata', searchParams?.hl);
|
||||
const mobile = await RouteVariants.getIsMobile(props);
|
||||
const locale = await parsePageLocale(props);
|
||||
|
||||
const discoverService = new DiscoverService();
|
||||
const list = await discoverService.getProviderList(locale);
|
||||
@@ -62,10 +65,8 @@ const Page = async (props: DiscoverPageProps) => {
|
||||
|
||||
export const generateStaticParams = async () => {
|
||||
const discoverService = new DiscoverService();
|
||||
const cates = await discoverService.getProviderList(DEFAULT_LANG);
|
||||
return cates.map((cate) => ({
|
||||
slug: cate.identifier,
|
||||
}));
|
||||
const categories = await discoverService.getProviderList(DEFAULT_LANG);
|
||||
return categories.map((cate) => ({ slug: cate.identifier }));
|
||||
};
|
||||
|
||||
Page.DisplayName = 'DiscoverModelsCategory';
|
||||
|
||||
@@ -8,6 +8,7 @@ import { memo, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import urlJoin from 'url-join';
|
||||
|
||||
import { withSuspense } from '@/components/withSuspense';
|
||||
import { useQueryRoute } from '@/hooks/useQueryRoute';
|
||||
import { DiscoverTab } from '@/types/discover';
|
||||
|
||||
@@ -79,4 +80,4 @@ const StoreSearchBar = memo<StoreSearchBarProps>(({ mobile, onBlur, onFocus, ...
|
||||
);
|
||||
});
|
||||
|
||||
export default StoreSearchBar;
|
||||
export default withSuspense(StoreSearchBar);
|
||||
|
||||
@@ -10,5 +10,3 @@ const MainLayout = ServerLayout<PropsWithChildren>({ Desktop, Mobile });
|
||||
MainLayout.displayName = 'DiscoverStoreLayout';
|
||||
|
||||
export default MainLayout;
|
||||
|
||||
export const dynamic = 'force-static';
|
||||
|
||||
@@ -71,3 +71,5 @@ const Page = async (props: Props) => {
|
||||
Page.DisplayName = 'DiscoverSearch';
|
||||
|
||||
export default Page;
|
||||
|
||||
export const dynamic = 'force-static';
|
||||
|
||||
Reference in New Issue
Block a user