diff --git a/apps/server/src/models/sys-logs/systemLog.service.ts b/apps/server/src/models/sys-logs/systemLog.service.ts index 76a7f77..63fe52c 100644 --- a/apps/server/src/models/sys-logs/systemLog.service.ts +++ b/apps/server/src/models/sys-logs/systemLog.service.ts @@ -5,8 +5,11 @@ import EventBus, { CrudOperation } from "@server/utils/event-bus"; @Injectable() export class SystemLogService extends BaseService { + protected readonly prismaClient: any; + constructor() { - super(db, ObjectType.SYSTEM_LOG, false); // 不自动处理更新时间和删除时间 + super(db, ObjectType.SYSTEM_LOG, false); + this.prismaClient = db; } async create(args: Prisma.SystemLogCreateArgs) { @@ -31,20 +34,19 @@ export class SystemLogService extends BaseService { return super.findMany(args); // 放弃分页结构 } - // 添加分页查询方法 async findManyWithPagination({ page = 1, pageSize = 20, where = {}, ...rest }: any) { const skip = (page - 1) * pageSize; try { const [items, total] = await Promise.all([ - this.delegate.findMany({ + this.prismaClient.systemLog.findMany({ where, skip, take: pageSize, orderBy: { timestamp: 'desc' }, ...rest }), - this.delegate.count({ where }) + this.prismaClient.systemLog.count({ where }) ]); return { @@ -119,7 +121,6 @@ export class SystemLogService extends BaseService { }; } }); - return { changes }; } diff --git a/apps/web/src/app/main/systemlog/SystemLogPage.tsx b/apps/web/src/app/main/systemlog/SystemLogPage.tsx index a0bbe4a..94f6bfa 100644 --- a/apps/web/src/app/main/systemlog/SystemLogPage.tsx +++ b/apps/web/src/app/main/systemlog/SystemLogPage.tsx @@ -4,7 +4,10 @@ import React, { useState, useEffect } from 'react'; // 创建一个全局变量来存储日志 let globalLogs: string[] = []; - +const clearLogs = () => { + localStorage.removeItem('systemLogs'); + setLogs([]); +}; // 添加日志的函数 export const addLog = (log: string) => { const timestamp = new Date().toLocaleString(); @@ -29,6 +32,9 @@ const SystemLogPage = () => { return (

系统日志

+
{logs.length === 0 ? (

暂无系统日志

@@ -47,3 +53,7 @@ const SystemLogPage = () => { }; export default SystemLogPage; +function setLogs(arg0: undefined[]) { + throw new Error('Function not implemented.'); +} + diff --git a/packages/common/prisma/schema.prisma b/packages/common/prisma/schema.prisma index 3ec5a29..58b41e7 100755 --- a/packages/common/prisma/schema.prisma +++ b/packages/common/prisma/schema.prisma @@ -567,7 +567,7 @@ model SystemLog { // 关联部门 departmentId String? @map("department_id") department Department? @relation(fields: [departmentId], references: [id]) - message String @map("message") // 完整的日志文本内容 + message String? @map("message") // 完整的日志文本内容 // 优化索引 @@index([timestamp]) @@index([level])