From 9cb46de3e1bfd26cc6b43df77d664d95c8df9ff2 Mon Sep 17 00:00:00 2001 From: Tsuki Date: Mon, 18 Aug 2025 00:03:16 +0800 Subject: [PATCH] fix url error --- app/[slug]/not-found.tsx | 36 ----- app/[slug]/page.tsx | 39 ----- app/admin/blogs/create-blog-form.tsx | 4 +- app/admin/categories/create-category-form.tsx | 2 +- .../role-permission-management.tsx | 8 +- app/admin/tags/create-tag-form.tsx | 2 +- app/api/login/route.ts | 1 + app/api/site/route.ts | 2 +- app/tl.tsx | 2 +- components/map-component.tsx | 2 +- .../simple/enhanced-simple-editor.tsx | 2 +- lib/apollo-client.ts | 5 +- lib/fetchers.ts | 32 +++- lib/gql.ts | 2 +- types/config.ts | 144 +++++++++++++++++- types/user.ts | 2 +- 16 files changed, 189 insertions(+), 96 deletions(-) delete mode 100644 app/[slug]/not-found.tsx delete mode 100644 app/[slug]/page.tsx diff --git a/app/[slug]/not-found.tsx b/app/[slug]/not-found.tsx deleted file mode 100644 index 89114a2..0000000 --- a/app/[slug]/not-found.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import Link from "next/link"; -import { Home, Search } from "lucide-react"; - -export default function NotFound() { - return ( -
-
-
404
-

- 页面未找到 -

-

- 抱歉,您访问的页面不存在或已被移除。 -

- -
- - - 返回首页 - - - - - 查看示例 - -
-
-
- ); -} \ No newline at end of file diff --git a/app/[slug]/page.tsx b/app/[slug]/page.tsx deleted file mode 100644 index 9e07323..0000000 --- a/app/[slug]/page.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { fetchPage } from "@/lib/fetchers"; -import { RenderBlock } from "@/components/registry"; -import { notFound } from "next/navigation"; - -export const revalidate = 60; // ISR: 60秒后重新验证 - -export default async function Page({ params }: { params: Promise<{ slug: string }> }) { - const { slug } = await params; - const page = await fetchPage(slug); - - if (!page) { - return notFound(); - } - - return ( -
-
- {/* 页面标题 */} -
-

- {page.title} -

