fix(webui): import book details does not show format

This commit is contained in:
Gauthier Roebroeck 2025-03-06 16:12:07 +08:00
parent 11c2c38e7e
commit b7069c23f6
2 changed files with 22 additions and 3 deletions

View file

@ -39,7 +39,7 @@
<tr>
<td class="font-weight-medium">{{ $t('dialog.transient_book_details.label_format') }}</td>
<td :class="rightBook ? 'diff' : ''">{{ getBookFormatFromMediaType(leftBook.mediaType).type }}</td>
<td v-if="rightBook">{{ getBookFormatFromMediaType(rightBook.media.mediaType).type }}</td>
<td v-if="rightBook">{{ getBookFormatFromMedia(rightBook.media).type }}</td>
</tr>
<tr>
@ -69,7 +69,7 @@
import Vue, {PropType} from 'vue'
import {TransientBookDto} from '@/types/komga-transientbooks'
import {BookDto, PageDto} from '@/types/komga-books'
import {getBookFormatFromMedia} from '@/functions/book-format'
import {getBookFormatFromMedia, getBookFormatFromMediaType} from '@/functions/book-format'
import PagesTable from '@/components/PagesTable.vue'
export default Vue.extend({
@ -78,7 +78,8 @@ export default Vue.extend({
data: () => {
return {
modal: false,
getBookFormatFromMediaType: getBookFormatFromMedia,
getBookFormatFromMediaType: getBookFormatFromMediaType,
getBookFormatFromMedia: getBookFormatFromMedia,
}
},
props: {

View file

@ -19,6 +19,24 @@ export function getBookFormatFromMedia(media: MediaDto): BookFormat {
}
}
export function getBookFormatFromMediaType(mediaType: string): BookFormat {
switch (mediaType) {
case 'application/x-rar-compressed':
case 'application/x-rar-compressed; version=4':
return {type: 'CBR', color: '#03A9F4'}
case 'application/zip':
return {type: 'CBZ', color: '#4CAF50'}
case 'application/pdf':
return {type: 'PDF', color: '#FF5722'}
case 'application/epub+zip':
return {type: 'EPUB', color: '#ff5ab1'}
case 'application/x-rar-compressed; version=5':
return {type: 'RAR5', color: '#000000'}
default:
return {type: mediaType, color: '#000000'}
}
}
export function getBookReadRouteFromMedia(media: MediaDto): string {
switch (lowerCase(media.mediaProfile)) {
case 'epub':