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 @@ + + + + + + + + + + + + + + + + + + + {{ portfolio.portfolioDescription }} + + + {{ portfolio.timeAgo }} + + + + + + + + 这里什么都没有! + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + {{user.nickname}} + + + + + + + + + 文章 + 作品集 + + + + + + + + + + + + + + + + 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) + }) + } +}