@lobehub/chat 1.78.0 → 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 (56) 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 +25 -0
  4. package/changelog/v1.json +9 -0
  5. package/{contributing/Basic/Add-New-Authentication-Providers.md → docs/development/basic/add-new-authentication-providers.mdx} +0 -10
  6. package/{contributing/Basic/Add-New-Authentication-Providers.zh-CN.md → docs/development/basic/add-new-authentication-providers.zh-CN.mdx} +0 -10
  7. package/{contributing/Basic/Architecture.md → docs/development/basic/architecture.mdx} +0 -10
  8. package/{contributing/Basic/Architecture.zh-CN.md → docs/development/basic/architecture.zh-CN.mdx} +0 -10
  9. package/{contributing/Basic/Chat-API.md → docs/development/basic/chat-api.mdx} +6 -12
  10. package/{contributing/Basic/Chat-API.zh-CN.md → docs/development/basic/chat-api.zh-CN.mdx} +6 -12
  11. package/{contributing/Basic/Contributing-Guidelines.md → docs/development/basic/contributing-guidelines.mdx} +0 -14
  12. package/{contributing/Basic/Contributing-Guidelines.zh-CN.md → docs/development/basic/contributing-guidelines.zh-CN.mdx} +0 -14
  13. package/{contributing/Basic/Feature-Development-Frontend.md → docs/development/basic/feature-development-frontend.mdx} +0 -8
  14. package/{contributing/Basic/Feature-Development-Frontend.zh-CN.md → docs/development/basic/feature-development-frontend.zh-CN.mdx} +0 -8
  15. package/{contributing/Basic/Feature-Development.md → docs/development/basic/feature-development.mdx} +9 -10
  16. package/{contributing/Basic/Feature-Development.zh-CN.md → docs/development/basic/feature-development.zh-CN.mdx} +14 -15
  17. package/{contributing/Basic/Resources.md → docs/development/basic/resources.mdx} +0 -6
  18. package/{contributing/Basic/Resources.zh-CN.md → docs/development/basic/resources.zh-CN.mdx} +0 -6
  19. package/{contributing/Basic/Setup-Development.md → docs/development/basic/setup-development.mdx} +0 -7
  20. package/{contributing/Basic/Setup-Development.zh-CN.md → docs/development/basic/setup-development.zh-CN.mdx} +0 -7
  21. package/{contributing/Basic/Test.md → docs/development/basic/test.mdx} +3 -11
  22. package/{contributing/Basic/Test.zh-CN.md → docs/development/basic/test.zh-CN.mdx} +3 -11
  23. package/{contributing/Internationalization/Add-New-Locale.md → docs/development/internationalization/add-new-locale.mdx} +0 -8
  24. package/{contributing/Internationalization/Add-New-Locale.zh-CN.md → docs/development/internationalization/add-new-locale.zh-CN.mdx} +0 -8
  25. package/{contributing/Internationalization/Internationalization-Implementation.md → docs/development/internationalization/internationalization-implementation.mdx} +3 -11
  26. package/{contributing/Internationalization/Internationalization-Implementation.zh-CN.md → docs/development/internationalization/internationalization-implementation.zh-CN.mdx} +3 -11
  27. package/{contributing/Others/Lighthouse.md → docs/development/others/lighthouse.mdx} +8 -13
  28. package/{contributing/Others/Lighthouse.zh-CN.md → docs/development/others/lighthouse.zh-CN.mdx} +8 -13
  29. package/{contributing/Basic/Intro.md → docs/development/start.mdx} +6 -15
  30. package/{contributing/Basic/Intro.zh-CN.md → docs/development/start.zh-CN.mdx} +6 -15
  31. package/{contributing/State-Management/State-Management-Intro.md → docs/development/state-management/state-management-intro.mdx} +4 -9
  32. package/{contributing/State-Management/State-Management-Intro.zh-CN.md → docs/development/state-management/state-management-intro.zh-CN.mdx} +11 -16
  33. package/docs/wiki/HOME.md +11 -0
  34. package/package.json +2 -2
  35. package/scripts/dbmlWorkflow/index.ts +1 -1
  36. package/src/locales/default/tool.ts +10 -10
  37. package/src/server/modules/SearXNG.ts +7 -4
  38. package/src/server/routers/tools/search.ts +7 -5
  39. package/src/services/search.ts +1 -1
  40. package/src/store/chat/slices/builtinTool/actions/searXNG.test.ts +9 -9
  41. package/src/store/chat/slices/builtinTool/actions/searXNG.ts +7 -3
  42. package/src/tools/web-browsing/components/CategoryAvatar.tsx +1 -1
  43. package/src/tools/web-browsing/components/SearchBar.tsx +1 -3
  44. package/src/tools/web-browsing/const.ts +11 -11
  45. package/src/tools/web-browsing/index.ts +2 -2
  46. package/src/types/tool/search.ts +1 -1
  47. package/contributing/Home.md +0 -87
  48. package/contributing/Upstream-Sync.md +0 -58
  49. package/contributing/Upstream-Sync.zh-CN.md +0 -58
  50. package/contributing/_Footer.md +0 -1
  51. package/contributing/_Sidebar.md +0 -48
  52. /package/{contributing/Basic/Folder-Structure.md → docs/development/basic/folder-structure.mdx} +0 -0
  53. /package/{contributing/Basic/Folder-Structure.zh-CN.md → docs/development/basic/folder-structure.zh-CN.mdx} +0 -0
  54. /package/docs/{developer → development}/database-schema.dbml +0 -0
  55. /package/{contributing/State-Management/State-Management-Selectors.md → docs/development/state-management/state-management-selectors.mdx} +0 -0
  56. /package/{contributing/State-Management/State-Management-Selectors.zh-CN.md → docs/development/state-management/state-management-selectors.zh-CN.mdx} +0 -0
