diff --git a/komga-webui/package-lock.json b/komga-webui/package-lock.json index c7938ff97..5cb6fbece 100644 --- a/komga-webui/package-lock.json +++ b/komga-webui/package-lock.json @@ -15550,6 +15550,11 @@ "shelljs": "^0.8.3" } }, + "vue-cookies": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/vue-cookies/-/vue-cookies-1.6.1.tgz", + "integrity": "sha512-qyzhuq0x9xLEwniSXFoEsFErHgQ24jviB527IDul+8KrlxU9jdqrvVunRRBk4lPpxPgL0ywv8NxcD6MDWcTMug==" + }, "vue-hot-reload-api": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz", diff --git a/komga-webui/package.json b/komga-webui/package.json index 0119e4713..b850f68a8 100644 --- a/komga-webui/package.json +++ b/komga-webui/package.json @@ -15,6 +15,7 @@ "lodash": "^4.17.15", "qs": "^6.9.1", "vue": "^2.6.11", + "vue-cookies": "^1.6.1", "vue-line-clamp": "^1.3.2", "vue-router": "^3.0.3", "vue-slick": "^1.1.15", diff --git a/komga-webui/src/main.ts b/komga-webui/src/main.ts index 1782653d1..7064c5d5f 100644 --- a/komga-webui/src/main.ts +++ b/komga-webui/src/main.ts @@ -1,5 +1,6 @@ import _, { LoDashStatic } from 'lodash' import Vue from 'vue' +import VueCookies from 'vue-cookies' // @ts-ignore import * as lineClamp from 'vue-line-clamp' import Vuelidate from 'vuelidate' @@ -18,6 +19,7 @@ import store from './store' Vue.use(Vuelidate) Vue.use(lineClamp) +Vue.use(VueCookies) Vue.use(httpPlugin) Vue.use(komgaFileSystem, { http: Vue.prototype.$http }) diff --git a/komga-webui/src/views/BookReader.vue b/komga-webui/src/views/BookReader.vue index 47a334d6c..ed314dfb1 100644 --- a/komga-webui/src/views/BookReader.vue +++ b/komga-webui/src/views/BookReader.vue @@ -146,11 +146,11 @@ - + Fit to width - + Fit to height @@ -311,6 +311,17 @@ export default Vue.extend({ async mounted () { window.addEventListener('keydown', this.keyPressed) this.setup(this.bookId, Number(this.$route.query.page)) + + if (this.$cookies.isKey('webreader.rtl')) { + if (this.$cookies.get('webreader.rtl') === 'true') { + this.setRtl(true) + } + } + if (this.$cookies.isKey('webreader.fitHeight')) { + if (this.$cookies.get('webreader.fitHeight') === 'false') { + this.setFitHeight(false) + } + } }, destroyed () { window.removeEventListener('keydown', this.keyPressed) @@ -438,8 +449,18 @@ export default Vue.extend({ }, setRtl (rtl: boolean) { this.rtl = rtl - this.slickOptions.rtl = rtl; - (this.$refs.slick as any).setOption('rtl', rtl, true) + this.slickOptions.rtl = rtl + this.rtlButtons = rtl ? 1 : 0 + try { + (this.$refs.slick as any).setOption('rtl', rtl, true) + } catch (e) { + } + this.$cookies.set('webreader.rtl', rtl, Infinity) + }, + setFitHeight (fitHeight: boolean) { + this.fitHeight = fitHeight + this.fitButtons = fitHeight ? 1 : 0 + this.$cookies.set('webreader.fitHeight', fitHeight, Infinity) }, setDoublePages (doublePages: boolean) { this.doublePages = doublePages