mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-08 21:08:43 +02:00
Add:Theme option setting #916
This commit is contained in:
@@ -245,6 +245,13 @@ export default ({ store, app }, inject) => {
|
||||
const eventBus = new Vue()
|
||||
inject('eventBus', eventBus)
|
||||
|
||||
// Set theme
|
||||
app.$localStore?.getTheme()?.then((theme) => {
|
||||
if (theme) {
|
||||
document.documentElement.dataset.theme = theme
|
||||
}
|
||||
})
|
||||
|
||||
// iOS Only
|
||||
// backButton event does not work with iOS swipe navigation so use this workaround
|
||||
if (app.router && Capacitor.getPlatform() === 'ios') {
|
||||
|
||||
@@ -141,6 +141,25 @@ class LocalStorage {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async setTheme(theme) {
|
||||
try {
|
||||
await Preferences.set({ key: 'theme', value: theme })
|
||||
console.log('[LocalStorage] Set theme', theme)
|
||||
} catch (error) {
|
||||
console.error('[LocalStorage] Failed to set theme', error)
|
||||
}
|
||||
}
|
||||
|
||||
async getTheme() {
|
||||
try {
|
||||
var obj = await Preferences.get({ key: 'theme' }) || {}
|
||||
return obj.value || null
|
||||
} catch (error) {
|
||||
console.error('[LocalStorage] Failed to get theme', error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user