Update add log wiki

This commit is contained in:
Joseph Le 2025-09-29 17:13:57 +10:00
parent 64e2046402
commit 55b52e2ea9
2 changed files with 14 additions and 1 deletions

View File

@ -14,3 +14,12 @@ export const checkSpecialVersion = (paragraph: string): string => {
return "";
}
};
export const checkDateWiki = (logString:string) => {
const now = new Date();
const currentDate = `ngay ${String(now.getDate()).padStart(2, "0")}/${String(now.getMonth() + 1).padStart(2, "0")}/${now.getFullYear()}`;
const lines = logString.split("<br/>").slice(0,3);
const lineDate = lines?.length > 1 ? lines[1] : ""
return lineDate === currentDate
}

View File

@ -30,6 +30,7 @@ import { sendDeviceInfora } from "App/utils/sendDeviceInfor";
import InfoDevice from "App/Models/InfoDevice";
import LogReport from "App/Models/LogReport";
import Cache from "@ioc:Kaperskyguru/Adonis-Cache";
import { checkDateWiki } from "App/utils/helper";
const util = require("util");
const exec = util.promisify(require("child_process").exec);
const { DocumentProcessorServiceClient } =
@ -407,7 +408,10 @@ License: ${license ?? ""}
const oldContent = pageJson.query.pages[pageId]?.revisions?.[0]?.['*'] ?? ''
// nối nội dung mới vào
const newText = `${text}\n\n${oldContent}`
const now = new Date();
const lineDate = `${String(now.getDate()).padStart(2, "0")}/${String(now.getMonth() + 1).padStart(2, "0")}/${now.getFullYear()}`;
const scopeDate = `-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*<br/>ngay ${lineDate}<br/>-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*<br/><br/>`
const newText = `${scopeDate}${text}\n\n${checkDateWiki(oldContent) ? oldContent.replace(scopeDate, "") : oldContent}`
// ============ EDIT PAGE ============
const formData = new FormData()