diff --git a/src/App.vue b/src/App.vue index 38b76a52408e3f8089f363b3e06871ce63038be3..8c99a0d603eb3a5c7b1d3ab18be304aa52ca33be 100644 --- a/src/App.vue +++ b/src/App.vue @@ -27,6 +27,7 @@ window.onpopstate = function (event) { if (event.state) { app.__vue__._data.article = event.state.article app.__vue__._data.search_results = event.state.search_results + app.__vue__._data.lang = event.state.lang } } @@ -80,17 +81,19 @@ export default { this.$refs.search.value = '' document.activeElement.blur() if(event._source){ + this.$router.push('/' + this.lang + '/' + event._id) + history.replaceState({article: this.article, search_results: this.search_results, lang: this.lang}, '') this.search_results = [] this.article = event._source - history.pushState({article: this.article, search_results: this.search_results}, '', '/' + this.lang + '/' + event._id) }else{ var self = this self.waiting = true self.article = {lemmas: [], body:{pronunciation: [], definitions: [], etymology: []}} axios.get(api_endpoint + '/' + self.lang + '/_search?q=' + event.q) .then(function(response){ + self.$router.push('/' + self.lang + '/_search?q=' + event.q) + history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '') self.search_results = response.data.hits.hits - history.pushState({article: self.article, search_results: self.search_results}, '', '/' + self.lang + '/_search?q=' + event.q) self.waiting = false }) } @@ -102,13 +105,13 @@ export default { .then(function(response){ self.article = response.data._source self.waiting = false - history.replaceState({article: self.article, search_results: self.search_results}, '') + history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '') }) }, search_hit_click: function(article){ this.search_results = [] this.article = article - history.replaceState({article: article, search_results: []}, '') + history.replaceState({article: article, search_results: [], lang: this.lang}, '') } }, mounted: function(){ @@ -126,7 +129,7 @@ export default { .then(function(response){ self.article = response.data._source self.waiting = false - history.replaceState({article: self.article, search_results: self.search_results}, '') + history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '') }) } else { diff --git a/src/components/SubArticle.vue b/src/components/SubArticle.vue index f56ab1f42ff294cdad3f9e78bbc52f83c70a45d7..13189b8b35fef5c690dc00b35a518d26d42bb19c 100644 --- a/src/components/SubArticle.vue +++ b/src/components/SubArticle.vue @@ -1,7 +1,7 @@ <template> <li class="sub_article"> <span class="sub_article_header"> - <router-link :to="'' + body.article_id" @click.native="article_link_click(body)"> + <router-link :to="'./' + body.article_id" @click.native="article_link_click(body)"> {{body.lemmas[0]}} </router-link> </span>