refactor(webui): remove cookie to local storage migration code

This commit is contained in:
Gauthier Roebroeck 2021-07-30 15:02:59 +08:00
parent bb1eb36dae
commit 6d40836a2b
4 changed files with 48 additions and 255 deletions

File diff suppressed because it is too large Load diff

View file

@ -20,7 +20,6 @@
"lodash": "^4.17.19",
"qs": "^6.10.1",
"vue": "^2.6.14",
"vue-cookies": "^1.7.4",
"vue-i18n": "^8.24.4",
"vue-line-clamp": "^1.3.2",
"vue-read-more-smooth": "^0.1.8",

View file

@ -9,74 +9,11 @@ import {Theme} from '@/types/themes'
import {LIBRARY_ADDED, LIBRARY_CHANGED, LIBRARY_DELETED} from '@/types/events'
import {LibrarySseDto} from '@/types/komga-sse'
const cookieLocale = 'locale'
const cookieTheme = 'theme'
const cookieFit = 'webreader.fit'
const cookieContinuousReaderFit = 'webreader.continuousReaderFit'
const cookieContinuousReaderPadding = 'webreader.continuousReaderPadding'
const cookieReadingDirection = 'webreader.readingDirection'
const cookiePageLayout = 'webreader.pageLayout'
const cookieSwipe = 'webreader.swipe'
const cookieAnimations = 'webreader.animations'
const cookieBackground = 'webreader.background'
const cookiePageSize = 'pagesize'
export default Vue.extend({
name: 'App',
created() {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', this.systemThemeChange)
// TODO: remove this after a few months (moved to local storage in 0.85.0 - 29 Mar 2021)
// remove also vue-cookie npm package
if (this.$cookies.isKey(cookieLocale)) {
this.$store.commit('setLocale', this.$cookies.get(cookieLocale))
this.$cookies.remove(cookieLocale)
}
if (this.$cookies.isKey(cookieTheme)) {
this.$store.commit('setTheme', this.$cookies.get(cookieTheme))
this.$cookies.remove(cookieTheme)
}
if (this.$cookies.isKey(cookieFit)) {
this.$store.commit('setWebreaderPagedScale', this.$cookies.get(cookieFit))
this.$cookies.remove(cookieFit)
}
if (this.$cookies.isKey(cookieContinuousReaderFit)) {
this.$store.commit('setWebreaderContinuousScale', this.$cookies.get(cookieContinuousReaderFit))
this.$cookies.remove(cookieContinuousReaderFit)
}
if (this.$cookies.isKey(cookieContinuousReaderPadding)) {
this.$store.commit('setWebreaderContinuousPadding', parseInt(this.$cookies.get(cookieContinuousReaderPadding)))
this.$cookies.remove(cookieContinuousReaderPadding)
}
if (this.$cookies.isKey(cookieReadingDirection)) {
this.$store.commit('setWebreaderReadingDirection', this.$cookies.get(cookieReadingDirection))
this.$cookies.remove(cookieReadingDirection)
}
if (this.$cookies.isKey(cookiePageLayout)) {
this.$store.commit('setWebreaderPagedPageLayout', this.$cookies.get(cookiePageLayout))
this.$cookies.remove(cookiePageLayout)
}
if (this.$cookies.isKey(cookieSwipe)) {
this.$store.commit('setWebreaderSwipe', this.$cookies.get(cookieSwipe))
this.$cookies.remove(cookieSwipe)
}
if (this.$cookies.isKey(cookieAnimations)) {
this.$store.commit('setWebreaderAnimations', this.$cookies.get(cookieAnimations))
this.$cookies.remove(cookieAnimations)
}
if (this.$cookies.isKey(cookieBackground)) {
this.$store.commit('setWebreaderBackground', this.$cookies.get(cookieBackground))
this.$cookies.remove(cookieBackground)
}
if (this.$cookies.isKey(cookiePageSize)) {
this.$store.commit('setBrowsingPageSize', parseInt(this.$cookies.get(cookiePageSize)))
this.$cookies.remove(cookiePageSize)
}
this.$cookies.keys()
.filter(x => x.startsWith('collection.filter') || x.startsWith('library.filter') || x.startsWith('library.sort'))
.forEach(x => this.$cookies.remove(x))
this.$eventHub.$on(LIBRARY_ADDED, this.reloadLibraries)
this.$eventHub.$on(LIBRARY_DELETED, this.reloadLibraries)
this.$eventHub.$on(LIBRARY_CHANGED, this.reloadLibraries)

View file

@ -1,6 +1,5 @@
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'
@ -30,7 +29,6 @@ Vue.prototype.$eventHub = new Vue()
Vue.use(Vuelidate)
Vue.use(lineClamp)
Vue.use(VueCookies)
Vue.use(httpPlugin)
Vue.use(komgaFileSystem, {http: Vue.prototype.$http})