Private
Public Access
1
0

重构:统一文件类型配置管理,移除重复硬编码

新增:
- constants.js 添加 CONFIG 数组(json、xml、yaml、toml、ini、cfg、conf、props、env 等)
- fileTypeHelpers.js 添加 isConfigFile() 函数

优化:
- 移除 6 处重复的文件类型硬编码
- 统一使用 FILE_EXTENSIONS.CONFIG
- 移除 3 处重复的 isOfficeFile() 定义

修改文件:
- web/src/utils/constants.js
- web/src/utils/fileTypeHelpers.js
- web/src/components/FileSystem/composables/useFileEdit.ts
- web/src/components/FileSystem/composables/useFilePreview.ts
- web/src/components/FileSystem/components/ContextMenu.vue
- web/src/composables/useFilePreview.js
This commit is contained in:
2026-02-04 12:37:09 +08:00
parent edd5b7c869
commit ce2698f245
6 changed files with 48 additions and 30 deletions

View File

@@ -9,6 +9,7 @@ import { ref, computed } from 'vue'
import { marked } from '@/utils/markedExtensions'
import { FILE_EXTENSIONS, FILE_SIZE_THRESHOLDS } from '@/utils/constants'
import { getExt } from '@/utils/fileHelpers'
import { isOfficeFile } from '@/utils/fileTypeHelpers'
import { debugLog, debugWarn, debugError } from '@/utils/debugLog'
/**
@@ -532,16 +533,6 @@ export function useFilePreview(options = {}) {
imageHeight.value = 0
}
/**
* 判断是否为 Office 文件
* @param {string} fileName - 文件名
* @returns {boolean}
*/
const isOfficeFile = (fileName) => {
const ext = getExt(fileName).toLowerCase()
return ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'].includes(ext)
}
return {
// 状态
previewUrl,