Last active
May 23, 2017 19:16
-
-
Save eLafo/16853b8d2549687ad8a6486258dc1bfd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This content has been reduced. You can find the original content in https://github.com/akifo/vue-memo/blob/dev/src/js/main.js | |
import Vue from 'vue' | |
import App from './App' | |
import { sync } from 'vuex-router-sync' | |
import store from './vuex' | |
import router from './router' | |
sync(store, router) | |
Vue.filter('formatDate', function (value, format) { | |
return moment(value).format('YYYY.MM.DD hh:mm:ss') | |
}) | |
const app = new Vue({ | |
router, | |
store, | |
el: '#app', | |
render: h => h(App) | |
}) | |
global._App = app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setMemos (state, { memos }) { | |
state.memos = memos || {} | |
} | |
fetchMemos ({ commit }, { count, type }) { | |
if (state.user.loggedIn || type === 'public') { // is signed in. Firebase | |
Firebase.fetchMemos(count, type) | |
.then(memos => { | |
commit('setMemos', { memos }) | |
}) | |
} else { // is signed out. Localstrage | |
} | |
} | |
memos: state => state.memos, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/akifo/vue-memo/blob/dev/src/js/router/index.js | |
import VueRouter from 'vue-router' | |
import Vue from 'vue' | |
import Index from '../components/Index' | |
import Editor from '../components/Editor' | |
import Viewer from '../components/Viewer' | |
Vue.use(VueRouter) | |
var router = new VueRouter({ | |
routes: [ | |
{ | |
path: '/', | |
name: 'index', | |
component: Index | |
}, { | |
path: '/editor', | |
name: 'newEditor', | |
component: Editor | |
}, { | |
path: '/editor/:id', | |
name: 'updateEditor', | |
component: Editor | |
}, { | |
path: '/viewer/:id', | |
name: 'viewer', | |
component: Viewer | |
} | |
] | |
}) | |
export default router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This content has been reduced. You can find the original content in https://github.com/akifo/vue-memo/blob/dev/src/js/vuex/index.js | |
import Vue from 'vue' | |
import Vuex from 'vuex' | |
Vue.use(Vuex) | |
const state = { | |
user: { | |
loggedIn: false, | |
uid: '', | |
name: '', | |
profilePicUrl: '' | |
}, | |
memos: {} | |
// route: {} // vue-router has created state.route | |
} | |
const mutations = { | |
// here come the mutations | |
} | |
const actions = { | |
// here come the actions | |
} | |
const getters = { | |
// here come the actions | |
} | |
export default new Vuex.Store({ | |
state, | |
getters, | |
actions, | |
mutations, | |
strict: debug | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment