@lobehub/chat 1.43.2 → 1.43.4
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.
- package/CHANGELOG.md +50 -0
- package/changelog/v1.json +18 -0
- package/next.config.ts +2 -8
- package/package.json +2 -2
- package/src/features/User/DataStatistics.tsx +4 -20
- package/src/layout/AuthProvider/Clerk/index.tsx +1 -0
- package/src/middleware.ts +2 -2
- package/src/utils/format.test.ts +5 -3
- package/src/utils/format.ts +1 -1
- package/src/utils/server/auth.ts +1 -1
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,56 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.43.4](https://github.com/lobehub/lobe-chat/compare/v1.43.3...v1.43.4)
|
6
|
+
|
7
|
+
<sup>Released on **2025-01-06**</sup>
|
8
|
+
|
9
|
+
#### 🐛 Bug Fixes
|
10
|
+
|
11
|
+
- **misc**: Fix format short number.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### What's fixed
|
19
|
+
|
20
|
+
- **misc**: Fix format short number, closes [#5294](https://github.com/lobehub/lobe-chat/issues/5294) ([d8a29ec](https://github.com/lobehub/lobe-chat/commit/d8a29ec))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
30
|
+
### [Version 1.43.3](https://github.com/lobehub/lobe-chat/compare/v1.43.2...v1.43.3)
|
31
|
+
|
32
|
+
<sup>Released on **2025-01-04**</sup>
|
33
|
+
|
34
|
+
#### ♻ Code Refactoring
|
35
|
+
|
36
|
+
- **misc**: Upgrade `@clerk/nextjs` to v6.
|
37
|
+
|
38
|
+
<br/>
|
39
|
+
|
40
|
+
<details>
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
42
|
+
|
43
|
+
#### Code refactoring
|
44
|
+
|
45
|
+
- **misc**: Upgrade `@clerk/nextjs` to v6, closes [#5291](https://github.com/lobehub/lobe-chat/issues/5291) ([de09895](https://github.com/lobehub/lobe-chat/commit/de09895))
|
46
|
+
|
47
|
+
</details>
|
48
|
+
|
49
|
+
<div align="right">
|
50
|
+
|
51
|
+
[](#readme-top)
|
52
|
+
|
53
|
+
</div>
|
54
|
+
|
5
55
|
### [Version 1.43.2](https://github.com/lobehub/lobe-chat/compare/v1.43.1...v1.43.2)
|
6
56
|
|
7
57
|
<sup>Released on **2025-01-04**</sup>
|
package/changelog/v1.json
CHANGED
@@ -1,4 +1,22 @@
|
|
1
1
|
[
|
2
|
+
{
|
3
|
+
"children": {
|
4
|
+
"fixes": [
|
5
|
+
"Fix format short number."
|
6
|
+
]
|
7
|
+
},
|
8
|
+
"date": "2025-01-06",
|
9
|
+
"version": "1.43.4"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"children": {
|
13
|
+
"improvements": [
|
14
|
+
"Upgrade @clerk/nextjs to v6."
|
15
|
+
]
|
16
|
+
},
|
17
|
+
"date": "2025-01-04",
|
18
|
+
"version": "1.43.3"
|
19
|
+
},
|
2
20
|
{
|
3
21
|
"children": {
|
4
22
|
"fixes": [
|
package/next.config.ts
CHANGED
@@ -10,7 +10,6 @@ const enableReactScan = !!process.env.REACT_SCAN_MONITOR_API_KEY;
|
|
10
10
|
const isUsePglite = process.env.NEXT_PUBLIC_CLIENT_DB === 'pglite';
|
11
11
|
|
12
12
|
// if you need to proxy the api endpoint to remote server
|
13
|
-
const API_PROXY_ENDPOINT = process.env.API_PROXY_ENDPOINT || '';
|
14
13
|
|
15
14
|
const basePath = process.env.NEXT_PUBLIC_BASE_PATH;
|
16
15
|
|
@@ -28,7 +27,6 @@ const nextConfig: NextConfig = {
|
|
28
27
|
],
|
29
28
|
webVitalsAttribution: ['CLS', 'LCP'],
|
30
29
|
},
|
31
|
-
|
32
30
|
async headers() {
|
33
31
|
return [
|
34
32
|
{
|
@@ -166,14 +164,10 @@ const nextConfig: NextConfig = {
|
|
166
164
|
source: '/welcome',
|
167
165
|
},
|
168
166
|
],
|
169
|
-
rewrites: async () => [
|
170
|
-
// due to google api not work correct in some countries
|
171
|
-
// we need a proxy to bypass the restriction
|
172
|
-
{ destination: `${API_PROXY_ENDPOINT}/api/chat/google`, source: '/api/chat/google' },
|
173
|
-
],
|
174
|
-
|
175
167
|
serverExternalPackages: ['@electric-sql/pglite'],
|
176
168
|
|
169
|
+
transpilePackages: ['pdfjs-dist', 'mermaid'],
|
170
|
+
|
177
171
|
webpack(config) {
|
178
172
|
config.experiments = {
|
179
173
|
asyncWebAssembly: true,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.43.
|
3
|
+
"version": "1.43.4",
|
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",
|
@@ -115,7 +115,7 @@
|
|
115
115
|
"@baiducloud/qianfan": "^0.1.9",
|
116
116
|
"@cfworker/json-schema": "^4.0.0",
|
117
117
|
"@clerk/localizations": "^3.3.0",
|
118
|
-
"@clerk/nextjs": "^
|
118
|
+
"@clerk/nextjs": "^6.9.6",
|
119
119
|
"@clerk/themes": "^2.1.37",
|
120
120
|
"@codesandbox/sandpack-react": "^2.19.9",
|
121
121
|
"@cyntler/react-doc-viewer": "^1.17.0",
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import { Icon, Tooltip } from '@lobehub/ui';
|
4
4
|
import { Badge } from 'antd';
|
5
5
|
import { createStyles } from 'antd-style';
|
6
|
-
import {
|
6
|
+
import { isUndefined } from 'lodash-es';
|
7
7
|
import { LoaderCircle } from 'lucide-react';
|
8
8
|
import { memo, useMemo } from 'react';
|
9
9
|
import { useTranslation } from 'react-i18next';
|
@@ -14,6 +14,7 @@ import { messageService } from '@/services/message';
|
|
14
14
|
import { sessionService } from '@/services/session';
|
15
15
|
import { topicService } from '@/services/topic';
|
16
16
|
import { useServerConfigStore } from '@/store/serverConfig';
|
17
|
+
import { formatShortenNumber } from '@/utils/format';
|
17
18
|
import { today } from '@/utils/time';
|
18
19
|
|
19
20
|
const useStyles = createStyles(({ css, token }) => ({
|
@@ -42,23 +43,6 @@ const useStyles = createStyles(({ css, token }) => ({
|
|
42
43
|
`,
|
43
44
|
}));
|
44
45
|
|
45
|
-
const formatNumber = (num: any) => {
|
46
|
-
if (!isNumber(num)) return num;
|
47
|
-
// 使用Intl.NumberFormat来添加千分号
|
48
|
-
const formattedWithComma = new Intl.NumberFormat('en-US').format(num);
|
49
|
-
|
50
|
-
// 格式化为 K 或 M
|
51
|
-
if (num >= 10_000_000) {
|
52
|
-
return (num / 1_000_000).toFixed(1) + 'M';
|
53
|
-
} else if (num >= 10_000) {
|
54
|
-
return (num / 1000).toFixed(1) + 'K';
|
55
|
-
} else if (num === 0) {
|
56
|
-
return 0;
|
57
|
-
} else {
|
58
|
-
return formattedWithComma;
|
59
|
-
}
|
60
|
-
};
|
61
|
-
|
62
46
|
const DataStatistics = memo<Omit<FlexboxProps, 'children'>>(({ style, ...rest }) => {
|
63
47
|
const mobile = useServerConfigStore((s) => s.isMobile);
|
64
48
|
// sessions
|
@@ -128,7 +112,7 @@ const DataStatistics = memo<Omit<FlexboxProps, 'children'>>(({ style, ...rest })
|
|
128
112
|
key={item.key}
|
129
113
|
>
|
130
114
|
<Flexbox gap={2}>
|
131
|
-
<div className={styles.count}>{
|
115
|
+
<div className={styles.count}>{formatShortenNumber(item.count)}</div>
|
132
116
|
<div className={styles.title}>{item.title}</div>
|
133
117
|
</Flexbox>
|
134
118
|
{showBadge && (
|
@@ -150,7 +134,7 @@ const DataStatistics = memo<Omit<FlexboxProps, 'children'>>(({ style, ...rest })
|
|
150
134
|
return (
|
151
135
|
<Flexbox className={styles.card} flex={1} gap={2} key={item.key}>
|
152
136
|
<Flexbox horizontal>
|
153
|
-
<div className={styles.count}>{
|
137
|
+
<div className={styles.count}>{formatShortenNumber(item.count)}</div>
|
154
138
|
</Flexbox>
|
155
139
|
<div className={styles.title}>{item.title}</div>
|
156
140
|
</Flexbox>
|
@@ -44,6 +44,7 @@ const Clerk = memo(({ children }: PropsWithChildren) => {
|
|
44
44
|
return (
|
45
45
|
<ClerkProvider
|
46
46
|
appearance={updatedAppearance}
|
47
|
+
dynamic
|
47
48
|
localization={localization}
|
48
49
|
signUpUrl={!enableClerkSignUp ? '/login' : '/signup'} // Redirect sign-up to sign-in if disabled
|
49
50
|
>
|
package/src/middleware.ts
CHANGED
@@ -54,8 +54,8 @@ const isProtectedRoute = createRouteMatcher([
|
|
54
54
|
|
55
55
|
export default authEnv.NEXT_PUBLIC_ENABLE_CLERK_AUTH
|
56
56
|
? clerkMiddleware(
|
57
|
-
(auth, req) => {
|
58
|
-
if (isProtectedRoute(req)) auth
|
57
|
+
async (auth, req) => {
|
58
|
+
if (isProtectedRoute(req)) await auth.protect();
|
59
59
|
},
|
60
60
|
{
|
61
61
|
// https://github.com/lobehub/lobe-chat/pull/3084
|
package/src/utils/format.test.ts
CHANGED
@@ -16,7 +16,6 @@ import {
|
|
16
16
|
formatTokenNumber,
|
17
17
|
} from './format';
|
18
18
|
|
19
|
-
// 保留你已经编写的测试用例
|
20
19
|
describe('format', () => {
|
21
20
|
describe('formatSize', () => {
|
22
21
|
it('should format bytes to KB correctly', () => {
|
@@ -128,10 +127,13 @@ describe('format', () => {
|
|
128
127
|
expect(formatShortenNumber(9999)).toBe('9,999');
|
129
128
|
});
|
130
129
|
|
131
|
-
it('should format numbers between 10,000 and
|
130
|
+
it('should format numbers between 10,000 and 999,999 correctly', () => {
|
132
131
|
expect(formatShortenNumber(10000)).toBe('10.0K');
|
133
132
|
expect(formatShortenNumber(123456)).toBe('123.5K');
|
134
|
-
expect(formatShortenNumber(
|
133
|
+
expect(formatShortenNumber(998000)).toBe('998.0K');
|
134
|
+
expect(formatShortenNumber(999999)).toBe('1000.0K');
|
135
|
+
expect(formatShortenNumber(1000000)).toBe('1.0M');
|
136
|
+
expect(formatShortenNumber(9999999)).toBe('10.0M');
|
135
137
|
});
|
136
138
|
|
137
139
|
it('should format numbers 10,000,000 and above correctly', () => {
|
package/src/utils/format.ts
CHANGED
@@ -69,7 +69,7 @@ export const formatShortenNumber = (num: any) => {
|
|
69
69
|
const formattedWithComma = new Intl.NumberFormat('en-US').format(num);
|
70
70
|
|
71
71
|
// 格式化为 K 或 M
|
72
|
-
if (num >=
|
72
|
+
if (num >= 1_000_000) {
|
73
73
|
return (num / 1_000_000).toFixed(1) + 'M';
|
74
74
|
} else if (num >= 10_000) {
|
75
75
|
return (num / 1000).toFixed(1) + 'K';
|
package/src/utils/server/auth.ts
CHANGED