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:
2026-06-02 23:17:28 +08:00
parent 1f05f259d0
commit b1dec691e9
76 changed files with 249 additions and 111 deletions

View File

@@ -4,7 +4,7 @@ import { createElement } from "react";
import type { Conversation, Model } from "../../../src/shared/api";
import { ChatPanel } from "../../../src/web/consoles/workbench/components/chat/ChatPanel";
import { ChatPanel } from "../../../src/web/features/chat/ChatPanel";
import { installFetchMock, jsonResponse, renderWithProviders } from "../test-utils";
const PROJECT_ID = "proj-1";

View File

@@ -3,7 +3,7 @@ import { App as AntApp, ConfigProvider } from "antd";
import { describe, expect, test } from "bun:test";
import { createElement } from "react";
import { ErrorBoundary } from "../../../src/web/components/ErrorBoundary";
import { ErrorBoundary } from "../../../src/web/shared/components/ErrorBoundary";
function BrokenChild(): never {
throw new Error("render failed");

View File

@@ -4,7 +4,7 @@ import { createElement } from "react";
import type { Model, ProviderOption } from "../../../src/shared/api";
import { ModelTable } from "../../../src/web/pages/models/components/ModelTable";
import { ModelTable } from "../../../src/web/features/models/components/ModelTable";
import { renderWithProviders } from "../test-utils";
const OPENAI_PROVIDER: ProviderOption = {

View File

@@ -4,7 +4,7 @@ import { createElement } from "react";
import type { Provider } from "../../../src/shared/api";
import { ProviderTable } from "../../../src/web/pages/models/components/ProviderTable";
import { ProviderTable } from "../../../src/web/features/models/components/ProviderTable";
import { renderWithProviders } from "../test-utils";
const OPENAI_PROVIDER: Provider = {

View File

@@ -3,8 +3,8 @@ import { describe, expect, test } from "bun:test";
import { createElement } from "react";
import { useLocation } from "react-router";
import { Sidebar } from "../../../../src/web/components/Sidebar";
import { ADMIN_MENU_ITEMS } from "../../../../src/web/consoles/admin/menu";
import { ADMIN_MENU_ITEMS } from "../../../../src/web/layouts/admin-layout/menu";
import { Sidebar } from "../../../../src/web/shared/components/Sidebar";
import { renderWithProviders } from "../../test-utils";
function LocationProbe() {

View File

@@ -2,7 +2,7 @@ import { screen } from "@testing-library/react";
import { describe, expect, mock, test } from "bun:test";
import { createElement } from "react";
import { CodeBlockWithCopy } from "../../../../src/web/consoles/workbench/components/chat/parts/CodeBlockWithCopy";
import { CodeBlockWithCopy } from "../../../../src/web/features/chat/parts/CodeBlockWithCopy";
import { renderWithProviders } from "../../test-utils";
const mockWriteText = mock(() => Promise.resolve());

View File

@@ -2,7 +2,7 @@ import { fireEvent, screen } from "@testing-library/react";
import { describe, expect, test } from "bun:test";
import { createElement } from "react";
import { ReasoningPart } from "../../../../src/web/consoles/workbench/components/chat/parts/ReasoningPart";
import { ReasoningPart } from "../../../../src/web/features/chat/parts/ReasoningPart";
import { renderWithProviders } from "../../test-utils";
describe("ReasoningPart", () => {

View File

@@ -2,7 +2,7 @@ import { screen } from "@testing-library/react";
import { describe, expect, test } from "bun:test";
import { createElement } from "react";
import { ToolPart } from "../../../../src/web/consoles/workbench/components/chat/parts/ToolPart";
import { ToolPart } from "../../../../src/web/features/chat/parts/ToolPart";
import { renderWithProviders } from "../../test-utils";
describe("ToolPart 工具显示名", () => {

View File

@@ -3,7 +3,7 @@ import { render } from "@testing-library/react";
import { describe, expect, test } from "bun:test";
import { createElement, useRef } from "react";
import { useCreateProject } from "../../../src/web/hooks/use-projects";
import { useCreateProject } from "../../../src/web/shared/hooks/use-projects";
import { installFetchMock, jsonResponse } from "../test-utils";
describe("QueryClient MutationCache onError", () => {

View File

@@ -8,20 +8,20 @@ import {
useDeleteModel,
useTestModelConnection,
useUpdateModel,
} from "../../../src/web/hooks/use-models";
} from "../../../src/web/shared/hooks/use-models";
import {
useArchiveProject,
useCreateProject,
useDeleteProject,
useRestoreProject,
useUpdateProject,
} from "../../../src/web/hooks/use-projects";
} from "../../../src/web/shared/hooks/use-projects";
import {
useCreateProvider,
useDeleteProvider,
useTestProviderConfig,
useUpdateProvider,
} from "../../../src/web/hooks/use-providers";
} from "../../../src/web/shared/hooks/use-providers";
import { installFetchMock, jsonResponse } from "../test-utils";
const MODEL = {

View File

@@ -3,7 +3,7 @@ import type { UIMessage } from "ai";
import { act, renderHook } from "@testing-library/react";
import { describe, expect, mock, test } from "bun:test";
import { useChatScroll } from "../../../src/web/consoles/workbench/components/chat/use-chat-scroll";
import { useChatScroll } from "../../../src/web/features/chat/use-chat-scroll";
interface HookProps {
loadingHistory: boolean;

View File

@@ -1,9 +1,9 @@
import { describe, expect, mock, test } from "bun:test";
import { act, createElement, useState } from "react";
import type { Logger } from "../../../src/web/utils/logger";
import type { Logger } from "../../../src/web/shared/utils/logger";
import { useLogger } from "../../../src/web/hooks/use-logger";
import { useLogger } from "../../../src/web/shared/hooks/use-logger";
import { renderWithProviders } from "../test-utils";
function BindingsHookTester({

View File

@@ -7,7 +7,7 @@ import {
fetchModelList,
testModelConnection,
updateModel,
} from "../../../src/web/hooks/use-models";
} from "../../../src/web/shared/hooks/use-models";
import { installFetchMock, jsonResponse } from "../test-utils";
const MODEL = {

View File

@@ -8,7 +8,7 @@ import {
fetchProjectList,
restoreProject,
updateProject,
} from "../../../src/web/hooks/use-projects";
} from "../../../src/web/shared/hooks/use-projects";
import { installFetchMock, jsonResponse } from "../test-utils";
const PROJECT = {

View File

@@ -8,7 +8,7 @@ import {
fetchProviderOptions,
testProviderConfig,
updateProvider,
} from "../../../src/web/hooks/use-providers";
} from "../../../src/web/shared/hooks/use-providers";
import { installFetchMock, jsonResponse } from "../test-utils";
const PROVIDER = {

View File

@@ -5,7 +5,7 @@ import {
readSidebarCollapsed,
SIDEBAR_COLLAPSED_STORAGE_KEY,
writeSidebarCollapsed,
} from "../../../src/web/hooks/use-sidebar-collapsed";
} from "../../../src/web/shared/hooks/use-sidebar-collapsed";
function createStorage(initial?: string): Storage {
const values = new Map<string, string>();

View File

@@ -8,7 +8,7 @@ import {
THEME_MEDIA_QUERY,
THEME_PREFERENCE_STORAGE_KEY,
writeThemePreference,
} from "../../../src/web/hooks/use-theme-preference";
} from "../../../src/web/shared/hooks/use-theme-preference";
function createStorage(initial?: string): Storage {
const values = new Map<string, string>();

View File

@@ -3,7 +3,7 @@ import { describe, expect, test } from "bun:test";
import { createElement } from "react";
import { useLocation } from "react-router";
import { NotFoundPage } from "../../../src/web/pages/404";
import { NotFoundPage } from "../../../src/web/features/not-found";
import { renderWithProviders } from "../test-utils";
function LocationProbe() {

View File

@@ -3,7 +3,7 @@ import { screen } from "@testing-library/react";
import { describe, expect, test } from "bun:test";
import { createElement } from "react";
import { DashboardPage } from "../../../src/web/pages/dashboard";
import { DashboardPage } from "../../../src/web/features/dashboard";
import { renderWithProviders } from "../test-utils";
describe("DashboardPage", () => {

View File

@@ -4,8 +4,8 @@ import { createElement } from "react";
import type { Model, Provider } from "../../../src/shared/api";
import { ModelFormModal } from "../../../src/web/pages/models/components/ModelFormModal";
import { ProviderFormModal } from "../../../src/web/pages/models/components/ProviderFormModal";
import { ModelFormModal } from "../../../src/web/features/models/components/ModelFormModal";
import { ProviderFormModal } from "../../../src/web/features/models/components/ProviderFormModal";
import { renderWithProviders } from "../test-utils";
const ENABLED_PROVIDER: Provider = {

View File

@@ -6,8 +6,8 @@ import { useLocation } from "react-router";
import type { Project } from "../../../src/shared/api";
import { App } from "../../../src/web/app";
import { ProjectFormModal } from "../../../src/web/pages/projects/components/ProjectFormModal";
import { ProjectTable } from "../../../src/web/pages/projects/components/ProjectTable";
import { ProjectFormModal } from "../../../src/web/features/projects/components/ProjectFormModal";
import { ProjectTable } from "../../../src/web/features/projects/components/ProjectTable";
import { installFetchMock, jsonResponse, mockMetaResponse, renderWithProviders } from "../test-utils";
const ACTIVE_PROJECT: Project = {

View File

@@ -6,7 +6,7 @@ import { mock } from "bun:test";
import { createElement, StrictMode } from "react";
import { MemoryRouter } from "react-router";
import { ErrorBoundary } from "../../src/web/components/ErrorBoundary";
import { ErrorBoundary } from "../../src/web/shared/components/ErrorBoundary";
const REAL_FETCH = globalThis.fetch.bind(globalThis);

View File

@@ -1,6 +1,6 @@
import { describe, expect, mock, test } from "bun:test";
import { handleResponse, handleVoidResponse } from "../../../src/web/utils/api";
import { handleResponse, handleVoidResponse } from "../../../src/web/shared/utils/api";
function expectRejects(action: () => Promise<unknown>, message: string) {
return action().then(

View File

@@ -1,6 +1,6 @@
import { describe, expect, mock, test } from "bun:test";
import type { Sink } from "../../../src/web/utils/logger";
import type { Sink } from "../../../src/web/shared/utils/logger";
import {
AntdMessageSink,
@@ -9,7 +9,7 @@ import {
createDefaultLogger,
createMemoryLogger,
createNoopLogger,
} from "../../../src/web/utils/logger";
} from "../../../src/web/shared/utils/logger";
describe("ConsoleSink", () => {
test("调试环境输出 debug 级别", () => {

View File

@@ -6,7 +6,7 @@ import {
formatRelativeTime,
isOlderThan,
subtractHours,
} from "../../../src/web/utils/time";
} from "../../../src/web/shared/utils/time";
describe("subtractHours", () => {
test("正常扣减小时", () => {