Private
Public Access
1
0

优化:文件服务器安全重构+编辑器增强+搜索排序+更新面板Markdown渲染

- 路径校验提取validateFilePath+sentinel error替代字符串匹配
- requireUpdateAPI收敛7处重复nil检查
- 端口18765统一为8073,消除分散魔法数字
- CodeMirror添加搜索功能+滚动位置LRU缓存恢复
- 文件列表新增列排序+搜索过滤
- Toolbar重排:快捷访问内嵌+搜索框集成+历史改图标
- 重命名零闪烁:updateFilePath草稿迁移
- changelog用marked渲染+sanitizeHtml防XSS
- MigrateTabConfig扩展map驱动覆盖openclaw-manager→version迁移

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-21 21:53:31 +08:00
parent 691e38604f
commit 72fef3e56f
23 changed files with 614 additions and 257 deletions

View File

@@ -29,8 +29,17 @@ export interface UseFilePreviewOptions {
export function useFilePreview(options: UseFilePreviewOptions = {}) {
const { filePath = ref(''), isBrowsingZip = ref(false) } = options
// 文件服务器 URL硬编码,与旧版本保持一致
const fileServerURL = 'http://localhost:18765'
// 文件服务器 URL优先从后端获取,降级到默认值
let _fileServerURL = 'http://localhost:8073'
const initFileServerURL = async () => {
try {
const url = await window.go.main.App.GetFileServerURL()
if (url) _fileServerURL = url
} catch { /* 使用默认值 */ }
}
initFileServerURL()
const getFileServerURL = () => _fileServerURL
// 预览 URL
const previewUrl = ref('')
@@ -45,7 +54,7 @@ export function useFilePreview(options: UseFilePreviewOptions = {}) {
const getPreviewUrl = (path: string): string => {
if (!path) return ''
// 使用与旧版本相同的 URL 格式:/localfs/ 路径 + 规范化路径
return `${fileServerURL}/localfs/${normalizeFilePath(path, true)}`
return `${getFileServerURL()}/localfs/${normalizeFilePath(path, true)}`
}
/**
@@ -188,12 +197,6 @@ export function useFilePreview(options: UseFilePreviewOptions = {}) {
// 文件类型判断(同步,基于扩展名)
getFileType,
isImageFile,
isVideoFile,
isAudioFile,
isPdfFile,
isHtmlFile,
isMarkdownFile,
isPreviewable,
isEditable,