diff --git a/src/api/search.js b/src/api/search.js index 5482d81a7628a959c7a6629718c6afe934e0ce18..7ba274862d30793ddef402bbb1c37b4369f00932 100644 --- a/src/api/search.js +++ b/src/api/search.js @@ -2,7 +2,18 @@ import request from '@/util/request' export function searchByKeyword(query){ return request({ - url: '/search', + url: '/search/searchList', + method: 'get', + params:{ + keyword: query.keyword, + pageNum: query.pageNum, + pageSize: query.pageSize + } + }) +} +export function searchByTagName(query){ + return request({ + url: '/search/searchByTag', method: 'get', params:{ keyword: query.keyword, diff --git a/src/router/index.js b/src/router/index.js index a57a416556b4fcbb3fe109024396149092936ed3..91962055d747f4e2518ee74140f8b3a4a4436433 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -51,6 +51,12 @@ const routes = [{ component: () => import('@/view/Search'), meta: {title: '检索'} }, + { + name: 'tag', + path: '/tag', + component: () => import('@/view/Tag'), + meta: {title: '检索'} + }, { path: '*', redirect: '/404', diff --git a/src/view/Search.vue b/src/view/Search.vue index 7ac4bd270ae58503a4c479f45ae47fde1c64df0f..9a9a8683fac67a1a278eb8152508bf7b84c75d6b 100644 --- a/src/view/Search.vue +++ b/src/view/Search.vue @@ -2,7 +2,7 @@
- 检索到 {{ list.length }} + 检索到 {{ query.total }} 条关于 {{ query.keyword }} 的记录
@@ -41,9 +41,9 @@ :key="index" class="tag is-hidden-mobile is-success is-light mr-1" > - - {{ "#" + tag.name }} - + + {{ "#" + tag.name }} + 浏览:{{ item.view }} @@ -105,6 +105,9 @@ export default { this.query.pageSize = data.size this.query.pageNum = data.current }) + }, + search(tagName) { + this.$router.push({ path: '/tag?key=' + tagName }) } } } diff --git a/src/view/Tag.vue b/src/view/Tag.vue new file mode 100644 index 0000000000000000000000000000000000000000..c6b3aa393f51aac34d6a8fdc5b446a86f80fe5a5 --- /dev/null +++ b/src/view/Tag.vue @@ -0,0 +1,118 @@ + + + + + diff --git a/src/view/post/Detail.vue b/src/view/post/Detail.vue index 977d84d2df6effd9d8d9a8fce21852819c24a7f6..cf3b95587bc3242dbcb307ffd43769c10a86dc44 100644 --- a/src/view/post/Detail.vue +++ b/src/view/post/Detail.vue @@ -52,15 +52,10 @@

- - - {{ "#" + tag.name }} - - + + {{ "#" + tag.name }} +

@@ -199,6 +194,9 @@ export default { unliking(id){ this.liked = false; this.handleunLike(id); + }, + search(tagName) { + this.$router.push({ path: '/tag?key=' + tagName }) } }, }; diff --git a/src/view/post/Index.vue b/src/view/post/Index.vue index 9e7bff2581a6f08e4054b9733a983ae44884aa74..3247beb0da7ed7644651870338e1340481d81f48 100644 --- a/src/view/post/Index.vue +++ b/src/view/post/Index.vue @@ -53,11 +53,9 @@ :key="index" class="tag is-hidden-mobile is-success is-light mr-1" > - + {{ "#" + tag.name }} - + {{ $t('post.view') }}:{{ item.view }} @@ -118,11 +116,9 @@ :key="index" class="tag is-hidden-mobile is-success is-light mr-1" > - + {{ "#" + tag.name }} - + {{ $t('post.view') }}:{{ item.view }} @@ -183,11 +179,9 @@ :key="index" class="tag is-hidden-mobile is-success is-light mr-1" > - + {{ "#" + tag.name }} - + {{ $t('post.view') }}:{{ item.view }} @@ -249,12 +243,16 @@ export default { this.page.total = data.total; this.page.size = data.size; this.articleList = data.records; + this.page.tab = data.tab; }); }, handleClick(tab) { this.page.current = 1; this.init(tab.name); }, + search(tagName) { + this.$router.push({ path: '/tag?key=' + tagName }) + } }, };