Explorar el Código

feat: wrapping getters in another getter

tags/0.9.0
J hace 6 años
padre
commit
b149633aa8
Se han modificado 2 ficheros con 15 adiciones y 3 borrados
  1. 1
    1
      vue-theme/src/index.js
  2. 14
    2
      vue-theme/src/pages/list.vue

+ 1
- 1
vue-theme/src/index.js Ver fichero

14
     mode: 'history',
14
     mode: 'history',
15
     routes: [
15
     routes: [
16
         { path: '/', component: IndexPage },
16
         { path: '/', component: IndexPage },
17
+        { path: '/lazy', component:  () => import(/* webpackChunkName: "pages-lazy" */ './pages/lazy.vue') },
17
         {
18
         {
18
             path: '/:type',
19
             path: '/:type',
19
             component: ListPage,
20
             component: ListPage,
20
             props: { sidebar: true }
21
             props: { sidebar: true }
21
         },
22
         },
22
-        { path: '/lazy', component:  () => import(/* webpackChunkName: "pages-lazy" */ './pages/lazy.vue') },
23
     ]
23
     ]
24
 })
24
 })
25
 
25
 

+ 14
- 2
vue-theme/src/pages/list.vue Ver fichero

9
             h4 {{ $route.params.type }}
9
             h4 {{ $route.params.type }}
10
             p {{ Object.values(allArtists).length }}
10
             p {{ Object.values(allArtists).length }}
11
             p {{ sidebar }}
11
             p {{ sidebar }}
12
+        section(v-for="post in posts")
13
+            h4 {{ post.title }}
12
     //- COMPONENT: Make this with a prop
14
     //- COMPONENT: Make this with a prop
13
     aside(v-if="sidebar").shadow.b-radius
15
     aside(v-if="sidebar").shadow.b-radius
14
         header
16
         header
29
         ...mapGetters({
31
         ...mapGetters({
30
             allArtists: 'allArtists',
32
             allArtists: 'allArtists',
31
             allArtistsLoaded: 'allArtistsLoaded',
33
             allArtistsLoaded: 'allArtistsLoaded',
34
+
32
             allEpisodes: 'allEpisodes',
35
             allEpisodes: 'allEpisodes',
33
             allEpisodesLoaded: 'allEpisodesLoaded',
36
             allEpisodesLoaded: 'allEpisodesLoaded',
34
         }),
37
         }),
38
+        posts() {
39
+            switch (this.$route.params.type) {
40
+                case 'artists':
41
+                    return this.allArtists
42
+                    break
43
+                case 'episodes':
44
+                    return this.allEpisodes
45
+                    break
46
+            }
47
+        },
35
     },
48
     },
36
     data() {
49
     data() {
37
         return {
50
         return {
44
             case 'artists':
57
             case 'artists':
45
                 this.$store.dispatch('getAllArtists')
58
                 this.$store.dispatch('getAllArtists')
46
                 break
59
                 break
47
-            case 'episodess':
60
+            case 'episodes':
48
                 this.$store.dispatch('getAllEpisodes')
61
                 this.$store.dispatch('getAllEpisodes')
49
                 break
62
                 break
50
         }
63
         }
51
-        
52
     }
64
     }
53
 }
65
 }
54
 </script>
66
 </script>

Loading…
Cancelar
Guardar