mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2024-08-14 23:57:27 +00:00 
			
		
		
		
	Add router caching.
This commit is contained in:
		
							parent
							
								
									9345e1a917
								
							
						
					
					
						commit
						c03a9bf2d6
					
				
					 6 changed files with 36 additions and 16 deletions
				
			
		| 
						 | 
					@ -5,7 +5,11 @@
 | 
				
			||||||
        :class="{ 'uk-light': darkMode }"
 | 
					        :class="{ 'uk-light': darkMode }"
 | 
				
			||||||
    >
 | 
					    >
 | 
				
			||||||
        <Navigation />
 | 
					        <Navigation />
 | 
				
			||||||
        <router-view />
 | 
					        <router-view v-slot="{ Component }">
 | 
				
			||||||
 | 
					            <keep-alive>
 | 
				
			||||||
 | 
					                <component :key="$route.fullPath" :is="Component" />
 | 
				
			||||||
 | 
					            </keep-alive>
 | 
				
			||||||
 | 
					        </router-view>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <div style="text-align: center">
 | 
					        <div style="text-align: center">
 | 
				
			||||||
            <a aria-label="GitHub" href="https://github.com/TeamPiped/Piped">
 | 
					            <a aria-label="GitHub" href="https://github.com/TeamPiped/Piped">
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,9 +32,11 @@ export default {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    mounted() {
 | 
					    mounted() {
 | 
				
			||||||
        this.getChannelData();
 | 
					        this.getChannelData();
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    activated() {
 | 
				
			||||||
        window.addEventListener("scroll", this.handleScroll);
 | 
					        window.addEventListener("scroll", this.handleScroll);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    unmounted() {
 | 
					    deactivated() {
 | 
				
			||||||
        window.removeEventListener("scroll", this.handleScroll);
 | 
					        window.removeEventListener("scroll", this.handleScroll);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    methods: {
 | 
					    methods: {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,6 +29,11 @@ export default {
 | 
				
			||||||
        selectedAutoPlay: Boolean,
 | 
					        selectedAutoPlay: Boolean,
 | 
				
			||||||
        selectedAutoLoop: Boolean,
 | 
					        selectedAutoLoop: Boolean,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    data() {
 | 
				
			||||||
 | 
					        return {
 | 
				
			||||||
 | 
					            player: null,
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    computed: {
 | 
					    computed: {
 | 
				
			||||||
        shouldAutoPlay: _this => {
 | 
					        shouldAutoPlay: _this => {
 | 
				
			||||||
            return _this.getPreferenceBoolean("playerAutoPlay", true);
 | 
					            return _this.getPreferenceBoolean("playerAutoPlay", true);
 | 
				
			||||||
| 
						 | 
					@ -196,7 +201,7 @@ export default {
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    mounted() {
 | 
					    activated() {
 | 
				
			||||||
        import("hotkeys-js")
 | 
					        import("hotkeys-js")
 | 
				
			||||||
            .then(mod => mod.default)
 | 
					            .then(mod => mod.default)
 | 
				
			||||||
            .then(hotkeys => {
 | 
					            .then(hotkeys => {
 | 
				
			||||||
| 
						 | 
					@ -239,11 +244,15 @@ export default {
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    beforeUnmount() {
 | 
					    deactivated() {
 | 
				
			||||||
 | 
					        if (this.ui) {
 | 
				
			||||||
 | 
					            this.ui.destroy();
 | 
				
			||||||
 | 
					            this.ui = undefined;
 | 
				
			||||||
 | 
					            this.player = undefined;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        if (this.player) {
 | 
					        if (this.player) {
 | 
				
			||||||
            this.player.destroy();
 | 
					            this.player.destroy();
 | 
				
			||||||
            this.player = undefined;
 | 
					            this.player = undefined;
 | 
				
			||||||
            this.ui = undefined;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (this.hotkeys) this.hotkeys.unbind();
 | 
					        if (this.hotkeys) this.hotkeys.unbind();
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,9 +46,11 @@ export default {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    mounted() {
 | 
					    mounted() {
 | 
				
			||||||
        this.getPlaylistData();
 | 
					        this.getPlaylistData();
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    activated() {
 | 
				
			||||||
        window.addEventListener("scroll", this.handleScroll);
 | 
					        window.addEventListener("scroll", this.handleScroll);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    unmounted() {
 | 
					    deactivated() {
 | 
				
			||||||
        window.removeEventListener("scroll", this.handleScroll);
 | 
					        window.removeEventListener("scroll", this.handleScroll);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    computed: {
 | 
					    computed: {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,9 +86,11 @@ export default {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    mounted() {
 | 
					    mounted() {
 | 
				
			||||||
        this.updateResults();
 | 
					        this.updateResults();
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    activated() {
 | 
				
			||||||
        window.addEventListener("scroll", this.handleScroll);
 | 
					        window.addEventListener("scroll", this.handleScroll);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    unmounted() {
 | 
					    deactivated() {
 | 
				
			||||||
        window.removeEventListener("scroll", this.handleScroll);
 | 
					        window.removeEventListener("scroll", this.handleScroll);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    watch: {
 | 
					    watch: {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -134,21 +134,24 @@ export default {
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    mounted() {
 | 
					    mounted() {
 | 
				
			||||||
        this.selectedAutoPlay = this.getPreferenceBoolean("autoplay", true);
 | 
					        this.getVideoData().then(() => {
 | 
				
			||||||
        this.getVideoData();
 | 
					            console.log(this.video.title);
 | 
				
			||||||
 | 
					            this.$refs.videoPlayer.loadVideo();
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
        this.getSponsors();
 | 
					        this.getSponsors();
 | 
				
			||||||
        this.getComments();
 | 
					        this.getComments();
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    activated() {
 | 
				
			||||||
 | 
					        this.selectedAutoPlay = this.getPreferenceBoolean("autoplay", true);
 | 
				
			||||||
 | 
					        if (this.video.duration) this.$refs.videoPlayer.loadVideo();
 | 
				
			||||||
        window.addEventListener("scroll", this.handleScroll);
 | 
					        window.addEventListener("scroll", this.handleScroll);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    unmounted() {
 | 
					    deactivated() {
 | 
				
			||||||
        window.removeEventListener("scroll", this.handleScroll);
 | 
					        window.removeEventListener("scroll", this.handleScroll);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    watch: {
 | 
					    watch: {
 | 
				
			||||||
        "$route.query.v": function(v) {
 | 
					        "$route.query.v": function(v) {
 | 
				
			||||||
            if (v) {
 | 
					            if (v) {
 | 
				
			||||||
                this.getVideoData();
 | 
					 | 
				
			||||||
                this.getSponsors();
 | 
					 | 
				
			||||||
                this.getComments();
 | 
					 | 
				
			||||||
                window.scrollTo(0, 0);
 | 
					                window.scrollTo(0, 0);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
| 
						 | 
					@ -175,7 +178,7 @@ export default {
 | 
				
			||||||
            this.setPreference("autoplay", this.selectedAutoPlay);
 | 
					            this.setPreference("autoplay", this.selectedAutoPlay);
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        async getVideoData() {
 | 
					        async getVideoData() {
 | 
				
			||||||
            this.fetchVideo()
 | 
					            await this.fetchVideo()
 | 
				
			||||||
                .then(data => {
 | 
					                .then(data => {
 | 
				
			||||||
                    this.video = data;
 | 
					                    this.video = data;
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
| 
						 | 
					@ -189,8 +192,6 @@ export default {
 | 
				
			||||||
                                .replaceAll("https://www.youtube.com", "")
 | 
					                                .replaceAll("https://www.youtube.com", "")
 | 
				
			||||||
                                .replaceAll("\n", "<br>"),
 | 
					                                .replaceAll("\n", "<br>"),
 | 
				
			||||||
                        );
 | 
					                        );
 | 
				
			||||||
 | 
					 | 
				
			||||||
                        this.$refs.videoPlayer.loadVideo();
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue