From e3a79166c25087efa678402f836ac00b0e7d4eed Mon Sep 17 00:00:00 2001 From: ZhenYi <434836402@qq.com> Date: Mon, 18 May 2026 20:43:49 +0800 Subject: [PATCH] refactor(ui): update App routing structure and main entry point Reorganize lazy-loaded route components and update import formatting. Update main.tsx entry point to align with new theme system. --- src/App.tsx | 294 +++++++++++++++++++++++++++++++++++++-------------- src/main.tsx | 4 +- 2 files changed, 216 insertions(+), 82 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 9455ece..0156bc4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,76 +1,166 @@ -import { lazy, Suspense } from "react"; -import { BrowserRouter, Navigate, Route, Routes } from "react-router-dom"; -import { RootLayout } from "@/app/layout"; -import { MeLayout } from "@/app/me"; -import { ChannelLayout } from "@/app/channel"; -import { - ProjectLayout, - ProjectSettingsLayout, -} from "@/app/project"; -import { RedirectIfAuth, RequireAuth } from "@/components/auth"; -import { - SettingsLayout, -} from "@/app/settings"; -import RepoSettingsLayout from "@/app/project/repo/settings/RepoSettingsLayout"; -import { ErrorBoundary } from "@/components/ui/ErrorBoundary"; +import { lazy, Suspense } from "react" +import { BrowserRouter, Navigate, Route, Routes } from "react-router-dom" +import { RootLayout } from "@/app/layout" +import { MeLayout } from "@/app/me" +import { ChannelLayout } from "@/app/channel" +import { ProjectLayout, ProjectSettingsLayout } from "@/app/project" +import { RedirectIfAuth, RequireAuth } from "@/components/auth" +import { SettingsLayout } from "@/app/settings" +import RepoSettingsLayout from "@/app/project/repo/settings/RepoSettingsLayout" +import { ErrorBoundary } from "@/components/ui/ErrorBoundary" // Lazy-loaded page components -const LoginPage = lazy(() => import("@/app/auth/login").then(m => ({ default: m.LoginPage }))); -const RegisterPage = lazy(() => import("@/app/auth/register").then(m => ({ default: m.RegisterPage }))); -const ForgotPasswordPage = lazy(() => import("@/app/auth/forgot-password").then(m => ({ default: m.ForgotPasswordPage }))); -const ResetPasswordPage = lazy(() => import("@/app/auth/reset-password").then(m => ({ default: m.ResetPasswordPage }))); -const TwoFactorPage = lazy(() => import("@/app/auth/two-factor").then(m => ({ default: m.TwoFactorPage }))); -const VerifyEmailPage = lazy(() => import("@/app/auth/verify-email").then(m => ({ default: m.VerifyEmailPage }))); -const ChangePasswordPage = lazy(() => import("@/app/auth/change-password").then(m => ({ default: m.ChangePasswordPage }))); -const MePage = lazy(() => import("@/app/me").then(m => ({ default: m.MePage }))); -const MyInvitationsPage = lazy(() => import("@/app/me/MyInvitationsPage")); -const ChatPage = lazy(() => import("@/app/chat").then(m => ({ default: m.ChatPage }))); -const ExplorePage = lazy(() => import("@/app/explore/ExplorePage").then(m => ({ default: m.ExplorePage }))); -const MyAccountPage = lazy(() => import("@/app/settings").then(m => ({ default: m.MyAccountPage }))); -const BillingPage = lazy(() => import("@/app/settings").then(m => ({ default: m.BillingPage }))); -const AppearancePage = lazy(() => import("@/app/settings").then(m => ({ default: m.AppearancePage }))); -const NotificationsPage = lazy(() => import("@/app/settings").then(m => ({ default: m.NotificationsPage }))); -const PasswordPage = lazy(() => import("@/app/settings").then(m => ({ default: m.PasswordPage }))); -const EmailPage = lazy(() => import("@/app/settings").then(m => ({ default: m.EmailPage }))); -const SshKeysPage = lazy(() => import("@/app/settings").then(m => ({ default: m.SshKeysPage }))); -const AccessKeysPage = lazy(() => import("@/app/settings").then(m => ({ default: m.AccessKeysPage }))); -const PushSettingsPage = lazy(() => import("@/app/settings").then(m => ({ default: m.PushSettingsPage }))); -const ReposPage = lazy(() => import("@/app/project").then(m => ({ default: m.ReposPage }))); -const IssuesPage = lazy(() => import("@/app/project").then(m => ({ default: m.IssuesPage }))); -const NewIssuePage = lazy(() => import("@/app/project").then(m => ({ default: m.NewIssuePage }))); -const SkillsPage = lazy(() => import("@/app/project").then(m => ({ default: m.SkillsPage }))); -const BoardPage = lazy(() => import("@/app/project").then(m => ({ default: m.BoardPage }))); -const ChannelPage = lazy(() => import("@/app/project").then(m => ({ default: m.ChannelPage }))); -const RepoDetailPage = lazy(() => import("@/app/project").then(m => ({ default: m.RepoDetailPage }))); -const CommitDetailPage = lazy(() => import("@/app/project").then(m => ({ default: m.CommitDetailPage }))); -const IssueDetailPage = lazy(() => import("@/app/project").then(m => ({ default: m.IssueDetailPage }))); -const SkillDetailPage = lazy(() => import("@/app/project").then(m => ({ default: m.SkillDetailPage }))); -const PullRequestDetailPage = lazy(() => import("@/app/project").then(m => ({ default: m.PullRequestDetailPage }))); -const ProjectJoinPage = lazy(() => import("@/app/project").then(m => ({ default: m.ProjectJoinPage }))); -const ProjectInvitationPage = lazy(() => import("@/app/project").then(m => ({ default: m.ProjectInvitationPage }))); -const GeneralSettings = lazy(() => import("@/app/project").then(m => ({ default: m.GeneralSettings }))); -const MembersSettings = lazy(() => import("@/app/project").then(m => ({ default: m.MembersSettings }))); -const AccessSettings = lazy(() => import("@/app/project").then(m => ({ default: m.AccessSettings }))); -const LabelsSettings = lazy(() => import("@/app/project").then(m => ({ default: m.LabelsSettings }))); -const BillingSettings = lazy(() => import("@/app/project").then(m => ({ default: m.BillingSettings }))); -const CodePage = lazy(() => import("@/app/project/repo/code")); -const CommitsPage = lazy(() => import("@/app/project/repo/commits")); -const PullsPage = lazy(() => import("@/app/project/repo/pulls")); -const BranchesPage = lazy(() => import("@/app/project/repo/branches")); -const TagsPage = lazy(() => import("@/app/project/repo/tags")); -const RepoGeneralSettings = lazy(() => import("@/app/project/repo/settings/GeneralSettings")); -const BranchProtectionSettings = lazy(() => import("@/app/project/repo/settings/BranchProtectionSettings")); -const TreePage = lazy(() => import("@/app/project/repo/tree")); +const LoginPage = lazy(() => + import("@/app/auth/login").then((m) => ({ default: m.LoginPage })) +) +const RegisterPage = lazy(() => + import("@/app/auth/register").then((m) => ({ default: m.RegisterPage })) +) +const ForgotPasswordPage = lazy(() => + import("@/app/auth/forgot-password").then((m) => ({ + default: m.ForgotPasswordPage, + })) +) +const ResetPasswordPage = lazy(() => + import("@/app/auth/reset-password").then((m) => ({ + default: m.ResetPasswordPage, + })) +) +const TwoFactorPage = lazy(() => + import("@/app/auth/two-factor").then((m) => ({ default: m.TwoFactorPage })) +) +const VerifyEmailPage = lazy(() => + import("@/app/auth/verify-email").then((m) => ({ + default: m.VerifyEmailPage, + })) +) +const ChangePasswordPage = lazy(() => + import("@/app/auth/change-password").then((m) => ({ + default: m.ChangePasswordPage, + })) +) +const MePage = lazy(() => + import("@/app/me").then((m) => ({ default: m.MePage })) +) +const MyInvitationsPage = lazy(() => import("@/app/me/MyInvitationsPage")) +const ChatPage = lazy(() => + import("@/app/chat").then((m) => ({ default: m.ChatPage })) +) +const ExplorePage = lazy(() => + import("@/app/explore/ExplorePage").then((m) => ({ default: m.ExplorePage })) +) +const MyAccountPage = lazy(() => + import("@/app/settings").then((m) => ({ default: m.MyAccountPage })) +) +const BillingPage = lazy(() => + import("@/app/settings").then((m) => ({ default: m.BillingPage })) +) +const AppearancePage = lazy(() => + import("@/app/settings").then((m) => ({ default: m.AppearancePage })) +) +const NotificationsPage = lazy(() => + import("@/app/settings").then((m) => ({ default: m.NotificationsPage })) +) +const PasswordPage = lazy(() => + import("@/app/settings").then((m) => ({ default: m.PasswordPage })) +) +const EmailPage = lazy(() => + import("@/app/settings").then((m) => ({ default: m.EmailPage })) +) +const SshKeysPage = lazy(() => + import("@/app/settings").then((m) => ({ default: m.SshKeysPage })) +) +const AccessKeysPage = lazy(() => + import("@/app/settings").then((m) => ({ default: m.AccessKeysPage })) +) +const PushSettingsPage = lazy(() => + import("@/app/settings").then((m) => ({ default: m.PushSettingsPage })) +) +const ReposPage = lazy(() => + import("@/app/project").then((m) => ({ default: m.ReposPage })) +) +const IssuesPage = lazy(() => + import("@/app/project").then((m) => ({ default: m.IssuesPage })) +) +const NewIssuePage = lazy(() => + import("@/app/project").then((m) => ({ default: m.NewIssuePage })) +) +const SkillsPage = lazy(() => + import("@/app/project").then((m) => ({ default: m.SkillsPage })) +) +const BoardPage = lazy(() => + import("@/app/project").then((m) => ({ default: m.BoardPage })) +) +const ChannelPage = lazy(() => + import("@/app/project").then((m) => ({ default: m.ChannelPage })) +) +const RepoDetailPage = lazy(() => + import("@/app/project").then((m) => ({ default: m.RepoDetailPage })) +) +const CommitDetailPage = lazy(() => + import("@/app/project").then((m) => ({ default: m.CommitDetailPage })) +) +const IssueDetailPage = lazy(() => + import("@/app/project").then((m) => ({ default: m.IssueDetailPage })) +) +const SkillDetailPage = lazy(() => + import("@/app/project").then((m) => ({ default: m.SkillDetailPage })) +) +const PullRequestDetailPage = lazy(() => + import("@/app/project").then((m) => ({ default: m.PullRequestDetailPage })) +) +const ProjectJoinPage = lazy(() => + import("@/app/project").then((m) => ({ default: m.ProjectJoinPage })) +) +const ProjectInvitationPage = lazy(() => + import("@/app/project").then((m) => ({ default: m.ProjectInvitationPage })) +) +const GeneralSettings = lazy(() => + import("@/app/project").then((m) => ({ default: m.GeneralSettings })) +) +const MembersSettings = lazy(() => + import("@/app/project").then((m) => ({ default: m.MembersSettings })) +) +const AccessSettings = lazy(() => + import("@/app/project").then((m) => ({ default: m.AccessSettings })) +) +const LabelsSettings = lazy(() => + import("@/app/project").then((m) => ({ default: m.LabelsSettings })) +) +const BillingSettings = lazy(() => + import("@/app/project").then((m) => ({ default: m.BillingSettings })) +) +const CodePage = lazy(() => import("@/app/project/repo/code")) +const CommitsPage = lazy(() => import("@/app/project/repo/commits")) +const PullsPage = lazy(() => import("@/app/project/repo/pulls")) +const BranchesPage = lazy(() => import("@/app/project/repo/branches")) +const TagsPage = lazy(() => import("@/app/project/repo/tags")) +const RepoGeneralSettings = lazy( + () => import("@/app/project/repo/settings/GeneralSettings") +) +const BranchProtectionSettings = lazy( + () => import("@/app/project/repo/settings/BranchProtectionSettings") +) +const TreePage = lazy(() => import("@/app/project/repo/tree")) function PageLoader() { return ( -