Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
9c77dfbd
authored
Dec 03, 2023
by
Archer
Committed by
GitHub
Dec 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: img compress (#546)
parent
7fc05af0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
7 deletions
+14
-7
docSite/content/docs/installation/upgrading/463.md
+1
-0
projects/app/src/pages/api/core/chat/update.ts
+7
-4
projects/app/src/pages/chat/index.tsx
+1
-1
projects/app/src/pages/dataset/detail/components/Import/ImportModal.tsx
+2
-2
projects/app/src/web/common/file/controller.ts
+1
-0
projects/app/src/web/common/file/utils.ts
+2
-0
No files found.
docSite/content/docs/installation/upgrading/463.md
View file @
9c77dfbd
...
@@ -30,3 +30,4 @@ curl --location --request POST 'https://{{host}}/api/admin/initv463' \
...
@@ -30,3 +30,4 @@ curl --location --request POST 'https://{{host}}/api/admin/initv463' \
4.
优化 - 流读取文件,防止内存溢出
4.
优化 - 流读取文件,防止内存溢出
5.
优化 - 4v模型自动将 url 转 base64,本地也可调试
5.
优化 - 4v模型自动将 url 转 base64,本地也可调试
6.
优化 - 图片压缩等级
6.
优化 - 图片压缩等级
7.
修复 - 图片压缩失败报错,防止文件读取过程卡死。
projects/app/src/pages/api/core/chat/update.ts
View file @
9c77dfbd
...
@@ -13,10 +13,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...
@@ -13,10 +13,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
await
authChat
({
req
,
authToken
:
true
,
chatId
});
await
authChat
({
req
,
authToken
:
true
,
chatId
});
await
MongoChat
.
findOneAndUpdate
({
chatId
},
{
await
MongoChat
.
findOneAndUpdate
(
...(
customTitle
&&
{
customTitle
}),
{
chatId
},
...(
top
&&
{
top
})
{
});
...(
customTitle
!==
undefined
&&
{
customTitle
}),
...(
top
!==
undefined
&&
{
top
})
}
);
jsonRes
(
res
);
jsonRes
(
res
);
}
catch
(
err
)
{
}
catch
(
err
)
{
jsonRes
(
res
,
{
jsonRes
(
res
,
{
...
...
projects/app/src/pages/chat/index.tsx
View file @
9c77dfbd
...
@@ -328,7 +328,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
...
@@ -328,7 +328,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
}
}
}
}
onSetCustomTitle=
{
async
(
e
)
=>
{
onSetCustomTitle=
{
async
(
e
)
=>
{
try
{
try
{
await
putChatHistory
({
putChatHistory
({
chatId
:
e
.
chatId
,
chatId
:
e
.
chatId
,
customTitle
:
e
.
title
customTitle
:
e
.
title
});
});
...
...
projects/app/src/pages/dataset/detail/components/Import/ImportModal.tsx
View file @
9c77dfbd
...
@@ -84,8 +84,8 @@ const ImportData = ({
...
@@ -84,8 +84,8 @@ const ImportData = ({
title=
{
<
Box
{
...
TitleStyle
}
>
{
t
(
'dataset.data.File import'
)
}
</
Box
>
}
title=
{
<
Box
{
...
TitleStyle
}
>
{
t
(
'dataset.data.File import'
)
}
</
Box
>
}
isOpen
isOpen
isCentered
isCentered
maxW=
{
[
'90vw'
,
'
85vw
'
]
}
maxW=
{
[
'90vw'
,
'
min(1440px,85vw)
'
]
}
w=
{
[
'90vw'
,
'
85vw
'
]
}
w=
{
[
'90vw'
,
'
min(1440px,85vw)
'
]
}
h=
{
'90vh'
}
h=
{
'90vh'
}
>
>
<
ModalCloseButton
onClick=
{
onClose
}
/>
<
ModalCloseButton
onClick=
{
onClose
}
/>
...
...
projects/app/src/web/common/file/controller.ts
View file @
9c77dfbd
...
@@ -92,6 +92,7 @@ export const compressBase64ImgAndUpload = ({
...
@@ -92,6 +92,7 @@ export const compressBase64ImgAndUpload = ({
reject
(
error
);
reject
(
error
);
}
}
};
};
img
.
onerror
=
reject
;
});
});
};
};
export
const
compressImgFileAndUpload
=
async
({
export
const
compressImgFileAndUpload
=
async
({
...
...
projects/app/src/web/common/file/utils.ts
View file @
9c77dfbd
...
@@ -187,6 +187,7 @@ export const formatMarkdown = async (rawText: string = '') => {
...
@@ -187,6 +187,7 @@ export const formatMarkdown = async (rawText: string = '') => {
maxH
:
4329
,
maxH
:
4329
,
maxSize
:
1024
*
1024
*
5
maxSize
:
1024
*
1024
*
5
});
});
rawText
=
rawText
.
replace
(
base64
,
str
);
rawText
=
rawText
.
replace
(
base64
,
str
);
}
catch
(
error
)
{
}
catch
(
error
)
{
rawText
=
rawText
.
replace
(
base64
,
''
);
rawText
=
rawText
.
replace
(
base64
,
''
);
...
@@ -194,6 +195,7 @@ export const formatMarkdown = async (rawText: string = '') => {
...
@@ -194,6 +195,7 @@ export const formatMarkdown = async (rawText: string = '') => {
}
}
})
})
);
);
// Remove white space on both sides of the picture
// Remove white space on both sides of the picture
const
trimReg
=
/
\s
*
(
!
\[
.*
\]\(
.*
\))\s
*/g
;
const
trimReg
=
/
\s
*
(
!
\[
.*
\]\(
.*
\))\s
*/g
;
if
(
trimReg
.
test
(
rawText
))
{
if
(
trimReg
.
test
(
rawText
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment