feat(settings): 文件名过滤编辑器预置默认排除集
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
|
||||
import { clearFilenameFilter, fetchFilenameFilters, parseExtensionDraft, saveFilenameFilter } from './filenameFilters'
|
||||
import { clearFilenameFilter, DEFAULT_EXCLUDED_EXTENSIONS, fetchFilenameFilters, parseExtensionDraft, saveFilenameFilter } from './filenameFilters'
|
||||
import type { FilenameFilterRule } from './filenameFilters'
|
||||
import './systemSettings.css'
|
||||
|
||||
@@ -37,7 +37,7 @@ export function FilenameFilterEditorView({ label, directExtensions, inheritedExt
|
||||
|
||||
export function FilenameFilterEditor({ connectionID, directoryPath = '', label, onChanged }: { connectionID: string; directoryPath?: string; label: string; onChanged?: () => void }) {
|
||||
const [rules, setRules] = useState<FilenameFilterRule[]>([])
|
||||
const [draft, setDraft] = useState('zip, rar, mp4')
|
||||
const [draft, setDraft] = useState(DEFAULT_EXCLUDED_EXTENSIONS.join(', '))
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [message, setMessage] = useState<string | null>(null)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
@@ -57,7 +57,7 @@ export function FilenameFilterEditor({ connectionID, directoryPath = '', label,
|
||||
const next = await fetchFilenameFilters(connectionID, signal)
|
||||
setRules(next)
|
||||
const current = next.find((rule) => rule.directory_path === directoryPath)
|
||||
setDraft(current?.excluded_extensions.join(', ') || 'zip, rar, mp4')
|
||||
setDraft(current?.excluded_extensions.join(', ') || DEFAULT_EXCLUDED_EXTENSIONS.join(', '))
|
||||
}
|
||||
useEffect(() => {
|
||||
const controller = new AbortController()
|
||||
|
||||
@@ -43,6 +43,17 @@ export async function clearFilenameFilter(connectionID: string, directoryPath: s
|
||||
if (!response.ok) throw new Error(`清除文件名筛选失败(HTTP ${response.status})`)
|
||||
}
|
||||
|
||||
// Source-wide default exclusions: archives/media/executables/CAD/design
|
||||
// binaries have no RAG value for the support knowledge bases.
|
||||
export const DEFAULT_EXCLUDED_EXTENSIONS = [
|
||||
"zip", "rar", "7z", "gz", "tgz", "tar", "xz", "iso", "crdownload",
|
||||
"mp4", "avi", "mkv", "mov", "wmv", "m4v", "mp3", "wav", "flac",
|
||||
"exe", "dll", "so", "msi", "apk", "bin", "pyc", "pyd", "pyi", "whl", "dtb", "u-boot", "imx",
|
||||
"stp", "step", "stl", "x_t", "x_b", "jt", "sldprt", "sldasm", "slddrw", "dwg", "dxf", "igs", "cat", "obj", "p2m", "p2s", "sol", "dwf",
|
||||
"psd", "ai", "otf", "ttf",
|
||||
"dlink", "atomproject", "amind", "appt", "rdk", "vcmx", "swf", "dav",
|
||||
].sort()
|
||||
|
||||
export function parseExtensionDraft(value: string): string[] {
|
||||
return [...new Set(value.split(/[,,\s]+/).map((item) => item.trim().toLowerCase().replace(/^\./, '')).filter(Boolean))].sort()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user