@lobehub/chat 0.51.0 → 0.52.1
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/README.md +2 -2
- package/package.json +1 -1
- package/src/features/AvatarWithUpload/index.tsx +34 -2
- package/src/pages/_document.page.tsx +2 -26
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.52.1](https://github.com/lobehub/lobe-chat/compare/v0.52.0...v0.52.1)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-08-15**</sup>
|
|
8
|
+
|
|
9
|
+
#### ♻ Code Refactoring
|
|
10
|
+
|
|
11
|
+
- **misc**: Replace cdn.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### Code refactoring
|
|
19
|
+
|
|
20
|
+
- **misc**: Replace cdn ([2875400](https://github.com/lobehub/lobe-chat/commit/2875400))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
## [Version 0.52.0](https://github.com/lobehub/lobe-chat/compare/v0.51.0...v0.52.0)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2023-08-15**</sup>
|
|
33
|
+
|
|
34
|
+
#### ✨ Features
|
|
35
|
+
|
|
36
|
+
- **misc**: Add avatar compress.
|
|
37
|
+
|
|
38
|
+
<br/>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
42
|
+
|
|
43
|
+
#### What's improved
|
|
44
|
+
|
|
45
|
+
- **misc**: Add avatar compress ([1325b40](https://github.com/lobehub/lobe-chat/commit/1325b40))
|
|
46
|
+
|
|
47
|
+
</details>
|
|
48
|
+
|
|
49
|
+
<div align="right">
|
|
50
|
+
|
|
51
|
+
[](#readme-top)
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
5
55
|
## [Version 0.51.0](https://github.com/lobehub/lobe-chat/compare/v0.50.0...v0.51.0)
|
|
6
56
|
|
|
7
57
|
<sup>Released on **2023-08-15**</sup>
|
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
<img height="120" src="https://
|
|
5
|
+
<img height="120" src="https://registry.npmmirror.com/@lobehub/assets-logo/1.0.0/files/assets/logo-3d.webp">
|
|
6
6
|
<img height="120" src="https://gw.alipayobjects.com/zos/kitchen/qJ3l3EPsdW/split.svg">
|
|
7
|
-
<img height="120" src="https://
|
|
7
|
+
<img height="120" src="https://registry.npmmirror.com/@lobehub/assets-emoji/1.3.0/files/assets/robot.webp">
|
|
8
8
|
|
|
9
9
|
<h1>Lobe Chat</h1>
|
|
10
10
|
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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 (
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Meta } from '@lobehub/ui';
|
|
1
2
|
import { StyleProvider, extractStaticStyle } from 'antd-style';
|
|
2
3
|
import Document, { DocumentContext, Head, Html, Main, NextScript } from 'next/document';
|
|
3
4
|
|
|
@@ -31,32 +32,7 @@ class MyDocument extends Document {
|
|
|
31
32
|
return (
|
|
32
33
|
<Html>
|
|
33
34
|
<Head>
|
|
34
|
-
<
|
|
35
|
-
href="https://npm.elemecdn.com/@lobehub/assets-favicons/assets/apple-touch-icon.png"
|
|
36
|
-
rel="apple-touch-icon"
|
|
37
|
-
sizes="180x180"
|
|
38
|
-
/>
|
|
39
|
-
<link
|
|
40
|
-
href="https://npm.elemecdn.com/@lobehub/assets-favicons/assets/favicon-32x32.png"
|
|
41
|
-
rel="icon"
|
|
42
|
-
sizes="32x32"
|
|
43
|
-
type="image/png"
|
|
44
|
-
/>
|
|
45
|
-
<link
|
|
46
|
-
href="https://npm.elemecdn.com/@lobehub/assets-favicons/assets/favicon-16x16.png"
|
|
47
|
-
rel="icon"
|
|
48
|
-
sizes="16x16"
|
|
49
|
-
type="image/png"
|
|
50
|
-
/>
|
|
51
|
-
<link
|
|
52
|
-
color="#000000"
|
|
53
|
-
href="https://npm.elemecdn.com/@lobehub/assets-favicons/assets/safari-pinned-tab.svg"
|
|
54
|
-
rel="mask-icon"
|
|
55
|
-
/>
|
|
56
|
-
<meta content="LobeHub" name="apple-mobile-web-app-title" />
|
|
57
|
-
<meta content="LobeHub" name="application-name" />
|
|
58
|
-
<meta content="#000000" name="msapplication-TileColor" />
|
|
59
|
-
<meta content="#000000" name="theme-color" />
|
|
35
|
+
<Meta title={'LobeChat'} />
|
|
60
36
|
<link href="/manifest.json" rel="manifest" />
|
|
61
37
|
</Head>
|
|
62
38
|
<body>
|