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
Commit
bf81d23d
authored
Mar 05, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 去除console,
parent
52a752da
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
21 additions
and
48 deletions
+21
-48
src/api/request.ts
+1
-1
src/components/Layout/auth.tsx
+1
-1
src/components/Markdown/index.module.scss
+0
-1
src/components/Markdown/index.tsx
+4
-4
src/pages/api/chat/chatGpt.ts
+1
-1
src/pages/api/chat/init.ts
+1
-1
src/pages/api/test.ts
+0
-24
src/pages/model/components/ModelEditForm.tsx
+1
-1
src/pages/model/components/Training.tsx
+1
-1
src/pages/model/detail.tsx
+5
-7
src/pages/model/list.tsx
+1
-1
src/service/response.ts
+2
-2
src/service/utils/sendEmail.ts
+2
-2
src/utils/tools.ts
+1
-1
No files found.
src/api/request.ts
View file @
bf81d23d
...
@@ -34,7 +34,7 @@ function responseSuccess(response: AxiosResponse<ResponseDataType>) {
...
@@ -34,7 +34,7 @@ function responseSuccess(response: AxiosResponse<ResponseDataType>) {
*/
*/
function
checkRes
(
data
:
ResponseDataType
)
{
function
checkRes
(
data
:
ResponseDataType
)
{
if
(
data
===
undefined
)
{
if
(
data
===
undefined
)
{
console
.
log
(
data
,
'data is empty'
);
console
.
error
(
data
,
'data is empty'
);
return
Promise
.
reject
(
'服务器异常'
);
return
Promise
.
reject
(
'服务器异常'
);
}
else
if
(
data
.
code
<
200
||
data
.
code
>=
400
)
{
}
else
if
(
data
.
code
<
200
||
data
.
code
>=
400
)
{
return
Promise
.
reject
(
data
.
message
);
return
Promise
.
reject
(
data
.
message
);
...
...
src/components/Layout/auth.tsx
View file @
bf81d23d
...
@@ -39,7 +39,7 @@ const Auth = ({ children }: { children: JSX.Element }) => {
...
@@ -39,7 +39,7 @@ const Auth = ({ children }: { children: JSX.Element }) => {
}
}
},
},
onError
(
error
)
{
onError
(
error
)
{
console
.
log
(
error
);
console
.
error
(
error
);
router
.
push
(
'/login'
);
router
.
push
(
'/login'
);
toast
();
toast
();
},
},
...
...
src/components/Markdown/index.module.scss
View file @
bf81d23d
...
@@ -107,7 +107,6 @@
...
@@ -107,7 +107,6 @@
font-size
:
28px
;
font-size
:
28px
;
}
}
.markdown
h2
{
.markdown
h2
{
border-bottom
:
1px
solid
#cccccc
;
color
:
#000000
;
color
:
#000000
;
font-size
:
24px
;
font-size
:
24px
;
}
}
...
...
src/components/Markdown/index.tsx
View file @
bf81d23d
import
React
,
{
memo
}
from
'react'
;
import
React
,
{
memo
,
useMemo
}
from
'react'
;
import
ReactMarkdown
from
'react-markdown'
;
import
ReactMarkdown
from
'react-markdown'
;
import
remarkGfm
from
'remark-gfm'
;
import
remarkGfm
from
'remark-gfm'
;
import
styles
from
'./index.module.scss'
;
import
styles
from
'./index.module.scss'
;
...
@@ -9,9 +9,9 @@ import { useCopyData } from '@/utils/tools';
...
@@ -9,9 +9,9 @@ import { useCopyData } from '@/utils/tools';
import
Icon
from
'@/components/Icon'
;
import
Icon
from
'@/components/Icon'
;
const
Markdown
=
({
source
,
isChatting
}:
{
source
:
string
;
isChatting
:
boolean
})
=>
{
const
Markdown
=
({
source
,
isChatting
}:
{
source
:
string
;
isChatting
:
boolean
})
=>
{
// const formatSource = useMemo(() => source.replace(/\n/g, '
\n'), [source]);
const
formatSource
=
useMemo
(()
=>
source
.
replace
(
/
\n
/g
,
'
\n'
),
[
source
]);
const
{
copyData
}
=
useCopyData
();
const
{
copyData
}
=
useCopyData
();
// console.log(source);
return
(
return
(
<
ReactMarkdown
<
ReactMarkdown
className=
{
`${styles.markdown} ${
className=
{
`${styles.markdown} ${
...
@@ -56,7 +56,7 @@ const Markdown = ({ source, isChatting }: { source: string; isChatting: boolean
...
@@ -56,7 +56,7 @@ const Markdown = ({ source, isChatting }: { source: string; isChatting: boolean
}
}
}
}
}
}
>
>
{
s
ource
}
{
formatS
ource
}
</
ReactMarkdown
>
</
ReactMarkdown
>
);
);
};
};
...
...
src/pages/api/chat/chatGpt.ts
View file @
bf81d23d
...
@@ -104,7 +104,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...
@@ -104,7 +104,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
res
.
end
();
res
.
end
();
}
catch
(
err
:
any
)
{
}
catch
(
err
:
any
)
{
console
.
log
(
err
?.
response
?.
data
||
err
);
console
.
error
(
err
?.
response
?.
data
||
err
);
// 删除最一条数据库记录, 也就是预发送的那一条
// 删除最一条数据库记录, 也就是预发送的那一条
await
ChatWindow
.
findByIdAndUpdate
(
windowId
,
{
await
ChatWindow
.
findByIdAndUpdate
(
windowId
,
{
$pop
:
{
content
:
1
},
$pop
:
{
content
:
1
},
...
...
src/pages/api/chat/init.ts
View file @
bf81d23d
...
@@ -82,7 +82,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...
@@ -82,7 +82,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}
}
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
);
console
.
error
(
err
);
jsonRes
(
res
,
{
jsonRes
(
res
,
{
code
:
500
,
code
:
500
,
error
:
err
error
:
err
...
...
src/pages/api/test.ts
deleted
100644 → 0
View file @
52a752da
import
type
{
NextApiRequest
,
NextApiResponse
}
from
'next'
;
export
default
async
function
handler
(
req
:
NextApiRequest
,
res
:
NextApiResponse
<
any
>
)
{
if
(
req
.
method
!==
'GET'
)
return
;
res
.
writeHead
(
200
,
{
Connection
:
'keep-alive'
,
'Content-Encoding'
:
'none'
,
'Cache-Control'
:
'no-cache'
,
'Content-Type'
:
'text/event-stream'
});
let
val
=
0
;
const
timer
=
setInterval
(()
=>
{
console
.
log
(
'发送消息'
,
val
);
res
.
write
(
`data:
${
val
++
}
\n\n`
);
if
(
val
>
30
)
{
clearInterval
(
timer
);
res
.
write
(
`data: [DONE]\n\n`
);
res
.
end
();
}
},
500
);
}
src/pages/model/components/ModelEditForm.tsx
View file @
bf81d23d
...
@@ -34,7 +34,7 @@ const ModelEditForm = ({ model }: { model?: ModelType }) => {
...
@@ -34,7 +34,7 @@ const ModelEditForm = ({ model }: { model?: ModelType }) => {
status
:
'success'
status
:
'success'
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
);
console
.
error
(
err
);
toast
({
toast
({
title
:
err
as
string
,
title
:
err
as
string
,
status
:
'success'
status
:
'success'
...
...
src/pages/model/components/Training.tsx
View file @
bf81d23d
...
@@ -29,7 +29,7 @@ const Training = ({ model }: { model: ModelType }) => {
...
@@ -29,7 +29,7 @@ const Training = ({ model }: { model: ModelType }) => {
const
res
=
await
getModelTrainings
(
id
);
const
res
=
await
getModelTrainings
(
id
);
setRecords
(
res
);
setRecords
(
res
);
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
);
console
.
error
(
error
);
}
}
},
[]);
},
[]);
...
...
src/pages/model/detail.tsx
View file @
bf81d23d
...
@@ -41,10 +41,8 @@ const ModelDetail = () => {
...
@@ -41,10 +41,8 @@ const ModelDetail = () => {
const
res
=
await
getModelById
(
modelId
as
string
);
const
res
=
await
getModelById
(
modelId
as
string
);
res
.
security
.
expiredTime
/=
60
*
60
*
1000
;
res
.
security
.
expiredTime
/=
60
*
60
*
1000
;
setModel
(
res
);
setModel
(
res
);
console
.
log
(
res
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
);
console
.
error
(
err
);
}
}
setLoading
(
false
);
setLoading
(
false
);
},
[
modelId
,
setLoading
]);
},
[
modelId
,
setLoading
]);
...
@@ -65,7 +63,7 @@ const ModelDetail = () => {
...
@@ -65,7 +63,7 @@ const ModelDetail = () => {
});
});
router
.
replace
(
'/model/list'
);
router
.
replace
(
'/model/list'
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
);
console
.
error
(
err
);
}
}
setLoading
(
false
);
setLoading
(
false
);
},
[
setLoading
,
model
,
router
,
toast
]);
},
[
setLoading
,
model
,
router
,
toast
]);
...
@@ -79,7 +77,7 @@ const ModelDetail = () => {
...
@@ -79,7 +77,7 @@ const ModelDetail = () => {
router
.
push
(
`/chat?chatId=
${
chatId
}
`
);
router
.
push
(
`/chat?chatId=
${
chatId
}
`
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
);
console
.
error
(
err
);
}
}
setLoading
(
false
);
setLoading
(
false
);
},
[
setLoading
,
model
,
router
]);
},
[
setLoading
,
model
,
router
]);
...
@@ -107,7 +105,7 @@ const ModelDetail = () => {
...
@@ -107,7 +105,7 @@ const ModelDetail = () => {
title
:
typeof
err
===
'string'
?
err
:
'文件格式错误'
,
title
:
typeof
err
===
'string'
?
err
:
'文件格式错误'
,
status
:
'error'
status
:
'error'
});
});
console
.
log
(
err
);
console
.
error
(
err
);
}
}
setLoading
(
false
);
setLoading
(
false
);
},
},
...
@@ -123,7 +121,7 @@ const ModelDetail = () => {
...
@@ -123,7 +121,7 @@ const ModelDetail = () => {
await
putModelTrainingStatus
(
model
.
_id
);
await
putModelTrainingStatus
(
model
.
_id
);
loadModel
();
loadModel
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
);
console
.
error
(
error
);
}
}
setLoading
(
false
);
setLoading
(
false
);
},
[
setLoading
,
loadModel
,
model
]);
},
[
setLoading
,
loadModel
,
model
]);
...
...
src/pages/model/list.tsx
View file @
bf81d23d
...
@@ -44,7 +44,7 @@ const ModelList = () => {
...
@@ -44,7 +44,7 @@ const ModelList = () => {
shallow
:
true
shallow
:
true
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
);
console
.
error
(
err
);
}
}
setIsLoading
(
false
);
setIsLoading
(
false
);
},
},
...
...
src/service/response.ts
View file @
bf81d23d
...
@@ -24,8 +24,8 @@ export const jsonRes = (
...
@@ -24,8 +24,8 @@ export const jsonRes = (
typeof
error
===
'string'
typeof
error
===
'string'
?
error
?
error
:
openaiError
[
error
?.
response
?.
data
?.
message
]
||
error
?.
message
||
'请求错误'
;
:
openaiError
[
error
?.
response
?.
data
?.
message
]
||
error
?.
message
||
'请求错误'
;
console
.
error
(
error
);
console
.
log
(
msg
);
console
.
error
(
msg
);
}
}
res
.
json
({
res
.
json
({
...
...
src/service/utils/sendEmail.ts
View file @
bf81d23d
...
@@ -34,7 +34,7 @@ export const sendCode = (email: string, code: string, type: `${EmailTypeEnum}`)
...
@@ -34,7 +34,7 @@ export const sendCode = (email: string, code: string, type: `${EmailTypeEnum}`)
};
};
mailTransport
.
sendMail
(
options
,
function
(
err
,
msg
)
{
mailTransport
.
sendMail
(
options
,
function
(
err
,
msg
)
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
console
.
error
(
err
);
reject
(
'邮箱异常'
);
reject
(
'邮箱异常'
);
}
else
{
}
else
{
resolve
(
''
);
resolve
(
''
);
...
@@ -53,7 +53,7 @@ export const sendTrainSucceed = (email: string, modelName: string) => {
...
@@ -53,7 +53,7 @@ export const sendTrainSucceed = (email: string, modelName: string) => {
};
};
mailTransport
.
sendMail
(
options
,
function
(
err
,
msg
)
{
mailTransport
.
sendMail
(
options
,
function
(
err
,
msg
)
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
console
.
error
(
err
);
reject
(
'邮箱异常'
);
reject
(
'邮箱异常'
);
}
else
{
}
else
{
resolve
(
''
);
resolve
(
''
);
...
...
src/utils/tools.ts
View file @
bf81d23d
...
@@ -21,7 +21,7 @@ export const useCopyData = () => {
...
@@ -21,7 +21,7 @@ export const useCopyData = () => {
duration
:
1000
duration
:
1000
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
);
console
.
error
(
error
);
toast
({
toast
({
title
:
'复制失败'
,
title
:
'复制失败'
,
status
:
'error'
status
:
'error'
...
...
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