feat: baidu statistic

This commit is contained in:
archer 2023-06-19 17:28:25 +08:00
parent 1d236f87ae
commit f2d37c30a5
No known key found for this signature in database
GPG Key ID: 569A5660D2379E28
3 changed files with 47 additions and 24 deletions

View 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);
})();

View File

@ -52,6 +52,7 @@ function App({ Component, pageProps }: AppProps) {
<Script src="/js/qrcode.min.js" strategy="afterInteractive"></Script> <Script src="/js/qrcode.min.js" strategy="afterInteractive"></Script>
<Script src="/js/pdf.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/html2pdf.bundle.min.js" strategy="afterInteractive"></Script>
<Script src="/js/baidutongji.js" strategy="afterInteractive"></Script>
{googleVerKey && ( {googleVerKey && (
<> <>
<Script <Script

View File

@ -60,13 +60,15 @@ export async function saveChat({
})); }));
if (String(model.userId) === userId) { if (String(model.userId) === userId) {
Model.findByIdAndUpdate(modelId, { await Model.findByIdAndUpdate(modelId, {
updateTime: new Date() updateTime: new Date()
}); });
} }
const response = await (chatId const [response] = await Promise.all([
? Chat.findByIdAndUpdate(chatId, { ...(chatId
? [
Chat.findByIdAndUpdate(chatId, {
$push: { $push: {
content: { content: {
$each: content $each: content
@ -78,7 +80,9 @@ export async function saveChat({
}).then(() => ({ }).then(() => ({
newChatId: '' newChatId: ''
})) }))
: Chat.create({ ]
: [
Chat.create({
_id: newChatId, _id: newChatId,
userId, userId,
modelId, modelId,
@ -87,7 +91,17 @@ export async function saveChat({
latestChat: content[1].value latestChat: content[1].value
}).then((res) => ({ }).then((res) => ({
newChatId: String(res._id) newChatId: String(res._id)
}))); }))
]),
// update model
...(String(model.userId) === userId
? [
Model.findByIdAndUpdate(modelId, {
updateTime: new Date()
})
]
: [])
]);
return { return {
...response ...response