feat(webui): display book number in webreader tab title and toolbar

Closes: #1543
This commit is contained in:
Gauthier Roebroeck 2025-01-22 16:12:13 +08:00
parent dd31f5b062
commit 38fa3ccaa7
4 changed files with 10 additions and 7 deletions

View file

@ -1,7 +1,10 @@
export function getBookTitleCompact (bookTitle: string, seriesTitle: string): string {
export function getBookTitleCompact(bookTitle: string, seriesTitle: string, number?: string): string {
if (bookTitle?.toLowerCase().includes(seriesTitle?.toLowerCase())) {
return bookTitle
} else {
return `${seriesTitle} - ${bookTitle}`
if (number != undefined)
return `${seriesTitle} - ${number} - ${bookTitle}`
else
return `${seriesTitle} - ${bookTitle}`
}
}

View file

@ -660,7 +660,7 @@ export default Vue.extend({
.then(v => this.readLists = v)
if (this.$_.has(this.book, 'metadata.title')) {
document.title = `Komga - ${getBookTitleCompact(this.book.metadata.title, this.book.seriesTitle)}`
document.title = `Komga - ${getBookTitleCompact(this.book.metadata.title, this.book.seriesTitle, this.book.oneshot ? undefined : this.book.metadata.number)}`
}
if (this?.context.origin === ContextOrigin.READLIST) {

View file

@ -504,7 +504,7 @@ export default Vue.extend({
return this.pages.length
},
bookTitle(): string {
return getBookTitleCompact(this.book.metadata.title, this.series.metadata.title)
return getBookTitleCompact(this.book.metadata.title, this.series.metadata.title, this.book.oneshot ? undefined : this.book.metadata.number)
},
readingDirectionText(): string {
return this.$t(`enums.reading_direction.${this.readingDirection}`).toString()
@ -673,7 +673,7 @@ export default Vue.extend({
this.contextName = (await (this.$komgaReadLists.getOneReadList(this.context.id))).name
document.title = `Komga - ${this.contextName} - ${this.book.metadata.title}`
} else {
document.title = `Komga - ${getBookTitleCompact(this.book.metadata.title, this.series.metadata.title)}`
document.title = `Komga - ${this.bookTitle}`
}
// parse query params to get incognito mode

View file

@ -509,7 +509,7 @@ export default Vue.extend({
},
bookTitle(): string {
if (!!this.book && !!this.series)
return getBookTitleCompact(this.book.metadata.title, this.series.metadata.title)
return getBookTitleCompact(this.book.metadata.title, this.series.metadata.title, this.book.oneshot ? undefined : this.book.metadata.number)
return this.book?.metadata?.title
},
appearance: {
@ -715,7 +715,7 @@ export default Vue.extend({
document.title = `Komga - ${this.contextName} - ${this.book.metadata.title}`
}
} else {
document.title = `Komga - ${getBookTitleCompact(this.book.metadata.title, this.series.metadata.title)}`
document.title = `Komga - ${this.bookTitle}`
}
// parse query params to get incognito mode