Commit f2d37c30 by archer

feat: baidu statistic

parent 1d236f87
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,13 +60,15 @@ 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, {
const [response] = await Promise.all([
...(chatId
? [
Chat.findByIdAndUpdate(chatId, {
$push: {
content: {
$each: content
......@@ -78,7 +80,9 @@ export async function saveChat({
}).then(() => ({
newChatId: ''
}))
: Chat.create({
]
: [
Chat.create({
_id: newChatId,
userId,
modelId,
......@@ -87,7 +91,17 @@ export async function saveChat({
latestChat: content[1].value
}).then((res) => ({
newChatId: String(res._id)
})));
}))
]),
// update model
...(String(model.userId) === userId
? [
Model.findByIdAndUpdate(modelId, {
updateTime: new Date()
})
]
: [])
]);
return {
...response
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment