@lobehub/chat 0.50.0 → 0.52.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 0.52.0](https://github.com/lobehub/lobe-chat/compare/v0.51.0...v0.52.0)
6
+
7
+ <sup>Released on **2023-08-15**</sup>
8
+
9
+ #### ✨ Features
10
+
11
+ - **misc**: Add avatar compress.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's improved
19
+
20
+ - **misc**: Add avatar compress ([1325b40](https://github.com/lobehub/lobe-chat/commit/1325b40))
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
+
30
+ ## [Version 0.51.0](https://github.com/lobehub/lobe-chat/compare/v0.50.0...v0.51.0)
31
+
32
+ <sup>Released on **2023-08-15**</sup>
33
+
34
+ #### ✨ Features
35
+
36
+ - **misc**: Add Footer component and modify Token and index files.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### What's improved
44
+
45
+ - **misc**: Add Footer component and modify Token and index files ([41a3823](https://github.com/lobehub/lobe-chat/commit/41a3823))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ## [Version 0.50.0](https://github.com/lobehub/lobe-chat/compare/v0.49.0...v0.50.0)
6
56
 
7
57
  <sup>Released on **2023-08-15**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.50.0",
3
+ "version": "0.52.0",
4
4
  "description": "Lobe Chat is an open-source chatbot client using LangChain, Typescript and Next.js",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -23,15 +23,47 @@ const useStyle = createStyles(
23
23
  );
24
24
 
25
25
  interface AvatarWithUploadProps {
26
+ compressSize?: number;
26
27
  size?: number;
27
28
  }
28
29
 
29
- const AvatarWithUpload = memo<AvatarWithUploadProps>(({ size = 40 }) => {
30
+ const AvatarWithUpload = memo<AvatarWithUploadProps>(({ size = 40, compressSize = 128 }) => {
30
31
  const [avatar, setSettings] = useGlobalStore((st) => [st.settings.avatar, st.setSettings]);
31
32
  const { styles } = useStyle();
32
33
 
33
34
  const handleUploadAvatar = createUploadImageHandler((avatar) => {
34
- setSettings({ avatar });
35
+ const img = new Image();
36
+ img.src = avatar;
37
+ img.addEventListener('load', () => {
38
+ const canvas = document.createElement('canvas');
39
+ const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
40
+ let startX = 0;
41
+ let startY = 0;
42
+
43
+ if (img.width > img.height) {
44
+ startX = (img.width - img.height) / 2;
45
+ } else {
46
+ startY = (img.height - img.width) / 2;
47
+ }
48
+
49
+ canvas.width = compressSize;
50
+ canvas.height = compressSize;
51
+
52
+ ctx.drawImage(
53
+ img,
54
+ startX,
55
+ startY,
56
+ Math.min(img.width, img.height),
57
+ Math.min(img.width, img.height),
58
+ 0,
59
+ 0,
60
+ compressSize,
61
+ compressSize,
62
+ );
63
+
64
+ const webpBase64 = canvas.toDataURL('image/webp');
65
+ setSettings({ avatar: webpBase64 });
66
+ });
35
67
  });
36
68
 
37
69
  return (
@@ -80,4 +80,5 @@ export default {
80
80
  },
81
81
  updateAgent: '更新助理信息',
82
82
  updatePrompt: '更新提示词',
83
+ warp: '换行',
83
84
  };
@@ -0,0 +1,49 @@
1
+ import { Icon, Tooltip } from '@lobehub/ui';
2
+ import { Button } from 'antd';
3
+ import { useTheme } from 'antd-style';
4
+ import { ArrowBigUp, CornerDownLeft, LucideGalleryVerticalEnd } from 'lucide-react';
5
+ import { memo } from 'react';
6
+ import { useTranslation } from 'react-i18next';
7
+ import { Flexbox } from 'react-layout-kit';
8
+
9
+ export interface FooterProps {
10
+ hasTopic: boolean;
11
+ saveToTopic: () => void;
12
+ }
13
+
14
+ const Footer = memo<FooterProps>(({ hasTopic, saveToTopic }) => {
15
+ const theme = useTheme();
16
+ const { t } = useTranslation('common');
17
+
18
+ const saveTopic = hasTopic ? null : (
19
+ <Tooltip title={t('topic.saveCurrentMessages')}>
20
+ <Button icon={<Icon icon={LucideGalleryVerticalEnd} />} onClick={saveToTopic} />
21
+ </Tooltip>
22
+ );
23
+
24
+ const footerTooltip = (
25
+ <Flexbox
26
+ gap={4}
27
+ horizontal
28
+ style={{ color: theme.colorTextDescription, fontSize: 12, marginRight: 12 }}
29
+ >
30
+ <Icon icon={CornerDownLeft} />
31
+ <span>{t('send')}</span>
32
+ <span>/</span>
33
+ <Flexbox horizontal>
34
+ <Icon icon={ArrowBigUp} />
35
+ <Icon icon={CornerDownLeft} />
36
+ </Flexbox>
37
+ <span>{t('warp')}</span>
38
+ </Flexbox>
39
+ );
40
+
41
+ return (
42
+ <>
43
+ {footerTooltip}
44
+ {saveTopic}
45
+ </>
46
+ );
47
+ });
48
+
49
+ export default Footer;
@@ -22,6 +22,7 @@ const Token = memo<{ input: string }>(({ input }) => {
22
22
  <Tooltip placement={'bottom'} title={t('tokenDetail', { chatsToken, systemRoleToken })}>
23
23
  <TokenTag
24
24
  maxValue={ModelTokens[model]}
25
+ style={{ marginLeft: 8 }}
25
26
  text={{
26
27
  overload: t('tokenTag.overload'),
27
28
  remained: t('tokenTag.remained'),
@@ -1,6 +1,4 @@
1
- import { ChatInputArea, DraggablePanel, Icon, Tooltip } from '@lobehub/ui';
2
- import { Button } from 'antd';
3
- import { LucideGalleryVerticalEnd } from 'lucide-react';
1
+ import { ChatInputArea, DraggablePanel } from '@lobehub/ui';
4
2
  import { memo, useState } from 'react';
5
3
  import { useTranslation } from 'react-i18next';
6
4
 
@@ -10,6 +8,7 @@ import { useSessionStore } from '@/store/session';
10
8
 
11
9
  import InputActions from './Action';
12
10
  import ActionsRight from './ActionRight';
11
+ import Footer from './Footer';
13
12
  import Token from './Token';
14
13
 
15
14
  const ChatInput = () => {
@@ -31,12 +30,6 @@ const ChatInput = () => {
31
30
  ],
32
31
  );
33
32
 
34
- const footer = hasTopic ? null : (
35
- <Tooltip title={t('topic.saveCurrentMessages')}>
36
- <Button icon={<Icon icon={LucideGalleryVerticalEnd} />} onClick={saveToTopic} />
37
- </Tooltip>
38
- );
39
-
40
33
  return (
41
34
  <DraggablePanel
42
35
  expandable={false}
@@ -63,7 +56,7 @@ const ChatInput = () => {
63
56
  }
64
57
  actionsRight={<ActionsRight />}
65
58
  expand={expand}
66
- footer={footer}
59
+ footer={<Footer hasTopic={hasTopic} saveToTopic={saveToTopic} />}
67
60
  loading={isLoading}
68
61
  minHeight={CHAT_TEXTAREA_HEIGHT}
69
62
  onExpandChange={setExpand}