diff --git a/components/archive/list.vue b/components/archive/list.vue
index 111472d..497de54 100644
--- a/components/archive/list.vue
+++ b/components/archive/list.vue
@@ -10,7 +10,7 @@
- {{ article.articleTitle }}
+
# {{ tag.tagTitle }}
-
{{ article.articlePreviewContent }}
+
- {{ portfolio.portfolioTitle }}
+
- {{ portfolio.portfolioDescription }}
+
diff --git a/components/common/user/list.vue b/components/common/user/list.vue
index d0ff3ed..2ccc057 100644
--- a/components/common/user/list.vue
+++ b/components/common/user/list.vue
@@ -8,9 +8,9 @@
- {{ user.nickname }}
+
- {{ user.signature }}
+
diff --git a/components/layouts/pc/header.vue b/components/layouts/pc/header.vue
index 29fc24f..a9c546c 100644
--- a/components/layouts/pc/header.vue
+++ b/components/layouts/pc/header.vue
@@ -18,34 +18,21 @@
-
-
-
-
-
-
-
- {{ item.label }}
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
创建作品集
@@ -91,6 +78,17 @@
+
+
+
+
+
+
登录
@@ -115,8 +113,7 @@ export default {
computed: {
...mapState({
activeMenu: state => state.activeMenu,
- user: state => state.oauth,
- initialSearchData: state => state.search.list
+ user: state => state.oauth
}),
avatarURL() {
let _ts = this;
@@ -164,7 +161,9 @@ export default {
timeout: null,
show: false,
notifications: [],
- notificationNumbers: ""
+ notificationNumbers: "",
+ showPopover: false,
+ autofocus: false
};
},
watch: {
@@ -173,21 +172,17 @@ export default {
}
},
methods: {
- querySearchAsync(queryString, cb) {
- let initialSearchData = this.initialSearchData;
- let results = queryString ? initialSearchData.filter(this.createStateFilter(queryString)) : initialSearchData;
-
- clearTimeout(this.timeout);
- this.timeout = setTimeout(() => {
- cb(results);
- }, 3000 * Math.random());
+ querySearchAsync() {
+ this.$router.push({
+ path: `/search?q=${this.queryString}`
+ })
+ this.$set(this, 'showPopover', false);
+ this.$set(this, 'queryString', '');
},
- createStateFilter(queryString) {
- return (state) => {
- if (state && state.label) {
- return (state.label.toLowerCase().indexOf(queryString.toLowerCase()) > -1);
- }
- };
+ handleShowPopover() {
+ setTimeout(function () {
+ document.getElementById("searchInput").focus()
+ }, 500);
},
handleSelectMenu(item) {
let _ts = this;
@@ -217,15 +212,6 @@ export default {
}
}
},
- handleSelect(item) {
- console.log(item);
- let _ts = this;
- if (item) {
- _ts.$router.push({
- path: `/${item.type}/${item.value}`
- })
- }
- },
handleCommand(item) {
let _ts = this;
switch (item) {
@@ -260,23 +246,6 @@ export default {
}
})
}
- },
- search() {
- console.log(this.queryString)
- },
- getSearchResultType(type) {
- switch (type) {
- case 'article':
- type = '文章';
- break;
- case 'portfolio':
- type = '作品集';
- break;
- case 'user':
- type = '用户';
- break;
- }
- return type;
}
},
mounted() {
diff --git a/pages/search.vue b/pages/search.vue
new file mode 100644
index 0000000..9ec0214
--- /dev/null
+++ b/pages/search.vue
@@ -0,0 +1,105 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/store/index.js b/store/index.js
index 0b94d49..cd986cd 100644
--- a/store/index.js
+++ b/store/index.js
@@ -76,9 +76,7 @@ export const actions = {
const initFetchAppData = [
// 内容数据
store.dispatch('topic/fetchNavList'),
- store.dispatch('article/fetchList'),
- store.dispatch('article/fetchAnnouncementList'),
- store.dispatch('search/fetchList'),
+ store.dispatch('article/fetchList')
]
return Promise.all(initFetchAppData)
diff --git a/store/search.js b/store/search.js
index 96caed8..3ae44d3 100644
--- a/store/search.js
+++ b/store/search.js
@@ -1,9 +1,39 @@
-export const BASE_API_PATH = '/api/console';
+export const BASE_API_PATH = '/api/lucene';
+const getDefaultArticleListData = () => {
+ return {
+ articles: [],
+ pagination: {}
+ }
+}
+const getDefaultUserListData = () => {
+ return {
+ users: [],
+ pagination: {}
+ }
+}
+const getDefaultPortfolioListData = () => {
+ return {
+ portfolios: [],
+ pagination: {}
+ }
+}
export const state = () => {
return {
fetching: false,
- list: []
+ list: [],
+ articles: {
+ fetching: false,
+ data: getDefaultArticleListData()
+ },
+ users: {
+ fetching: false,
+ data: getDefaultUserListData()
+ },
+ portfolios: {
+ fetching: false,
+ data: getDefaultPortfolioListData()
+ }
}
}
@@ -14,25 +44,102 @@ export const mutations = {
},
updateListData(state, action) {
state.list = action
- }
+ },
+ // 数据列表
+ updateArticleListFetching(state, action) {
+ state.articles.fetching = action
+ },
+ updateArticleListData(state, action) {
+ state.articles.data = action
+ },
+ // 数据列表
+ updateUserListFetching(state, action) {
+ state.users.fetching = action
+ },
+ updateUserListData(state, action) {
+ state.users.data = action
+ },
+ // 数据列表
+ updatePortfolioFetching(state, action) {
+ state.portfolios.fetching = action
+ },
+ updatePortfolioListData(state, action) {
+ state.portfolios.data = action
+ },
}
export const actions = {
// 获取文章列表
- fetchList({commit}, params = {}) {
+ fetchArticleList({commit}, params = {}) {
// 清空已有数据
- commit('updateListData', []);
- commit('updateListFetching', true);
+ commit('updateArticleListData', getDefaultArticleListData());
+ if (!params.queryString) {
+ return false;
+ }
+ commit('updateArticleListFetching', true);
return this.$axios
- .$get(`${BASE_API_PATH}/initial-search`)
+ .$get(`${BASE_API_PATH}/search-article`, {
+ params: {
+ q: params.queryString,
+ page: params.page || 1
+ }
+ })
.then(response => {
- commit('updateListFetching', false);
- commit('updateListData', response);
+ commit('updateArticleListFetching', false);
+ commit('updateArticleListData', response ? response : getDefaultArticleListData());
})
.catch(error => {
console.log(error);
- commit('updateListFetching', false);
+ commit('updateArticleListFetching', false);
+ });
+ },
+ fetchUserList({commit}, params = {}) {
+ // 清空已有数据
+ commit('updateUserListData', getDefaultUserListData());
+ if (!params.queryString) {
+ return false;
+ }
+ commit('updateUserListFetching', true);
+
+ return this.$axios
+ .$get(`${BASE_API_PATH}/search-user`, {
+ params: {
+ q: params.queryString,
+ page: params.page || 1
+ }
+ })
+ .then(response => {
+ commit('updateUserListFetching', false);
+ commit('updateUserListData', response ? response : getDefaultUserListData());
+ })
+ .catch(error => {
+ console.log(error);
+ commit('updateUserListFetching', false);
+ });
+ },
+ fetchPortfolioList({commit}, params = {}) {
+ // 清空已有数据
+ commit('updatePortfolioListData', getDefaultPortfolioListData());
+ if (!params.queryString) {
+ return false;
+ }
+ commit('updatePortfolioFetching', true);
+
+ return this.$axios
+ .$get(`${BASE_API_PATH}/search-portfolio`, {
+ params: {
+ q: params.queryString,
+ page: params.page || 1
+ }
+ })
+ .then(response => {
+ commit('updatePortfolioFetching', false);
+ commit('updatePortfolioListData', response ? response : getDefaultPortfolioListData());
+ })
+ .catch(error => {
+ console.log(error);
+ commit('updatePortfolioFetching', false);
});
}
}