Kaynağa Gözat

:poop: found this uncommited code

tags/0.9.0
j 5 yıl önce
ebeveyn
işleme
fc0311ec32

+ 20
- 4
vue-theme/src/components/gallery.vue Dosyayı Görüntüle

@@ -1,8 +1,14 @@
1 1
 <template lang="pug">
2 2
 .gallery.active.f-col.center
3 3
     button(@click="hideGallery").hide hide
4
-    p {{ imageIds }}
5
-    p image: {{ imageIds[selected] }}
4
+    
5
+    .wrap(v-if="allMediaLoaded")
6
+        p image: {{ imageIds[activeImageIndex] }}
7
+        p {{ imageIds }}
8
+        p {{ allMedia }}
9
+    .loading(v-else)
10
+        p loading...
11
+
6 12
     ul
7 13
         li(v-for="(image, i) of images" :class="{ active: i === selected }")
8 14
             .image-wrapper.f-col.center
@@ -14,6 +20,8 @@
14 20
 </template>
15 21
 
16 22
 <script>
23
+import { mapGetters } from 'vuex'
24
+
17 25
 export default {
18 26
     props: {
19 27
         imageIds: { type: Array, required: true },
@@ -25,6 +33,12 @@ export default {
25 33
             selected: -1
26 34
         }
27 35
     },
36
+    computed: {
37
+        ...mapGetters({
38
+            allMedia: 'allMedia',
39
+            allMediaLoaded: 'allMediaLoaded',
40
+        })
41
+    },
28 42
     methods: {
29 43
         prev() {
30 44
             this.selected > 0 ? this.selected-- : this.selected = this.imageIds.length - 1
@@ -54,10 +68,10 @@ export default {
54 68
             this.selected = newVal
55 69
         }
56 70
     },
57
-    mounted() {
71
+    async mounted() {
58 72
         // Set the first selection
59 73
         this.selected = this.activeImageIndex
60
-
74
+        this.$store.dispatch(`getMediaById`, this.imageIds)
61 75
         window.addEventListener('keydown', this.interpretKeypress)
62 76
     },
63 77
     unmounted() {
@@ -68,6 +82,8 @@ export default {
68 82
 
69 83
 <style lang="postcss">
70 84
 .gallery
85
+    .wrap
86
+        width: 60vw
71 87
     &.active
72 88
         position: fixed
73 89
         top: 0

+ 6
- 6
vue-theme/src/pages/single.vue Dosyayı Görüntüle

@@ -28,11 +28,11 @@
28 28
                     //- Just a regular block
29 29
                     .block(v-else v-html="block")
30 30
 
31
-    //- sidebar(v-if="sidebar" :type="`${type}`")
32
-    //-     .shadow
33
-    //-         h1.t-up single slot
34
-    //-         div
35
-    //-             p body whatever
31
+    sidebar(v-if="sidebar" :type="`${type}`")
32
+        .shadow
33
+            h1.t-up single slot
34
+            div
35
+                p body whatever
36 36
 </template>
37 37
 
38 38
 <script>
@@ -96,7 +96,7 @@ export default {
96 96
         },
97 97
         checkAndSetHero(posts) {
98 98
             const post = posts[this.$route.params.slug]
99
-            if(!post || ! post.hero) return
99
+            if(!post || !post.hero) return
100 100
 
101 101
             const json = JSON.parse(post.hero)
102 102
             this.$store.commit('SET_HERO', json)

+ 8
- 5
vue-theme/src/store/modules/media.js Dosyayı Görüntüle

@@ -6,19 +6,22 @@ const state = {
6 6
 }
7 7
 
8 8
 const getters = {
9
-    allArtists: state => state.all,
10
-    allArtistsLoaded: state => state.loaded,
9
+    allMedia: state => state.all,
10
+    allMediaLoaded: state => state.loaded,
11 11
 }
12 12
 
13 13
 const actions = {
14
-    getMediaById({ commit }, ids) {
14
+    async getMediaById({ commit }, ids) {
15 15
         commit('CLEAR_MEDIA')
16 16
         commit('MEDIA_LOADED', false)
17
-        ids.forEach(id => {
18
-            api.getSingleMedia(id, media => {
17
+        
18
+        const p = ids.map(async id => {
19
+            return await api.getSingleMedia(id, media => {
19 20
                 commit('STORE_FETCHED_MEDIA', { media })
20 21
             })
21 22
         })
23
+        console.log(p)
24
+        await Promise.all(p)
22 25
         commit('MEDIA_LOADED', true) 
23 26
     }
24 27
 }

+ 1
- 1
vue-theme/src/utils/api.js Dosyayı Görüntüle

@@ -20,7 +20,7 @@ export default {
20 20
             }).catch(e => { cb(e) })
21 21
         }
22 22
     },
23
-    getSingleMedia(id) {
23
+    getSingleMedia(id, cb) {
24 24
         axios.get(SETTINGS.API_MEDIA_PATH + `${id}`).then(response => {
25 25
             cb(response.data)
26 26
         }).catch(e => { cb(e) })

Loading…
İptal
Kaydet