Add vuex structure

Signed-off-by: Julius Härtl <jus@bitgrid.net>
pull/8/head
Julius Härtl 2018-10-10 09:46:26 +02:00
rodzic 72655b0734
commit d5643d82ab
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4C614C6ED2CDE6DF
4 zmienionych plików z 106 dodań i 16 usunięć

Wyświetl plik

@ -97,26 +97,29 @@
};
},
beforeMount: function() {
let example = {
message: 'Want to #DropDropbox? #DeleteGoogle? #decentralize? We got you covered, easy as a piece of 🥞\n' +
'\n' +
'Get started right now: https://nextcloud.com/signup',
author: 'Nextcloud 📱☁️💻',
authorId: '@nextcloud@mastodon.xyz',
authorAvatar: OC.linkTo('social', 'img/nextcloud.png'),
timestamp: '1 day ago'
};
let data = [];
for (let i=0; i<20; i++) {
example.id = Math.floor((Math.random() * 100));
data.push(example);
}
this.$store.commit('addToTimeline', data);
},
computed: {
socialId: function() {
return '@' + OC.getCurrentUser().uid + '@' + OC.getHost();
},
timeline: function() {
let example = {
message: 'Want to #DropDropbox? #DeleteGoogle? #decentralize? We got you covered, easy as a piece of 🥞\n' +
'\n' +
'Get started right now: https://nextcloud.com/signup',
author: 'Nextcloud 📱☁️💻',
authorId: '@nextcloud@mastodon.xyz',
authorAvatar: OC.linkTo('social', 'img/nextcloud.png'),
timestamp: '1 day ago'
};
let data = [];
for (let i=0; i<20; i++) {
example.id = Math.floor((Math.random() * 100));
data.push(example);
}
return data;
return this.$store.getters.getTimeline;
},
menu: function () {
let defaultCategories = [

Wyświetl plik

@ -23,6 +23,9 @@
import Vue from 'vue'
import App from './App'
import store from './store';
Vue.prototype.t = t
Vue.prototype.n = n
Vue.prototype.OC = OC
@ -30,5 +33,6 @@ Vue.prototype.OCA = OCA
/* eslint-disable-next-line no-new */
new Vue({
render: h => h(App)
render: h => h(App),
store: store
}).$mount('#content')

43
src/store/index.js 100644
Wyświetl plik

@ -0,0 +1,43 @@
/*
* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import Vue from 'vue';
import Vuex from 'vuex';
import timeline from './timeline';
Vue.use(Vuex)
const debug = process.env.NODE_ENV !== 'production';
const mutations = {
};
export default new Vuex.Store({
modules: {
timeline
},
strict: debug,
mutations
});

Wyświetl plik

@ -0,0 +1,40 @@
/*
* @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
const state = {
timeline: []
};
const mutations = {
addToTimeline(state, data) {
for (let item in data) {
state.timeline.push(data[item]);
}
}
};
const getters = {
getTimeline(state) {
return state.timeline;
}
};
const actions = {};
export default {state, mutations, getters, actions};