@lobehub/lobehub 2.0.0-next.42 → 2.0.0-next.43

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 CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 2.0.0-next.43](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.42...v2.0.0-next.43)
6
+
7
+ <sup>Released on **2025-11-09**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Abnormal animation of tokens.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Abnormal animation of tokens, closes [#10106](https://github.com/lobehub/lobe-chat/issues/10106) ([129df7b](https://github.com/lobehub/lobe-chat/commit/129df7b))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ## [Version 2.0.0-next.42](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.41...v2.0.0-next.42)
6
31
 
7
32
  <sup>Released on **2025-11-09**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,13 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "fixes": [
5
+ "Abnormal animation of tokens."
6
+ ]
7
+ },
8
+ "date": "2025-11-09",
9
+ "version": "2.0.0-next.43"
10
+ },
2
11
  {
3
12
  "children": {
4
13
  "fixes": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/lobehub",
3
- "version": "2.0.0-next.42",
3
+ "version": "2.0.0-next.43",
4
4
  "description": "LobeHub - an open-source,comprehensive AI Agent 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",
@@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next';
8
8
  import { Center, Flexbox } from 'react-layout-kit';
9
9
 
10
10
  import InfoTooltip from '@/components/InfoTooltip';
11
+ import { useIsMobile } from '@/hooks/useIsMobile';
11
12
  import { aiModelSelectors, useAiInfraStore } from '@/store/aiInfra';
12
13
  import { useGlobalStore } from '@/store/global';
13
14
  import { systemStatusSelectors } from '@/store/global/selectors';
@@ -27,6 +28,11 @@ interface TokenDetailProps {
27
28
  const TokenDetail = memo<TokenDetailProps>(({ meta, model, provider }) => {
28
29
  const { t } = useTranslation('chat');
29
30
  const theme = useTheme();
31
+ const isMobile = useIsMobile();
32
+
33
+ // 使用 systemStatus 管理短格式显示状态
34
+ const isShortFormat = useGlobalStore(systemStatusSelectors.tokenDisplayFormatShort);
35
+ const updateSystemStatus = useGlobalStore((s) => s.updateSystemStatus);
30
36
 
31
37
  const modelCard = useAiInfraStore(aiModelSelectors.getModelCard(model, provider));
32
38
  const isShowCredit = useGlobalStore(systemStatusSelectors.isShowCredit) && !!modelCard?.pricing;
@@ -211,12 +217,32 @@ const TokenDetail = memo<TokenDetailProps>(({ meta, model, provider }) => {
211
217
  </Flexbox>
212
218
  }
213
219
  placement={'top'}
214
- trigger={['hover', 'click']}
220
+ trigger={isMobile ? ['click'] : ['hover']}
215
221
  >
216
- <Center gap={2} horizontal style={{ cursor: 'default' }}>
222
+ <Center
223
+ gap={2}
224
+ horizontal
225
+ onClick={(e) => {
226
+ // 移动端:让 Popover 处理点击事件
227
+ if (isMobile) return;
228
+
229
+ // 桌面端:阻止 Popover 并切换格式
230
+ e.preventDefault();
231
+ e.stopPropagation();
232
+ updateSystemStatus({ tokenDisplayFormatShort: !isShortFormat });
233
+ }}
234
+ style={{ cursor: isMobile ? 'default' : 'pointer' }}
235
+ >
217
236
  <Icon icon={isShowCredit ? BadgeCent : CoinsIcon} />
218
237
  <AnimatedNumber
219
- formatter={(value) => (formatShortenNumber(value) as string).toLowerCase?.()}
238
+ duration={1500}
239
+ formatter={(value) => {
240
+ const roundedValue = Math.round(value);
241
+ if (isShortFormat) {
242
+ return (formatShortenNumber(roundedValue) as string).toLowerCase?.();
243
+ }
244
+ return new Intl.NumberFormat('en-US').format(roundedValue);
245
+ }}
220
246
  // Force remount when switching between token/credit to prevent unwanted animation
221
247
  // See: https://github.com/lobehub/lobe-chat/pull/10098
222
248
  key={isShowCredit ? 'credit' : 'token'}
@@ -99,6 +99,10 @@ export interface SystemStatus {
99
99
  * theme mode
100
100
  */
101
101
  themeMode?: ThemeMode;
102
+ /**
103
+ * 是否使用短格式显示 token
104
+ */
105
+ tokenDisplayFormatShort?: boolean;
102
106
  zenMode?: boolean;
103
107
  }
104
108
 
@@ -151,6 +155,7 @@ export const INITIAL_STATUS = {
151
155
  showSystemRole: false,
152
156
  systemRoleExpandedMap: {},
153
157
  themeMode: 'auto',
158
+ tokenDisplayFormatShort: true,
154
159
  zenMode: false,
155
160
  } satisfies SystemStatus;
156
161
 
@@ -66,6 +66,8 @@ const getAgentSystemRoleExpanded =
66
66
  const disabledModelProvidersSortType = (s: GlobalState) =>
67
67
  s.status.disabledModelProvidersSortType || 'default';
68
68
  const disabledModelsSortType = (s: GlobalState) => s.status.disabledModelsSortType || 'default';
69
+ const tokenDisplayFormatShort = (s: GlobalState) =>
70
+ s.status.tokenDisplayFormatShort !== undefined ? s.status.tokenDisplayFormatShort : true;
69
71
 
70
72
  export const systemStatusSelectors = {
71
73
  chatInputHeight,
@@ -99,5 +101,6 @@ export const systemStatusSelectors = {
99
101
  showSystemRole,
100
102
  systemStatus,
101
103
  themeMode,
104
+ tokenDisplayFormatShort,
102
105
  wideScreen,
103
106
  };