@lobehub/chat 1.77.18 → 1.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/.github/workflows/sync-database-schema.yml +1 -1
  2. package/.github/workflows/wiki-sync.yml +2 -2
  3. package/CHANGELOG.md +50 -0
  4. package/README.md +1 -1
  5. package/README.zh-CN.md +1 -1
  6. package/changelog/v1.json +18 -0
  7. package/{contributing/Basic/Add-New-Authentication-Providers.md → docs/development/basic/add-new-authentication-providers.mdx} +0 -10
  8. package/{contributing/Basic/Add-New-Authentication-Providers.zh-CN.md → docs/development/basic/add-new-authentication-providers.zh-CN.mdx} +0 -10
  9. package/{contributing/Basic/Architecture.md → docs/development/basic/architecture.mdx} +0 -10
  10. package/{contributing/Basic/Architecture.zh-CN.md → docs/development/basic/architecture.zh-CN.mdx} +0 -10
  11. package/{contributing/Basic/Chat-API.md → docs/development/basic/chat-api.mdx} +6 -12
  12. package/{contributing/Basic/Chat-API.zh-CN.md → docs/development/basic/chat-api.zh-CN.mdx} +6 -12
  13. package/{contributing/Basic/Contributing-Guidelines.md → docs/development/basic/contributing-guidelines.mdx} +0 -14
  14. package/{contributing/Basic/Contributing-Guidelines.zh-CN.md → docs/development/basic/contributing-guidelines.zh-CN.mdx} +0 -14
  15. package/{contributing/Basic/Feature-Development-Frontend.md → docs/development/basic/feature-development-frontend.mdx} +0 -8
  16. package/{contributing/Basic/Feature-Development-Frontend.zh-CN.md → docs/development/basic/feature-development-frontend.zh-CN.mdx} +0 -8
  17. package/{contributing/Basic/Feature-Development.md → docs/development/basic/feature-development.mdx} +9 -10
  18. package/{contributing/Basic/Feature-Development.zh-CN.md → docs/development/basic/feature-development.zh-CN.mdx} +14 -15
  19. package/{contributing/Basic/Resources.md → docs/development/basic/resources.mdx} +0 -6
  20. package/{contributing/Basic/Resources.zh-CN.md → docs/development/basic/resources.zh-CN.mdx} +0 -6
  21. package/{contributing/Basic/Setup-Development.md → docs/development/basic/setup-development.mdx} +0 -7
  22. package/{contributing/Basic/Setup-Development.zh-CN.md → docs/development/basic/setup-development.zh-CN.mdx} +0 -7
  23. package/{contributing/Basic/Test.md → docs/development/basic/test.mdx} +3 -11
  24. package/{contributing/Basic/Test.zh-CN.md → docs/development/basic/test.zh-CN.mdx} +3 -11
  25. package/{contributing/Internationalization/Add-New-Locale.md → docs/development/internationalization/add-new-locale.mdx} +0 -8
  26. package/{contributing/Internationalization/Add-New-Locale.zh-CN.md → docs/development/internationalization/add-new-locale.zh-CN.mdx} +0 -8
  27. package/{contributing/Internationalization/Internationalization-Implementation.md → docs/development/internationalization/internationalization-implementation.mdx} +3 -11
  28. package/{contributing/Internationalization/Internationalization-Implementation.zh-CN.md → docs/development/internationalization/internationalization-implementation.zh-CN.mdx} +3 -11
  29. package/{contributing/Others/Lighthouse.md → docs/development/others/lighthouse.mdx} +8 -13
  30. package/{contributing/Others/Lighthouse.zh-CN.md → docs/development/others/lighthouse.zh-CN.mdx} +8 -13
  31. package/{contributing/Basic/Intro.md → docs/development/start.mdx} +6 -15
  32. package/{contributing/Basic/Intro.zh-CN.md → docs/development/start.zh-CN.mdx} +6 -15
  33. package/{contributing/State-Management/State-Management-Intro.md → docs/development/state-management/state-management-intro.mdx} +4 -9
  34. package/{contributing/State-Management/State-Management-Intro.zh-CN.md → docs/development/state-management/state-management-intro.zh-CN.mdx} +11 -16
  35. package/docs/self-hosting/advanced/auth/next-auth/keycloak.mdx +119 -0
  36. package/docs/self-hosting/advanced/auth/next-auth/keycloak.zh-CN.mdx +116 -0
  37. package/docs/self-hosting/advanced/auth.mdx +3 -0
  38. package/docs/self-hosting/advanced/auth.zh-CN.mdx +3 -0
  39. package/docs/wiki/HOME.md +11 -0
  40. package/package.json +2 -2
  41. package/scripts/dbmlWorkflow/index.ts +1 -1
  42. package/src/libs/next-auth/sso-providers/index.ts +2 -0
  43. package/src/libs/next-auth/sso-providers/keycloak.ts +25 -0
  44. package/src/locales/default/tool.ts +10 -10
  45. package/src/server/modules/SearXNG.ts +7 -4
  46. package/src/server/routers/tools/search.ts +7 -5
  47. package/src/services/search.ts +1 -1
  48. package/src/store/chat/slices/builtinTool/actions/searXNG.test.ts +9 -9
  49. package/src/store/chat/slices/builtinTool/actions/searXNG.ts +7 -3
  50. package/src/tools/web-browsing/components/CategoryAvatar.tsx +1 -1
  51. package/src/tools/web-browsing/components/SearchBar.tsx +1 -3
  52. package/src/tools/web-browsing/const.ts +11 -11
  53. package/src/tools/web-browsing/index.ts +2 -2
  54. package/src/types/tool/search.ts +1 -1
  55. package/contributing/Home.md +0 -87
  56. package/contributing/Upstream-Sync.md +0 -58
  57. package/contributing/Upstream-Sync.zh-CN.md +0 -58
  58. package/contributing/_Footer.md +0 -1
  59. package/contributing/_Sidebar.md +0 -48
  60. /package/{contributing/Basic/Folder-Structure.md → docs/development/basic/folder-structure.mdx} +0 -0
  61. /package/{contributing/Basic/Folder-Structure.zh-CN.md → docs/development/basic/folder-structure.zh-CN.mdx} +0 -0
  62. /package/docs/{developer → development}/database-schema.dbml +0 -0
  63. /package/{contributing/State-Management/State-Management-Selectors.md → docs/development/state-management/state-management-selectors.mdx} +0 -0
  64. /package/{contributing/State-Management/State-Management-Selectors.zh-CN.md → docs/development/state-management/state-management-selectors.zh-CN.mdx} +0 -0
