Skip to content
Snippets Groups Projects
Commit 1d64b762 authored by lain's avatar lain
Browse files

Add basic configuration module, make it work for title and theme.

parent 340b2147
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,8 @@ export default {
}),
computed: {
currentUser () { return this.$store.state.users.currentUser },
style () { return { 'background-image': `url(${this.currentUser.background_image})` } }
style () { return { 'background-image': `url(${this.currentUser.background_image})` } },
sitename () { return this.$store.state.config.name }
},
methods: {
activatePanel (panelName) {
......
......@@ -3,7 +3,7 @@
<nav class='container base01-background base04'>
<div class='inner-nav'>
<div class='item'>
<a route-to='friends-timeline' href="#">Pleroma FE</a>
<a route-to='friends-timeline' href="#">{{sitename}}</a>
</div>
<style-switcher></style-switcher>
</div>
......
import StyleSetter from '../../services/style_setter/style_setter.js'
export default {
data: () => ({
availableStyles: [],
......@@ -13,8 +11,7 @@ export default {
},
watch: {
selected () {
const fullPath = `/static/css/${this.selected}`
StyleSetter.setStyle(fullPath)
this.$store.dispatch('setOption', { name: 'theme', value: this.selected })
}
}
}
......@@ -12,11 +12,10 @@ import UserProfile from './components/user_profile/user_profile.vue'
import statusesModule from './modules/statuses.js'
import usersModule from './modules/users.js'
import apiModule from './modules/api.js'
import configModule from './modules/config.js'
import VueTimeago from 'vue-timeago'
import StyleSetter from './services/style_setter/style_setter.js'
Vue.use(Vuex)
Vue.use(VueRouter)
Vue.use(VueTimeago, {
......@@ -30,7 +29,8 @@ const store = new Vuex.Store({
modules: {
statuses: statusesModule,
users: usersModule,
api: apiModule
api: apiModule,
config: configModule
}
})
......@@ -61,4 +61,9 @@ new Vue({
components: { App }
})
StyleSetter.setStyle('/static/css/base16-solarized-light.css')
window.fetch('/static/config.json')
.then((res) => res.json())
.then(({name, theme}) => {
store.dispatch('setOption', { name: 'name', value: name })
store.dispatch('setOption', { name: 'theme', value: theme })
})
import { set } from 'vue'
import StyleSetter from '../services/style_setter/style_setter.js'
const defaultState = {
name: 'Pleroma FE'
}
const config = {
state: defaultState,
mutations: {
setOption (state, { name, value }) {
set(state, name, value)
}
},
actions: {
setOption ({ commit }, { name, value }) {
commit('setOption', {name, value})
switch (name) {
case 'name':
document.title = value
break
case 'theme':
const fullPath = `/static/css/${value}`
StyleSetter.setStyle(fullPath)
}
}
}
}
export default config
{
"name": "Pleroma FE",
"theme": "base16-ashes.css"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment