From 47984f56382a8999fbffa0ec4c4b442d0ac8f1c2 Mon Sep 17 00:00:00 2001 From: x ronger Date: Sun, 2 Aug 2020 19:23:32 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E4=BD=9C=E5=93=81=E9=9B=86?= =?UTF-8?q?=E7=AE=A1=E7=90=86=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 | 2 +- .../common/portfolio/manager/bind/list.vue | 69 ++++ components/common/portfolio/manager/list.vue | 151 +++++++++ pages/portfolio/manager/_portfolio_id.vue | 106 ++++++ .../portfolio/manager/bind/_portfolio_id.vue | 87 +++++ pages/portfolio/post/_portfolio_id.vue | 312 ++++++++++++++++++ store/portfolio.js | 69 +++- 7 files changed, 790 insertions(+), 6 deletions(-) create mode 100644 components/common/portfolio/manager/bind/list.vue create mode 100644 components/common/portfolio/manager/list.vue create mode 100644 pages/portfolio/manager/_portfolio_id.vue create mode 100644 pages/portfolio/manager/bind/_portfolio_id.vue create mode 100644 pages/portfolio/post/_portfolio_id.vue diff --git a/components/common/portfolio/list.vue b/components/common/portfolio/list.vue index 777201c..d1a7e86 100644 --- a/components/common/portfolio/list.vue +++ b/components/common/portfolio/list.vue @@ -62,7 +62,7 @@ ) }, currentChange(page) { - this.$emit('currentChangePortfolios', page); + this.$emit('currentChange', page); } } } diff --git a/components/common/portfolio/manager/bind/list.vue b/components/common/portfolio/manager/bind/list.vue new file mode 100644 index 0000000..8712a67 --- /dev/null +++ b/components/common/portfolio/manager/bind/list.vue @@ -0,0 +1,69 @@ + + + + + diff --git a/components/common/portfolio/manager/list.vue b/components/common/portfolio/manager/list.vue new file mode 100644 index 0000000..8324c64 --- /dev/null +++ b/components/common/portfolio/manager/list.vue @@ -0,0 +1,151 @@ + + + + + diff --git a/pages/portfolio/manager/_portfolio_id.vue b/pages/portfolio/manager/_portfolio_id.vue new file mode 100644 index 0000000..8a6c48f --- /dev/null +++ b/pages/portfolio/manager/_portfolio_id.vue @@ -0,0 +1,106 @@ + + + + + diff --git a/pages/portfolio/manager/bind/_portfolio_id.vue b/pages/portfolio/manager/bind/_portfolio_id.vue new file mode 100644 index 0000000..57261ca --- /dev/null +++ b/pages/portfolio/manager/bind/_portfolio_id.vue @@ -0,0 +1,87 @@ + + + + + diff --git a/pages/portfolio/post/_portfolio_id.vue b/pages/portfolio/post/_portfolio_id.vue new file mode 100644 index 0000000..eb8cc44 --- /dev/null +++ b/pages/portfolio/post/_portfolio_id.vue @@ -0,0 +1,312 @@ + + + + + diff --git a/store/portfolio.js b/store/portfolio.js index 6208d25..d57012f 100644 --- a/store/portfolio.js +++ b/store/portfolio.js @@ -1,7 +1,8 @@ import Vue from 'vue'; import { isBrowser } from '~/environment'; -export const PORTFOLIO_API_PATH = '/api/console' +export const BASE_API_PATH = '/api/console' +export const PORTFOLIO_API_PATH = '/api/portfolio' const getDefaultListData = () => { return { @@ -23,6 +24,10 @@ export const state = () => { articles: { articles: [], pagination: {} + }, + unbindArticles: { + articles: [], + pagination: {} } } } @@ -51,6 +56,10 @@ export const mutations = { state.articles.articles = action.articles state.articles.pagination = action.pagination }, + updateUnbindArticleList(state, action) { + state.unbindArticles.articles = action.articles + state.unbindArticles.pagination = action.pagination + }, // 更新作品集阅读全文状态 updateDetailRenderedState(state, action) { @@ -75,7 +84,7 @@ export const actions = { } return this.$axios - .$get(`${PORTFOLIO_API_PATH}/portfolios`, { + .$get(`${BASE_API_PATH}/portfolios`, { params: data }) .then(response => { @@ -103,7 +112,7 @@ export const actions = { commit('updateDetailFetching', true) // commit('updateDetailData', {}) return this.$axios - .$get(`${PORTFOLIO_API_PATH}/portfolio/${params.portfolio_id}`) + .$get(`${BASE_API_PATH}/portfolio/${params.portfolio_id}`) .then(response => { return new Promise(resolve => { commit('updateDetailData', response) @@ -122,9 +131,9 @@ export const actions = { fetchArticleList({commit}, params) { commit('updateDetailFetching', true) return this.$axios - .$get(`${PORTFOLIO_API_PATH}/portfolio/${params.portfolio_id}/articles`, { + .$get(`${BASE_API_PATH}/portfolio/${params.portfolio_id}/articles`, { params: { - page: params.page + page: params.page || 1 } }) .then(response => { @@ -134,5 +143,55 @@ export const actions = { .catch(error => { commit('updateDetailFetching', false) }) + }, + fetchUnBindArticleList({commit}, params) { + commit('updateDetailFetching', true) + return this.$axios + .$get(`${PORTFOLIO_API_PATH}/${params.portfolio_id}/unbind-articles`, { + params: { + page: params.page || 1, + searchText: params.searchText || '' + } + }) + .then(response => { + commit('updateUnbindArticleList', response) + commit('updateDetailFetching', false) + }) + .catch(error => { + commit('updateDetailFetching', false) + }) + }, + fetchPostDetail({ commit }, params = {}) { + // const delay = fetchDelay( + // isBrowser + // ) + // if (isBrowser) { + // Vue.nextTick(() => { + // window.scrollTo(0, 300); + // }) + // } + + if (typeof params.portfolio_id === 'undefined') { + commit('updateDetailData', getDefaultListData()) + return; + } + commit('updateDetailFetching', true) + // commit('updateDetailData', {}) + return this.$axios + .$get(`${PORTFOLIO_API_PATH}/detail/${params.portfolio_id}`) + .then(response => { + return new Promise(resolve => { + commit('updateDetailData', response) + commit('updateDetailFetching', false) + resolve(response) + // delay(() => { + // resolve(response) + // }) + }) + }) + .catch(error => { + commit('updateDetailFetching', false) + return Promise.reject(error) + }) } }