@@ -2,13 +2,6 @@
2
2
 
3
3
  欢迎阅读 LobeChat 的开发环境设置指南。
4
4
 
5
- #### TOC
6
-
7
- - [在线开发](#在线开发)
8
- - [本地开发](#本地开发)
9
- - [开发环境需求](#开发环境需求)
10
- - [项目设置](#项目设置)
11
-
12
5
  ## 在线开发
13
6
 
14
7
  如果你有 GitHub Codespaces 的使用权限,可以点击下方按钮一键进入在线开发环境:
@@ -2,21 +2,13 @@
2
2
 
3
3
  LobeChat's testing strategy includes unit testing and end-to-end (E2E) testing. Below are detailed explanations of each type of testing:
4
4
 
5
- #### TOC
6
-
7
- - [Unit Testing](#unit-testing)
8
- - [🚧 End-to-End Testing](#-end-to-end-testing)
9
- - [Development Testing](#development-testing)
10
- - [1. Unit Testing](#1-unit-testing)
11
- - [Testing Strategy](#testing-strategy)
12
-
13
5
  ## Unit Testing
14
6
 
15
7
  Unit testing is used to test the functionality of independent units in the application, such as components, functions, utility functions, etc. We use [vitest][vitest-url] for unit testing.
16
8
 
17
9
  To run unit tests, you can use the following command:
18
10
 
19
- ```
11
+ ```bash
20
12
  npm run test
21
13
  ```
22
14
 
@@ -42,7 +34,7 @@ Before writing unit tests, you need to create a directory with the same name as
42
34
 
43
35
  In the test file, you can use the `describe` and `it` functions to organize and write test cases. The `describe` function is used to create a test suite, and the `it` function is used to write specific test cases.
44
36
 
45
- ```typescript
37
+ ```ts
46
38
  import { formatNumber } from './formatNumber';
47
39
 
48
40
  describe('formatNumber', () => {
@@ -64,7 +56,7 @@ In test cases, you can use the `expect` function to assert whether the test resu
64
56
 
65
57
  Execute unit tests by running the following command:
66
58
 
67
- ```
59
+ ```bash
68
60
  npm run test
69
61
  ```
70
62
 
@@ -2,21 +2,13 @@
2
2
 
3
3
  LobeChat 的测试策略包括单元测试和端到端 (E2E) 测试。下面是每种测试的详细说明:
4
4
 
5
- #### TOC
6
-
7
- - [单元测试](#单元测试)
8
- - [🚧 端到端测试](#-端到端测试)
9
- - [开发测试](#开发测试)
10
- - [1. 单元测试](#1-单元测试)
11
- - [测试策略](#测试策略)
12
-
13
5
  ## 单元测试
14
6
 
15
7
  单元测试用于测试应用中的独立单元(如组件、函数、工具函数等)的功能。我们使用 [vitest][vitest-url] 进行单元测试。
16
8
 
17
9
  要运行单元测试,可以使用以下命令:
18
10
 
19
- ```
11
+ ```bash
20
12
  npm run test
21
13
  ```
22
14
 
@@ -42,7 +34,7 @@ npm run test
42
34
 
43
35
  在测试文件中,您可以使用 `describe` 和 `it` 函数来组织和编写测试用例。`describe` 函数用于创建测试套件,`it` 函数用于编写具体的测试用例。
44
36
 
45
- ```typescript
37
+ ```ts
46
38
  import { formatNumber } from './formatNumber';
47
39
 
48
40
  describe('formatNumber', () => {
@@ -64,7 +56,7 @@ describe('formatNumber', () => {
64
56
 
65
57
  通过运行以下命令来执行单元测试:
66
58
 
67
- ```
59
+ ```bash
68
60
  npm run test
69
61
  ```
70
62
 
@@ -2,14 +2,6 @@
2
2
 
3
3
  LobeChat uses [lobe-i18n](https://github.com/lobehub/lobe-cli-toolbox/tree/master/packages/lobe-i18n) as the i18n solution, which allows for quick addition of new language support in the application.
4
4
 
5
- ## TOC
6
-
7
- - [Adding New Language Support](#adding-new-language-support)
8
- - [Step 1: Update the Internationalization Configuration File](#step-1-update-the-internationalization-configuration-file)
9
- - [Step 2: Automatically Translate Language Files](#step-2-automatically-translate-language-files)
10
- - [Step 3: Submit and Review Your Changes](#step-3-submit-and-review-your-changes)
11
- - [Additional Information](#additional-information)
12
-
13
5
  ## Adding New Language Support
14
6
 
15
7
  To add new language internationalization support in LobeChat (for example, adding Vietnamese `vi-VN`), please follow the steps below:
@@ -2,14 +2,6 @@
2
2
 
3
3
  LobeChat 使用 [lobe-i18n](https://github.com/lobehub/lobe-cli-toolbox/tree/master/packages/lobe-i18n) 作为 i18n 解决方案,可以在应用中快速添加新的语言支持。
4
4
 
5
- ## TOC
6
-
7
- - [添加新的语言支持](#添加新的语言支持)
8
- - [步骤 1: 更新国际化配置文件](#步骤-1-更新国际化配置文件)
9
- - [步骤 2: 自动翻译语言文件](#步骤-2-自动翻译语言文件)
10
- - [步骤 3: 提交和审查你的更改](#步骤-3-提交和审查你的更改)
11
- - [附加信息](#附加信息)
12
-
13
5
  ## 添加新的语言支持
14
6
 
15
7
  为了在 LobeChat 中添加新的语言国际化支持,(例如添加越南语 `vi-VN`),请按照以下步骤操作:
@@ -2,14 +2,6 @@
2
2
 
3
3
  Welcome to the LobeChat Internationalization Implementation Guide. This document will guide you through understanding the internationalization mechanism of LobeChat, including file structure and how to add new languages. LobeChat uses `i18next` and `lobe-i18n` as the internationalization solution, aiming to provide users with seamless multilingual support.
4
4
 
5
- ## TOC
6
-
7
- - [Internationalization Overview](#internationalization-overview)
8
- - [File Structure](#file-structure)
9
- - [Core Implementation Logic](#core-implementation-logic)
10
- - [Adding Support for New Languages](#adding-support-for-new-languages)
11
- - [Resources and Further Reading](#resources-and-further-reading)
12
-
13
5
  ## Internationalization Overview
14
6
 
15
7
  Internationalization (i18n for short) is the process of enabling an application to adapt to different languages and regions. In LobeChat, we support multiple languages and achieve dynamic language switching and content localization through the `i18next` library. Our goal is to provide a localized experience for global users.
@@ -23,7 +15,7 @@ In the LobeChat project, internationalization-related files are organized as fol
23
15
 
24
16
  In the directory structure of `src/locales`, the `default` folder contains the original translation files (Chinese), while each other language folder contains JSON translation files for the respective language. The files in each language folder correspond to the TypeScript files in the `default` folder, ensuring consistency in the structure of translation files across languages.
25
17
 
26
- ```
18
+ ```bash
27
19
  src/locales
28
20
  ├── create.ts
29
21
  ├── default
@@ -42,7 +34,7 @@ src/locales
42
34
 
43
35
  The file structure generated by lobe-i18n is as follows:
44
36
 
45
- ```
37
+ ```bash
46
38
  locales
47
39
  ├── ar
48
40
  │ ├── chat.json
@@ -115,7 +107,7 @@ We have already supported a variety of languages globally through the following
115
107
  - [🌐 feat(locale): Add fr-FR (#637) #645](https://github.com/lobehub/lobe-chat/pull/645)
116
108
  - [🌐 Add russian localy #137](https://github.com/lobehub/lobe-chat/pull/137)
117
109
 
118
- To add support for new languages, please refer to the detailed steps in the [New Locale Addition Guide](Add-New-Locale.en-US).
110
+ To add support for new languages, please refer to the detailed steps in the [New Locale Addition Guide](add-new-locale).
119
111
 
120
112
  ## Resources and Further Reading
121
113
 
@@ -2,14 +2,6 @@
2
2
 
3
3
  欢迎阅读 LobeChat 国际化实现指南。本文档将指导你了解 LobeChat 的国际化机制,包括文件结构、如何添加新语种。LobeChat 采用 `i18next` 和 `lobe-i18n` 作为国际化解决方案,旨在为用户提供流畅的多语言支持。
4
4
 
5
- ## TOC
6
-
7
- - [国际化概述](#国际化概述)
8
- - [文件结构](#文件结构)
9
- - [核心实现逻辑](#核心实现逻辑)
10
- - [添加新的语言支持](#添加新的语言支持)
11
- - [资源和进一步阅读](#资源和进一步阅读)
12
-
13
5
  ## 国际化概述
14
6
 
15
7
  国际化(Internationalization,简称为 i18n)是一个让应用能够适应不同语言和地区的过程。在 LobeChat 中,我们支持多种语言,并通过 `i18next` 库来实现语言的动态切换和内容的本地化。我们的目标是让 LobeChat 能够为全球用户提供本地化的体验。
@@ -23,7 +15,7 @@
23
15
 
24
16
  在 `src/locales` 这个目录结构中,`default` 文件夹包含了原始的翻译文件(中文),其他每个语言文件夹则包含了相应语言的 JSON 翻译文件。每个语言文件夹中的文件对应 `default` 文件夹中的 TypeScript 文件,确保了各语种之间的翻译文件结构一致性。
25
17
 
26
- ```
18
+ ```bash
27
19
  src/locales
28
20
  ├── create.ts
29
21
  ├── default
@@ -42,7 +34,7 @@ src/locales
42
34
 
43
35
  通过 lobe-i18n 自动生成的文件结构如下:
44
36
 
45
- ```
37
+ ```bash
46
38
  locales
47
39
  ├── ar
48
40
  │ ├── chat.json
@@ -115,7 +107,7 @@ const createI18nInstance = (lang) => {
115
107
  - [🌐 feat(locale): Add fr-FR (#637) #645](https://github.com/lobehub/lobe-chat/pull/645)
116
108
  - [🌐 Add russian localy #137](https://github.com/lobehub/lobe-chat/pull/137)
117
109
 
118
- 要添加新的语种支持, 详细步骤请参考:[新语种添加指南](Add-New-Locale.zh-CN.md)。
110
+ 要添加新的语种支持, 详细步骤请参考:[新语种添加指南](/zh/docs/development/internationalization/add-new-locale)。
119
111
 
120
112
  ## 资源和进一步阅读
121
113
 
@@ -1,28 +1,23 @@
1
1
  # Lighthouse Reports
2
2
 
3
- #### TOC
4
-
5
- - [Chat Page](#chat-page)
6
- - [Discover Page](#discover-page)
7
-
8
3
  ## Chat Page
9
4
 
10
5
  > **Info**\
11
- > <https://lobechat.com/chat>
6
+ > [https://lobechat.com/chat](https://lobechat.com/chat)
12
7
 
13
- | Desktop | Mobile |
14
- | :------------------------------------------: | :-----------------------------------------: |
15
- | ![][chat-desktop] | ![][chat-mobile] |
8
+ | Desktop | Mobile |
9
+ | :-----------------------------------------: | :----------------------------------------: |
10
+ | ![][chat-desktop] | ![][chat-mobile] |
16
11
  | [⚡️ Lighthouse Report][chat-desktop-report] | [⚡️ Lighthouse Report][chat-mobile-report] |
17
12
 
18
13
  ## Discover Page
19
14
 
20
15
  > **Info**\
21
- > <https://lobechat.com/discover>
16
+ > [https://lobechat.com/discover](https://lobechat.com/discover)
22
17
 
23
- | Desktop | Mobile |
24
- | :----------------------------------------------: | :---------------------------------------------: |
25
- | ![][discover-desktop] | ![][discover-mobile] |
18
+ | Desktop | Mobile |
19
+ | :---------------------------------------------: | :--------------------------------------------: |
20
+ | ![][discover-desktop] | ![][discover-mobile] |
26
21
  | [⚡️ Lighthouse Report][discover-desktop-report] | [⚡️ Lighthouse Report][discover-mobile-report] |
27
22
 
28
23
  [chat-desktop]: https://raw.githubusercontent.com/lobehub/lobe-chat/lighthouse/lighthouse/chat/desktop/pagespeed.svg
@@ -1,28 +1,23 @@
1
1
  # Lighthouse 测试报告
2
2
 
3
- #### TOC
4
-
5
- - [Chat 聊天页面](#chat-聊天页面)
6
- - [Discover 发现页面](#discover-发现页面)
7
-
8
3
  ## Chat 聊天页面
9
4
 
10
5
  > **Info**\
11
- > <https://lobechat.com/chat>
6
+ > [https://lobechat.com/chat](https://lobechat.com/chat)
12
7
 
13
- | Desktop | Mobile |
14
- | :------------------------------------------: | :-----------------------------------------: |
15
- | ![][chat-desktop] | ![][chat-mobile] |
8
+ | Desktop | Mobile |
9
+ | :-----------------------------------------: | :----------------------------------------: |
10
+ | ![][chat-desktop] | ![][chat-mobile] |
16
11
  | [⚡️ Lighthouse Report][chat-desktop-report] | [⚡️ Lighthouse Report][chat-mobile-report] |
17
12
 
18
13
  ## Discover 发现页面
19
14
 
20
15
  > **Info**\
21
- > <https://lobechat.com/discover>
16
+ > [https://lobechat.com/discover](https://lobechat.com/discover)
22
17
 
23
- | Desktop | Mobile |
24
- | :----------------------------------------------: | :---------------------------------------------: |
25
- | ![][discover-desktop] | ![][discover-mobile] |
18
+ | Desktop | Mobile |
19
+ | :---------------------------------------------: | :--------------------------------------------: |
20
+ | ![][discover-desktop] | ![][discover-mobile] |
26
21
  | [⚡️ Lighthouse Report][discover-desktop-report] | [⚡️ Lighthouse Report][discover-mobile-report] |
27
22
 
28
23
  [chat-desktop]: https://raw.githubusercontent.com/lobehub/lobe-chat/lighthouse/lighthouse/chat/desktop/pagespeed.svg
@@ -2,15 +2,6 @@
2
2
 
3
3
  Welcome to the LobeChat Technical Development Getting Started Guide. LobeChat is an AI conversation application built on the Next.js framework, incorporating a range of technology stacks to achieve diverse functionalities and features. This guide will detail the main technical components of LobeChat and how to configure and use these technologies in your development environment.
4
4
 
5
- #### TOC
6
-
7
- - [Basic Technology Stack](#basic-technology-stack)
8
- - [Folder Directory Structure](#folder-directory-structure)
9
- - [Local Development Environment Setup](#local-development-environment-setup)
10
- - [Code Style and Contribution Guide](#code-style-and-contribution-guide)
11
- - [Internationalization Implementation Guide](#internationalization-implementation-guide)
12
- - [Appendix: Resources and References](#appendix-resources-and-references)
13
-
14
5
  ## Basic Technology Stack
15
6
 
16
7
  The core technology stack of LobeChat is as follows:
@@ -44,7 +35,7 @@ src
44
35
  └── utils # General utility functions
45
36
  ```
46
37
 
47
- For a detailed introduction to the directory structure, see: [Folder Directory Structure](Folder-Structure.zh-CN.md)
38
+ For a detailed introduction to the directory structure, see: [Folder Directory Structure](/docs/development/basic/folder-structure)
48
39
 
49
40
  ## Local Development Environment Setup
50
41
 
@@ -79,7 +70,7 @@ bun run dev
79
70
  > \[!IMPORTANT]\
80
71
  > If you encounter the error "Could not find 'stylelint-config-recommended'" when installing dependencies with `npm`, please reinstall the dependencies using `pnpm` or `bun`.
81
72
 
82
- Now, you should be able to see the welcome page of LobeChat in your browser. For a detailed environment setup guide, please refer to [Development Environment Setup Guide](Setup-Development.zh-CN.md).
73
+ Now, you should be able to see the welcome page of LobeChat in your browser. For a detailed environment setup guide, please refer to [Development Environment Setup Guide](/docs/development/basic/setup-development).
83
74
 
84
75
  ## Code Style and Contribution Guide
85
76
 
@@ -90,7 +81,7 @@ In the LobeChat project, we place great emphasis on the quality and consistency
90
81
 
91
82
  All contributions will undergo code review. Maintainers may suggest modifications or requirements. Please respond actively to review comments and make timely adjustments. We look forward to your participation and contribution.
92
83
 
93
- For detailed code style and contribution guidelines, please refer to [Code Style and Contribution Guide](Contributing-Guidelines.zh-CN.md).
84
+ For detailed code style and contribution guidelines, please refer to [Code Style and Contribution Guide](/docs/development/basic/contributing-guidelines).
94
85
 
95
86
  ## Internationalization Implementation Guide
96
87
 
@@ -98,13 +89,13 @@ LobeChat uses `i18next` and `lobe-i18n` to implement multilingual support, ensur
98
89
 
99
90
  Internationalization files are located in `src/locales`, containing the default language (Chinese). We generate other language JSON files automatically through `lobe-i18n`.
100
91
 
101
- If you want to add a new language, follow specific steps detailed in [New Language Addition Guide](../Internationalization/Add-New-Locale.zh-CN.md). We encourage you to participate in our internationalization efforts to provide better services to global users.
92
+ If you want to add a new language, follow specific steps detailed in [New Language Addition Guide](/docs/development/internationalization/add-new-locale). We encourage you to participate in our internationalization efforts to provide better services to global users.
102
93
 
103
- For a detailed guide on internationalization implementation, please refer to [Internationalization Implementation Guide](../Internationalization/Internationalization-Implementation.zh-CN.md).
94
+ For a detailed guide on internationalization implementation, please refer to [Internationalization Implementation Guide](/docs/development/internationalization/internationalization-implementation).
104
95
 
105
96
  ## Appendix: Resources and References
106
97
 
107
- To support developers in better understanding and using the technology stack of LobeChat, we provide a comprehensive list of resources and references — [LobeChat Resources and References](https://github.com/lobehub/lobe-chat/wiki/Resources.zh-CN) - Visit our maintained list of resources, including tutorials, articles, and other useful links.
98
+ To support developers in better understanding and using the technology stack of LobeChat, we provide a comprehensive list of resources and references — [LobeChat Resources and References](/docs/development/basic/resources) - Visit our maintained list of resources, including tutorials, articles, and other useful links.
108
99
 
109
100
  We encourage developers to utilize these resources to deepen their learning and enhance their skills, join community discussions through [LobeChat GitHub Discussions](https://github.com/lobehub/lobe-chat/discussions) or [Discord](https://discord.com/invite/AYFPHvv2jT), ask questions, or share your experiences.
110
101
 
@@ -2,15 +2,6 @@
2
2
 
3
3
  欢迎来到 LobeChat 技术开发上手指南。LobeChat 是一款基于 Next.js 框架构建的 AI 会话应用,它汇集了一系列的技术栈,以实现多样化的功能和特性。本指南将详细介绍 LobeChat 的主要技术组成,以及如何在你的开发环境中配置和使用这些技术。
4
4
 
5
- #### TOC
6
-
7
- - [基础技术栈](#基础技术栈)
8
- - [文件夹目录架构](#文件夹目录架构)
9
- - [本地开发环境设置](#本地开发环境设置)
10
- - [代码风格与贡献指南](#代码风格与贡献指南)
11
- - [国际化实现指南](#国际化实现指南)
12
- - [附录:资源与参考](#附录资源与参考)
13
-
14
5
  ## 基础技术栈
15
6
 
16
7
  LobeChat 的核心技术栈如下:
@@ -44,7 +35,7 @@ src
44
35
  └── utils # 通用的工具函数
45
36
  ```
46
37
 
47
- 有关目录架构的详细介绍,详见: [文件夹目录架构](Folder-Structure.zh-CN.md)
38
+ 有关目录架构的详细介绍,详见: [文件夹目录架构](/zh/docs/development/basic/folder-structure)
48
39
 
49
40
  ## 本地开发环境设置
50
41
 
@@ -79,7 +70,7 @@ bun run dev
79
70
  > \[!IMPORTANT]\
80
71
  > 如果使用`npm`安装依赖出现`Could not find "stylelint-config-recommended"`错误,请使用 `pnpm` 或者 `bun` 重新安装依赖。
81
72
 
82
- 现在,你应该可以在浏览器中看到 LobeChat 的欢迎页面。详细的环境配置指南,请参考 [开发环境设置指南](Setup-Development.zh-CN.md)。
73
+ 现在,你应该可以在浏览器中看到 LobeChat 的欢迎页面。详细的环境配置指南,请参考 [开发环境设置指南](/zh/docs/development/basic/setup-development)。
83
74
 
84
75
  ## 代码风格与贡献指南
85
76
 
@@ -90,7 +81,7 @@ bun run dev
90
81
 
91
82
  所有的贡献都将经过代码审查。维护者可能会提出修改建议或要求。请积极响应审查意见,并及时做出调整,我们期待你的参与和贡献。
92
83
 
93
- 详细的代码风格和贡献指南,请参考 [代码风格与贡献指南](Contributing-Guidelines.zh-CN.md)。
84
+ 详细的代码风格和贡献指南,请参考 [代码风格与贡献指南](/zh/docs/development/basic/contributing-guidelines)。
94
85
 
95
86
  ## 国际化实现指南
96
87
 
@@ -98,13 +89,13 @@ LobeChat 采用 `i18next` 和 `lobe-i18n` 实现多语言支持,确保用户
98
89
 
99
90
  国际化文件位于 `src/locales`,包含默认语言(中文)。 我们会通过 `lobe-i18n` 自动生成其他的语言 JSON 文件。
100
91
 
101
- 如果要添加新语种,需遵循特定步骤,详见 [新语种添加指南](../Internationalization/Add-New-Locale.zh-CN.md)。 我们鼓励你参与我们的国际化努力,共同为全球用户提供更好的服务。
92
+ 如果要添加新语种,需遵循特定步骤,详见 [新语种添加指南](/zh/docs/development/internationalization/add-new-locale)。 我们鼓励你参与我们的国际化努力,共同为全球用户提供更好的服务。
102
93
 
103
- 详细的国际化实现指南指南,请参考 [国际化实现指南](../Internationalization/Internationalization-Implementation.zh-CN.md)。
94
+ 详细的国际化实现指南,请参考 [国际化实现指南](/zh/docs/development/internationalization/internationalization-implementation)。
104
95
 
105
96
  ## 附录:资源与参考
106
97
 
107
- 为了支持开发者更好地理解和使用 LobeChat 的技术栈,我们提供了一份详尽的资源与参考列表 —— [LobeChat 资源与参考](https://github.com/lobehub/lobe-chat/wiki/Resources.zh-CN) - 访问我们维护的资源列表,包括教程、文章和其他有用的链接。
98
+ 为了支持开发者更好地理解和使用 LobeChat 的技术栈,我们提供了一份详尽的资源与参考列表 —— [LobeChat 资源与参考](/zh/docs/development/basic/resources) - 访问我们维护的资源列表,包括教程、文章和其他有用的链接。
108
99
 
109
100
  我们鼓励开发者利用这些资源深入学习和提升技能,通过 [LobeChat GitHub Discussions](https://github.com/lobehub/lobe-chat/discussions) 或者 [Discord](https://discord.com/invite/AYFPHvv2jT) 加入社区讨论,提出问题或分享你的经验。
110
101
 
@@ -1,14 +1,9 @@
1
+ {/* eslint-disable no-irregular-whitespace */}
2
+
1
3
  # Best Practices for State Management
2
4
 
3
5
  LobeChat differs from traditional CRUD web applications in that it involves a large amount of rich interactive capabilities. Therefore, it is crucial to design a data flow architecture that is easy to develop and maintain. This document will introduce the best practices for data flow management in LobeChat.
4
6
 
5
- ## TOC
6
-
7
- - [Key Concepts](#key-concepts)
8
- - [Hierarchical Structure](#hierarchical-structure)
9
- - [Best Practices for LobeChat SessionStore Directory Structure](#best-practices-for-lobechat-sessionstore-directory-structure)
10
- - [Implementation of SessionStore](#implementation-of-sessionstore)
11
-
12
7
  ## Key Concepts
13
8
 
14
9
  | Concept | Explanation |
@@ -151,7 +146,7 @@ src/store/session
151
146
 
152
147
  In LobeChat, the SessionStore is designed as the core module for managing session state and logic. It consists of multiple Slices, with each Slice managing a relevant portion of state and logic. Below is a simplified example of the SessionStore implementation:
153
148
 
154
- #### store.ts
149
+ ### store.ts
155
150
 
156
151
  ```ts
157
152
  import { PersistOptions, devtools, persist, subscribeWithSelector } from 'zustand/middleware';
@@ -192,7 +187,7 @@ export const useSessionStore = createWithEqualityFn<SessionStore>()(
192
187
 
193
188
  In this `store.ts` file, we create a `useSessionStore` hook that uses the `zustand` library to create a global state manager. We merge the initialState with the actions from each Slice to create a complete SessionStore.
194
189
 
195
- #### slices/session/action.ts
190
+ ### slices/session/action.ts
196
191
 
197
192
  ```ts
198
193
  import { StateCreator } from 'zustand';
@@ -1,24 +1,19 @@
1
+ {/* eslint-disable no-irregular-whitespace */}
2
+
1
3
  # 状态管理最佳实践
2
4
 
3
5
  LobeChat 不同于传统 CRUD 的网页,存在大量的富交互能力,如何设计一个易于开发与易于维护的数据流架构非常重要。本篇文档将介绍 LobeChat 中的数据流管理最佳实践。
4
6
 
5
- ## TOC
6
-
7
- - [概念要素](#概念要素)
8
- - [结构分层](#结构分层)
9
- - [LobeChat SessionStore 目录结构最佳实践](#lobechat-sessionstore-目录结构最佳实践)
10
- - [SessionStore 的实现](#sessionstore-的实现)
11
-
12
7
  ## 概念要素
13
8
 
14
- | 概念名词 | 解释 |
15
- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
16
- | store | 状态库 (store),包含存储应用的状态、动作。允许在应用渲染中访问和修改状态。 |
17
- | state | 状态 (state) 是指应用程序的数据,存储了应用程序的当前状态,状态的变化**一定会触发应用的重新渲染**,以反映新的状态。 |
18
- | action | 动作 (action) 是一个操作函数,它描述了应用程序中发生的交互事件。动作通常是由用户交互、网络请求或定时器等触发。 action 可以是**同步**的,也可以是**异步**的。 |
19
- | reducer | 归约器 (reducer) 是一个纯函数,它接收当前状态和动作作为参数,并返回一个新的状态。它用于根据动作类型来更新应用程序的状态。Reducer 是一个纯函数,不存在副作用,因此一定是 **同步** 函数。 |
9
+ | 概念名词 | 解释 |
10
+ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
11
+ | store | 状态库 (store),包含存储应用的状态、动作。允许在应用渲染中访问和修改状态。 |
12
+ | state | 状态 (state) 是指应用程序的数据,存储了应用程序的当前状态,状态的变化**一定会触发应用的重新渲染**,以反映新的状态。 |
13
+ | action | 动作 (action) 是一个操作函数,它描述了应用程序中发生的交互事件。动作通常是由用户交互、网络请求或定时器等触发。 action 可以是**同步**的,也可以是**异步**的。 |
14
+ | reducer | 归约器 (reducer) 是一个纯函数,它接收当前状态和动作作为参数,并返回一个新的状态。它用于根据动作类型来更新应用程序的状态。Reducer 是一个纯函数,不存在副作用,因此一定是 **同步** 函数。 |
20
15
  | selector | 选择器 (selector) 是一个函数,用于从应用程序的状态中获取特定的数据。它接收应用程序的状态作为参数,并返回经过计算或转换后的数据。Selector 可以将状态的一部分或多个状态组合起来,以生成派生的数据。Selector 通常用于将应用程序的状态映射到组件的 props,以供组件使用。 |
21
- | slice | 切片 (slice) 是一个概念,用于表达数据模型状态的一部分。它指定了一个状态切片(slice),以及与该切片相关的 state、action、reducer 和 selector。使用 Slice 可以将大型的 Store 拆分为更小的、可维护的子类型。 |
16
+ | slice | 切片 (slice) 是一个概念,用于表达数据模型状态的一部分。它指定了一个状态切片(slice),以及与该切片相关的 state、action、reducer 和 selector。使用 Slice 可以将大型的 Store 拆分为更小的、可维护的子类型。 |
22
17
 
23
18
  ## 结构分层
24
19
 
@@ -143,7 +138,7 @@ src/store/session
143
138
 
144
139
  在 LobeChat 中,SessionStore 被设计为管理会话状态和逻辑的核心模块。它由多个 Slices 组成,每个 Slice 管理一部分相关的状态和逻辑。下面是一个简化的 SessionStore 的实现示例:
145
140
 
146
- #### store.ts
141
+ ### store.ts
147
142
 
148
143
  ```ts
149
144
  import { PersistOptions, devtools, persist, subscribeWithSelector } from 'zustand/middleware';
@@ -184,7 +179,7 @@ export const useSessionStore = createWithEqualityFn<SessionStore>()(
184
179
 
185
180
  在这个 `store.ts` 文件中,我们创建了一个 `useSessionStore` 钩子,它使用 `zustand` 库来创建一个全局状态管理器。我们将 initialState 和每个 Slice 的动作合并,以创建完整的 SessionStore。
186
181
 
187
- #### slices/session/action.ts
182
+ ### slices/session/action.ts
188
183
 
189
184
  ```ts
190
185
  import { StateCreator } from 'zustand';
@@ -0,0 +1,119 @@
1
+ ---
2
+ title: Configuring Keycloak Authentication Service in LobeChat
3
+ description: >-
4
+ Learn how to configure the Keycloak authentication service in LobeChat,
5
+ including deployment, creation, permission settings, and environment
6
+ variables.
7
+ tags:
8
+ - Keycloak Authentication
9
+ - Environment Variable Configuration
10
+ - Single Sign-On
11
+ - LobeChat
12
+ ---
13
+
14
+ # Configuring Keycloak Authentication Service in LobeChat
15
+
16
+ [Keycloak](https://www.keycloak.org/) is an open-source identity and access management solution that provides single sign-on, identity brokering, and social login features, suitable for modern applications and services.
17
+
18
+ <Callout type={'tip'}>
19
+ If you want to privately deploy Keycloak, we recommend using it together with LobeChat via Docker Compose deployment for easier service management.
20
+ </Callout>
21
+
22
+ ## Keycloak Configuration Process
23
+
24
+ If you deploy using a local network IP, this guide assumes:
25
+
26
+ - Your LobeChat database version IP/port is `http://LOBECHAT_IP:3210`.
27
+ - Your privately deployed Keycloak domain is `http://KEYCLOAK_IP:8080`.
28
+
29
+ If you deploy using a public network, this guide assumes:
30
+
31
+ - Your LobeChat database version domain is `https://lobe.example.com`.
32
+ - Your privately deployed Keycloak domain is `https://lobe-auth-api.example.com`.
33
+
34
+ <Steps>
35
+ ### Create Keycloak Realm and Client
36
+
37
+ Access your privately deployed Keycloak admin console (default is `http://localhost:8080/admin`) and log in with the administrator account.
38
+
39
+ 1. Create a new Realm
40
+ - Click the dropdown menu in the upper left corner and select "Create Realm"
41
+ - Enter a name, such as "LobeChat", then click "Create"
42
+
43
+ 2. Create a Client
44
+ - Select "Clients" from the left menu, then click "Create client"
45
+ - Fill in the following information:
46
+ - Client ID: `lobechat`
47
+ - Client type: `OpenID Connect`
48
+ - Click "Next"
49
+ - On the "Capability config" page:
50
+ - Enable "Client authentication"
51
+ - Enable "Standard flow"
52
+ - Click "Next"
53
+ - On the "Login settings" page:
54
+ - Valid redirect URIs:
55
+ - Local development environment: `http://localhost:3210/api/auth/callback/keycloak`
56
+ - Local network IP deployment: `http://LOBECHAT_IP:3210/api/auth/callback/keycloak`
57
+ - Public environment: `https://lobe.example.com/api/auth/callback/keycloak`
58
+ - Web origins: Add your LobeChat domain or IP
59
+ - Click "Save"
60
+
61
+ 3. Get Client Secret
62
+ - On the client details page, switch to the "Credentials" tab
63
+ - Copy the "Client secret" value, which will be needed later
64
+
65
+ ### Configure Users and Roles (Optional)
66
+
67
+ 1. Create Users
68
+ - Select "Users" from the left menu, then click "Add user"
69
+ - Fill in the user information and click "Create"
70
+ - On the user details page, switch to the "Credentials" tab
71
+ - Set a password, and disable the "Temporary" option if needed
72
+ - Click "Set Password" to save
73
+
74
+ 2. Create Roles and Permissions
75
+ - Select "Realm roles" from the left menu
76
+ - Click "Create role"
77
+ - Create necessary roles, such as "admin", "user", etc.
78
+ - Assign roles to users: On the user details page, switch to the "Role mapping" tab and assign appropriate roles
79
+
80
+ ### Disable Registration (Optional)
81
+
82
+ To ensure the security of your application, it's recommended to control Keycloak's registration functionality.
83
+
84
+ 1. Select "Realm settings" from the left menu
85
+ 2. Switch to the "Login" tab
86
+ 3. In the "User registration" section, disable the "User registration" option
87
+ 4. Click "Save" to save the settings
88
+
89
+ <Callout type={'warning'}>
90
+ If registration is not disabled, anyone might be able to register and log in to your application. Please configure according to your security requirements.
91
+ </Callout>
92
+
93
+ ### Configure Environment Variables
94
+
95
+ Set the obtained client ID and client secret as `AUTH_KEYCLOAK_ID` and `AUTH_KEYCLOAK_SECRET` in the LobeChat environment variables.
96
+
97
+ Configure the LobeChat environment variable `AUTH_KEYCLOAK_ISSUER` as:
98
+
99
+ - `http://localhost:8080/realms/LobeChat` for local development environment
100
+ - `http://KEYCLOAK_IP:8080/realms/LobeChat` for privately deployed Keycloak on a local network
101
+ - `https://lobe-auth-api.example.com/realms/LobeChat` for Keycloak deployed in a public environment
102
+
103
+ When deploying LobeChat, you need to configure the following environment variables:
104
+
105
+ | Environment Variable | Type | Description |
106
+ | ------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
107
+ | `NEXT_AUTH_SECRET` | Required | Key used to encrypt Auth.js session tokens. You can generate a key using: `openssl rand -base64 32` |
108
+ | `NEXT_AUTH_SSO_PROVIDERS` | Required | Select the single sign-on provider for LobeChat. For Keycloak, fill in `keycloak`. |
109
+ | `AUTH_KEYCLOAK_ID` | Required | Keycloak client ID |
110
+ | `AUTH_KEYCLOAK_SECRET` | Required | Keycloak client secret |
111
+ | `AUTH_KEYCLOAK_ISSUER` | Required | OpenID Connect issuer URL for the Keycloak provider, in the format `{keycloak_url}/realms/{realm_name}` |
112
+ | `NEXTAUTH_URL` | Required | This URL specifies the callback address for Auth.js during OAuth verification. Only needed when the default generated redirect address is incorrect. `https://lobe.example.com/api/auth` |
113
+
114
+ <Callout type={'tip'}>
115
+ Visit [📘 Environment Variables](/zh/docs/self-hosting/environment-variables/auth#keycloak) for details on related variables.
116
+ </Callout>
117
+ </Steps>
118
+
119
+ <Callout type={'info'}>After successful deployment, users will be able to authenticate through Keycloak and use LobeChat.</Callout>