add more documents format support
This commit is contained in:
@ -3,13 +3,24 @@
|
||||
/**
|
||||
* Определение типа файла
|
||||
* @param {File} file
|
||||
* @returns {'image' | 'pdf' | 'other'}
|
||||
* @returns {'image' | 'pdf' | 'office' | 'other'}
|
||||
*/
|
||||
export function detectFileType(file) {
|
||||
if (!file) return 'other';
|
||||
if (file.type.startsWith('image/')) return 'image';
|
||||
if (file.type === 'application/pdf') return 'pdf';
|
||||
return 'other';
|
||||
if (!file) return 'other';
|
||||
if (file.type.startsWith('image/')) return 'image';
|
||||
if (file.type === 'application/pdf') return 'pdf';
|
||||
|
||||
// Офисные документы — определяем по расширению,
|
||||
// т.к. MIME может быть пустым или некорректным
|
||||
const ext = (file.name || '').toLowerCase().split('.').pop() || '';
|
||||
const officeExts = [
|
||||
'doc', 'docx', 'odt', // текст
|
||||
'xls', 'xlsx', 'ods', // таблицы
|
||||
'ppt', 'pptx', 'odp', // презентации (на всякий случай)
|
||||
];
|
||||
if (officeExts.includes(ext)) return 'office';
|
||||
|
||||
return 'other';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -17,9 +28,9 @@ export function detectFileType(file) {
|
||||
* @param {import('$lib/pages/print/stores/print.store.svelte').FileEntry} entry
|
||||
*/
|
||||
export function pagesLabel(entry) {
|
||||
if (!entry.totalPages || entry.totalPages === 0) return '...';
|
||||
if (!entry.selectedPages || entry.selectedPages.size === 0) return 'Нет';
|
||||
if (entry.selectedPages.size === entry.totalPages) return 'Все';
|
||||
if (entry.selectedPages.size === 1) return `стр. ${[...entry.selectedPages][0]}`;
|
||||
return `${entry.selectedPages.size}/${entry.totalPages} стр.`;
|
||||
if (!entry.totalPages || entry.totalPages === 0) return '...';
|
||||
if (!entry.selectedPages || entry.selectedPages.size === 0) return 'Нет';
|
||||
if (entry.selectedPages.size === entry.totalPages) return 'Все';
|
||||
if (entry.selectedPages.size === 1) return `стр. ${[...entry.selectedPages][0]}`;
|
||||
return `${entry.selectedPages.size}/${entry.totalPages} стр.`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user