mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00
feat: baidu statistic
This commit is contained in:
8
client/public/js/baidutongji.js
Normal file
8
client/public/js/baidutongji.js
Normal file
@@ -0,0 +1,8 @@
|
||||
var _hmt = _hmt || [];
|
||||
|
||||
(function () {
|
||||
const hm = document.createElement('script');
|
||||
hm.src = 'https://hm.baidu.com/hm.js?a5357e9dab086658bac0b6faf148882e';
|
||||
const s = document.getElementsByTagName('script')[0];
|
||||
s.parentNode.insertBefore(hm, s);
|
||||
})();
|
@@ -52,6 +52,7 @@ function App({ Component, pageProps }: AppProps) {
|
||||
<Script src="/js/qrcode.min.js" strategy="afterInteractive"></Script>
|
||||
<Script src="/js/pdf.js" strategy="afterInteractive"></Script>
|
||||
<Script src="/js/html2pdf.bundle.min.js" strategy="afterInteractive"></Script>
|
||||
<Script src="/js/baidutongji.js" strategy="afterInteractive"></Script>
|
||||
{googleVerKey && (
|
||||
<>
|
||||
<Script
|
||||
|
@@ -60,34 +60,48 @@ export async function saveChat({
|
||||
}));
|
||||
|
||||
if (String(model.userId) === userId) {
|
||||
Model.findByIdAndUpdate(modelId, {
|
||||
await Model.findByIdAndUpdate(modelId, {
|
||||
updateTime: new Date()
|
||||
});
|
||||
}
|
||||
|
||||
const response = await (chatId
|
||||
? Chat.findByIdAndUpdate(chatId, {
|
||||
$push: {
|
||||
content: {
|
||||
$each: content
|
||||
}
|
||||
},
|
||||
title: content[0].value.slice(0, 20),
|
||||
latestChat: content[1].value,
|
||||
updateTime: new Date()
|
||||
}).then(() => ({
|
||||
newChatId: ''
|
||||
}))
|
||||
: Chat.create({
|
||||
_id: newChatId,
|
||||
userId,
|
||||
modelId,
|
||||
content,
|
||||
title: content[0].value.slice(0, 20),
|
||||
latestChat: content[1].value
|
||||
}).then((res) => ({
|
||||
newChatId: String(res._id)
|
||||
})));
|
||||
const [response] = await Promise.all([
|
||||
...(chatId
|
||||
? [
|
||||
Chat.findByIdAndUpdate(chatId, {
|
||||
$push: {
|
||||
content: {
|
||||
$each: content
|
||||
}
|
||||
},
|
||||
title: content[0].value.slice(0, 20),
|
||||
latestChat: content[1].value,
|
||||
updateTime: new Date()
|
||||
}).then(() => ({
|
||||
newChatId: ''
|
||||
}))
|
||||
]
|
||||
: [
|
||||
Chat.create({
|
||||
_id: newChatId,
|
||||
userId,
|
||||
modelId,
|
||||
content,
|
||||
title: content[0].value.slice(0, 20),
|
||||
latestChat: content[1].value
|
||||
}).then((res) => ({
|
||||
newChatId: String(res._id)
|
||||
}))
|
||||
]),
|
||||
// update model
|
||||
...(String(model.userId) === userId
|
||||
? [
|
||||
Model.findByIdAndUpdate(modelId, {
|
||||
updateTime: new Date()
|
||||
})
|
||||
]
|
||||
: [])
|
||||
]);
|
||||
|
||||
return {
|
||||
...response
|
||||
|
Reference in New Issue
Block a user