Private
Public Access
1
0

修复:大文件点击卡死 + Dockerfile高亮支持

- useFileEdit: 新增 KNOWN_BINARY_EXTS 集合,exe/dll/zip 等 28 种二进制扩展名直接判定,不再读取文件内容
- index.vue: loadFileContent 增加大文件预检,基于 fileSize 超过阈值直接拦截
- service.go: ReadFile 增加 10MB 读取上限,超限返回错误
- Dockerfile 支持:CODE 分类、🐳图标、CodeMirror shell 模式高亮、languageMap 映射
This commit is contained in:
2026-04-07 11:39:50 +08:00
parent e5dbe89a6f
commit fb12ec48e8
7 changed files with 71 additions and 22 deletions

View File

@@ -119,13 +119,23 @@ func (s *FileSystemService) Read(path string) (string, error) {
return s.ReadFile(path)
}
// ReadFile 读取文件内容
// ReadFile 读取文件内容(限制最大 10MB
func (s *FileSystemService) ReadFile(path string) (string, error) {
// 路径验证
if err := s.validatePath(path); err != nil {
return "", err
}
// 检查文件大小,避免读取超大文件导致内存问题
info, err := os.Stat(path)
if err != nil {
return "", fmt.Errorf("获取文件信息失败: %v", err)
}
const maxReadSize = 10 * 1024 * 1024 // 10MB
if info.Size() > maxReadSize {
return "", fmt.Errorf("文件过大 (%.1f MB),超过读取上限 (%d MB)", float64(info.Size())/1024/1024, maxReadSize/1024/1024)
}
// 读取文件
data, err := os.ReadFile(path)
if err != nil {

View File

@@ -14,7 +14,7 @@ import (
// ==================== 常量定义 ====================
// AppVersion 应用版本号(发布时直接修改此处)
const AppVersion = "0.3.2"
const AppVersion = "0.3.3"
// 版本号缓存
var (