From 1eaf61cf416ac38d1d0f74aa71d82572a5535c6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=BB=9D=E5=B0=98?= <237809796@qq.com>
Date: Fri, 27 Feb 2026 18:15:17 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9AOffice/CSV=20?=
=?UTF-8?q?=E9=A2=84=E8=A7=88=E5=A2=9E=E5=BC=BA=20+=20=E6=B8=85=E7=90=86?=
=?UTF-8?q?=E5=86=97=E4=BD=99=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Office 预览优化:
- 重构 Excel/Word 预览,使用本地文件服务器直接加载
- 添加 CSV 文件预览支持(表格形式展示)
- 优化加载状态和错误提示 UI
CSV 文件支持:
- 后端添加 CSV/TSV 文件类型和 MIME 映射
- 前端添加 isCsvFile 类型判断
代码清理:
- 移除未使用的 ReadFileAsBase64 API
---
internal/filesystem/asset_handler.go | 538 +++++++++++++++++-
internal/filesystem/config.go | 10 +-
internal/filesystem/service.go | 2 +-
web/package.json.md5 | 2 +-
.../FileSystem/components/FileEditorPanel.vue | 81 ++-
.../FileSystem/composables/useFileEdit.ts | 30 +-
web/src/components/FileSystem/index.vue | 5 +-
web/src/types/file-system.ts | 2 +
web/src/utils/filePreviewHandlers.js | 510 ++++++++++-------
web/src/utils/fileTypeHelpers.js | 14 +-
10 files changed, 934 insertions(+), 260 deletions(-)
diff --git a/internal/filesystem/asset_handler.go b/internal/filesystem/asset_handler.go
index 35a2fc5..6fe1a85 100644
--- a/internal/filesystem/asset_handler.go
+++ b/internal/filesystem/asset_handler.go
@@ -9,11 +9,40 @@ import (
"net/url"
"os"
"path/filepath"
+ "regexp"
"strings"
"sync"
"time"
)
+// 预编译正则表达式(避免每次调用重复编译)
+var (
+ // CSS 相关
+ cssImportRegex = regexp.MustCompile(`@import\s+(?:url\s*\(\s*)?["']([^"']+)["']\s*\)?\s*;`)
+ cssUrlRegex = regexp.MustCompile(`url\(\s*["']?([^"')]+)["']?\s*\)`)
+
+ // HTML 标签
+ htmlLinkTagRegex = regexp.MustCompile(`]*)>`)
+ htmlScriptTagRegex = regexp.MustCompile(`
+`
+
+ // 在