feat(electron-vue-template):重构认证与设备管理模块
- 统一token存取逻辑,封装getToken/setToken/removeToken方法 -优化设备ID获取逻辑,调整API路径 - 完善设备管理接口类型定义,增强类型安全 - 调整SSE连接逻辑,使用统一配置管理- 重构HTTP客户端,集中管理后端服务配置 - 更新认证相关API接口,完善请求/响应类型 - 优化设备列表展示逻辑,移除冗余字段 - 调整图片代理路径,统一API前缀 - 完善用户反馈列表展示功能,增强交互体验 - 移除冗余的错误处理逻辑,简化代码结构
This commit is contained in:
@@ -495,6 +495,63 @@ ipcMain.handle('write-file', async (event, filePath: string, data: Uint8Array) =
|
||||
return { success: true };
|
||||
});
|
||||
|
||||
// 获取日志日期列表
|
||||
ipcMain.handle('get-log-dates', async () => {
|
||||
try {
|
||||
const logDir = 'C:/ProgramData/erp-logs';
|
||||
if (!existsSync(logDir)) {
|
||||
return { dates: [] };
|
||||
}
|
||||
|
||||
const files = await fs.readdir(logDir);
|
||||
const dates: string[] = [];
|
||||
|
||||
// 获取今天的日期(YYYY-MM-DD格式)
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
|
||||
files.forEach(file => {
|
||||
if (file === 'spring-boot.log') {
|
||||
// 当天的日志文件,使用今天的日期
|
||||
dates.push(today);
|
||||
} else if (file.startsWith('spring-boot-') && file.endsWith('.log')) {
|
||||
// 历史日志文件,提取日期
|
||||
const date = file.replace('spring-boot-', '').replace('.log', '');
|
||||
dates.push(date);
|
||||
}
|
||||
});
|
||||
|
||||
// 排序,最新的在前面
|
||||
dates.sort().reverse();
|
||||
|
||||
return { dates };
|
||||
} catch (error) {
|
||||
console.error('获取日志日期列表失败:', error);
|
||||
return { dates: [] };
|
||||
}
|
||||
});
|
||||
|
||||
// 读取指定日期的日志文件
|
||||
ipcMain.handle('read-log-file', async (event, logDate: string) => {
|
||||
try {
|
||||
const logDir = 'C:/ProgramData/erp-logs';
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
|
||||
// 如果是今天的日期,读取 spring-boot.log,否则读取带日期的文件
|
||||
const fileName = logDate === today ? 'spring-boot.log' : `spring-boot-${logDate}.log`;
|
||||
const logFilePath = `${logDir}/${fileName}`;
|
||||
|
||||
if (!existsSync(logFilePath)) {
|
||||
return { success: false, error: '日志文件不存在' };
|
||||
}
|
||||
|
||||
const content = await fs.readFile(logFilePath, 'utf-8');
|
||||
return { success: true, content };
|
||||
} catch (error) {
|
||||
console.error('读取日志文件失败:', error);
|
||||
return { success: false, error: error instanceof Error ? error.message : '读取失败' };
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
async function getFileSize(url: string): Promise<number> {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
Reference in New Issue
Block a user