feat(web reader): remember fit and rtl

closes #66
This commit is contained in:
Gauthier Roebroeck 2020-01-10 15:00:38 +08:00
parent d50f0db9e5
commit 78c181e130
4 changed files with 33 additions and 4 deletions

View file

@ -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",

View file

@ -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",

View file

@ -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 })

View file

@ -146,11 +146,11 @@
<v-row justify="center">
<v-col cols="auto">
<v-btn-toggle v-model="fitButtons" dense mandatory active-class="primary">
<v-btn @click="fitHeight = false">
<v-btn @click="setFitHeight(false)">
Fit to width
</v-btn>
<v-btn @click="fitHeight = true">
<v-btn @click="setFitHeight(true)">
Fit to height
</v-btn>
</v-btn-toggle>
@ -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