feat: show book file size in book details (#1114)
This commit is contained in:
@@ -50,7 +50,6 @@
|
||||
"Highlight": "تمييز",
|
||||
"Horizontal Direction": "الاتجاه الأفقي",
|
||||
"Hyphenation": "الواصلة",
|
||||
"Identifier:": "المعرف:",
|
||||
"Import Books": "استيراد الكتب",
|
||||
"Language:": "اللغة:",
|
||||
"Layout": "التخطيط",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "جارٍ التحقق من التحديثات...",
|
||||
"Error checking for updates": "خطأ في التحقق من التحديثات",
|
||||
"Details": "التفاصيل",
|
||||
"Cancel Selection": "إلغاء التحديد"
|
||||
"Cancel Selection": "إلغاء التحديد",
|
||||
"File Size:": "حجم الملف:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "Hervorheben",
|
||||
"Horizontal Direction": "Horizontale Richtung",
|
||||
"Hyphenation": "Silbentrennung",
|
||||
"Identifier:": "Kennung:",
|
||||
"Import Books": "Bücher importieren",
|
||||
"Language:": "Sprache:",
|
||||
"Layout": "Layout",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "Auf Updates prüfen...",
|
||||
"Error checking for updates": "Fehler beim Überprüfen auf Updates",
|
||||
"Details": "Details",
|
||||
"Cancel Selection": "Auswahl abbrechen"
|
||||
"Cancel Selection": "Auswahl abbrechen",
|
||||
"File Size:": "Dateigröße:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "Επισήμανση",
|
||||
"Horizontal Direction": "Οριζόντια κατεύθυνση",
|
||||
"Hyphenation": "Συλλαβισμός",
|
||||
"Identifier:": "Αναγνωριστικό:",
|
||||
"Import Books": "Εισαγωγή βιβλίων",
|
||||
"Language:": "Γλώσσα:",
|
||||
"Layout": "Διάταξη",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "Έλεγχος για ενημερώσεις...",
|
||||
"Error checking for updates": "Σφάλμα κατά τον έλεγχο για ενημερώσεις",
|
||||
"Details": "Πληρ.",
|
||||
"Cancel Selection": "Ακύρωση επιλογής"
|
||||
"Cancel Selection": "Ακύρωση επιλογής",
|
||||
"File Size:": "Μέγεθος αρχείου:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "Resaltar",
|
||||
"Horizontal Direction": "Dirección horizontal",
|
||||
"Hyphenation": "Guionización",
|
||||
"Identifier:": "Identificador:",
|
||||
"Import Books": "Importar libros",
|
||||
"Language:": "Idioma:",
|
||||
"Layout": "Diseño",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "Comprobando actualizaciones...",
|
||||
"Error checking for updates": "Error al comprobar actualizaciones",
|
||||
"Details": "Detalles",
|
||||
"Cancel Selection": "Cancelar selección"
|
||||
"Cancel Selection": "Cancelar selección",
|
||||
"File Size:": "Peso del archivo:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "Surligner",
|
||||
"Horizontal Direction": "Direction horizontale",
|
||||
"Hyphenation": "Césure",
|
||||
"Identifier:": "Identifiant :",
|
||||
"Import Books": "Importer des livres",
|
||||
"Language:": "Langue :",
|
||||
"Layout": "Mise en page",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "Vérification des mises à jour...",
|
||||
"Error checking for updates": "Erreur lors de la vérification des mises à jour",
|
||||
"Details": "Détails",
|
||||
"Cancel Selection": "Annuler la sélection"
|
||||
"Cancel Selection": "Annuler la sélection",
|
||||
"File Size:": "Taille du fichier :"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "हाइलाइट",
|
||||
"Horizontal Direction": "क्षैतिज दिशा",
|
||||
"Hyphenation": "हाइफ़नेशन",
|
||||
"Identifier:": "पहचानकर्ता:",
|
||||
"Import Books": "पुस्तकें आयात करें",
|
||||
"Language:": "भाषा:",
|
||||
"Layout": "लेआउट",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "अपडेट की जांच कर रहा है...",
|
||||
"Error checking for updates": "अपडेट की जांच करते समय त्रुटि",
|
||||
"Details": "विवरण",
|
||||
"Cancel Selection": "चयन रद्द करें"
|
||||
"Cancel Selection": "चयन रद्द करें",
|
||||
"File Size:": "फ़ाइल आकार:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "Sorot",
|
||||
"Horizontal Direction": "Arah Horizontal",
|
||||
"Hyphenation": "Pemenggalan Kata",
|
||||
"Identifier:": "Pengenal:",
|
||||
"Import Books": "Impor Buku",
|
||||
"Language:": "Bahasa:",
|
||||
"Layout": "Tata Letak",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "Memeriksa pembaruan...",
|
||||
"Error checking for updates": "Kesalahan saat memeriksa pembaruan",
|
||||
"Details": "Detail",
|
||||
"Cancel Selection": "Batalkan Pilihan"
|
||||
"Cancel Selection": "Batalkan Pilihan",
|
||||
"File Size:": "Ukuran File:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "Evidenzia",
|
||||
"Horizontal Direction": "Direzione orizzontale",
|
||||
"Hyphenation": "Sillabazione",
|
||||
"Identifier:": "Identificatore:",
|
||||
"Import Books": "Importa libri",
|
||||
"Language:": "Lingua:",
|
||||
"Layout": "Layout",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "Controllo aggiornamenti...",
|
||||
"Error checking for updates": "Errore durante il controllo degli aggiornamenti",
|
||||
"Details": "Dettagli",
|
||||
"Cancel Selection": "Annulla selezione"
|
||||
"Cancel Selection": "Annulla selezione",
|
||||
"File Size:": "Dimensione file:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "ハイライト",
|
||||
"Horizontal Direction": "横書",
|
||||
"Hyphenation": "ハイフネーション",
|
||||
"Identifier:": "識別子:",
|
||||
"Import Books": "書籍をインポート",
|
||||
"Language:": "言語:",
|
||||
"Layout": "レイアウト",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "更新を確認中...",
|
||||
"Error checking for updates": "更新の確認中にエラーが発生しました",
|
||||
"Details": "詳細",
|
||||
"Cancel Selection": "選択をキャンセル"
|
||||
"Cancel Selection": "選択をキャンセル",
|
||||
"File Size:": "ファイルサイズ:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "하이라이트",
|
||||
"Horizontal Direction": "수평 방향",
|
||||
"Hyphenation": "하이픈 넣기",
|
||||
"Identifier:": "식별자:",
|
||||
"Import Books": "책 가져오기",
|
||||
"Language:": "언어:",
|
||||
"Layout": "레이아웃",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "업데이트 확인 중...",
|
||||
"Error checking for updates": "업데이트 확인 중 오류 발생",
|
||||
"Details": "세부정보",
|
||||
"Cancel Selection": "선택 취소"
|
||||
"Cancel Selection": "선택 취소",
|
||||
"File Size:": "파일 크기:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "Zaznacz",
|
||||
"Horizontal Direction": "Kierunek poziomy",
|
||||
"Hyphenation": "Dzielenie wyrazów",
|
||||
"Identifier:": "Identyfikator:",
|
||||
"Import Books": "Importuj książki",
|
||||
"Language:": "Język:",
|
||||
"Layout": "Układ",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "Sprawdzanie aktualizacji...",
|
||||
"Error checking for updates": "Błąd podczas sprawdzania aktualizacji",
|
||||
"Details": "Szczegóły",
|
||||
"Cancel Selection": "Anuluj zaznaczenie"
|
||||
"Cancel Selection": "Anuluj zaznaczenie",
|
||||
"File Size:": "Rozmiar pliku:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "Destaque",
|
||||
"Horizontal Direction": "Direção Horizontal",
|
||||
"Hyphenation": "Hifenização",
|
||||
"Identifier:": "Identificador:",
|
||||
"Import Books": "Importar Livros",
|
||||
"Language:": "Idioma:",
|
||||
"Layout": "Layout",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "Verificando atualizações...",
|
||||
"Error checking for updates": "Erro ao verificar atualizações",
|
||||
"Details": "Detalhes",
|
||||
"Cancel Selection": "Cancelar Seleção"
|
||||
"Cancel Selection": "Cancelar Seleção",
|
||||
"File Size:": "Tamanho do arquivo:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "Выделить",
|
||||
"Horizontal Direction": "Горизонтальное направление",
|
||||
"Hyphenation": "Перенос слов",
|
||||
"Identifier:": "Идентификатор:",
|
||||
"Import Books": "Импорт книг",
|
||||
"Language:": "Язык:",
|
||||
"Layout": "Макет",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "Проверка обновлений...",
|
||||
"Error checking for updates": "Ошибка при проверке обновлений",
|
||||
"Details": "Инфо",
|
||||
"Cancel Selection": "Отменить выбор"
|
||||
"Cancel Selection": "Отменить выбор",
|
||||
"File Size:": "Размер файла:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "Vurgula",
|
||||
"Horizontal Direction": "Yatay Yön",
|
||||
"Hyphenation": "Heceleme",
|
||||
"Identifier:": "Tanımlayıcı:",
|
||||
"Import Books": "Kitapları İçe Aktar",
|
||||
"Language:": "Dil:",
|
||||
"Layout": "Düzen",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "Yenilikler kontrol ediliyor...",
|
||||
"Error checking for updates": "Güncellemeleri kontrol ederken hata oluştu",
|
||||
"Details": "Detaylar",
|
||||
"Cancel Selection": "Işaretlemeyi İptal Et"
|
||||
"Cancel Selection": "Işaretlemeyi İptal Et",
|
||||
"File Size:": "Dosya Boyutu:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "Виділення",
|
||||
"Horizontal Direction": "Горизонтальний напрямок",
|
||||
"Hyphenation": "Перенесення слів",
|
||||
"Identifier:": "Ідентифікатор:",
|
||||
"Import Books": "Імпортувати книги",
|
||||
"Language:": "Мова:",
|
||||
"Layout": "Макет",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "Перевірка наявності оновлень...",
|
||||
"Error checking for updates": "Помилка перевірки наявності оновлень",
|
||||
"Details": "Деталі",
|
||||
"Cancel Selection": "Скасувати вибір"
|
||||
"Cancel Selection": "Скасувати вибір",
|
||||
"File Size:": "Розмір файлу:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "Đánh dấu",
|
||||
"Horizontal Direction": "Hướng ngang",
|
||||
"Hyphenation": "Gạch nối từ",
|
||||
"Identifier:": "Định danh:",
|
||||
"Import Books": "Nhập sách",
|
||||
"Language:": "Ngôn ngữ:",
|
||||
"Layout": "Bố cục",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "Đang kiểm tra cập nhật...",
|
||||
"Error checking for updates": "Lỗi khi kiểm tra cập nhật",
|
||||
"Details": "Chi tiết",
|
||||
"Cancel Selection": "Hủy chọn"
|
||||
"Cancel Selection": "Hủy chọn",
|
||||
"File Size:": "Kích thước tệp:"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "划线",
|
||||
"Horizontal Direction": "横排",
|
||||
"Hyphenation": "断字",
|
||||
"Identifier:": "识别码",
|
||||
"Import Books": "导入书籍",
|
||||
"Language:": "语言",
|
||||
"Layout": "布局",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "检查更新中...",
|
||||
"Error checking for updates": "检查更新时出错",
|
||||
"Details": "详情",
|
||||
"Cancel Selection": "取消选择"
|
||||
"Cancel Selection": "取消选择",
|
||||
"File Size:": "文件大小"
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"Highlight": "劃線",
|
||||
"Horizontal Direction": "橫排",
|
||||
"Hyphenation": "斷字",
|
||||
"Identifier:": "識別碼",
|
||||
"Import Books": "導入書籍",
|
||||
"Language:": "語言",
|
||||
"Layout": "版面",
|
||||
@@ -307,5 +306,6 @@
|
||||
"Checking for updates...": "檢查更新中...",
|
||||
"Error checking for updates": "檢查更新時出錯",
|
||||
"Details": "詳情",
|
||||
"Cancel Selection": "取消選擇"
|
||||
"Cancel Selection": "取消選擇",
|
||||
"File Size:": "檔案大小"
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useTranslation } from '@/hooks/useTranslation';
|
||||
import {
|
||||
formatAuthors,
|
||||
formatDate,
|
||||
formatFileSize,
|
||||
formatLanguage,
|
||||
formatPublisher,
|
||||
formatSubject,
|
||||
@@ -41,6 +42,7 @@ const BookDetailModal = ({
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [showDeleteAlert, setShowDeleteAlert] = useState(false);
|
||||
const [bookMeta, setBookMeta] = useState<BookDoc['metadata'] | null>(null);
|
||||
const [fileSize, setFileSize] = useState<number | null>(null);
|
||||
const { envConfig } = useEnv();
|
||||
const { settings } = useSettingsStore();
|
||||
|
||||
@@ -50,7 +52,9 @@ const BookDetailModal = ({
|
||||
const appService = await envConfig.getAppService();
|
||||
try {
|
||||
const details = await appService.fetchBookDetails(book, settings);
|
||||
const size = await appService.getBookFileSize(book);
|
||||
setBookMeta(details);
|
||||
setFileSize(size);
|
||||
} finally {
|
||||
if (loadingTimeout) clearTimeout(loadingTimeout);
|
||||
setLoading(false);
|
||||
@@ -173,12 +177,6 @@ const BookDetailModal = ({
|
||||
{formatLanguage(bookMeta.language) || _('Unknown')}
|
||||
</p>
|
||||
</div>
|
||||
<div className='overflow-hidden'>
|
||||
<span className='font-bold'>{_('Identifier:')}</span>
|
||||
<p className='text-neutral-content line-clamp-1 text-sm'>
|
||||
{bookMeta.identifier || 'N/A'}
|
||||
</p>
|
||||
</div>
|
||||
<div className='overflow-hidden'>
|
||||
<span className='font-bold'>{_('Subjects:')}</span>
|
||||
<p className='text-neutral-content line-clamp-1 text-sm'>
|
||||
@@ -191,6 +189,12 @@ const BookDetailModal = ({
|
||||
{book.format || _('Unknown')}
|
||||
</p>
|
||||
</div>
|
||||
<div className='overflow-hidden'>
|
||||
<span className='font-bold'>{_('File Size:')}</span>
|
||||
<p className='text-neutral-content line-clamp-1 text-sm'>
|
||||
{formatFileSize(fileSize) || _('Unknown')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<span className='font-bold'>{_('Description:')}</span>
|
||||
|
||||
@@ -428,6 +428,20 @@ export abstract class BaseAppService implements AppService {
|
||||
return false;
|
||||
}
|
||||
|
||||
async getBookFileSize(book: Book): Promise<number | null> {
|
||||
const fp = getLocalBookFilename(book);
|
||||
if (await this.fs.exists(fp, 'Books')) {
|
||||
const file = await this.fs.openFile(fp, 'Books');
|
||||
const size = file.size;
|
||||
const f = file as ClosableFile;
|
||||
if (f && f.close) {
|
||||
await f.close();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async loadBookContent(book: Book, settings: SystemSettings): Promise<BookContent> {
|
||||
let file: File;
|
||||
const fp = getLocalBookFilename(book);
|
||||
|
||||
@@ -58,6 +58,7 @@ export interface AppService {
|
||||
uploadBook(book: Book, onProgress?: ProgressHandler): Promise<void>;
|
||||
downloadBook(book: Book, onlyCover?: boolean, onProgress?: ProgressHandler): Promise<void>;
|
||||
isBookAvailable(book: Book): Promise<boolean>;
|
||||
getBookFileSize(book: Book): Promise<number | null>;
|
||||
loadBookConfig(book: Book, settings: SystemSettings): Promise<BookConfig>;
|
||||
fetchBookDetails(book: Book, settings: SystemSettings): Promise<BookDoc['metadata']>;
|
||||
saveBookConfig(book: Book, config: BookConfig, settings?: SystemSettings): Promise<void>;
|
||||
|
||||
@@ -47,6 +47,7 @@ export const getBaseFilename = (filename: string) => {
|
||||
const baseName = normalizedPath.split('/').pop()?.split('.').slice(0, -1).join('.') || '';
|
||||
return baseName;
|
||||
};
|
||||
|
||||
export const INIT_BOOK_CONFIG: BookConfig = {
|
||||
updatedAt: 0,
|
||||
};
|
||||
@@ -141,6 +142,18 @@ export const formatSubject = (subject: string | string[] | undefined) => {
|
||||
return Array.isArray(subject) ? subject.join(', ') : subject;
|
||||
};
|
||||
|
||||
export const formatFileSize = (size: number | null) => {
|
||||
if (size === null) return '';
|
||||
const formatter = new Intl.NumberFormat('en', {
|
||||
style: 'unit',
|
||||
unit: 'byte',
|
||||
unitDisplay: 'narrow',
|
||||
notation: 'compact',
|
||||
compactDisplay: 'short',
|
||||
});
|
||||
return formatter.format(size);
|
||||
};
|
||||
|
||||
export const getCurrentPage = (book: Book, progress: BookProgress) => {
|
||||
const bookFormat = book.format;
|
||||
const { section, pageinfo } = progress;
|
||||
|
||||
Reference in New Issue
Block a user