Просмотр исходного кода

:recycle: changine to vue 3 life cycle names | squished another loading bug for home page

tags/0.9.0
J 5 лет назад
Родитель
Сommit
0f698707d9

+ 1
- 1
vue-theme/src/components/gallery.vue Просмотреть файл

@@ -62,7 +62,7 @@ export default {
62 62
 
63 63
         window.addEventListener('keydown', this.interpretKeypress)
64 64
     },
65
-    destroyed() {
65
+    unmounted() {
66 66
         window.removeEventListener('keydown', this.interpretKeypress)
67 67
     }
68 68
 }

+ 1
- 1
vue-theme/src/components/hero.vue Просмотреть файл

@@ -46,7 +46,7 @@ export default {
46 46
             Object.assign(this.$el.style, {height: this.heroHeight + 'px'})
47 47
         }
48 48
     },
49
-    beforeDestroy() {
49
+    beforeUnmount() {
50 50
         window.removeEventListener('resize', this.onResize)
51 51
     },
52 52
     

+ 10
- 2
vue-theme/src/pages/list.vue Просмотреть файл

@@ -54,12 +54,20 @@ export default {
54 54
             allEpisodes: 'allEpisodes',
55 55
             allEpisodesLoaded: 'allEpisodesLoaded',
56 56
         }),
57
+        allLoaded() {
58
+            const flags = []
59
+            flags.push(this.allPagesLoaded)
60
+            flags.push(this.allPostsLoaded)
61
+            flags.push(this.allArtistsLoaded)
62
+            flags.push(this.allEpisodesLoaded)
63
+            return flags.every(Boolean)
64
+        },
57 65
         type() { // Checks for type and fixes Episodes route edge case 
58 66
             return this.$route.params.type ? this.$route.params.type : this.$route.fullPath.slice(1)
59 67
         },
60 68
         posts() {
61 69
             let type = this.convertTitleCase(this.type)
62
-            console.log('type: ', type)
70
+            
63 71
             // We're override the API to sort by date
64 72
             // because items are returned by ID
65 73
             let unsortedOfType = Object.values(this[`all${type}`])
@@ -76,7 +84,7 @@ export default {
76 84
             return type.charAt(0).toUpperCase() + type.slice(1)
77 85
         }
78 86
     },
79
-    mounted() {
87
+    created() {
80 88
         let type = this.convertTitleCase(this.type)
81 89
         
82 90
         this.$store.dispatch(`getAll${type}`, this.sortBy)

+ 9
- 5
vue-theme/src/pages/single.vue Просмотреть файл

@@ -61,8 +61,10 @@ export default {
61 61
             return this.$route.params.type ? this.$route.params.type : this.$route.fullPath.slice(1)
62 62
         },
63 63
         posts() {
64
-            let type = this.type.charAt(0).toUpperCase() + this.type.slice(1)
65
-
64
+            let type = this.convertTitleCase(this.type)
65
+            
66
+            if(!type) return []
67
+            
66 68
             // Return list keyed by slug
67 69
             return Object.values(this[`all${type}`]).reduce((postsMap, post) => { 
68 70
                 postsMap[post.slug] = post
@@ -71,6 +73,9 @@ export default {
71 73
         }
72 74
     },
73 75
     methods: {
76
+        convertTitleCase(type) {
77
+            return type.charAt(0).toUpperCase() + type.slice(1)
78
+        },
74 79
         pageBlocks(posts) {
75 80
             if(this.images.length < 1) return []
76 81
             return posts[this.$route.params.slug].blocks.map(block => {
@@ -128,9 +133,8 @@ export default {
128 133
     },
129 134
     created() {
130 135
         if(!this.allLoaded) {
131
-            let type = this.$route.params.type
132
-            type = type.charAt(0).toUpperCase() + type.slice(1)
133
-            console.log('retrieving...', type)
136
+            let type = this.convertTitleCase(this.$route.params.type)
137
+            console.log('Retrieving...', type)
134 138
             this.$store.dispatch(`getAll${type}`)
135 139
         }
136 140
     }

Загрузка…
Отмена
Сохранить