limit max number of logs page

This commit is contained in:
pompurin404 2024-09-27 17:31:32 +08:00
parent c420f0397c
commit 927b438a4b
No known key found for this signature in database

View File

@ -33,6 +33,9 @@ const Logs: React.FC = () => {
window.electron.ipcRenderer.on('mihomoLogs', (_e, log: IMihomoLogInfo) => { window.electron.ipcRenderer.on('mihomoLogs', (_e, log: IMihomoLogInfo) => {
log.time = new Date().toLocaleString() log.time = new Date().toLocaleString()
setLogs((prevLogs) => { setLogs((prevLogs) => {
if (prevLogs.length >= 500) {
prevLogs.shift()
}
return [...prevLogs, log] return [...prevLogs, log]
}) })
}) })