sbkwgh 7 роки тому
батько
коміт
878873cf0c

+ 6 - 2
frontend/src/App.vue

@@ -123,7 +123,8 @@
 			<div class='header__overlay' :class='{ "header__overlay--show": showMenu }' @click='toggleMenu'></div>
 			<span class='fa fa-bars header__menu_button' @click='toggleMenu'></span>
 		</header>
-		<router-view></router-view>
+		<not-found v-show='$store.state.show404Page'></not-found>
+		<router-view v-show='!$store.state.show404Page'></router-view>
 	</div>
 </template>
 
@@ -134,6 +135,8 @@
 	import LoadingButton from './components/LoadingButton'
 	import NotificationButton from './components/NotificationButton'
 	import SearchBox from './components/SearchBox'
+
+	import NotFound from './components/routes/NotFound'
 	
 	import AjaxErrorHandler from './assets/js/errorHandler'
 
@@ -145,7 +148,8 @@
 			FancyInput,
 			LoadingButton,
 			NotificationButton,
-			SearchBox
+			SearchBox,
+			NotFound
 		},
 		data () {
 			return {

+ 5 - 0
frontend/src/main.js

@@ -68,6 +68,11 @@ const router = new VueRouter({
 	mode: 'history'
 })
 
+router.beforeEach((to, from, next) => {
+	next()
+	router.app.$store.commit('set404Page', false)
+})
+
 Vue.filter('formatDate', function (value, format = '', join = ' ') {
 	if(typeof value !== 'object') {
 		value = new Date(value)

+ 5 - 0
frontend/src/store/index.js

@@ -23,6 +23,8 @@ export default new Vuex.Store({
 
 		token: null,
 
+		show404Page: false,
+
 		ajaxErrors: [],
 		ajaxErrorsModal: false
 	},
@@ -71,6 +73,9 @@ export default new Vuex.Store({
 		setToken (state, token) {
 			state.token = token
 		},
+		set404Page (state, value) {
+			state.show404Page = value
+		},
 		setAccountTabs (state, index) {
 			state.accountTabs = index;
 		},

+ 11 - 1
frontend/src/store/modules/thread.js

@@ -132,7 +132,17 @@ const actions = {
 					vue.$router.push({ name: 'thread-post', params: { post_number: postNumber } })
 					vue.highlightPost(+postNumber)
 				}
-			}).catch(AjaxErrorHandler(vue.$store))
+			}).catch(e => {
+				let invalidId = e.response.data.errors.find(error => {
+					return error.name === 'invalidParameter' && error.parameter === 'id'
+				})
+
+				if(invalidId) {
+					commit('set404Page', true)
+				} else {
+					AjaxErrorHandler(vue.$store)(e)
+				}
+			})
 	},
 	loadPostsAsync ({ state, commit, rootState }, { vue, previous }) {
 		let URL