* 将文件路径转换为安全的文件名 * @param filePath 原始文件路径 * @returns 安全的文件名
(filePath: string)
| 8 | * @returns 安全的文件名 |
| 9 | */ |
| 10 | static toSafeFileName(filePath: string): string { |
| 11 | return filePath |
| 12 | .replace(/[/\\:*?"<>|]/g, '_') // 替换特殊字符 |
| 13 | .replace(/\s+/g, '_') // 替换空格 |
| 14 | .toLowerCase() // 转小写 |
| 15 | + '.json'; |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * 从安全文件名恢复原始路径(需要配合映射文件) |
no test coverage detected