上传文件窗口,库里面的文件图标改为与file列表页的文件图标方案保持一致
This commit is contained in:
parent
ed3a7080d9
commit
6bedb266a0
@ -337,31 +337,27 @@ const pendingCount = computed(() => uploadQueue.value.filter(f => f.status === '
|
||||
// Track last drop time to prevent duplicate drops
|
||||
let lastDropTime = 0
|
||||
|
||||
const IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'bmp', 'ico']
|
||||
|
||||
function switchTab(tab: string) {
|
||||
activeTab.value = tab
|
||||
}
|
||||
|
||||
function getFileIcon(filename: string): string {
|
||||
const ext = filename.split('.').pop()?.toLowerCase()
|
||||
const iconMap: Record<string, string> = {
|
||||
pdf: 'tabler:file-type-pdf',
|
||||
doc: 'tabler:file-type-doc',
|
||||
docx: 'tabler:file-type-doc',
|
||||
xls: 'tabler:file-type-xls',
|
||||
xlsx: 'tabler:file-type-xls',
|
||||
ppt: 'tabler:file-type-ppt',
|
||||
pptx: 'tabler:file-type-ppt',
|
||||
zip: 'tabler:file-zip',
|
||||
rar: 'tabler:file-zip',
|
||||
txt: 'tabler:file-text',
|
||||
jpg: 'tabler:photo',
|
||||
jpeg: 'tabler:photo',
|
||||
png: 'tabler:photo',
|
||||
gif: 'tabler:photo',
|
||||
mp4: 'tabler:video',
|
||||
mp3: 'tabler:music',
|
||||
}
|
||||
return iconMap[ext || ''] || 'tabler:file'
|
||||
if (!ext) return 'tabler:file'
|
||||
if (IMAGE_EXTENSIONS.includes(ext)) return 'tabler:photo'
|
||||
if (['pdf'].includes(ext)) return 'tabler:file-type-pdf'
|
||||
if (['doc', 'docx'].includes(ext)) return 'tabler:file-type-doc'
|
||||
if (['xls', 'xlsx'].includes(ext)) return 'tabler:file-type-xls'
|
||||
if (['csv'].includes(ext)) return 'tabler:file-type-csv'
|
||||
if (['ppt', 'pptx'].includes(ext)) return 'tabler:file-type-ppt'
|
||||
if (['zip', 'rar', '7z', 'tar', 'gz'].includes(ext)) return 'tabler:file-zip'
|
||||
if (['mp4', 'avi', 'mov', 'mkv', 'webm', 'wmv', 'flv'].includes(ext)) return 'tabler:video'
|
||||
if (['mp3', 'wav', 'flac', 'aac', 'ogg'].includes(ext)) return 'tabler:file-type-audio'
|
||||
if (['txt', 'md'].includes(ext)) return 'tabler:file-type-txt'
|
||||
if (['js', 'ts', 'py', 'html', 'css', 'json', 'xml'].includes(ext)) return 'tabler:file-type-code'
|
||||
return 'tabler:file'
|
||||
}
|
||||
|
||||
function formatFileSize(bytes: number): string {
|
||||
@ -633,20 +629,19 @@ function toggleLibraryFile(file: any) {
|
||||
}
|
||||
|
||||
function getLibraryFileIcon(file: any): string {
|
||||
if (file.file_type) {
|
||||
const ext = file.file_type.toLowerCase()
|
||||
const iconMap: Record<string, string> = {
|
||||
pdf: 'tabler:file-type-pdf',
|
||||
doc: 'tabler:file-type-doc', docx: 'tabler:file-type-doc',
|
||||
xls: 'tabler:file-type-xls', xlsx: 'tabler:file-type-xls',
|
||||
ppt: 'tabler:file-type-ppt', pptx: 'tabler:file-type-ppt',
|
||||
zip: 'tabler:file-zip', rar: 'tabler:file-zip',
|
||||
txt: 'tabler:file-text',
|
||||
jpg: 'tabler:photo', jpeg: 'tabler:photo', png: 'tabler:photo', gif: 'tabler:photo',
|
||||
mp4: 'tabler:video', webm: 'tabler:video', mov: 'tabler:video',
|
||||
}
|
||||
return iconMap[ext] || 'tabler:file'
|
||||
}
|
||||
if (file.is_folder) return 'tabler:folder'
|
||||
const ext = (file.file_type || '').toLowerCase()
|
||||
if (IMAGE_EXTENSIONS.includes(ext)) return 'tabler:photo'
|
||||
if (['pdf'].includes(ext)) return 'tabler:file-type-pdf'
|
||||
if (['doc', 'docx'].includes(ext)) return 'tabler:file-type-doc'
|
||||
if (['xls', 'xlsx'].includes(ext)) return 'tabler:file-type-xls'
|
||||
if (['csv'].includes(ext)) return 'tabler:file-type-csv'
|
||||
if (['ppt', 'pptx'].includes(ext)) return 'tabler:file-type-ppt'
|
||||
if (['zip', 'rar', '7z', 'tar', 'gz'].includes(ext)) return 'tabler:file-zip'
|
||||
if (['mp4', 'avi', 'mov', 'mkv', 'webm', 'wmv', 'flv'].includes(ext)) return 'tabler:video'
|
||||
if (['mp3', 'wav', 'flac', 'aac', 'ogg'].includes(ext)) return 'tabler:file-type-audio'
|
||||
if (['txt', 'md'].includes(ext)) return 'tabler:file-type-txt'
|
||||
if (['js', 'ts', 'py', 'html', 'css', 'json', 'xml'].includes(ext)) return 'tabler:file-type-code'
|
||||
return 'tabler:file'
|
||||
}
|
||||
|
||||
|
||||
@ -47,14 +47,14 @@ def get_files_in_folder(folder: str, start: int = 0, page_length: int = 20) -> d
|
||||
attachment_folder = jingrow.db.get_value(
|
||||
"File",
|
||||
"Home/Attachments",
|
||||
["name", "file_name", "file_url", "is_folder", "modified"],
|
||||
["name", "file_name", "file_url", "file_type", "is_folder", "modified"],
|
||||
as_dict=1,
|
||||
)
|
||||
|
||||
files = jingrow.get_all(
|
||||
"File",
|
||||
{"folder": folder},
|
||||
["name", "file_name", "file_url", "is_folder", "modified"],
|
||||
["name", "file_name", "file_url", "file_type", "is_folder", "modified"],
|
||||
ignore_permissions=True,
|
||||
start=start,
|
||||
page_length=page_length + 1,
|
||||
@ -74,7 +74,7 @@ def get_files_by_search_text(text: str) -> list[dict]:
|
||||
text = "%" + cstr(text).lower() + "%"
|
||||
return jingrow.get_list(
|
||||
"File",
|
||||
fields=["name", "file_name", "file_url", "is_folder", "modified"],
|
||||
fields=["name", "file_name", "file_url", "file_type", "is_folder", "modified"],
|
||||
filters={"is_folder": False},
|
||||
or_filters={
|
||||
"file_name": ("like", text),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user