fix(webui): add logs in the frontend

This commit is contained in:
Gauthier Roebroeck 2021-09-20 18:07:49 +08:00
parent 42f3addd6d
commit 9b2c971ae7
5 changed files with 64 additions and 179 deletions

View file

@ -1 +1,2 @@
VUE_APP_KOMGA_API_URL=http://localhost:8080
VUE_APP_LOG_LEVEL=debug

File diff suppressed because it is too large Load diff

View file

@ -17,6 +17,7 @@
"js-file-downloader": "^1.1.22",
"language-tags": "^1.0.5",
"lodash": "^4.17.21",
"loglevel": "^1.7.1",
"qs": "^6.10.1",
"screenfull": "^5.1.0",
"vue": "^2.6.14",

View file

@ -24,10 +24,15 @@ import './public-path'
import router from './router'
import store from './store'
import i18n from './i18n'
import log from 'loglevel'
Vue.prototype.$_ = _
Vue.prototype.$eventHub = new Vue()
Vue.prototype.$log = log
if (process.env.VUE_APP_LOG_LEVEL)
Vue.prototype.$log.setLevel(process.env.VUE_APP_LOG_LEVEL)
Vue.use(Vuelidate)
Vue.use(lineClamp)
@ -63,6 +68,7 @@ declare module 'vue/types/vue' {
interface Vue {
$_: LoDashStatic;
$eventHub: Vue;
$log: log.RootLogger;
}
}

View file

@ -420,6 +420,9 @@ export default Vue.extend({
if (screenfull.isEnabled) screenfull.on('change', this.fullscreenChanged)
},
async mounted() {
this.$log.debug('mounted')
this.$log.debug(`route.query: ${JSON.stringify(this.$route.query)}`)
this.readingDirection = this.$store.state.persistedState.webreader.readingDirection
this.animations = this.$store.state.persistedState.webreader.animations
this.pageLayout = this.$store.state.persistedState.webreader.paged.pageLayout
@ -451,6 +454,7 @@ export default Vue.extend({
// route update means either:
// - going to previous/next book, in this case the query.page is not set, so it will default to first page
// - pressing the back button of the browser and navigating to the previous book, in this case the query.page is set, so we honor it
this.$log.debug(`beforeRouteUpdate, to.query: ${JSON.stringify(to.query)}`)
this.setup(to.params.bookId, Number(to.query.page))
}
next()
@ -625,6 +629,7 @@ export default Vue.extend({
this.shortcuts[e.key]?.execute(this)
},
async setup(bookId: string, page?: number) {
this.$log.debug(`setup bookId:${bookId}, page:${page}`)
this.book = await this.$komgaBooks.getBook(bookId)
this.series = await this.$komgaSeries.getOneSeries(this.book.seriesId)
@ -649,6 +654,8 @@ export default Vue.extend({
pageDtos.forEach((p: any) => p['url'] = this.getPageUrl(p))
this.pages = pageDtos as PageDtoWithUrl[]
this.$log.debug(`pages count: ${this.pagesCount}`)
this.$log.debug(`read progress: ${JSON.stringify(this.book.readProgress)}`)
if (page && page >= 1 && page <= this.pagesCount) {
this.goTo(page)
} else if (this.book.readProgress?.completed === false) {
@ -729,6 +736,7 @@ export default Vue.extend({
}
},
goTo(page: number) {
this.$log.debug(`goTo: ${page}`)
this.page = page
this.markProgress(page)
},