- {page.description && ( -

- {page.description} -

- )} -
- - {/* 渲染所有块 */} -
- {page.blocks.map((block) => ( - - ))} -
-
-
- ); -} \ No newline at end of file diff --git a/app/admin/blogs/create-blog-form.tsx b/app/admin/blogs/create-blog-form.tsx index 1b99280..24005b8 100644 --- a/app/admin/blogs/create-blog-form.tsx +++ b/app/admin/blogs/create-blog-form.tsx @@ -32,8 +32,8 @@ const schema = z.object({ status: z.enum(["draft", "published", "archived"]), metaTitle: z.string().optional(), metaDescription: z.string().optional(), - isFeatured: z.boolean().default(false), - isActive: z.boolean().default(true), + isFeatured: z.boolean(), + isActive: z.boolean(), }) export default function CreateBlogForm() { diff --git a/app/admin/categories/create-category-form.tsx b/app/admin/categories/create-category-form.tsx index 31e272a..6dbc743 100644 --- a/app/admin/categories/create-category-form.tsx +++ b/app/admin/categories/create-category-form.tsx @@ -30,7 +30,7 @@ const schema = z.object({ color: z.string().optional(), icon: z.string().optional(), parentId: z.string().optional(), - isActive: z.boolean().default(true), + isActive: z.boolean(), }) export default function CreateCategoryForm() { diff --git a/app/admin/permissions/role-permission-management.tsx b/app/admin/permissions/role-permission-management.tsx index 9efb1f9..53953f8 100644 --- a/app/admin/permissions/role-permission-management.tsx +++ b/app/admin/permissions/role-permission-management.tsx @@ -447,14 +447,14 @@ export function RolePermissionManagement() { const roles = rolesData?.roles?.items || [] const permissions = permissionsData?.permissions?.items || [] - const activeRoles = roles.filter(r => r.isActive) - const currentRole = selectedRole ? roles.find(r => r.id === selectedRole) : null + const activeRoles = roles.filter((r: any) => r.isActive) + const currentRole = selectedRole ? roles.find((r: any) => r.id === selectedRole) : null return (
{/* 角色概览卡片 */}
- {activeRoles.map((role) => ( + {activeRoles.map((role: any) => (
- {currentRole.permissions.map((permission) => ( + {currentRole.permissions.map((permission: any) => (
diff --git a/app/admin/tags/create-tag-form.tsx b/app/admin/tags/create-tag-form.tsx index c483d87..1d8a433 100644 --- a/app/admin/tags/create-tag-form.tsx +++ b/app/admin/tags/create-tag-form.tsx @@ -27,7 +27,7 @@ const schema = z.object({ slug: z.string().min(1, "别名不能为空"), description: z.string().optional(), color: z.string().optional(), - isActive: z.boolean().default(true), + isActive: z.boolean(), }) export default function CreateTagForm() { diff --git a/app/api/login/route.ts b/app/api/login/route.ts index 9b81d79..c3d9107 100644 --- a/app/api/login/route.ts +++ b/app/api/login/route.ts @@ -39,6 +39,7 @@ export async function POST(request: NextRequest) { } catch (error) { + console.log(process.env.GRAPHQL_BACKEND_URL) console.error('Login error:', error); return NextResponse.json( diff --git a/app/api/site/route.ts b/app/api/site/route.ts index ea8cea1..af75e49 100644 --- a/app/api/site/route.ts +++ b/app/api/site/route.ts @@ -12,7 +12,7 @@ const GET_CONFIGS = gql` ` export async function GET(request: NextRequest) { - const client = new GraphQLClient(process.env.GRAPHQL_URL || 'http://localhost:3050/graphql'); + const client = new GraphQLClient(process.env.GRAPHQL_BACKEND_URL || 'http://localhost:3050/graphql'); try { const data: any = await client.request(GET_CONFIGS); return NextResponse.json(data.siteConfigs); diff --git a/app/tl.tsx b/app/tl.tsx index 7d6f87d..5ee6b83 100644 --- a/app/tl.tsx +++ b/app/tl.tsx @@ -164,7 +164,7 @@ export const Timeline: React.FC = React.memo(({ }, onDateChange: async (date: Date) => { const datestr = formatInTimeZone(date, 'UTC', 'yyyyMMddHHmmss') - const url_base = process.env.GRAPHQL_BACKEND_URL || 'http://localhost:3050' + const url_base = process.env.GRAPHQL_BACKEND_URL?.replace('/graphql', '') || 'http://localhost:3050' const response = await fetch(`${url_base}/api/v1/data/nearest?datetime=${datestr}&area=cn`) setTimelineTime(date) diff --git a/components/map-component.tsx b/components/map-component.tsx index 02c1912..e23d878 100644 --- a/components/map-component.tsx +++ b/components/map-component.tsx @@ -58,7 +58,7 @@ export function MapComponent({ useEffect(() => { if (!isMapReady || !currentDatetime) return; const utc_time_str = formatInTimeZone(currentDatetime, 'UTC', 'yyyyMMddHHmmss') - const new_url_prefix = process.env.GRAPHQL_BACKEND_URL || 'http://localhost:3050' + const new_url_prefix = process.env.GRAPHQL_BACKEND_URL?.replace('/graphql', '') || 'http://localhost:3050' const new_url = `${new_url_prefix}/api/v1/data?datetime=${utc_time_str}&area=cn` fetchRadarTile(new_url) }, [currentDatetime, isMapReady]) diff --git a/components/tiptap-templates/simple/enhanced-simple-editor.tsx b/components/tiptap-templates/simple/enhanced-simple-editor.tsx index 69f3249..d5132ee 100644 --- a/components/tiptap-templates/simple/enhanced-simple-editor.tsx +++ b/components/tiptap-templates/simple/enhanced-simple-editor.tsx @@ -248,7 +248,7 @@ export function EnhancedSimpleEditor({ content, onChange }: EnhancedSimpleEditor // Only update if content actually changed to avoid infinite loops if (JSON.stringify(currentContent) !== JSON.stringify(newContent)) { - editor.commands.setContent(newContent, false) + editor.commands.setContent(newContent, { emitUpdate: false }) } } }, [editor, content]) diff --git a/lib/apollo-client.ts b/lib/apollo-client.ts index b6578a0..57a39e6 100644 --- a/lib/apollo-client.ts +++ b/lib/apollo-client.ts @@ -8,11 +8,12 @@ import { createClient } from 'graphql-ws'; const TOKEN_KEY = 'auth_token'; const httpLink = createHttpLink({ - uri: "http://127.0.0.1:3050/graphql", + uri: process.env.GRAPHQL_BACKEND_URL || 'http://localhost:3050/graphql', }); const wsLink = new GraphQLWsLink(createClient({ - url: "ws://127.0.0.1:3050/ws", + // url: "ws://127.0.0.1:3050/ws", + url: process.env.GRAPHQL_BACKEND_URL?.replace('/graphql', '/ws')?.replace('http://', 'ws://') || 'ws://localhost:3050/ws', })); const authLink = setContext((_, { headers }) => { diff --git a/lib/fetchers.ts b/lib/fetchers.ts index 0ef5ec8..6574a0a 100644 --- a/lib/fetchers.ts +++ b/lib/fetchers.ts @@ -63,8 +63,32 @@ export async function fetchPage(slug: string, jwt?: string): Promise