From f9736deab8b7b52f0657f4f8aa447fa4e011dac8 Mon Sep 17 00:00:00 2001 From: Che <30403707+Che-Zhu@users.noreply.github.com> Date: Mon, 19 Jan 2026 14:43:59 +0800 Subject: [PATCH 1/3] refactor: reorganize app directory with route groups and add error pages - Organize application routes into (auth) and (dashboard) groups - Add global error.tsx and not-found.tsx for better error handling - Move sealos-auth action to lib directory - Update references and imports --- app/{error => (auth)/auth-error}/page.tsx | 0 app/{ => (auth)}/login/page.tsx | 0 .../projects/[id]/auth/page.tsx | 0 .../[id]/database/connection-string.tsx | 0 .../projects/[id]/database/page.tsx | 0 .../projects/[id]/environment/page.tsx | 0 .../projects/[id]/exec-test/client.tsx | 0 .../projects/[id]/exec-test/page.tsx | 0 .../projects/[id]/github/page.tsx | 0 .../projects/[id]/layout.tsx | 0 app/{ => (dashboard)}/projects/[id]/page.tsx | 0 .../projects/[id]/payment/page.tsx | 0 .../projects/[id]/secrets/page.tsx | 0 .../projects/[id]/terminal/page.tsx | 0 app/{ => (dashboard)}/projects/page.tsx | 0 app/error.tsx | 88 +++++++++++++++++++ app/not-found.tsx | 64 ++++++++++++++ components/home-page.tsx | 2 +- {app => lib}/actions/sealos-auth.ts | 0 lib/auth.ts | 2 +- 20 files changed, 154 insertions(+), 2 deletions(-) rename app/{error => (auth)/auth-error}/page.tsx (100%) rename app/{ => (auth)}/login/page.tsx (100%) rename app/{ => (dashboard)}/projects/[id]/auth/page.tsx (100%) rename app/{ => (dashboard)}/projects/[id]/database/connection-string.tsx (100%) rename app/{ => (dashboard)}/projects/[id]/database/page.tsx (100%) rename app/{ => (dashboard)}/projects/[id]/environment/page.tsx (100%) rename app/{ => (dashboard)}/projects/[id]/exec-test/client.tsx (100%) rename app/{ => (dashboard)}/projects/[id]/exec-test/page.tsx (100%) rename app/{ => (dashboard)}/projects/[id]/github/page.tsx (100%) rename app/{ => (dashboard)}/projects/[id]/layout.tsx (100%) rename app/{ => (dashboard)}/projects/[id]/page.tsx (100%) rename app/{ => (dashboard)}/projects/[id]/payment/page.tsx (100%) rename app/{ => (dashboard)}/projects/[id]/secrets/page.tsx (100%) rename app/{ => (dashboard)}/projects/[id]/terminal/page.tsx (100%) rename app/{ => (dashboard)}/projects/page.tsx (100%) create mode 100644 app/error.tsx create mode 100644 app/not-found.tsx rename {app => lib}/actions/sealos-auth.ts (100%) diff --git a/app/error/page.tsx b/app/(auth)/auth-error/page.tsx similarity index 100% rename from app/error/page.tsx rename to app/(auth)/auth-error/page.tsx diff --git a/app/login/page.tsx b/app/(auth)/login/page.tsx similarity index 100% rename from app/login/page.tsx rename to app/(auth)/login/page.tsx diff --git a/app/projects/[id]/auth/page.tsx b/app/(dashboard)/projects/[id]/auth/page.tsx similarity index 100% rename from app/projects/[id]/auth/page.tsx rename to app/(dashboard)/projects/[id]/auth/page.tsx diff --git a/app/projects/[id]/database/connection-string.tsx b/app/(dashboard)/projects/[id]/database/connection-string.tsx similarity index 100% rename from app/projects/[id]/database/connection-string.tsx rename to app/(dashboard)/projects/[id]/database/connection-string.tsx diff --git a/app/projects/[id]/database/page.tsx b/app/(dashboard)/projects/[id]/database/page.tsx similarity index 100% rename from app/projects/[id]/database/page.tsx rename to app/(dashboard)/projects/[id]/database/page.tsx diff --git a/app/projects/[id]/environment/page.tsx b/app/(dashboard)/projects/[id]/environment/page.tsx similarity index 100% rename from app/projects/[id]/environment/page.tsx rename to app/(dashboard)/projects/[id]/environment/page.tsx diff --git a/app/projects/[id]/exec-test/client.tsx b/app/(dashboard)/projects/[id]/exec-test/client.tsx similarity index 100% rename from app/projects/[id]/exec-test/client.tsx rename to app/(dashboard)/projects/[id]/exec-test/client.tsx diff --git a/app/projects/[id]/exec-test/page.tsx b/app/(dashboard)/projects/[id]/exec-test/page.tsx similarity index 100% rename from app/projects/[id]/exec-test/page.tsx rename to app/(dashboard)/projects/[id]/exec-test/page.tsx diff --git a/app/projects/[id]/github/page.tsx b/app/(dashboard)/projects/[id]/github/page.tsx similarity index 100% rename from app/projects/[id]/github/page.tsx rename to app/(dashboard)/projects/[id]/github/page.tsx diff --git a/app/projects/[id]/layout.tsx b/app/(dashboard)/projects/[id]/layout.tsx similarity index 100% rename from app/projects/[id]/layout.tsx rename to app/(dashboard)/projects/[id]/layout.tsx diff --git a/app/projects/[id]/page.tsx b/app/(dashboard)/projects/[id]/page.tsx similarity index 100% rename from app/projects/[id]/page.tsx rename to app/(dashboard)/projects/[id]/page.tsx diff --git a/app/projects/[id]/payment/page.tsx b/app/(dashboard)/projects/[id]/payment/page.tsx similarity index 100% rename from app/projects/[id]/payment/page.tsx rename to app/(dashboard)/projects/[id]/payment/page.tsx diff --git a/app/projects/[id]/secrets/page.tsx b/app/(dashboard)/projects/[id]/secrets/page.tsx similarity index 100% rename from app/projects/[id]/secrets/page.tsx rename to app/(dashboard)/projects/[id]/secrets/page.tsx diff --git a/app/projects/[id]/terminal/page.tsx b/app/(dashboard)/projects/[id]/terminal/page.tsx similarity index 100% rename from app/projects/[id]/terminal/page.tsx rename to app/(dashboard)/projects/[id]/terminal/page.tsx diff --git a/app/projects/page.tsx b/app/(dashboard)/projects/page.tsx similarity index 100% rename from app/projects/page.tsx rename to app/(dashboard)/projects/page.tsx diff --git a/app/error.tsx b/app/error.tsx new file mode 100644 index 0000000..0b77ad4 --- /dev/null +++ b/app/error.tsx @@ -0,0 +1,88 @@ +'use client'; + +import { useEffect } from 'react'; +import { AlertCircle, Home,RefreshCw } from 'lucide-react'; +import Link from 'next/link'; + +import { Button } from '@/components/ui/button'; + +export default function Error({ + error, + reset, +}: { + error: Error & { digest?: string }; + reset: () => void; +}) { + useEffect(() => { + // Log the error to an error reporting service + console.error('Application error:', error); + }, [error]); + + return ( +
+
+ {/* Error Header */} +
+
+ +
+
+

Something went wrong

+

+ An unexpected error occurred. Please try again or return to the home page. +

+
+
+ + {/* Error Details */} + {error.digest && ( +
+
+ + Error Reference +
+
{error.digest}
+
+ )} + + {/* Actions */} +
+ + + + +
+ + {/* Help Text */} +
+

+ If this problem persists, please{' '} + + open an issue + + {' '}on GitHub. +

+
+
+
+ ); +} diff --git a/app/not-found.tsx b/app/not-found.tsx new file mode 100644 index 0000000..49ea5ce --- /dev/null +++ b/app/not-found.tsx @@ -0,0 +1,64 @@ +import { ArrowLeft,FileQuestion, Home } from 'lucide-react'; +import Link from 'next/link'; + +import { Button } from '@/components/ui/button'; + +export default function NotFound() { + return ( +
+
+ {/* Header */} +
+
+ +
+
+

Page Not Found

+

+ The page you're looking for doesn't exist or has been moved. +

+
+
+ + {/* 404 Code Box */} +
+
+ + HTTP Status +
+
404 - NOT_FOUND
+
+ + {/* Actions */} +
+ + + + + + +
+ + {/* Help Text */} +
+

+ Check the URL for typos, or use the navigation above to find what you need. +

+
+
+
+ ); +} diff --git a/components/home-page.tsx b/components/home-page.tsx index f84348b..b23f608 100644 --- a/components/home-page.tsx +++ b/components/home-page.tsx @@ -6,9 +6,9 @@ import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { useSession } from 'next-auth/react'; -import { authenticateWithSealos } from '@/app/actions/sealos-auth'; import { MatrixRain } from '@/components/MatrixRain'; import { Button } from '@/components/ui/button'; +import { authenticateWithSealos } from '@/lib/actions/sealos-auth'; import { useSealos } from '@/provider/sealos'; /** diff --git a/app/actions/sealos-auth.ts b/lib/actions/sealos-auth.ts similarity index 100% rename from app/actions/sealos-auth.ts rename to lib/actions/sealos-auth.ts diff --git a/lib/auth.ts b/lib/auth.ts index 2d0f568..35d0e7d 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -515,7 +515,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth({ useSecureCookies: process.env.NODE_ENV === 'production', pages: { signIn: '/login', - error: '/error', + error: '/auth-error', }, secret: process.env.NEXTAUTH_SECRET, }) From e385f2b98dea1f9d6daa0d734534e910e2dc0f34 Mon Sep 17 00:00:00 2001 From: Che <30403707+Che-Zhu@users.noreply.github.com> Date: Mon, 19 Jan 2026 14:48:13 +0800 Subject: [PATCH 2/3] refactor: use Next.js Image component for GitHub avatar - Replace string img tag with next/image in settings dialog - Allow avatars.githubusercontent.com in next.config.ts --- components/dialog/settings-dialog.tsx | 7 +++++-- next.config.ts | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/components/dialog/settings-dialog.tsx b/components/dialog/settings-dialog.tsx index 180f559..c8aa5b3 100644 --- a/components/dialog/settings-dialog.tsx +++ b/components/dialog/settings-dialog.tsx @@ -1,6 +1,7 @@ 'use client'; import { useEffect, useState } from 'react'; +import Image from 'next/image'; import { Code, Database, Github, Save, Terminal } from 'lucide-react'; import { toast } from 'sonner'; @@ -614,10 +615,12 @@ export default function SettingsDialog({
{githubStatus.avatar_url && ( - GitHub Avatar )}
diff --git a/next.config.ts b/next.config.ts index 9de6bc0..3549a9d 100644 --- a/next.config.ts +++ b/next.config.ts @@ -6,6 +6,16 @@ const nextConfig: NextConfig = { compress: true, // Exclude server-side packages from bundling serverExternalPackages: ['pino'], + images: { + remotePatterns: [ + { + protocol: 'https', + hostname: 'avatars.githubusercontent.com', + port: '', + pathname: '/**', + }, + ], + }, } export default nextConfig From d3c62b1a536c845d81653979b0bb4ad2b1ce9cda Mon Sep 17 00:00:00 2001 From: Che <30403707+Che-Zhu@users.noreply.github.com> Date: Mon, 19 Jan 2026 14:54:28 +0800 Subject: [PATCH 3/3] style: reorder imports in settings dialog --- components/dialog/settings-dialog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/dialog/settings-dialog.tsx b/components/dialog/settings-dialog.tsx index c8aa5b3..2b00d3c 100644 --- a/components/dialog/settings-dialog.tsx +++ b/components/dialog/settings-dialog.tsx @@ -1,8 +1,8 @@ 'use client'; import { useEffect, useState } from 'react'; -import Image from 'next/image'; import { Code, Database, Github, Save, Terminal } from 'lucide-react'; +import Image from 'next/image'; import { toast } from 'sonner'; import {