From e15e3be1cc20173a26251cb31729c36bdd448dfb Mon Sep 17 00:00:00 2001 From: x ronger Date: Sat, 1 Aug 2020 00:41:00 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E4=B8=AA=E4=BA=BA=E4=B8=BB?= =?UTF-8?q?=E9=A1=B5=E6=A8=A1=E5=9D=97=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/common/portfolio/list.vue | 187 +++++++++++++++++++++++++ pages/user/_nickname.vue | 199 +++++++++++++++++++++++++++ store/user.js | 84 +++++++++++ 3 files changed, 470 insertions(+) create mode 100644 components/common/portfolio/list.vue create mode 100644 pages/user/_nickname.vue create mode 100644 store/user.js diff --git a/components/common/portfolio/list.vue b/components/common/portfolio/list.vue new file mode 100644 index 0000000..2c445bc --- /dev/null +++ b/components/common/portfolio/list.vue @@ -0,0 +1,187 @@ + + + + + diff --git a/pages/user/_nickname.vue b/pages/user/_nickname.vue new file mode 100644 index 0000000..cb43944 --- /dev/null +++ b/pages/user/_nickname.vue @@ -0,0 +1,199 @@ + + + + + diff --git a/store/user.js b/store/user.js new file mode 100644 index 0000000..5bd197d --- /dev/null +++ b/store/user.js @@ -0,0 +1,84 @@ +/** + * @file 用户信息状态 / ES module + * @module store/category + * @author Ronger + */ + +export const USER_API_PATH = '/api/user' + +export const state = () => { + return { + fetching: false, + data: [], + articles: { + fetching: false, + articles: [], + pagination: {} + }, + portfolios: { + fetching: false, + portfolios: [], + pagination: {} + } + } +} + +export const mutations = { + updateFetching(state, action) { + state.fetching = action + }, + updateDetailData(state, action) { + state.data = action + }, + updateArticleList(state, action) { + state.articles = action + }, + updatePortfolioList(state, action) { + state.portfolios = action + } +} + +export const actions = { + fetchDetail({ commit }, params) { + commit('updateFetching', true); + return this.$axios + .$get(`${USER_API_PATH}/${params.nickname}`) + .then(response => { + commit('updateDetailData', response) + commit('updateFetching', false) + }) + .catch(error => { + commit('updateFetching', false) + }) + }, + fetchArticleList({commit}, params) { + return this.$axios + .$get(`${USER_API_PATH}/${params.nickname}/articles`, { + params: { + page: params.page + } + }) + .then(response => { + commit('updateArticleList', response) + commit('updateFetching', false) + }) + .catch(error => { + commit('updateFetching', false) + }) + }, + fetchPortfolioList({commit}, params) { + return this.$axios + .$get(`${USER_API_PATH}/${params.nickname}/portfolios`, { + params: { + page: params.page + } + }) + .then(response => { + commit('updatePortfolioList', response) + commit('updateFetching', false) + }) + .catch(error => { + commit('updateFetching', false) + }) + } +}