feat(webui): use divina reader for compatible epub

Closes: #1324
This commit is contained in:
Gauthier Roebroeck 2023-12-14 16:06:32 +08:00
parent c2a4d1713d
commit 809a794cf8
7 changed files with 22 additions and 18 deletions

View file

@ -1,4 +1,4 @@
import {BookFormat} from '@/types/komga-books'
import {BookFormat, MediaDto} from '@/types/komga-books'
import {lowerCase} from 'lodash'
export function getBookFormatFromMediaType(mediaType: string): BookFormat {
@ -19,10 +19,10 @@ export function getBookFormatFromMediaType(mediaType: string): BookFormat {
}
}
export function getBookReadRouteFromMediaProfile(mediaProfile: string): string {
switch (lowerCase(mediaProfile)) {
export function getBookReadRouteFromMedia(media: MediaDto): string {
switch (lowerCase(media.mediaProfile)) {
case 'epub':
return 'read-epub'
return media.epubDivinaCompatible ? 'read-book' : 'read-epub'
default:
return 'read-book'
}

View file

@ -6,7 +6,7 @@ import i18n from '@/i18n'
import {MediaStatus} from '@/types/enum-books'
import {getFileSize} from '@/functions/file'
import {ReadListDto} from '@/types/komga-readlists'
import {getBookReadRouteFromMediaProfile} from '@/functions/book-format'
import {getBookReadRouteFromMedia} from '@/functions/book-format'
export enum ItemTypes {
BOOK, SERIES, COLLECTION, READLIST
@ -170,7 +170,7 @@ export class BookItem extends Item<BookDto> {
fabTo(): RawLocation {
return {
name: getBookReadRouteFromMediaProfile(this.item?.media?.mediaProfile),
name: getBookReadRouteFromMedia(this.item?.media),
params: {bookId: this.item.id},
query: {context: this.item?.context?.origin, contextId: this.item?.context?.id},
}

View file

@ -29,6 +29,7 @@ export interface MediaDto {
pagesCount: number,
comment: string,
mediaProfile: string,
epubDivinaCompatible: boolean,
}
export interface PageDto {

View file

@ -409,7 +409,7 @@ import BookActionsMenu from '@/components/menus/BookActionsMenu.vue'
import ItemCard from '@/components/ItemCard.vue'
import ToolbarSticky from '@/components/bars/ToolbarSticky.vue'
import {groupAuthorsByRole} from '@/functions/authors'
import {getBookFormatFromMediaType, getBookReadRouteFromMediaProfile} from '@/functions/book-format'
import {getBookFormatFromMediaType, getBookReadRouteFromMedia} from '@/functions/book-format'
import {getPagesLeft, getReadProgress, getReadProgressPercentage} from '@/functions/book-progress'
import {getBookTitleCompact} from '@/functions/book-title'
import {bookFileUrl, bookThumbnailUrl} from '@/functions/urls'
@ -488,7 +488,7 @@ export default Vue.extend({
},
computed: {
readRouteName(): string {
return getBookReadRouteFromMediaProfile(this.book.media.mediaProfile)
return getBookReadRouteFromMedia(this.book.media)
},
isAdmin(): boolean {
return this.$store.getters.meAdmin

View file

@ -484,7 +484,7 @@ import BookActionsMenu from '@/components/menus/BookActionsMenu.vue'
import ItemCard from '@/components/ItemCard.vue'
import ToolbarSticky from '@/components/bars/ToolbarSticky.vue'
import {groupAuthorsByRole} from '@/functions/authors'
import {getBookFormatFromMediaType, getBookReadRouteFromMediaProfile} from '@/functions/book-format'
import {getBookFormatFromMediaType, getBookReadRouteFromMedia} from '@/functions/book-format'
import {getPagesLeft, getReadProgress, getReadProgressPercentage} from '@/functions/book-progress'
import {getBookTitleCompact} from '@/functions/book-title'
import {bookFileUrl, seriesThumbnailUrl} from '@/functions/urls'
@ -597,7 +597,7 @@ export default Vue.extend({
},
computed: {
readRouteName(): string {
return getBookReadRouteFromMediaProfile(this.book.media.mediaProfile)
return getBookReadRouteFromMedia(this.book.media)
},
isAdmin(): boolean {
return this.$store.getters.meAdmin

View file

@ -339,7 +339,7 @@ import {SeriesDto} from '@/types/komga-series'
import jsFileDownloader from 'js-file-downloader'
import screenfull from 'screenfull'
import {ItemTypes} from '@/types/items'
import {getBookReadRouteFromMediaProfile} from '@/functions/book-format'
import {getBookReadRouteFromMedia} from '@/functions/book-format'
export default Vue.extend({
name: 'DivinaReader',
@ -742,7 +742,7 @@ export default Vue.extend({
if (!this.$_.isEmpty(this.siblingPrevious)) {
this.jumpToPreviousBook = false
this.$router.push({
name: getBookReadRouteFromMediaProfile(this.siblingPrevious.media.mediaProfile),
name: getBookReadRouteFromMedia(this.siblingPrevious.media),
params: {bookId: this.siblingPrevious.id.toString()},
query: {context: this.context.origin, contextId: this.context.id, incognito: this.incognito.toString()},
})
@ -754,7 +754,7 @@ export default Vue.extend({
} else {
this.jumpToNextBook = false
this.$router.push({
name: getBookReadRouteFromMediaProfile(this.siblingNext.media.mediaProfile),
name: getBookReadRouteFromMedia(this.siblingNext.media),
params: {bookId: this.siblingNext.id.toString()},
query: {context: this.context.origin, contextId: this.context.id, incognito: this.incognito.toString()},
})

View file

@ -319,7 +319,7 @@ import {
import {flattenToc} from '@/functions/toc'
import ShortcutHelpDialog from '@/components/dialogs/ShortcutHelpDialog.vue'
import screenfull from 'screenfull'
import {getBookReadRouteFromMediaProfile} from '@/functions/book-format'
import {getBookReadRouteFromMedia} from '@/functions/book-format'
import SettingsSelect from '@/components/SettingsSelect.vue'
import {createR2Progression, r2ProgressionToReadingPosition} from '@/functions/readium'
import {debounce} from 'lodash'
@ -462,6 +462,9 @@ export default Vue.extend({
next()
},
computed: {
isRtl(): boolean {
return this.effectiveDirection === 'rtl'
},
shortcuts(): any {
const shortcuts = [...epubShortcutsSettings, ...epubShortcutsMenus]
if (!this.fixedLayout) shortcuts.push(...epubShortcutsSettingsScroll)
@ -614,7 +617,7 @@ export default Vue.extend({
if (!this.$_.isEmpty(this.siblingPrevious)) {
this.jumpToPreviousBook = false
this.$router.push({
name: getBookReadRouteFromMediaProfile(this.siblingPrevious.media.mediaProfile),
name: getBookReadRouteFromMedia(this.siblingPrevious.media),
params: {bookId: this.siblingPrevious.id.toString()},
query: {context: this.context.origin, contextId: this.context.id, incognito: this.incognito.toString()},
})
@ -626,7 +629,7 @@ export default Vue.extend({
} else {
this.jumpToNextBook = false
this.$router.push({
name: getBookReadRouteFromMediaProfile(this.siblingNext.media.mediaProfile),
name: getBookReadRouteFromMedia(this.siblingNext.media),
params: {bookId: this.siblingNext.id.toString()},
query: {context: this.context.origin, contextId: this.context.id, incognito: this.incognito.toString()},
})
@ -686,8 +689,8 @@ export default Vue.extend({
}
} else {
if (this.settings.navigationClick) {
if (x < this.$vuetify.breakpoint.width / 4) return this.d2Reader.previousPage()
if (x > this.$vuetify.breakpoint.width * .75) return this.d2Reader.nextPage()
if (x < this.$vuetify.breakpoint.width / 4) return this.isRtl ? this.d2Reader.nextPage() : this.d2Reader.previousPage()
if (x > this.$vuetify.breakpoint.width * .75) return this.isRtl ? this.d2Reader.previousPage() : this.d2Reader.nextPage()
}
}
this.toggleToolbars()