feat(webui): ability to read incognito

This commit is contained in:
Gauthier Roebroeck 2021-04-26 16:48:57 +08:00
parent 8549c69166
commit dc0cc13807
3 changed files with 42 additions and 4 deletions

View file

@ -95,7 +95,8 @@
"show_hide_toolbars": "Show/hide toolbars", "show_hide_toolbars": "Show/hide toolbars",
"vertical": "Vertical", "vertical": "Vertical",
"webtoon": "Webtoon" "webtoon": "Webtoon"
} },
"tooltip_incognito": "Read progress will not be saved"
}, },
"browse_book": { "browse_book": {
"comment": "COMMENT", "comment": "COMMENT",

View file

@ -20,6 +20,13 @@
<v-toolbar-title> {{ bookTitle }}</v-toolbar-title> <v-toolbar-title> {{ bookTitle }}</v-toolbar-title>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-tooltip bottom v-if="incognito">
<template v-slot:activator="{ on }">
<v-icon v-on="on">mdi-incognito</v-icon>
</template>
<span>{{ $t('bookreader.tooltip_incognito') }}</span>
</v-tooltip>
<v-btn <v-btn
icon icon
@click="showHelp = !showHelp"> @click="showHelp = !showHelp">
@ -324,6 +331,7 @@ export default Vue.extend({
series: {} as SeriesDto, series: {} as SeriesDto,
context: {} as Context, context: {} as Context,
contextName: '', contextName: '',
incognito: false,
siblingPrevious: {} as BookDto, siblingPrevious: {} as BookDto,
siblingNext: {} as BookDto, siblingNext: {} as BookDto,
jumpToNextBook: false, jumpToNextBook: false,
@ -587,6 +595,9 @@ export default Vue.extend({
document.title = `Komga - ${getBookTitleCompact(this.book.metadata.title, this.series.metadata.title)}` document.title = `Komga - ${getBookTitleCompact(this.book.metadata.title, this.series.metadata.title)}`
} }
// parse query params to get incognito mode
this.incognito = !!(this.$route.query.incognito && this.$route.query.incognito.toString().toLowerCase() === 'true');
const pageDtos = (await this.$komgaBooks.getBookPages(bookId)) const pageDtos = (await this.$komgaBooks.getBookPages(bookId))
pageDtos.forEach((p: any) => p['url'] = this.getPageUrl(p)) pageDtos.forEach((p: any) => p['url'] = this.getPageUrl(p))
this.pages = pageDtos as PageDtoWithUrl[] this.pages = pageDtos as PageDtoWithUrl[]
@ -654,7 +665,7 @@ export default Vue.extend({
this.$router.push({ this.$router.push({
name: 'read-book', name: 'read-book',
params: {bookId: this.siblingPrevious.id.toString()}, params: {bookId: this.siblingPrevious.id.toString()},
query: {context: this.context.origin, contextId: this.context.id}, query: {context: this.context.origin, contextId: this.context.id, incognito: this.incognito.toString()},
}) })
} }
}, },
@ -666,7 +677,7 @@ export default Vue.extend({
this.$router.push({ this.$router.push({
name: 'read-book', name: 'read-book',
params: {bookId: this.siblingNext.id.toString()}, params: {bookId: this.siblingNext.id.toString()},
query: {context: this.context.origin, contextId: this.context.id}, query: {context: this.context.origin, contextId: this.context.id, incognito: this.incognito.toString()},
}) })
} }
}, },
@ -688,6 +699,7 @@ export default Vue.extend({
page: this.page.toString(), page: this.page.toString(),
context: this.context.origin, context: this.context.origin,
contextId: this.context.id, contextId: this.context.id,
incognito: this.incognito.toString(),
}, },
} as Location) } as Location)
}, },
@ -771,6 +783,7 @@ export default Vue.extend({
this.notification.enabled = true this.notification.enabled = true
}, },
async markProgress(page: number) { async markProgress(page: number) {
if (!this.incognito)
await this.$komgaBooks.updateReadProgress(this.bookId, {page: page}) await this.$komgaBooks.updateReadProgress(this.bookId, {page: page})
}, },
downloadCurrentPage() { downloadCurrentPage() {

View file

@ -122,6 +122,18 @@
{{ $t('common.read') }} {{ $t('common.read') }}
</v-btn> </v-btn>
</v-col> </v-col>
<v-col cols="auto">
<v-btn small
:title="$t('browse_book.read_book')"
:to="{name: 'read-book', params: { bookId: bookId}, query: { context: context.origin, contextId: context.id, incognito: true}}"
:disabled="book.media.status !== 'READY' || !canReadPages"
>
<v-icon left small>mdi-incognito</v-icon>
{{ $t('common.read') }}
</v-btn>
</v-col>
<v-col cols="auto"> <v-col cols="auto">
<v-btn :title="$t('browse_book.download_file')" <v-btn :title="$t('browse_book.download_file')"
small small
@ -155,6 +167,18 @@
{{ $t('common.read') }} {{ $t('common.read') }}
</v-btn> </v-btn>
</v-col> </v-col>
<v-col cols="auto">
<v-btn small
:title="$t('browse_book.read_book')"
:to="{name: 'read-book', params: { bookId: bookId}, query: { context: context.origin, contextId: context.id, incognito: true}}"
:disabled="book.media.status !== 'READY' || !canReadPages"
>
<v-icon left small>mdi-incognito</v-icon>
{{ $t('common.read') }}
</v-btn>
</v-col>
<v-col cols="auto"> <v-col cols="auto">
<v-btn :title="$t('browse_book.download_file')" <v-btn :title="$t('browse_book.download_file')"
small small