split per app

This commit is contained in:
2020-08-16 11:48:06 +02:00
parent d3a19c953a
commit c5be16963d
12 changed files with 126 additions and 14 deletions

View File

@ -11,10 +11,16 @@ import Vue from 'vue';
import VueRouter from 'vue-router';
import AppView from '../views/AppView.vue';
import NotFound from '../views/NotFound.vue';
import Home from '../views/Home.vue';
Vue.use (VueRouter);
const routes = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/app/:id',
name: 'AppView',

View File

@ -18,8 +18,8 @@ export default new Vuex.Store ({
}
},
actions: {
async get_log ({ commit }) {
const log = await fetch ('/log')
async get_log ({ commit }, { app_id }) {
const log = await fetch ('/log', { headers: { app_id } })
.then ((res) => res.json ());
commit ('set_log', log);
}

View File

@ -42,7 +42,7 @@ export default {
...Vuex.mapState ({ log: (state) => state.log })
},
mounted () {
this.get_log ();
this.get_log ({ app_id: this.$route.params.id });
document.body.addEventListener ('keydown', (ev) => {
if (ev.key === 's' && ev.ctrlKey) {
this.save_config ();

29
src/views/Home.vue Normal file
View File

@ -0,0 +1,29 @@
<template>
<ul>
<li
v-for="(app,key) in apps"
:key="key"
>
<a
:href="'/app/' + app.id"
v-text="app.name"
/>
</li>
</ul>
</template>
<script>
export default {
data () {
return { apps: [] };
},
async mounted () {
this.apps = await fetch ('/app')
.then ((res) => res.json ());
}
};
</script>
<style>
</style>