App.vue 523 Bytes
<template>
	<div id="app">
		<router-view v-if="isRouterAlive" />
	</div>
</template>

<script>
export default {
	provide(){
		return{
			reload:this.reload
		}
	},
	data(){
		return{
			isRouterAlive:true,
		}
	},
	mounted() {
		window.addEventListener("unload", this.saveState);
	},
	methods: {
		saveState() {
			sessionStorage.setItem("state", JSON.stringify(this.$store.state));
		},
		reload(){
			this.isRouterAlive = false;
			this.$nextTick(function () {
				this.isRouterAlive = true;
			})
		},
	},
};
</script>