refactor(web): 前端目录重构 — consoles/pages → layouts/features + shared
- consoles/admin/ → layouts/admin-layout/ - consoles/workbench/ → layouts/workbench-layout/ + features/chat/ - pages/ → features/ (dashboard, models, projects, not-found) - components/ → shared/components/ - hooks/ → shared/hooks/ - utils/ → shared/utils/ - 更新所有 import 路径 (src/web/ + tests/web/) - 更新开发文档 (README.md, frontend.md, architecture.md)
This commit is contained in:
@@ -4,12 +4,12 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { App, Spin } from "antd";
|
||||
import { useState } from "react";
|
||||
|
||||
import type { Conversation } from "../../../../shared/api";
|
||||
import type { Conversation } from "../../../shared/api";
|
||||
|
||||
import { createConversation, deleteConversation, fetchConversations } from "../../../hooks/use-conversations";
|
||||
import { useModelList } from "../../../hooks/use-models";
|
||||
import { ChatPanel } from "../components/chat/ChatPanel";
|
||||
import { useCurrentProject } from "../useCurrentProject";
|
||||
import { useCurrentProject } from "../../layouts/workbench-layout/useCurrentProject";
|
||||
import { createConversation, deleteConversation, fetchConversations } from "../../shared/hooks/use-conversations";
|
||||
import { useModelList } from "../../shared/hooks/use-models";
|
||||
import { ChatPanel } from "./ChatPanel";
|
||||
|
||||
export function ChatPage() {
|
||||
const project = useCurrentProject();
|
||||
@@ -11,9 +11,9 @@ import {
|
||||
fetchConversation,
|
||||
fetchMessages,
|
||||
updateConversation,
|
||||
} from "../../../../hooks/use-conversations";
|
||||
import { useLogger } from "../../../../hooks/use-logger";
|
||||
import { useModelList } from "../../../../hooks/use-models";
|
||||
} from "../../shared/hooks/use-conversations";
|
||||
import { useLogger } from "../../shared/hooks/use-logger";
|
||||
import { useModelList } from "../../shared/hooks/use-models";
|
||||
import { ChatScrollArea } from "./ChatScrollArea";
|
||||
import { ReasoningPart } from "./parts/ReasoningPart";
|
||||
import { TextPart } from "./parts/TextPart";
|
||||
@@ -6,7 +6,7 @@ import "overlayscrollbars/styles/overlayscrollbars.css";
|
||||
import { OverlayScrollbarsComponent, type OverlayScrollbarsComponentRef } from "overlayscrollbars-react";
|
||||
import { useCallback, useRef, useState } from "react";
|
||||
|
||||
import { useIsDark } from "../../../../hooks/use-is-dark";
|
||||
import { useIsDark } from "../../shared/hooks/use-is-dark";
|
||||
import { useChatScroll } from "./use-chat-scroll";
|
||||
|
||||
interface ChatScrollAreaProps {
|
||||
@@ -4,7 +4,7 @@ import { App, Button, Flex, Typography } from "antd";
|
||||
import React from "react";
|
||||
import { oneDark, oneLight } from "react-syntax-highlighter/dist/esm/styles/prism";
|
||||
|
||||
import { useIsDark } from "../../../../../hooks/use-is-dark";
|
||||
import { useIsDark } from "../../../shared/hooks/use-is-dark";
|
||||
|
||||
type SyntaxTheme = Record<string, Record<string, null | number | string>>;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Typography } from "antd";
|
||||
|
||||
import type { PartProps } from "./types";
|
||||
|
||||
import { useIsDark } from "../../../../../hooks/use-is-dark";
|
||||
import { useIsDark } from "../../../shared/hooks/use-is-dark";
|
||||
import { CodeBlockWithCopy } from "./CodeBlockWithCopy";
|
||||
|
||||
interface TextPartProps extends PartProps {
|
||||
@@ -3,7 +3,7 @@ import type { DescriptionsProps } from "antd";
|
||||
import { Alert, Card, Descriptions, Space, Spin, Typography } from "antd";
|
||||
|
||||
import { APP } from "../../../shared/app";
|
||||
import { useMeta } from "../../hooks/use-meta";
|
||||
import { useMeta } from "../../shared/hooks/use-meta";
|
||||
|
||||
export function DashboardPage() {
|
||||
const { data: meta, error, isLoading } = useMeta();
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
useModelList,
|
||||
useTestModelConnection,
|
||||
useUpdateModel,
|
||||
} from "../../hooks/use-models";
|
||||
} from "../../shared/hooks/use-models";
|
||||
import {
|
||||
useCreateProvider,
|
||||
useDeleteProvider,
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
useProviderOptions,
|
||||
useTestProviderConfig,
|
||||
useUpdateProvider,
|
||||
} from "../../hooks/use-providers";
|
||||
} from "../../shared/hooks/use-providers";
|
||||
import { ModelFormModal } from "./components/ModelFormModal";
|
||||
import { ModelsToolbar } from "./components/ModelsToolbar";
|
||||
import { ModelTable } from "./components/ModelTable";
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
useProjectList,
|
||||
useRestoreProject,
|
||||
useUpdateProject,
|
||||
} from "../../hooks/use-projects";
|
||||
} from "../../shared/hooks/use-projects";
|
||||
import { ProjectFormModal } from "./components/ProjectFormModal";
|
||||
import { ProjectTable } from "./components/ProjectTable";
|
||||
import { ProjectToolbar } from "./components/ProjectToolbar";
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ConsoleShell } from "../../components/ConsoleShell/ConsoleShell";
|
||||
import { ConsoleShell } from "../../shared/components/ConsoleShell/ConsoleShell";
|
||||
import { ADMIN_MENU_ITEMS } from "./menu";
|
||||
|
||||
export function AdminConsoleLayout() {
|
||||
@@ -4,7 +4,7 @@ import { useNavigate } from "react-router";
|
||||
|
||||
import type { Project } from "../../../shared/api";
|
||||
|
||||
import { ConsoleShell } from "../../components/ConsoleShell/ConsoleShell";
|
||||
import { ConsoleShell } from "../../shared/components/ConsoleShell/ConsoleShell";
|
||||
import { ProjectProvider } from "./ProjectContext";
|
||||
import { getWorkbenchMenuItems } from "./routes";
|
||||
import { useCurrentProject } from "./useCurrentProject";
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Alert, Button, Spin } from "antd";
|
||||
import { useNavigate, useParams } from "react-router";
|
||||
|
||||
import { useProject } from "../../hooks/use-projects";
|
||||
import { useProject } from "../../shared/hooks/use-projects";
|
||||
import { WorkbenchConsoleLayout } from "./WorkbenchConsoleLayout";
|
||||
|
||||
export function WorkbenchProjectGate() {
|
||||
@@ -5,8 +5,8 @@ import { createRoot } from "react-dom/client";
|
||||
import { BrowserRouter } from "react-router";
|
||||
|
||||
import { App } from "./app";
|
||||
import { ErrorBoundary } from "./components/ErrorBoundary";
|
||||
import { createConsoleLogger } from "./utils/logger";
|
||||
import { ErrorBoundary } from "./shared/components/ErrorBoundary";
|
||||
import { createConsoleLogger } from "./shared/utils/logger";
|
||||
import "./styles.css";
|
||||
|
||||
const logger = createConsoleLogger();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Route, Routes } from "react-router";
|
||||
|
||||
import { AdminConsoleLayout } from "./consoles/admin/AdminConsoleLayout";
|
||||
import { ChatPage } from "./consoles/workbench/pages/ChatPage";
|
||||
import { WorkbenchProjectGate } from "./consoles/workbench/WorkbenchProjectGate";
|
||||
import { NotFoundPage } from "./pages/404";
|
||||
import { DashboardPage } from "./pages/dashboard";
|
||||
import { ModelsPage } from "./pages/models";
|
||||
import { ProjectsPage } from "./pages/projects";
|
||||
import { ChatPage } from "./features/chat/ChatPage";
|
||||
import { DashboardPage } from "./features/dashboard";
|
||||
import { ModelsPage } from "./features/models";
|
||||
import { NotFoundPage } from "./features/not-found";
|
||||
import { ProjectsPage } from "./features/projects";
|
||||
import { AdminConsoleLayout } from "./layouts/admin-layout/AdminConsoleLayout";
|
||||
import { WorkbenchProjectGate } from "./layouts/workbench-layout/WorkbenchProjectGate";
|
||||
|
||||
export function AppRoutes() {
|
||||
return (
|
||||
|
||||
@@ -6,7 +6,7 @@ import zhCN from "antd/locale/zh_CN";
|
||||
|
||||
import type { ConsoleShellProps } from "./types";
|
||||
|
||||
import { APP } from "../../../shared/app";
|
||||
import { APP } from "../../../../shared/app";
|
||||
import { useMeta } from "../../hooks/use-meta";
|
||||
import { useSidebarCollapsed } from "../../hooks/use-sidebar-collapsed";
|
||||
import { useThemePreference } from "../../hooks/use-theme-preference";
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import type { MenuItemConfig } from "../../menu";
|
||||
import type { MenuItemConfig } from "../../../menu";
|
||||
|
||||
export interface ConsoleShellProps {
|
||||
headerExtra?: ReactNode;
|
||||
@@ -3,7 +3,7 @@ import type { MenuProps } from "antd";
|
||||
import { Menu } from "antd";
|
||||
import { useLocation, useNavigate } from "react-router";
|
||||
|
||||
import type { MenuItemConfig } from "../../menu";
|
||||
import type { MenuItemConfig } from "../../../menu";
|
||||
|
||||
type MenuItem = Required<MenuProps>["items"][number];
|
||||
|
||||
@@ -4,7 +4,7 @@ import type {
|
||||
ConversationResponse,
|
||||
MessageListResponse,
|
||||
UpdateConversationRequest,
|
||||
} from "../../shared/api";
|
||||
} from "../../../shared/api";
|
||||
|
||||
import { handleResponse, handleVoidResponse } from "../utils/api";
|
||||
import { createConsoleLogger } from "../utils/logger";
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import type { MetaResponse } from "../../shared/api";
|
||||
import type { MetaResponse } from "../../../shared/api";
|
||||
|
||||
export function useMeta() {
|
||||
return useQuery({
|
||||
@@ -9,7 +9,7 @@ import type {
|
||||
ModelTestResultResponse,
|
||||
TestModelRequest,
|
||||
UpdateModelRequest,
|
||||
} from "../../shared/api";
|
||||
} from "../../../shared/api";
|
||||
|
||||
import { handleResponse, handleVoidResponse } from "../utils/api";
|
||||
import { createConsoleLogger } from "../utils/logger";
|
||||
@@ -7,7 +7,7 @@ import type {
|
||||
ProjectResponse,
|
||||
ProjectStatus,
|
||||
UpdateProjectRequest,
|
||||
} from "../../shared/api";
|
||||
} from "../../../shared/api";
|
||||
|
||||
import { handleResponse, handleVoidResponse } from "../utils/api";
|
||||
import { createConsoleLogger } from "../utils/logger";
|
||||
@@ -9,7 +9,7 @@ import type {
|
||||
ProviderTestResponse,
|
||||
ProviderTestResultResponse,
|
||||
UpdateProviderRequest,
|
||||
} from "../../shared/api";
|
||||
} from "../../../shared/api";
|
||||
|
||||
import { handleResponse, handleVoidResponse } from "../utils/api";
|
||||
import { createConsoleLogger } from "../utils/logger";
|
||||
Reference in New Issue
Block a user