@@ -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,11 @@
1
+ <div align="center">
2
+
3
+ <img height="120" src="https://registry.npmmirror.com/@lobehub/assets-logo/1.0.0/files/assets/logo-3d.webp">
4
+ <img height="120" src="https://gw.alipayobjects.com/zos/kitchen/qJ3l3EPsdW/split.svg">
5
+ <img height="120" src="https://registry.npmmirror.com/@lobehub/assets-emoji/1.3.0/files/assets/robot.webp">
6
+
7
+ </div>
8
+
9
+ ![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
10
+
11
+ We've moved the contributing wiki to [this page](https://lobehub.com/zh/docs/development/start).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.78.0",
3
+ "version": "1.79.0",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -42,7 +42,7 @@
42
42
  "db:push": "drizzle-kit push",
43
43
  "db:push-test": "NODE_ENV=test drizzle-kit push",
44
44
  "db:studio": "drizzle-kit studio",
45
- "db:visualize": "dbdocs build docs/developer/database-schema.dbml --project lobe-chat",
45
+ "db:visualize": "dbdocs build docs/development/database-schema.dbml --project lobe-chat",
46
46
  "db:z-pull": "drizzle-kit introspect",
47
47
  "dev": "next dev --turbopack -p 3010",
48
48
  "docs:i18n": "lobe-i18n md && npm run lint:md && npm run lint:mdx",
@@ -3,7 +3,7 @@ import { join } from 'node:path';
3
3
 
4
4
  import * as schema from '../../src/database/schemas';
5
5
 
6
- const out = join(__dirname,'../../docs/developer/database-schema.dbml');
6
+ const out = join(__dirname, '../../docs/development/database-schema.dbml');
7
7
  const relational = true;
8
8
 
9
9
  pgGenerate({ out, relational, schema });
@@ -23,16 +23,16 @@ export default {
23
23
  placeholder: '搜索类别',
24
24
  title: '搜索类别:',
25
25
  value: {
26
- 'files': '文件',
27
- 'general': '通用',
28
- 'images': '图片',
29
- 'it': '信息技术',
30
- 'map': '地图',
31
- 'music': '音乐',
32
- 'news': '新闻',
33
- 'science': '科学',
34
- 'social_media': '社交媒体',
35
- 'videos': '视频',
26
+ files: '文件',
27
+ general: '通用',
28
+ images: '图片',
29
+ it: '信息技术',
30
+ map: '地图',
31
+ music: '音乐',
32
+ news: '新闻',
33
+ science: '科学',
34
+ social_media: '社交媒体',
35
+ videos: '视频',
36
36
  },
37
37
  },
38
38
  searchEngine: {
@@ -14,10 +14,13 @@ export class SearXNGClient {
14
14
  try {
15
15
  const { time_range, ...otherParams } = optionalParams;
16
16
 
17
- const processedParams = Object.entries(otherParams).reduce<Record<string, any>>((acc, [key, value]) => {
18
- acc[key] = Array.isArray(value) ? value.join(',') : value;
19
- return acc;
20
- }, {});
17
+ const processedParams = Object.entries(otherParams).reduce<Record<string, any>>(
18
+ (acc, [key, value]) => {
19
+ acc[key] = Array.isArray(value) ? value.join(',') : value;
20
+ return acc;
21
+ },
22
+ {},
23
+ );
21
24
 
22
25
  const searchParams = qs.stringify({
23
26
  ...processedParams,
@@ -43,11 +43,13 @@ export const searchRouter = router({
43
43
  query: searchProcedure
44
44
  .input(
45
45
  z.object({
46
- optionalParams: z.object({
47
- searchCategories: z.array(z.string()).optional(),
48
- searchEngines: z.array(z.string()).optional(),
49
- searchTimeRange: z.string().optional(),
50
- }).optional(),
46
+ optionalParams: z
47
+ .object({
48
+ searchCategories: z.array(z.string()).optional(),
49
+ searchEngines: z.array(z.string()).optional(),
50
+ searchTimeRange: z.string().optional(),
51
+ })
52
+ .optional(),
51
53
  query: z.string(),
52
54
  }),
53
55
  )
@@ -2,7 +2,7 @@ import { toolsClient } from '@/libs/trpc/client';
2
2
 
3
3
  class SearchService {
4
4
  search(query: string, optionalParams?: object) {
5
- return toolsClient.search.query.query({ optionalParams, query});
5
+ return toolsClient.search.query.query({ optionalParams, query });
6
6
  }
7
7
 
8
8
  crawlPage(url: string) {
@@ -90,8 +90,8 @@ describe('searXNG actions', () => {
90
90
  },
91
91
  ];
92
92
 
93
- expect( searchService.search ).toHaveBeenCalledWith('test query', {
94
- searchEngines: [ 'google' ]
93
+ expect(searchService.search).toHaveBeenCalledWith('test query', {
94
+ searchEngines: ['google'],
95
95
  });
96
96
  expect(result.current.searchLoading[messageId]).toBe(false);
97
97
  expect(result.current.internal_updateMessageContent).toHaveBeenCalledWith(
@@ -158,20 +158,20 @@ describe('searXNG actions', () => {
158
158
  });
159
159
 
160
160
  expect(searchService.search).toHaveBeenCalledTimes(3);
161
- expect(searchService.search).toHaveBeenNthCalledWith(1, "test query", {
162
- "searchEngines": [ "custom-engine" ],
163
- "searchTimeRange": "year",
161
+ expect(searchService.search).toHaveBeenNthCalledWith(1, 'test query', {
162
+ searchEngines: ['custom-engine'],
163
+ searchTimeRange: 'year',
164
164
  });
165
- expect(searchService.search).toHaveBeenNthCalledWith(2, "test query", {
166
- "searchTimeRange": "year",
165
+ expect(searchService.search).toHaveBeenNthCalledWith(2, 'test query', {
166
+ searchTimeRange: 'year',
167
167
  });
168
168
  expect(result.current.updatePluginArguments).toHaveBeenCalledWith(messageId, {
169
169
  optionalParams: {
170
- "searchTimeRange": "year",
170
+ searchTimeRange: 'year',
171
171
  },
172
172
  query: 'test query',
173
173
  });
174
- expect(searchService.search).toHaveBeenNthCalledWith(3, "test query");
174
+ expect(searchService.search).toHaveBeenNthCalledWith(3, 'test query');
175
175
  expect(result.current.updatePluginArguments).toHaveBeenCalledWith(messageId, {
176
176
  optionalParams: undefined,
177
177
  query: 'test query',
@@ -146,13 +146,17 @@ export const searchSlice: StateCreator<
146
146
  data = await searchService.search(params.query, params.optionalParams);
147
147
 
148
148
  // 如果没有搜索到结果,则执行第一次重试(移除搜索引擎限制)
149
- if (data?.results.length === 0 && params.optionalParams?.searchEngines && params.optionalParams?.searchEngines?.length > 0) {
149
+ if (
150
+ data?.results.length === 0 &&
151
+ params.optionalParams?.searchEngines &&
152
+ params.optionalParams?.searchEngines?.length > 0
153
+ ) {
150
154
  const paramsExcludeSearchEngines = {
151
155
  ...params,
152
156
  optionalParams: {
153
157
  ...params.optionalParams,
154
- searchEngines: undefined
155
- }
158
+ searchEngines: undefined,
159
+ },
156
160
  };
157
161
  data = await searchService.search(params.query, paramsExcludeSearchEngines.optionalParams);
158
162
  get().updatePluginArguments(id, paramsExcludeSearchEngines);
@@ -20,7 +20,7 @@ export const CategoryAvatar = memo<CategoryAvatarProps>(({ category }) => {
20
20
  backgroundColor: 'transparent',
21
21
  color: theme.colorTextSecondary,
22
22
  height: 16,
23
- width: 16
23
+ width: 16,
24
24
  }}
25
25
  />
26
26
  );