重构:统一文件类型配置管理,移除重复硬编码
新增: - 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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user