@lobehub/chat 0.160.4 → 0.160.6

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 (73) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/docs/self-hosting/environment-variables/analytics.mdx +12 -35
  3. package/docs/self-hosting/environment-variables/analytics.zh-CN.mdx +13 -34
  4. package/locales/ar/error.json +2 -0
  5. package/locales/bg-BG/error.json +2 -0
  6. package/locales/de-DE/error.json +2 -0
  7. package/locales/en-US/error.json +2 -0
  8. package/locales/es-ES/error.json +2 -0
  9. package/locales/fr-FR/error.json +2 -0
  10. package/locales/it-IT/error.json +2 -0
  11. package/locales/ja-JP/error.json +2 -0
  12. package/locales/ko-KR/error.json +2 -0
  13. package/locales/nl-NL/error.json +2 -0
  14. package/locales/pl-PL/error.json +2 -0
  15. package/locales/pt-BR/error.json +2 -0
  16. package/locales/ru-RU/error.json +2 -0
  17. package/locales/tr-TR/error.json +2 -0
  18. package/locales/vi-VN/error.json +2 -0
  19. package/locales/zh-CN/error.json +2 -0
  20. package/locales/zh-TW/error.json +2 -0
  21. package/package.json +3 -3
  22. package/src/app/(loading)/Redirect.tsx +8 -0
  23. package/src/app/(main)/chat/(workspace)/features/TelemetryNotification.tsx +42 -75
  24. package/src/app/(main)/market/_layout/Desktop/index.tsx +24 -20
  25. package/src/app/(main)/settings/llm/Azure/index.tsx +1 -0
  26. package/src/app/(main)/settings/llm/OpenAI/index.tsx +0 -1
  27. package/src/app/layout.tsx +3 -1
  28. package/src/app/trpc/edge/[trpc]/route.ts +1 -1
  29. package/src/components/Analytics/Clarity.tsx +28 -0
  30. package/src/components/Analytics/Google.tsx +2 -9
  31. package/src/components/Analytics/Plausible.tsx +7 -12
  32. package/src/components/Analytics/Posthog.tsx +9 -10
  33. package/src/components/Analytics/Umami.tsx +7 -6
  34. package/src/components/Analytics/Vercel.tsx +2 -4
  35. package/src/components/Analytics/index.tsx +29 -14
  36. package/src/components/FetchErrorNotification/Description.tsx +48 -0
  37. package/src/components/FetchErrorNotification/index.tsx +15 -0
  38. package/src/components/ModelProviderIcon/index.tsx +6 -1
  39. package/src/components/Notification/index.tsx +95 -0
  40. package/src/config/__tests__/analytics.test.ts +70 -0
  41. package/src/config/__tests__/client.test.ts +0 -6
  42. package/src/config/analytics.ts +148 -0
  43. package/src/config/client.ts +0 -35
  44. package/src/config/server/index.ts +1 -3
  45. package/src/config/server/provider.ts +1 -0
  46. package/src/database/client/models/__tests__/message.test.ts +2 -2
  47. package/src/database/client/models/message.ts +2 -2
  48. package/src/features/User/UserAvatar.tsx +4 -3
  49. package/src/locales/default/error.ts +3 -1
  50. package/src/middleware.ts +10 -1
  51. package/src/server/globalConfig/index.ts +2 -0
  52. package/src/server/routers/edge/config/__snapshots__/index.test.ts.snap +1 -0
  53. package/src/services/file/type.ts +2 -3
  54. package/src/services/message/client.test.ts +151 -23
  55. package/src/services/message/client.ts +9 -5
  56. package/src/services/message/type.ts +10 -3
  57. package/src/services/upload.ts +4 -4
  58. package/src/services/user/client.ts +17 -1
  59. package/src/services/user/type.ts +14 -0
  60. package/src/store/chat/slices/enchance/action.test.ts +4 -3
  61. package/src/store/chat/slices/enchance/action.ts +3 -2
  62. package/src/store/chat/slices/plugin/action.test.ts +3 -5
  63. package/src/store/chat/slices/plugin/action.ts +1 -1
  64. package/src/store/market/action.ts +8 -0
  65. package/src/store/user/slices/auth/selectors.ts +1 -1
  66. package/src/store/user/slices/preference/action.test.ts +4 -9
  67. package/src/store/user/slices/preference/action.ts +17 -20
  68. package/src/store/user/slices/settings/selectors/modelConfig.test.ts +29 -1
  69. package/src/store/user/slices/settings/selectors/modelConfig.ts +1 -1
  70. package/src/tools/dalle/Render/Item/Error.tsx +1 -1
  71. package/src/types/files.ts +33 -0
  72. package/src/config/server/analytics.ts +0 -32
  73. /package/src/types/{user.ts → user/index.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,71 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.160.6](https://github.com/lobehub/lobe-chat/compare/v0.160.5...v0.160.6)
6
+
7
+ <sup>Released on **2024-05-21**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Refactor a Notification component, refactor code, refactor message action, refactor the type, refactor user preference.
12
+
13
+ #### 💄 Styles
14
+
15
+ - **misc**: Add ENABLED_OPENAI env, add fetch error notification, improve openai fetch client switch, improve redirect when login.
16
+
17
+ <br/>
18
+
19
+ <details>
20
+ <summary><kbd>Improvements and Fixes</kbd></summary>
21
+
22
+ #### Code refactoring
23
+
24
+ - **misc**: Refactor a Notification component ([28db3d5](https://github.com/lobehub/lobe-chat/commit/28db3d5))
25
+ - **misc**: Refactor code, closes [#2584](https://github.com/lobehub/lobe-chat/issues/2584) ([086244c](https://github.com/lobehub/lobe-chat/commit/086244c))
26
+ - **misc**: Refactor message action ([224bd67](https://github.com/lobehub/lobe-chat/commit/224bd67))
27
+ - **misc**: Refactor the type ([ddf1abf](https://github.com/lobehub/lobe-chat/commit/ddf1abf))
28
+ - **misc**: Refactor user preference ([1823b0d](https://github.com/lobehub/lobe-chat/commit/1823b0d))
29
+
30
+ #### Styles
31
+
32
+ - **misc**: Add ENABLED_OPENAI env ([35f6230](https://github.com/lobehub/lobe-chat/commit/35f6230))
33
+ - **misc**: Add fetch error notification ([0186b4b](https://github.com/lobehub/lobe-chat/commit/0186b4b))
34
+ - **misc**: Improve openai fetch client switch ([3cad470](https://github.com/lobehub/lobe-chat/commit/3cad470))
35
+ - **misc**: Improve redirect when login ([cb26655](https://github.com/lobehub/lobe-chat/commit/cb26655))
36
+
37
+ </details>
38
+
39
+ <div align="right">
40
+
41
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
42
+
43
+ </div>
44
+
45
+ ### [Version 0.160.5](https://github.com/lobehub/lobe-chat/compare/v0.160.4...v0.160.5)
46
+
47
+ <sup>Released on **2024-05-20**</sup>
48
+
49
+ #### ♻ Code Refactoring
50
+
51
+ - **misc**: Refactor analytics env.
52
+
53
+ <br/>
54
+
55
+ <details>
56
+ <summary><kbd>Improvements and Fixes</kbd></summary>
57
+
58
+ #### Code refactoring
59
+
60
+ - **misc**: Refactor analytics env, closes [#2570](https://github.com/lobehub/lobe-chat/issues/2570) ([d809d3f](https://github.com/lobehub/lobe-chat/commit/d809d3f))
61
+
62
+ </details>
63
+
64
+ <div align="right">
65
+
66
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
67
+
68
+ </div>
69
+
5
70
  ### [Version 0.160.4](https://github.com/lobehub/lobe-chat/compare/v0.160.3...v0.160.4)
6
71
 
7
72
  <sup>Released on **2024-05-20**</sup>
@@ -1,7 +1,5 @@
1
1
  ---
2
- title: >-
3
- Integrating Data Analytics Services in LobeChat: Environment Variables and
4
- Configuration
2
+ title: Integrating Analytics in LobeChat
5
3
  description: >-
6
4
  Learn how to configure environment variables for Vercel Analytics, Google
7
5
  Analytics, PostHog Analytics, and Umami Analytics in LobeChat for data
@@ -36,44 +34,30 @@ We have integrated several free/open-source data analytics services in LobeChat
36
34
 
37
35
  ## Google Analytics
38
36
 
39
- ### `ENABLE_GOOGLE_ANALYTICS`
40
-
41
- - Type: Optional
42
- - Description: Used to configure the environment variable for Google Analytics. Set to `1` to enable Google Analytics.
43
- - Default: `-`
44
- - Example: `1`
45
-
46
37
  ### `GOOGLE_ANALYTICS_MEASUREMENT_ID`
47
38
 
48
39
  - Type: Required
49
- - Description: Google Analytics Measurement ID,you can get it from the Google Analytics dashboard.
40
+ - Description: Google Analytics Measurement ID,you can get it from the Google Analytics dashboard. Add it will auto enable Google Analytics.
50
41
  - Default: `-`
51
42
  - Example: `G-63LP2TV03T`
52
43
 
53
44
  ## Posthog Analytics
54
45
 
55
- ### `NEXT_PUBLIC_ANALYTICS_POSTHOG`
46
+ ### `POSTHOG_KEY`
56
47
 
57
- - Type: Optional
58
- - Description: Used to enable the environment variable for [PostHog Analytics][posthog-analytics-url]. Set to `1` to enable PostHog Analytics.
59
- - Default: `-`
60
- - Example: `1`
61
-
62
- ### `NEXT_PUBLIC_POSTHOG_KEY`
63
-
64
- - Type: Optional
65
- - Description: Set the PostHog project Key.
48
+ - Type: Required
49
+ - Description: Set the PostHog project Key. Add it will auto enable PostHog Analytics.
66
50
  - Default: `-`
67
51
  - Example: `phc_xxxxxxxx`
68
52
 
69
- ### `NEXT_PUBLIC_POSTHOG_HOST`
53
+ ### `POSTHOG_HOST`
70
54
 
71
55
  - Type: Optional
72
56
  - Description: Set the deployment address of the PostHog service, defaulting to the official SAAS address.
73
57
  - Default: `https://app.posthog.com`
74
58
  - Example: `https://example.com`
75
59
 
76
- ### `NEXT_PUBLIC_POSTHOG_DEBUG`
60
+ ### `DEBUG_POSTHOG_ANALYTICS`
77
61
 
78
62
  - Type: Optional
79
63
  - Description: Enable the debug mode for PostHog.
@@ -82,26 +66,19 @@ We have integrated several free/open-source data analytics services in LobeChat
82
66
 
83
67
  ## Umami Analytics
84
68
 
85
- ### `NEXT_PUBLIC_ANALYTICS_UMAMI`
69
+ ### `UMAMI_WEBSITE_ID`
86
70
 
87
- - Type: Optional
88
- - Description: Used to enable the environment variable for [Umami Analytics][umami-analytics-url]. Set to `1` to enable Umami Analytics.
71
+ - Type: Required
72
+ - Description: Your Umami Website ID. Add it will auto enable Umami Analytics.
89
73
  - Default: `-`
90
- - Example: `1`
74
+ - Example: `E738D82A-EE9E-4806-A81F-0CA3CAE57F65`
91
75
 
92
- ### `NEXT_PUBLIC_UMAMI_SCRIPT_URL`
76
+ ### `UMAMI_SCRIPT_URL`
93
77
 
94
78
  - Type: Optional
95
79
  - Description: The URL of the Umami script, defaulting to the script URL provided by Umami Cloud.
96
80
  - Default: `https://analytics.umami.is/script.js`
97
81
  - Example: `https://umami.your-site.com/script.js`
98
82
 
99
- ### `NEXT_PUBLIC_UMAMI_WEBSITE_ID`
100
-
101
- - Type: Required
102
- - Description: Your Umami Website ID.
103
- - Default: `-`
104
- - Example: `E738D82A-EE9E-4806-A81F-0CA3CAE57F65`
105
-
106
83
  [posthog-analytics-url]: https://posthog.com
107
84
  [umami-analytics-url]: https://umami.is
@@ -32,44 +32,30 @@ tags:
32
32
 
33
33
  ## Google Analytics
34
34
 
35
- ### `ENABLE_GOOGLE_ANALYTICS`
36
-
37
- - 类型:必选
38
- - 描述:用于配置 Google Analytics 的环境变量,当设为 `1` 时开启 Google Analytics
39
- - 默认值: `-`
40
- - 示例:`1`
41
-
42
35
  ### `GOOGLE_ANALYTICS_MEASUREMENT_ID`
43
36
 
44
37
  - 类型:必选
45
- - 描述:Google Analytics 的 Measurement ID,如果开启了 Google Analytics,此项必填
38
+ - 描述:Google Analytics 的 Measurement ID,填写此项后将自动开启 Google Analytics
46
39
  - 默认值: `-`
47
40
  - 示例:`G-63LP2TV03T`
48
41
 
49
42
  ## Posthog Analytics
50
43
 
51
- ### `NEXT_PUBLIC_ANALYTICS_POSTHOG`
52
-
53
- - 类型:可选
54
- - 描述:用于开启 [PostHog Analytics][posthog-analytics-url] 的环境变量,设为 `1` 时开启 PostHog Analytics
55
- - 默认值: `-`
56
- - 示例:`1`
44
+ ### `POSTHOG_KEY`
57
45
 
58
- ### `NEXT_PUBLIC_POSTHOG_KEY`
59
-
60
- - 类型:可选
61
- - 描述:设置 PostHog 项目 Key
46
+ - 类型:必选
47
+ - 描述:设置 PostHog 项目 Key,设置此项后将自动开启 PostHog Analytics
62
48
  - 默认值: `-`
63
49
  - 示例:`phc_xxxxxxxx`
64
50
 
65
- ### `NEXT_PUBLIC_POSTHOG_HOST`
51
+ ### `POSTHOG_HOST`
66
52
 
67
53
  - 类型:可选
68
- - 描述:设置 PostHog 服务的部署地址,默认为官方的 SAAS 地址
54
+ - 描述:设置 PostHog 服务的部署地址,默认为官方的 SaaS 地址
69
55
  - 默认值:`https://app.posthog.com`
70
56
  - 示例:`https://example.com`
71
57
 
72
- ### `NEXT_PUBLIC_POSTHOG_DEBUG`
58
+ ### `POSTHOG_DEBUG`
73
59
 
74
60
  - 类型:可选
75
61
  - 描述:开启 PostHog 的调试模式
@@ -78,26 +64,19 @@ tags:
78
64
 
79
65
  ## Umami Analytics
80
66
 
81
- ### `NEXT_PUBLIC_ANALYTICS_UMAMI`
67
+ ### `UMAMI_WEBSITE_ID`
82
68
 
83
- - 类型:可选
84
- - 描述:用于开启 [Umami Analytics][umami-analytics-url] 的环境变量,设为 `1` 时开启 Umami Analytics
85
- - 默认值: `-`
86
- - 示例:`1`
69
+ - 类型:必选
70
+ - 描述:你的 Umami Website ID,填写此项后将自动开启 Umami Analytics
71
+ - 默认值:`-`
72
+ - 示例:`E738D82A-EE9E-4806-A81F-0CA3CAE57F65`
87
73
 
88
- ### `NEXT_PUBLIC_UMAMI_SCRIPT_URL`
74
+ ### `UMAMI_SCRIPT_URL`
89
75
 
90
76
  - 类型:可选
91
77
  - 描述:Umami 脚本的网址,默认为 Umami Cloud 提供的脚本网址
92
78
  - 默认值:`https://analytics.umami.is/script.js`
93
79
  - 示例:`https://umami.your-site.com/script.js`
94
80
 
95
- ### `NEXT_PUBLIC_UMAMI_WEBSITE_ID`
96
-
97
- - 类型:必选
98
- - 描述:你的 Umami 的 Website ID
99
- - 默认值:`-`
100
- - 示例:`E738D82A-EE9E-4806-A81F-0CA3CAE57F65`
101
-
102
81
  [posthog-analytics-url]: https://posthog.com
103
82
  [umami-analytics-url]: https://umami.is
@@ -12,6 +12,8 @@
12
12
  "retry": "إعادة التحميل",
13
13
  "title": "واجهت الصفحة مشكلة ما.."
14
14
  },
15
+ "fetchError": "فشل الطلب",
16
+ "fetchErrorDetail": "تفاصيل الخطأ",
15
17
  "notFound": {
16
18
  "backHome": "العودة إلى الصفحة الرئيسية",
17
19
  "desc": "لم نتمكن من العثور على الصفحة التي تبحث عنها، يرجى التحقق مما إذا كان الرابط صحيحًا",
@@ -12,6 +12,8 @@
12
12
  "retry": "Опитай отново",
13
13
  "title": "Страницата се е сблъскала с проблем.."
14
14
  },
15
+ "fetchError": "Грешка при извличане",
16
+ "fetchErrorDetail": "Подробности за грешката",
15
17
  "notFound": {
16
18
  "backHome": "Върни се в началото",
17
19
  "desc": "Не можем да намерим страницата, която търсите. Моля, проверете дали връзката е правилна.",
@@ -12,6 +12,8 @@
12
12
  "retry": "Erneut laden",
13
13
  "title": "Ein Problem ist aufgetreten auf der Seite.."
14
14
  },
15
+ "fetchError": "Anforderung fehlgeschlagen",
16
+ "fetchErrorDetail": "Fehlerdetails",
15
17
  "notFound": {
16
18
  "backHome": "Zurück zur Startseite",
17
19
  "desc": "Die von Ihnen gesuchte Seite konnte nicht gefunden werden. Bitte überprüfen Sie, ob der Link korrekt ist.",
@@ -12,6 +12,8 @@
12
12
  "retry": "Reload",
13
13
  "title": "Oops, something went wrong.."
14
14
  },
15
+ "fetchError": "Request Failed",
16
+ "fetchErrorDetail": "Error Details",
15
17
  "notFound": {
16
18
  "backHome": "Back to Home",
17
19
  "desc": "We couldn't find the page you're looking for, please check if the link is correct",
@@ -12,6 +12,8 @@
12
12
  "retry": "Reintentar",
13
13
  "title": "Se ha producido un problema en la página.."
14
14
  },
15
+ "fetchError": "Error en la solicitud",
16
+ "fetchErrorDetail": "Detalles del error",
15
17
  "notFound": {
16
18
  "backHome": "Volver a la página de inicio",
17
19
  "desc": "No podemos encontrar la página que estás buscando, por favor verifica si el enlace es correcto",
@@ -12,6 +12,8 @@
12
12
  "retry": "Recharger",
13
13
  "title": "Un problème est survenu sur la page.."
14
14
  },
15
+ "fetchError": "Échec de la requête",
16
+ "fetchErrorDetail": "Détails de l'erreur",
15
17
  "notFound": {
16
18
  "backHome": "Retour à la page d'accueil",
17
19
  "desc": "La page que vous recherchez est introuvable. Veuillez vérifier si le lien est correct.",
@@ -12,6 +12,8 @@
12
12
  "retry": "Ricarica",
13
13
  "title": "La pagina ha riscontrato un problema.."
14
14
  },
15
+ "fetchError": "Errore di richiesta",
16
+ "fetchErrorDetail": "Dettagli dell'errore",
15
17
  "notFound": {
16
18
  "backHome": "Torna alla homepage",
17
19
  "desc": "Non riusciamo a trovare la pagina che stai cercando, controlla che il link sia corretto",
@@ -12,6 +12,8 @@
12
12
  "retry": "再読み込み",
13
13
  "title": "ページに問題が発生しました.."
14
14
  },
15
+ "fetchError": "リクエストが失敗しました",
16
+ "fetchErrorDetail": "エラーの詳細",
15
17
  "notFound": {
16
18
  "backHome": "ホームに戻る",
17
19
  "desc": "お探しのページが見つかりません。リンクが正しいかどうかをご確認ください",
@@ -12,6 +12,8 @@
12
12
  "retry": "다시 시도",
13
13
  "title": "페이지에서 문제가 발생했습니다."
14
14
  },
15
+ "fetchError": "요청 실패",
16
+ "fetchErrorDetail": "오류 상세",
15
17
  "notFound": {
16
18
  "backHome": "홈페이지로 돌아가기",
17
19
  "desc": "찾고 있는 페이지를 찾을 수 없습니다. 링크가 올바른지 확인해주세요.",
@@ -12,6 +12,8 @@
12
12
  "retry": "Opnieuw proberen",
13
13
  "title": "Er is een probleem opgetreden op de pagina.."
14
14
  },
15
+ "fetchError": "Verzoek mislukt",
16
+ "fetchErrorDetail": "Foutdetails",
15
17
  "notFound": {
16
18
  "backHome": "Terug naar startpagina",
17
19
  "desc": "We kunnen de pagina die je zoekt niet vinden, controleer of de link juist is",
@@ -12,6 +12,8 @@
12
12
  "retry": "Ponów próbę",
13
13
  "title": "Napotkano problem na stronie.."
14
14
  },
15
+ "fetchError": "Błąd żądania",
16
+ "fetchErrorDetail": "Szczegóły błędu",
15
17
  "notFound": {
16
18
  "backHome": "Powrót do strony głównej",
17
19
  "desc": "Nie możemy odnaleźć strony, której szukasz. Sprawdź, czy link jest poprawny.",
@@ -12,6 +12,8 @@
12
12
  "retry": "Tentar novamente",
13
13
  "title": "Ocorreu um problema na página.."
14
14
  },
15
+ "fetchError": "Falha na solicitação",
16
+ "fetchErrorDetail": "Detalhes do erro",
15
17
  "notFound": {
16
18
  "backHome": "Voltar para a página inicial",
17
19
  "desc": "Não conseguimos encontrar a página que você está procurando, por favor, verifique se o link está correto",
@@ -12,6 +12,8 @@
12
12
  "retry": "Повторить попытку",
13
13
  "title": "Произошла проблема на странице.."
14
14
  },
15
+ "fetchError": "Ошибка запроса",
16
+ "fetchErrorDetail": "Подробности ошибки",
15
17
  "notFound": {
16
18
  "backHome": "Вернуться на главную",
17
19
  "desc": "Мы не можем найти страницу, которую вы ищете. Пожалуйста, проверьте правильность ссылки",
@@ -12,6 +12,8 @@
12
12
  "retry": "Yeniden Yükle",
13
13
  "title": "Sayfa bir sorunla karşılaştı.."
14
14
  },
15
+ "fetchError": "İstek başarısız oldu",
16
+ "fetchErrorDetail": "Hata detayı",
15
17
  "notFound": {
16
18
  "backHome": "Ana Sayfaya Dön",
17
19
  "desc": "Aradığınız sayfayı bulamadık, lütfen bağlantının doğru olduğundan emin olun",
@@ -12,6 +12,8 @@
12
12
  "retry": "Thử lại",
13
13
  "title": "Trang gặp một chút vấn đề.."
14
14
  },
15
+ "fetchError": "Yêu cầu thất bại",
16
+ "fetchErrorDetail": "Chi tiết lỗi",
15
17
  "notFound": {
16
18
  "backHome": "Quay về Trang chủ",
17
19
  "desc": "Chúng tôi không thể tìm thấy trang bạn đang tìm, vui lòng kiểm tra xem liên kết có đúng không",
@@ -12,6 +12,8 @@
12
12
  "retry": "重新加载",
13
13
  "title": "页面遇到一点问题.."
14
14
  },
15
+ "fetchError": "请求失败",
16
+ "fetchErrorDetail": "错误详情",
15
17
  "notFound": {
16
18
  "backHome": "返回首页",
17
19
  "desc": "我们找不到你正在寻找的页面,请检查链接是否正确",
@@ -12,6 +12,8 @@
12
12
  "retry": "重新加載",
13
13
  "title": "頁面遇到一點問題.."
14
14
  },
15
+ "fetchError": "請求失敗",
16
+ "fetchErrorDetail": "錯誤詳情",
15
17
  "notFound": {
16
18
  "backHome": "返回首頁",
17
19
  "desc": "我們找不到您正在尋找的頁面,請檢查連結是否正確",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.160.4",
3
+ "version": "0.160.6",
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",
@@ -96,9 +96,9 @@
96
96
  "@icons-pack/react-simple-icons": "^9.5.0",
97
97
  "@lobehub/chat-plugin-sdk": "latest",
98
98
  "@lobehub/chat-plugins-gateway": "latest",
99
- "@lobehub/icons": "latest",
99
+ "@lobehub/icons": "^1.21.0",
100
100
  "@lobehub/tts": "latest",
101
- "@lobehub/ui": "^1.138.24",
101
+ "@lobehub/ui": "^1.138.26",
102
102
  "@microsoft/fetch-event-source": "^2.0.1",
103
103
  "@next/third-parties": "^14.2.3",
104
104
  "@sentry/nextjs": "^7.114.0",
@@ -5,6 +5,8 @@ import { memo, useEffect } from 'react';
5
5
 
6
6
  import { messageService } from '@/services/message';
7
7
  import { sessionService } from '@/services/session';
8
+ import { useUserStore } from '@/store/user';
9
+ import { authSelectors } from '@/store/user/selectors';
8
10
 
9
11
  const checkHasConversation = async () => {
10
12
  const hasMessages = await messageService.hasMessages();
@@ -14,8 +16,14 @@ const checkHasConversation = async () => {
14
16
 
15
17
  const Redirect = memo(() => {
16
18
  const router = useRouter();
19
+ const isLogin = useUserStore(authSelectors.isLogin);
17
20
 
18
21
  useEffect(() => {
22
+ if (!isLogin) {
23
+ router.replace('/welcome');
24
+ return;
25
+ }
26
+
19
27
  checkHasConversation().then((hasData) => {
20
28
  if (hasData) {
21
29
  router.replace('/chat');
@@ -5,58 +5,29 @@ import { Button } from 'antd';
5
5
  import { createStyles } from 'antd-style';
6
6
  import { LucideArrowUpRightFromSquare, TelescopeIcon } from 'lucide-react';
7
7
  import Link from 'next/link';
8
- import { rgba } from 'polished';
9
8
  import { memo } from 'react';
10
9
  import { useTranslation } from 'react-i18next';
11
10
  import { Flexbox } from 'react-layout-kit';
12
11
 
12
+ import Notification from '@/components/Notification';
13
13
  import { PRIVACY_URL } from '@/const/url';
14
14
  import { useServerConfigStore } from '@/store/serverConfig';
15
15
  import { serverConfigSelectors } from '@/store/serverConfig/selectors';
16
16
  import { useUserStore } from '@/store/user';
17
17
  import { preferenceSelectors } from '@/store/user/selectors';
18
18
 
19
- const useStyles = createStyles(({ css, token, isDarkMode }) => ({
20
- container: css`
21
- position: absolute;
22
- z-index: 1100;
23
- bottom: 16px;
24
- inset-inline-end: 20px;
25
-
26
- overflow: hidden;
27
-
28
- width: 422px;
29
-
30
- background: ${token.colorBgContainer};
31
- border: 1px solid ${token.colorSplit};
32
- border-radius: 8px;
33
- box-shadow: ${token.boxShadowSecondary};
34
- `,
19
+ const useStyles = createStyles(({ css, token }) => ({
35
20
  desc: css`
36
21
  color: ${token.colorTextSecondary};
37
22
  `,
38
- mobileContainer: css`
39
- bottom: 8px;
40
- inset-inline-start: 8px;
41
- width: calc(100% - 16px);
42
- `,
43
23
  title: css`
44
24
  font-size: 18px;
45
25
  font-weight: bold;
46
26
  `,
47
- wrapper: css`
48
- padding: 20px 20px 16px;
49
- background: linear-gradient(
50
- 180deg,
51
- ${rgba(token.colorBgContainer, 0)},
52
- ${token.colorBgContainer} ${isDarkMode ? '80' : '140'}px
53
- ),
54
- url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cg fill='${token.colorFillTertiary}' %3E %3Cpolygon fill-rule='evenodd' points='8 4 12 6 8 8 6 12 4 8 0 6 4 4 6 0 8 4'/%3E%3C/g%3E%3C/svg%3E");
55
- `,
56
27
  }));
57
28
 
58
29
  const TelemetryNotification = memo<{ mobile?: boolean }>(({ mobile }) => {
59
- const { styles, theme, cx } = useStyles();
30
+ const { styles, theme } = useStyles();
60
31
 
61
32
  const { t } = useTranslation('common');
62
33
  const shouldCheck = useServerConfigStore(serverConfigSelectors.enabledTelemetryChat);
@@ -75,51 +46,47 @@ const TelemetryNotification = memo<{ mobile?: boolean }>(({ mobile }) => {
75
46
  };
76
47
 
77
48
  return (
78
- showModal && (
79
- <Flexbox className={cx(styles.container, mobile && styles.mobileContainer)}>
80
- <Flexbox className={styles.wrapper} gap={16} horizontal>
81
- <Flexbox>
82
- <Avatar
83
- avatar={<TelescopeIcon />}
84
- background={theme.geekblue1}
85
- style={{ color: theme.geekblue7 }}
86
- ></Avatar>
87
- </Flexbox>
88
- <Flexbox gap={16}>
89
- <Flexbox gap={12}>
90
- <Flexbox className={styles.title}>{t('telemetry.title')}</Flexbox>
91
- <div className={styles.desc}>
92
- {t('telemetry.desc')}
93
- <span>
94
- <Link href={PRIVACY_URL} target={'_blank'}>
95
- {t('telemetry.learnMore')}
96
- <Icon icon={LucideArrowUpRightFromSquare} style={{ marginInlineStart: 4 }} />
97
- </Link>
98
- </span>
99
- </div>
100
- </Flexbox>
101
- <Flexbox gap={8} horizontal>
102
- <Button
103
- onClick={() => {
104
- updateTelemetry(true);
105
- }}
106
- type={'primary'}
107
- >
108
- {t('telemetry.allow')}
109
- </Button>
110
- <Button
111
- onClick={() => {
112
- updateTelemetry(false);
113
- }}
114
- type={'text'}
115
- >
116
- {t('telemetry.deny')}
117
- </Button>
118
- </Flexbox>
119
- </Flexbox>
49
+ <Notification mobile={mobile} show={showModal} showCloseIcon={false}>
50
+ <Flexbox>
51
+ <Avatar
52
+ avatar={<TelescopeIcon />}
53
+ background={theme.geekblue1}
54
+ style={{ color: theme.geekblue7 }}
55
+ ></Avatar>
56
+ </Flexbox>
57
+ <Flexbox gap={16}>
58
+ <Flexbox gap={12}>
59
+ <Flexbox className={styles.title}>{t('telemetry.title')}</Flexbox>
60
+ <div className={styles.desc}>
61
+ {t('telemetry.desc')}
62
+ <span>
63
+ <Link href={PRIVACY_URL} target={'_blank'}>
64
+ {t('telemetry.learnMore')}
65
+ <Icon icon={LucideArrowUpRightFromSquare} style={{ marginInlineStart: 4 }} />
66
+ </Link>
67
+ </span>
68
+ </div>
69
+ </Flexbox>
70
+ <Flexbox gap={8} horizontal>
71
+ <Button
72
+ onClick={() => {
73
+ updateTelemetry(true);
74
+ }}
75
+ type={'primary'}
76
+ >
77
+ {t('telemetry.allow')}
78
+ </Button>
79
+ <Button
80
+ onClick={() => {
81
+ updateTelemetry(false);
82
+ }}
83
+ type={'text'}
84
+ >
85
+ {t('telemetry.deny')}
86
+ </Button>
120
87
  </Flexbox>
121
88
  </Flexbox>
122
- )
89
+ </Notification>
123
90
  );
124
91
  });
125
92