Files
lobehub__lobehub/docs/development/start.zh-CN.mdx
YuTengjing 191f3fe776 📝 docs: fix outdated content across the docs site (#16964)
* 📝 docs: fix outdated content across the docs site

Audited docs/ against the current codebase and fixed stale content that
drifted after major refactors (Clerk/NextAuth → Better Auth, src/server →
apps/server, src/{config,envs,locales} → packages/*, model-bank updates).

- self-hosting/auth: mark removed NextAuth/Clerk pages with deprecation
  warnings; fix microsoft/zitadel alias claims and the Logto callback path
- environment-variables & advanced: correct wrong defaults (S3_SET_ACL,
  AI_IMAGE_DEFAULT_IMAGE_NUM, index/proxy URLs), drop non-existent env vars
  and fictional feature flags, fix OIDC config guidance
- development: update refactored paths, Better Auth, .mjs configs, remove
  the MSW section (msw is not a dependency)
- providers & model examples: replace retired model ids with in-bank ones;
  fix comfyui frontmatter corruption
- usage: rename Moderator→Orchestrator, GTD→Task, correct shortcut keys,
  channel capability tables, Feishu/Lark WebSocket mode
- platform/migration: fix dead links, docker service name, npx/npm → bun

EN and zh-CN pairs updated together.

* 📝 docs: fix Logto callback path and AUTH_SECRET deprecation guidance

- Revert Logto/Sealos callback URLs to /api/auth/callback/logto to match
  the runtime SSO redirectURI override
- Narrow legacy auth Callout: AUTH_SECRET remains required for Better Auth;
  mark NEXT_AUTH_SECRET as deprecated in zh-CN

* 📝 docs: refresh agent skills for locales, env, auth, and agentRun paths

Align OSS agent guidance with post-refactor layout:
- packages/locales/src/default + bun run i18n
- packages/env/src for env schemas (@/envs alias)
- spa-auth shell + src/routes/auth segments
- chat agentRun/transports/hetero instead of aiChat

* 📝 docs: document APP_URL as required for Better Auth base URL

Self-hosted auth uses appEnv.APP_URL as baseURL, not request-header
auto-detection. NEXT_PUBLIC_AUTH_URL remains deprecated.

* 📝 docs: note self-host search provider setup for web search

Built-in lobe-web-browsing needs no client plugin, but self-hosted
servers still require SEARCH_PROVIDERS / SEARXNG_URL (default SearXNG).

* 📝 docs: point feature guide welcome UI at AgentHome

Opening message/questions on the agent chat page live in
src/features/AgentHome, not Onboarding WelcomeMessage.
2026-07-10 17:50:03 +08:00

111 lines
6.9 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: 技术开发上手指南
description: 了解 LobeHub 的技术栈和开发环境设置,快速上手开发。
tags:
- LobeHub
- 技术开发
- Next.js
- 国际化
- 状态管理
---
# 技术开发上手指南
欢迎来到 LobeHub 技术开发上手指南。LobeHub 是一款基于 Next.js 框架构建的 AI 会话应用,它汇集了一系列的技术栈,以实现多样化的功能和特性。本指南将详细介绍 LobeHub 的主要技术组成,以及如何在你的开发环境中配置和使用这些技术。
## 基础技术栈
LobeHub 的核心技术栈如下:
- **框架**:[Next.js](https://nextjs.org/) 16 + [React](https://react.dev/) 19,为项目提供服务端渲染、Router Handler 等关键功能。
- **组件库**:[Ant Design (antd)](https://ant.design/) 作为基础组件库,[@lobehub/ui](https://github.com/lobehub/lobe-ui) 作为业务组件库。
- **状态管理**:[zustand](https://github.com/pmndrs/zustand),一款轻量级且易于使用的状态管理库。
- **数据获取**:[SWR](https://swr.vercel.app/) 用于客户端数据获取。
- **路由**:采用混合路由架构 —— [Next.js App Router](https://nextjs.org/) 处理静态页面(如认证页),[React Router DOM](https://reactrouter.com/) 承载主应用 SPA。
- **API**:[tRPC](https://trpc.io/) 实现端到端类型安全的 API 通信。
- **数据库**:[Drizzle ORM](https://orm.drizzle.team/) + PostgreSQL。
- **国际化**:[react-i18next](https://react.i18next.com/) 实现多语言支持。
- **样式**:[antd-style](https://github.com/ant-design/antd-style),与 Ant Design 配套的 CSS-in-JS 库。
- **单元测试**:[Vitest](https://github.com/vitest-dev/vitest) 进行单元测试。
## 文件夹目录架构
LobeHub 采用 Monorepo 架构(`@lobechat/` 命名空间),顶层目录结构如下:
```bash
lobehub/
├── apps/
│ ├── cli/ # LobeHub CLI
│ ├── desktop/ # Electron 桌面应用
│ └── server/ # 独立服务端(tRPC routers、services、modules)
├── packages/ # 共享包(@lobechat/*)
│ ├── database/ # 数据库 schemas、models、repositories
│ ├── agent-runtime/ # Agent 运行时
│ ├── model-runtime/ # 模型运行时
│ ├── app-config/ # 应用配置文件,包含客户端与服务端环境变量
│ ├── env/ # 环境变量定义和校验(分析、认证、LLM 等)
│ ├── locales/ # 国际化默认语言文件
│ ├── builtin-tools/ # 内置工具注册表(inspectors、interventions 等)
│ └── ... # 更多共享包
├── src/ # 主应用源码
│ ├── app/ # Next.js App Router:后端 API 路由 + SPA/认证页 HTML 外壳服务
│ ├── components/ # 可复用的 UI 组件
│ ├── const/ # 应用常量和枚举
│ ├── features/ # 业务功能模块,如 Agent 设置、插件开发弹窗等
│ ├── helpers/ # 工具辅助函数
│ ├── hooks/ # 全应用复用的自定义 Hooks
│ ├── layout/ # 布局组件(AuthProvider、GlobalProvider 等)
│ ├── libs/ # 第三方集成(better-auth、OIDC、tRPC 等)
│ ├── routes/ # SPA 页面片段,按平台分组((main)/(mobile)/(desktop)/(popup))
│ ├── server/ # 尚未迁移到 apps/server 的剩余服务端模块
│ ├── services/ # 客户端服务接口
│ ├── spa/ # SPA 入口和 React Router 配置
│ ├── store/ # zustand 状态管理
│ ├── styles/ # 全局样式和 CSS-in-JS 配置
│ ├── types/ # TypeScript 类型定义
│ └── utils/ # 通用工具函数
├── locales/ # 国际化翻译文件(zh-CN、en-US 等)
└── e2e/ # E2E 测试(Cucumber + Playwright)
```
有关目录架构的详细介绍,详见: [文件夹目录架构](/zh/docs/development/basic/folder-structure)
## 本地开发环境设置
请参考
[开发环境设置指南](/zh/docs/development/basic/setup-development)
了解完整的环境搭建流程,
包括软件安装、项目配置、Docker 服务启动和数据库迁移等步骤。
## 代码风格与贡献指南
在 LobeHub 项目中,我们十分重视代码的质量和一致性。为此,我们制定了一系列的代码风格规范和贡献流程,以确保每位开发者都能顺利地参与到项目中。以下是你作为开发者需要遵守的代码风格和贡献准则。
- **代码风格**:我们使用 `@lobehub/lint` 统一代码风格,包括 ESLint、Prettier、remarklint 和 stylelint 配置。请遵守我们的代码规范,以保持代码的一致性和可读性。
- **贡献流程**:我们采用 gitmoji 和 semantic release 作为代码提交和发布流程。请使用 gitmoji 标注您的提交信息,并确保遵循 semantic release 的规范,以便我们的自动化系统能够正确处理版本控制和发布。
所有的贡献都将经过代码审查。维护者可能会提出修改建议或要求。请积极响应审查意见,并及时做出调整,我们期待你的参与和贡献。
详细的代码风格和贡献指南,请参考 [代码风格与贡献指南](/zh/docs/development/basic/contributing-guidelines)。
## 国际化实现指南
LobeHub 采用 `react-i18next` 实现多语言支持,确保用户全球化体验。
默认语言文件位于 `packages/locales/src/default/`(英文),
翻译文件位于 `locales/` 目录。
开发时只需编辑 `packages/locales/src/default/` 中的 key,
CI 会自动生成其他语言的翻译文件。
如果要添加新语种,需遵循特定步骤,详见 [新语种添加指南](/zh/docs/development/internationalization/add-new-locale)。 我们鼓励你参与我们的国际化努力,共同为全球用户提供更好的服务。
详细的国际化实现指南,请参考 [国际化实现指南](/zh/docs/development/internationalization/internationalization-implementation)。
## 附录:资源与参考
为了支持开发者更好地理解和使用 LobeHub 的技术栈,我们提供了一份详尽的资源与参考列表 —— [LobeHub 资源与参考](/zh/docs/development/basic/resources) - 访问我们维护的资源列表,包括教程、文章和其他有用的链接。
我们鼓励开发者利用这些资源深入学习和提升技能,通过 [LobeHub GitHub Discussions](https://github.com/lobehub/lobehub/discussions) 或者 [Discord](https://discord.com/invite/AYFPHvv2jT) 加入社区讨论,提出问题或分享你的经验。
如果你有任何疑问,或者需要进一步的帮助,请不要犹豫,请通过上述渠道与我们联系。